equal
deleted
inserted
replaced
56 [pool release]; |
56 [pool release]; |
57 return retVal; |
57 return retVal; |
58 } |
58 } |
59 |
59 |
60 @implementation SDLUIKitDelegate |
60 @implementation SDLUIKitDelegate |
61 @synthesize mainViewController, uiwindow, secondWindow; |
61 @synthesize mainViewController, uiwindow, secondWindow, isInGame; |
62 |
62 |
63 // convenience method |
63 // convenience method |
64 +(SDLUIKitDelegate *)sharedAppDelegate { |
64 +(SDLUIKitDelegate *)sharedAppDelegate { |
65 // the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method |
65 // the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method |
66 return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate]; |
66 return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate]; |
130 // since the sdlwindow is not yet created, we add the overlayController with a delay |
130 // since the sdlwindow is not yet created, we add the overlayController with a delay |
131 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:isNetGameNum,@"net",menuStyle,@"menu",nil]; |
131 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:isNetGameNum,@"net",menuStyle,@"menu",nil]; |
132 [self performSelector:@selector(displayOverlayLater:) withObject:dict afterDelay:1]; |
132 [self performSelector:@selector(displayOverlayLater:) withObject:dict afterDelay:1]; |
133 |
133 |
134 // this is the pascal fuction that starts the game (wrapped around isInGame) |
134 // this is the pascal fuction that starts the game (wrapped around isInGame) |
135 isInGame = YES; |
135 self.isInGame = YES; |
136 Game(gameArgs); |
136 Game(gameArgs); |
137 isInGame = NO; |
137 self.isInGame = NO; |
138 free(gameArgs); |
138 free(gameArgs); |
139 |
139 |
140 [self.uiwindow makeKeyAndVisible]; |
140 [self.uiwindow makeKeyAndVisible]; |
141 [self.uiwindow bringSubviewToFront:self.mainViewController.view]; |
141 [self.uiwindow bringSubviewToFront:self.mainViewController.view]; |
142 |
142 |
202 } |
202 } |
203 |
203 |
204 -(void) applicationWillTerminate:(UIApplication *)application { |
204 -(void) applicationWillTerminate:(UIApplication *)application { |
205 SDL_SendQuit(); |
205 SDL_SendQuit(); |
206 |
206 |
207 if (isInGame) { |
207 if (self.isInGame) { |
208 HW_terminate(YES); |
208 HW_terminate(YES); |
209 // hack to prevent automatic termination. See SDL_uikitevents.m for details |
209 // hack to prevent automatic termination. See SDL_uikitevents.m for details |
210 longjmp(*(jump_env()), 1); |
210 longjmp(*(jump_env()), 1); |
211 } |
211 } |
212 } |
212 } |
216 MSG_MEMCLEAN(); |
216 MSG_MEMCLEAN(); |
217 print_free_memory(); |
217 print_free_memory(); |
218 } |
218 } |
219 |
219 |
220 -(void) applicationWillResignActive:(UIApplication *)application { |
220 -(void) applicationWillResignActive:(UIApplication *)application { |
221 if (isInGame) { |
221 if (self.isInGame) { |
222 HW_pause(); |
222 HW_pause(); |
223 |
223 |
224 // Send every window on every screen a MINIMIZED event. |
224 // Send every window on every screen a MINIMIZED event. |
225 SDL_VideoDevice *_this = SDL_GetVideoDevice(); |
225 SDL_VideoDevice *_this = SDL_GetVideoDevice(); |
226 if (!_this) |
226 if (!_this) |
235 } |
235 } |
236 } |
236 } |
237 } |
237 } |
238 |
238 |
239 -(void) applicationDidBecomeActive:(UIApplication *)application { |
239 -(void) applicationDidBecomeActive:(UIApplication *)application { |
240 if (isInGame) { |
240 if (self.isInGame) { |
241 HW_pause(); |
241 HW_pause(); |
242 |
242 |
243 // Send every window on every screen a RESTORED event. |
243 // Send every window on every screen a RESTORED event. |
244 SDL_VideoDevice *_this = SDL_GetVideoDevice(); |
244 SDL_VideoDevice *_this = SDL_GetVideoDevice(); |
245 if (!_this) |
245 if (!_this) |