project_files/HedgewarsMobile/Classes/RestoreViewController.m
branchqmlfrontend
changeset 11408 b894922d58cc
parent 11236 0425d60cd046
child 12877 00215a7ec5f5
equal deleted inserted replaced
11076:fcbdee9cdd74 11408:b894922d58cc
    18 
    18 
    19 
    19 
    20 #import "RestoreViewController.h"
    20 #import "RestoreViewController.h"
    21 #import "GameInterfaceBridge.h"
    21 #import "GameInterfaceBridge.h"
    22 
    22 
       
    23 @interface RestoreViewController ()
       
    24 @property (retain, nonatomic) IBOutlet UIButton *restoreButton;
       
    25 @property (retain, nonatomic) IBOutlet UIButton *dismissButton;
       
    26 @end
       
    27 
    23 @implementation RestoreViewController
    28 @implementation RestoreViewController
    24 
    29 
    25 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    30 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    26     return rotationManager(interfaceOrientation);
    31     return rotationManager(interfaceOrientation);
    27 }
    32 }
    30     UIButton *theButton = (UIButton *)sender;
    35     UIButton *theButton = (UIButton *)sender;
    31     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    36     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    32 
    37 
    33     if (theButton.tag != 0) {
    38     if (theButton.tag != 0) {
    34         [[AudioManagerController mainManager] playClickSound];
    39         [[AudioManagerController mainManager] playClickSound];
    35         [GameInterfaceBridge registerCallingController:self.parentViewController];
    40         [GameInterfaceBridge registerCallingController:self.presentingViewController];
    36         [GameInterfaceBridge startSaveGame:[[NSUserDefaults standardUserDefaults] objectForKey:@"savedGamePath"]];
    41         
       
    42         // Since iOS 8, the file system layout of app containers has changed.
       
    43         // So, we must rely now on saved game filename, not full path.
       
    44         NSString *oldSavedGamePath = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedGamePath"];
       
    45         NSString *savedGameFile = [oldSavedGamePath lastPathComponent];
       
    46         NSString *newSavedGamePath = [NSString stringWithFormat:@"%@%@", SAVES_DIRECTORY(), savedGameFile];
       
    47         
       
    48         [GameInterfaceBridge startSaveGame:newSavedGamePath];
    37     } else {
    49     } else {
    38         [[AudioManagerController mainManager] playBackSound];
    50         [[AudioManagerController mainManager] playBackSound];
    39         [defaults setObject:@"" forKey:@"savedGamePath"];
    51         [defaults setObject:@"" forKey:@"savedGamePath"];
    40         [defaults synchronize];
    52         [defaults synchronize];
    41     }
    53     }
    42     [self.parentViewController dismissModalViewControllerAnimated:YES];
    54     [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
    43 }
    55 }
    44 
    56 
    45 -(void) viewDidLoad {
    57 -(void) viewDidLoad {
    46     [super viewDidLoad];
    58     [super viewDidLoad];
       
    59     
       
    60     [self.restoreButton setTitle:NSLocalizedString(@"Restore", nil) forState:UIControlStateNormal];
       
    61     [self.dismissButton setTitle:NSLocalizedString(@"Dismiss", nil) forState:UIControlStateNormal];
       
    62     
       
    63     [self.restoreButton applyDarkBlueQuickStyle];
       
    64     [self.dismissButton applyDarkBlueQuickStyle];
    47 }
    65 }
    48 
    66 
    49 -(void) didReceiveMemoryWarning {
    67 -(void) didReceiveMemoryWarning {
    50     [super didReceiveMemoryWarning];
    68     [super didReceiveMemoryWarning];
    51 }
    69 }
    53 -(void) viewDidUnload {
    71 -(void) viewDidUnload {
    54     [super viewDidUnload];
    72     [super viewDidUnload];
    55 }
    73 }
    56 
    74 
    57 -(void) dealloc {
    75 -(void) dealloc {
       
    76     [_restoreButton release];
       
    77     [_dismissButton release];
    58     [super dealloc];
    78     [super dealloc];
    59 }
    79 }
    60 
    80 
    61 
    81 
    62 @end
    82 @end