project_files/HedgewarsMobile/Classes/MainMenuViewController.m
changeset 6020 c792d4b3e080
parent 6008 215f0c9719e3
child 6075 0173cd44c3bc
equal deleted inserted replaced
6019:8843ea756cfc 6020:c792d4b3e080
    25 #import "GameConfigViewController.h"
    25 #import "GameConfigViewController.h"
    26 #import "SplitViewRootController.h"
    26 #import "SplitViewRootController.h"
    27 #import "AboutViewController.h"
    27 #import "AboutViewController.h"
    28 #import "SavedGamesViewController.h"
    28 #import "SavedGamesViewController.h"
    29 #import "RestoreViewController.h"
    29 #import "RestoreViewController.h"
       
    30 #import "GameInterfaceBridge.h"
    30 #import "Appirater.h"
    31 #import "Appirater.h"
    31 #import "ServerSetup.h"
    32 #import "ServerSetup.h"
    32 
    33 
    33 
    34 
    34 @implementation MainMenuViewController
    35 @implementation MainMenuViewController
   117     }
   118     }
   118 
   119 
   119     // prompt for restoring any previous game
   120     // prompt for restoring any previous game
   120     NSString *saveString = [userDefaults objectForKey:@"savedGamePath"];
   121     NSString *saveString = [userDefaults objectForKey:@"savedGamePath"];
   121     if (saveString != nil && [saveString isEqualToString:@""] == NO) {
   122     if (saveString != nil && [saveString isEqualToString:@""] == NO) {
       
   123         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(launchRestoredGame) name:@"launchRestoredGame" object:nil];
   122         if (self.restoreViewController == nil) {
   124         if (self.restoreViewController == nil) {
   123             NSString *xibName = [@"RestoreViewController-" stringByAppendingString:(IS_IPAD() ? @"iPad" : @"iPhone")];
   125             NSString *xibName = [@"RestoreViewController-" stringByAppendingString:(IS_IPAD() ? @"iPad" : @"iPhone")];
   124             RestoreViewController *restored = [[RestoreViewController alloc] initWithNibName:xibName bundle:nil];
   126             RestoreViewController *restored = [[RestoreViewController alloc] initWithNibName:xibName bundle:nil];
   125             if ([restored respondsToSelector:@selector(setModalPresentationStyle:)])
   127             if ([restored respondsToSelector:@selector(setModalPresentationStyle:)])
   126                 restored.modalPresentationStyle = UIModalPresentationFormSheet;
   128                 restored.modalPresentationStyle = UIModalPresentationFormSheet;
   127             self.restoreViewController = restored;
   129             self.restoreViewController = restored;
   128             [restored release];
   130             [restored release];
   129         }
   131         }
   130         [self performSelector:@selector(presentModalViewController:animated:) withObject:self.restoreViewController afterDelay:0.3];
   132         [self performSelector:@selector(presentModalViewController:animated:) withObject:self.restoreViewController afterDelay:0.25];
   131     } else {
   133     } else {
   132         // let's not prompt for rating when app crashed >_>
   134         // let's not prompt for rating when app crashed >_>
   133         [Appirater appLaunched];
   135         [Appirater appLaunched];
   134     }
   136     }
   135 
   137 
   235             [alert release];
   237             [alert release];
   236             break;
   238             break;
   237     }
   239     }
   238 }
   240 }
   239 
   241 
       
   242 #pragma mark -
       
   243 -(void) launchRestoredGame {
       
   244     [[NSNotificationCenter defaultCenter] removeObserver:self];
       
   245     GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self];
       
   246     [bridge startSaveGame:[[NSUserDefaults standardUserDefaults] objectForKey:@"savedGamePath"]];
       
   247     [bridge release];
       
   248 }
       
   249 
       
   250 #pragma mark -
   240 -(void) viewDidUnload {
   251 -(void) viewDidUnload {
   241     self.gameConfigViewController = nil;
   252     self.gameConfigViewController = nil;
   242     self.settingsViewController = nil;
   253     self.settingsViewController = nil;
   243     self.aboutViewController = nil;
   254     self.aboutViewController = nil;
   244     self.savedGamesViewController = nil;
   255     self.savedGamesViewController = nil;