--- a/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m Mon Aug 22 23:56:25 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m Tue Aug 23 03:46:17 2011 +0200
@@ -122,54 +122,23 @@
}
}
--(void) applicationWillTerminate:(UIApplication *)application {
- if (self.isInGame)
- HW_terminate(YES);
-
- [super applicationWillTerminate:application];
-}
-
-(void) applicationDidReceiveMemoryWarning:(UIApplication *)application {
+ // don't stop music when it is playing
+ if (self.isInGame) {
+ [self.backgroundMusic stop];
+ releaseAndNil(self.backgroundMusic);
+ MSG_MEMCLEAN();
+ }
+ print_free_memory();
// don't clean mainMenuViewController here!!!
- [self.backgroundMusic stop];
- self.backgroundMusic = nil;
- MSG_MEMCLEAN();
- print_free_memory();
}
-//TODO: when the SDLUIKitDelegate methods applicationWillResignActive and applicationDidBecomeActive do work
-// you'll be able to remove the methods below and just handle the SDL_WINDOWEVENT_MINIMIZED/SDL_WINDOWEVENT_RESTORED
-// events in the MainLoop
-
-(void) applicationWillResignActive:(UIApplication *)application {
- //[super applicationWillResignActive:application];
-
- UIDevice *device = [UIDevice currentDevice];
- if ([device respondsToSelector:@selector(isMultitaskingSupported)] &&
- [device isMultitaskingSupported] && self.isInGame) {
- // let's try to be permissive with multitasking here...
- if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"multitasking"] boolValue])
- HW_suspend();
- else {
- // so the game returns to the configuration view
- if (isGameRunning())
- HW_terminate(NO);
- else {
- // while screen is loading you can't call HW_terminate() so we close the app
- [self applicationWillTerminate:application];
- }
- }
- }
+ // true multitasking with sdl works only on 4.2 and above; we close the game to avoid a black screen at return
+ if (self.isInGame && ([[[UIDevice currentDevice] systemVersion] floatValue] < 4.2f))
+ HW_terminate(NO);
+ [super applicationWillResignActive:application];
}
--(void) applicationDidBecomeActive:(UIApplication *)application {
- //[super applicationDidBecomeActive:application];
-
- UIDevice *device = [UIDevice currentDevice];
- if ([device respondsToSelector:@selector(isMultitaskingSupported)] &&
- [device isMultitaskingSupported] && self.isInGame) {
- HW_resume();
- }
-}
@end