ios: respond more gracefully to didReceiveMemoryWarning and add sounds to two buttons
authorkoda
Sun, 28 Aug 2011 14:50:04 +0200
changeset 5699 1a9a6a7662aa
parent 5698 332b4cc98569
child 5700 f0960a88ab0e
ios: respond more gracefully to didReceiveMemoryWarning and add sounds to two buttons
project_files/HedgewarsMobile/Classes/GameConfigViewController.m
project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m
project_files/HedgewarsMobile/Classes/RestoreViewController.m
project_files/HedgewarsMobile/Classes/SavedGamesViewController.m
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Sun Aug 28 11:50:26 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Sun Aug 28 14:50:04 2011 +0200
@@ -378,7 +378,7 @@
         self.mapConfigViewController = nil;
 
     self.imgContainer = nil;
-    self.interfaceBridge = nil;
+    //self.interfaceBridge = nil;
     MSG_MEMCLEAN();
     [super didReceiveMemoryWarning];
 }
--- a/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m	Sun Aug 28 11:50:26 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m	Sun Aug 28 14:50:04 2011 +0200
@@ -65,7 +65,7 @@
     AVAudioPlayer *background = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:musicString] error:nil];
 
     background.delegate = nil;
-    background.volume = 0.5f;
+    background.volume = 0.4f;
     background.numberOfLoops = -1;
     [background prepareToPlay];
     [HedgewarsAppDelegate sharedAppDelegate].backgroundMusic = background;
@@ -126,7 +126,7 @@
     // don't stop music when it is playing
     if (self.isInGame) {
         [self.backgroundMusic stop];
-        releaseAndNil(self.backgroundMusic);
+        self.backgroundMusic = nil;
         MSG_MEMCLEAN();
     }
     print_free_memory();
--- a/project_files/HedgewarsMobile/Classes/RestoreViewController.m	Sun Aug 28 11:50:26 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/RestoreViewController.m	Sun Aug 28 14:50:04 2011 +0200
@@ -36,6 +36,7 @@
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 
     if (theButton.tag != 0) {
+        playSound(@"clickSound");
         if (self.interfaceBridge == nil) {
             GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self.parentViewController];
             self.interfaceBridge = bridge;
@@ -44,6 +45,7 @@
         [self.parentViewController dismissModalViewControllerAnimated:NO];
         [self.interfaceBridge startSaveGame:[defaults objectForKey:@"savedGamePath"]];
     } else {
+        playSound(@"backSound");
         [defaults setObject:@"" forKey:@"savedGamePath"];
         [defaults synchronize];
         [self.parentViewController dismissModalViewControllerAnimated:YES];
@@ -63,7 +65,8 @@
 }
 
 -(void) didReceiveMemoryWarning {
-    self.interfaceBridge = nil;
+    // don't nil this one or it won't be able to send messages
+    //self.interfaceBridge = nil;
     [super didReceiveMemoryWarning];
 }
 
--- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m	Sun Aug 28 11:50:26 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m	Sun Aug 28 14:50:04 2011 +0200
@@ -240,7 +240,8 @@
 #pragma mark Memory Management
 -(void) didReceiveMemoryWarning {
     self.listOfSavegames = nil;
-    self.interfaceBridge = nil;
+    // don't nil this one or it won't be able to send messages
+    //self.interfaceBridge = nil;
     MSG_MEMCLEAN();
     [super didReceiveMemoryWarning];
 }