ios: don't prompt restoring a game that didn't complete loading
authorkoda
Sun, 08 Apr 2012 23:41:34 +0200
changeset 6866 efdd2e4fc45c
parent 6865 fe19af8278e6
child 6867 e7851ac961ba
ios: don't prompt restoring a game that didn't complete loading
project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
project_files/HedgewarsMobile/Classes/MainMenuViewController.m
project_files/HedgewarsMobile/Classes/ObjcExports.m
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Sun Apr 08 23:31:02 2012 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Sun Apr 08 23:41:34 2012 +0200
@@ -53,9 +53,10 @@
     [thisWindow addSubview:self.blackView];
     [self.blackView release];
 
-    // keep track of uncompleted games
+    // keep the point of return for games that completed loading
     NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
     [userDefaults setObject:self.savePath forKey:@"savedGamePath"];
+    [userDefaults setObject:[NSNumber numberWithBool:NO] forKey:@"saveIsValid"];
     [userDefaults synchronize];
 
     // let's launch the engine using this -perfomSelector so that the runloop can deal with queued messages first
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Sun Apr 08 23:31:02 2012 +0200
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Sun Apr 08 23:41:34 2012 +0200
@@ -61,7 +61,7 @@
 
     // prompt for restoring any previous game
     NSString *saveString = [userDefaults objectForKey:@"savedGamePath"];
-    if (saveString != nil && [saveString isEqualToString:@""] == NO) {
+    if (saveString != nil && [saveString isEqualToString:@""] == NO && [[userDefaults objectForKey:@"saveIsValid"] boolValue]) {
         if (self.restoreViewController == nil) {
             NSString *xibName = [@"RestoreViewController-" stringByAppendingString:(IS_IPAD() ? @"iPad" : @"iPhone")];
             RestoreViewController *restored = [[RestoreViewController alloc] initWithNibName:xibName bundle:nil];
--- a/project_files/HedgewarsMobile/Classes/ObjcExports.m	Sun Apr 08 23:31:02 2012 +0200
+++ b/project_files/HedgewarsMobile/Classes/ObjcExports.m	Sun Apr 08 23:41:34 2012 +0200
@@ -64,6 +64,9 @@
         [overlay_instance.loadingIndicator removeFromSuperview];
         [HWUtils setGameStatus:gsInGame];
     }
+    // mark the savefile as valid, eg it's been loaded correctly
+    [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:@"saveIsValid"];
+    [[NSUserDefaults standardUserDefaults] synchronize];
 }
 
 void saveFinishedSynching() {