project_files/HedgewarsMobile/Classes/MainMenuViewController.m
changeset 5220 76a2246f18f0
parent 5219 9e2a17ab178b
child 5224 6e8fbbfb0de5
equal deleted inserted replaced
5219:9e2a17ab178b 5220:76a2246f18f0
    24 #import "PascalImports.h"
    24 #import "PascalImports.h"
    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 "ServerSetup.h"
    30 #import "ServerSetup.h"
    30 
    31 
    31 @implementation MainMenuViewController
    32 @implementation MainMenuViewController
    32 @synthesize gameConfigViewController, settingsViewController, aboutViewController, savedGamesViewController;
    33 @synthesize gameConfigViewController, settingsViewController, aboutViewController, savedGamesViewController, restoreViewController;
    33 
    34 
    34 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    35 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    35     return rotationManager(interfaceOrientation);
    36     return rotationManager(interfaceOrientation);
    36 }
    37 }
    37 
    38 
   104         [userDefaults setObject:version forKey:@"HedgeVersion"];
   105         [userDefaults setObject:version forKey:@"HedgeVersion"];
   105         [userDefaults synchronize];
   106         [userDefaults synchronize];
   106         [self createNecessaryFiles];
   107         [self createNecessaryFiles];
   107     }
   108     }
   108 
   109 
       
   110     NSString *saveString = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedGamePath"];
       
   111     if (saveString != nil && [saveString isEqualToString:@""] == NO) {
       
   112         if (self.restoreViewController == nil) {
       
   113             NSString *xibName = [@"RestoreViewController-" stringByAppendingString:(IS_IPAD() ? @"iPad" : @"iPhone")]; 
       
   114             RestoreViewController *restored = [[RestoreViewController alloc] initWithNibName:xibName bundle:nil];
       
   115             if ([restored respondsToSelector:@selector(setModalPresentationStyle:)])
       
   116                 restored.modalPresentationStyle = UIModalPresentationFormSheet;
       
   117             self.restoreViewController = restored;
       
   118             [restored release];
       
   119         }
       
   120         [self performSelector:@selector(presentModalViewController:animated:) withObject:self.restoreViewController afterDelay:0.35];
       
   121     }
       
   122 
   109     /*
   123     /*
   110     ServerSetup *setup = [[ServerSetup alloc] init];
   124     ServerSetup *setup = [[ServerSetup alloc] init];
   111     if ([setup isNetworkReachable]) {
   125     if ([setup isNetworkReachable]) {
   112         DLog(@"network is reachable");
   126         DLog(@"network is reachable");
   113         [NSThread detachNewThreadSelector:@selector(serverProtocol)
   127         [NSThread detachNewThreadSelector:@selector(serverProtocol)
   207 -(void) viewDidUnload {
   221 -(void) viewDidUnload {
   208     self.gameConfigViewController = nil;
   222     self.gameConfigViewController = nil;
   209     self.settingsViewController = nil;
   223     self.settingsViewController = nil;
   210     self.aboutViewController = nil;
   224     self.aboutViewController = nil;
   211     self.savedGamesViewController = nil;
   225     self.savedGamesViewController = nil;
       
   226     self.restoreViewController = nil;
   212     MSG_DIDUNLOAD();
   227     MSG_DIDUNLOAD();
   213     [super viewDidUnload];
   228     [super viewDidUnload];
   214 }
   229 }
   215 
   230 
   216 -(void) didReceiveMemoryWarning {
   231 -(void) didReceiveMemoryWarning {
   220         self.gameConfigViewController = nil;
   235         self.gameConfigViewController = nil;
   221     if (self.aboutViewController.view.superview == nil)
   236     if (self.aboutViewController.view.superview == nil)
   222         self.aboutViewController = nil;
   237         self.aboutViewController = nil;
   223     if (self.savedGamesViewController.view.superview == nil)
   238     if (self.savedGamesViewController.view.superview == nil)
   224         self.savedGamesViewController = nil;
   239         self.savedGamesViewController = nil;
       
   240     if (self.restoreViewController.view.superview == nil)
       
   241         self.restoreViewController = nil;
   225     MSG_MEMCLEAN();
   242     MSG_MEMCLEAN();
   226     [super didReceiveMemoryWarning];
   243     [super didReceiveMemoryWarning];
   227 }
   244 }
   228 
   245 
   229 -(void) dealloc {
   246 -(void) dealloc {
   230     releaseAndNil(settingsViewController);
   247     releaseAndNil(settingsViewController);
   231     releaseAndNil(gameConfigViewController);
   248     releaseAndNil(gameConfigViewController);
   232     releaseAndNil(aboutViewController);
   249     releaseAndNil(aboutViewController);
   233     releaseAndNil(savedGamesViewController);
   250     releaseAndNil(savedGamesViewController);
       
   251     releaseAndNil(restoreViewController);
   234     [super dealloc];
   252     [super dealloc];
   235 }
   253 }
   236 
   254 
   237 @end
   255 @end