equal
deleted
inserted
replaced
45 return retVal; |
45 return retVal; |
46 } |
46 } |
47 |
47 |
48 @implementation SDLUIKitDelegate |
48 @implementation SDLUIKitDelegate |
49 |
49 |
50 @synthesize uiwindow, window, controller; |
50 @synthesize uiwindow, window, viewController; |
51 |
51 |
52 /* convenience method */ |
52 /* convenience method */ |
53 +(SDLUIKitDelegate *)sharedAppDelegate { |
53 +(SDLUIKitDelegate *)sharedAppDelegate { |
54 /* the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method */ |
54 /* the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method */ |
55 return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate]; |
55 return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate]; |
57 |
57 |
58 -(id) init { |
58 -(id) init { |
59 self = [super init]; |
59 self = [super init]; |
60 self.uiwindow = nil; |
60 self.uiwindow = nil; |
61 self.window = NULL; |
61 self.window = NULL; |
62 self.controller = nil; |
62 self.viewController = nil; |
63 return self; |
63 return self; |
64 } |
64 } |
65 |
65 |
66 -(void) dealloc { |
66 -(void) dealloc { |
67 [controller release]; |
67 [viewController release]; |
68 [uiwindow release]; |
68 [uiwindow release]; |
69 [super dealloc]; |
69 [super dealloc]; |
70 } |
70 } |
71 |
71 |
72 #pragma mark - |
72 #pragma mark - |
78 [setup startThread:@"engineProtocol"]; |
78 [setup startThread:@"engineProtocol"]; |
79 |
79 |
80 // remove the current view to free resources |
80 // remove the current view to free resources |
81 [UIView beginAnimations:@"removing main controller" context:NULL]; |
81 [UIView beginAnimations:@"removing main controller" context:NULL]; |
82 [UIView setAnimationDuration:1]; |
82 [UIView setAnimationDuration:1]; |
83 controller.view.alpha = 0; |
83 viewController.view.alpha = 0; |
84 [UIView commitAnimations]; |
84 [UIView commitAnimations]; |
85 [controller.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
85 [viewController.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
86 |
86 |
87 NSLog(@"Game is launching..."); |
87 NSLog(@"Game is launching..."); |
88 const char **gameArgs = [setup getSettings]; |
88 const char **gameArgs = [setup getSettings]; |
89 |
89 |
90 // direct execution or thread? check the one that gives most fps |
90 // direct execution or thread? check the one that gives most fps |
92 Game(gameArgs); |
92 Game(gameArgs); |
93 |
93 |
94 free(gameArgs); |
94 free(gameArgs); |
95 NSLog(@"Game is exting..."); |
95 NSLog(@"Game is exting..."); |
96 |
96 |
97 [[uiwindow viewWithTag:54321] removeFromSuperview]; |
|
98 [setup release]; |
97 [setup release]; |
99 |
98 |
100 [UIView beginAnimations:@"inserting main controller" context:NULL]; |
99 [UIView beginAnimations:@"inserting main controller" context:NULL]; |
101 [UIView setAnimationDuration:1]; |
100 [UIView setAnimationDuration:1]; |
102 controller.view.alpha = 1; |
101 viewController.view.alpha = 1; |
103 [UIView commitAnimations]; |
102 [UIView commitAnimations]; |
104 |
103 |
105 [uiwindow addSubview: controller.view]; |
104 [uiwindow addSubview: viewController.view]; |
106 [uiwindow makeKeyAndVisible]; |
105 [uiwindow makeKeyAndVisible]; |
107 |
106 |
108 [internal_pool release]; |
107 [internal_pool release]; |
109 } |
108 } |
110 |
109 |
150 */ |
149 */ |
151 } |
150 } |
152 |
151 |
153 #pragma mark - |
152 #pragma mark - |
154 #pragma mark SDLUIKitDelegate methods |
153 #pragma mark SDLUIKitDelegate methods |
|
154 |
|
155 |
155 // override the direct execution of SDL_main to allow us to implement the frontend (even using a nib) |
156 // override the direct execution of SDL_main to allow us to implement the frontend (even using a nib) |
156 -(void) applicationDidFinishLaunching:(UIApplication *)application { |
157 -(void) applicationDidFinishLaunching:(UIApplication *)application { |
157 [application setStatusBarHidden:YES animated:NO]; |
158 [application setStatusBarHidden:YES animated:NO]; |
158 |
159 [application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; |
|
160 |
159 [self checkFirstRun]; |
161 [self checkFirstRun]; |
160 |
162 |
161 /* Set working directory to resource path */ |
163 /* Set working directory to resource path */ |
162 [[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]]; |
164 [[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]]; |
163 |
165 |
164 [uiwindow addSubview:controller.view]; |
166 [uiwindow addSubview:viewController.view]; |
165 [uiwindow makeKeyAndVisible]; |
167 [uiwindow makeKeyAndVisible]; |
166 } |
168 } |
167 |
169 |
168 -(void) applicationWillTerminate:(UIApplication *)application { |
170 -(void) applicationWillTerminate:(UIApplication *)application { |
169 SDL_SendQuit(); |
171 SDL_SendQuit(); |