equal
deleted
inserted
replaced
32 } |
32 } |
33 |
33 |
34 @end |
34 @end |
35 |
35 |
36 @implementation HedgewarsAppDelegate |
36 @implementation HedgewarsAppDelegate |
37 @synthesize mainViewController, uiwindow, secondWindow, isInGame; |
37 @synthesize mainViewController, uiwindow, secondWindow; |
38 |
38 |
39 // convenience method |
39 // convenience method |
40 +(HedgewarsAppDelegate *)sharedAppDelegate { |
40 +(HedgewarsAppDelegate *)sharedAppDelegate { |
41 return (HedgewarsAppDelegate *)[[UIApplication sharedApplication] delegate]; |
41 return (HedgewarsAppDelegate *)[[UIApplication sharedApplication] delegate]; |
42 } |
42 } |
46 -(id) init { |
46 -(id) init { |
47 if (self = [super init]){ |
47 if (self = [super init]){ |
48 mainViewController = nil; |
48 mainViewController = nil; |
49 uiwindow = nil; |
49 uiwindow = nil; |
50 secondWindow = nil; |
50 secondWindow = nil; |
51 isInGame = NO; |
|
52 } |
51 } |
53 return self; |
52 return self; |
54 } |
53 } |
55 |
54 |
56 -(void) dealloc { |
55 -(void) dealloc { |
90 } |
89 } |
91 |
90 |
92 -(void) applicationDidReceiveMemoryWarning:(UIApplication *)application { |
91 -(void) applicationDidReceiveMemoryWarning:(UIApplication *)application { |
93 [HWUtils releaseCache]; |
92 [HWUtils releaseCache]; |
94 // don't stop music if it is playing |
93 // don't stop music if it is playing |
95 if (self.isInGame) { |
94 if ([HWUtils isGameLaunched]) { |
96 [AudioManagerController releaseCache]; |
95 [AudioManagerController releaseCache]; |
97 } |
96 } |
98 MSG_MEMCLEAN(); |
97 MSG_MEMCLEAN(); |
99 // don't clean mainMenuViewController here!!! |
98 // don't clean mainMenuViewController here!!! |
100 } |
99 } |
101 |
100 |
102 // true multitasking with sdl works only on 4.2 and above; we close the game to avoid a black screen at return |
101 // true multitasking with sdl works only on 4.2 and above; we close the game to avoid a black screen at return |
103 -(void) applicationWillResignActive:(UIApplication *)application { |
102 -(void) applicationWillResignActive:(UIApplication *)application { |
104 if (self.isInGame && [[[UIDevice currentDevice] systemVersion] floatValue] < 4.2f) |
103 if ([HWUtils isGameLaunched] && [[[UIDevice currentDevice] systemVersion] floatValue] < 4.2f) |
105 HW_terminate(NO); |
104 HW_terminate(NO); |
106 |
105 |
107 [super applicationWillResignActive:application]; |
106 [super applicationWillResignActive:application]; |
108 } |
107 } |
109 |
108 |