project_files/HedgewarsMobile/Classes/MainMenuViewController.m
changeset 5220 76a2246f18f0
parent 5219 9e2a17ab178b
child 5224 6e8fbbfb0de5
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Sat May 28 16:40:23 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Sat May 28 23:40:42 2011 +0200
@@ -26,10 +26,11 @@
 #import "SplitViewRootController.h"
 #import "AboutViewController.h"
 #import "SavedGamesViewController.h"
+#import "RestoreViewController.h"
 #import "ServerSetup.h"
 
 @implementation MainMenuViewController
-@synthesize gameConfigViewController, settingsViewController, aboutViewController, savedGamesViewController;
+@synthesize gameConfigViewController, settingsViewController, aboutViewController, savedGamesViewController, restoreViewController;
 
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
     return rotationManager(interfaceOrientation);
@@ -106,6 +107,19 @@
         [self createNecessaryFiles];
     }
 
+    NSString *saveString = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedGamePath"];
+    if (saveString != nil && [saveString isEqualToString:@""] == NO) {
+        if (self.restoreViewController == nil) {
+            NSString *xibName = [@"RestoreViewController-" stringByAppendingString:(IS_IPAD() ? @"iPad" : @"iPhone")]; 
+            RestoreViewController *restored = [[RestoreViewController alloc] initWithNibName:xibName bundle:nil];
+            if ([restored respondsToSelector:@selector(setModalPresentationStyle:)])
+                restored.modalPresentationStyle = UIModalPresentationFormSheet;
+            self.restoreViewController = restored;
+            [restored release];
+        }
+        [self performSelector:@selector(presentModalViewController:animated:) withObject:self.restoreViewController afterDelay:0.35];
+    }
+
     /*
     ServerSetup *setup = [[ServerSetup alloc] init];
     if ([setup isNetworkReachable]) {
@@ -209,6 +223,7 @@
     self.settingsViewController = nil;
     self.aboutViewController = nil;
     self.savedGamesViewController = nil;
+    self.restoreViewController = nil;
     MSG_DIDUNLOAD();
     [super viewDidUnload];
 }
@@ -222,6 +237,8 @@
         self.aboutViewController = nil;
     if (self.savedGamesViewController.view.superview == nil)
         self.savedGamesViewController = nil;
+    if (self.restoreViewController.view.superview == nil)
+        self.restoreViewController = nil;
     MSG_MEMCLEAN();
     [super didReceiveMemoryWarning];
 }
@@ -231,6 +248,7 @@
     releaseAndNil(gameConfigViewController);
     releaseAndNil(aboutViewController);
     releaseAndNil(savedGamesViewController);
+    releaseAndNil(restoreViewController);
     [super dealloc];
 }