project_files/HedgewarsMobile/Classes/RestoreViewController.m
changeset 6020 c792d4b3e080
parent 6008 215f0c9719e3
child 6321 5a0416e5a6de
equal deleted inserted replaced
6019:8843ea756cfc 6020:c792d4b3e080
    21 
    21 
    22 #import "RestoreViewController.h"
    22 #import "RestoreViewController.h"
    23 #import "GameInterfaceBridge.h"
    23 #import "GameInterfaceBridge.h"
    24 
    24 
    25 @implementation RestoreViewController
    25 @implementation RestoreViewController
    26 @synthesize interfaceBridge;
       
    27 
    26 
    28 // Override to allow orientations other than the default portrait orientation.
    27 // Override to allow orientations other than the default portrait orientation.
    29 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    28 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    30     return rotationManager(interfaceOrientation);
    29     return rotationManager(interfaceOrientation);
    31 }
    30 }
    35     UIButton *theButton = (UIButton *)sender;
    34     UIButton *theButton = (UIButton *)sender;
    36     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    35     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    37 
    36 
    38     if (theButton.tag != 0) {
    37     if (theButton.tag != 0) {
    39         [AudioManagerController playClickSound];
    38         [AudioManagerController playClickSound];
    40         if (self.interfaceBridge == nil) {
       
    41             GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self.parentViewController];
       
    42             self.interfaceBridge = bridge;
       
    43             [bridge release];
       
    44         }
       
    45         // TODO: it is useless to keep the modalcontroller around when calling interfacebridge
       
    46         // but as long as it is an instance we mustn't release it beforehand
       
    47         // moreover in this way the stats don't show up :/
       
    48         [self.interfaceBridge startSaveGame:[defaults objectForKey:@"savedGamePath"]];
       
    49         [self.parentViewController dismissModalViewControllerAnimated:NO];
    39         [self.parentViewController dismissModalViewControllerAnimated:NO];
       
    40         [[NSNotificationCenter defaultCenter] postNotificationName:@"launchRestoredGame" object:nil];
    50     } else {
    41     } else {
    51         [AudioManagerController playBackSound];
    42         [AudioManagerController playBackSound];
    52         [defaults setObject:@"" forKey:@"savedGamePath"];
    43         [defaults setObject:@"" forKey:@"savedGamePath"];
    53         [defaults synchronize];
    44         [defaults synchronize];
    54         [self.parentViewController dismissModalViewControllerAnimated:YES];
    45         [self.parentViewController dismissModalViewControllerAnimated:YES];
    66     [img release];
    57     [img release];
    67     [super viewDidLoad];
    58     [super viewDidLoad];
    68 }
    59 }
    69 
    60 
    70 -(void) didReceiveMemoryWarning {
    61 -(void) didReceiveMemoryWarning {
    71     // don't nil this one or it won't be able to send messages
       
    72     //self.interfaceBridge = nil;
       
    73     [super didReceiveMemoryWarning];
    62     [super didReceiveMemoryWarning];
    74 }
    63 }
    75 
    64 
    76 -(void) viewDidUnload {
    65 -(void) viewDidUnload {
    77     self.interfaceBridge = nil;
       
    78     [super viewDidUnload];
    66     [super viewDidUnload];
    79 }
    67 }
    80 
    68 
    81 -(void) dealloc {
    69 -(void) dealloc {
    82     releaseAndNil(interfaceBridge);
       
    83     [super dealloc];
    70     [super dealloc];
    84 }
    71 }
    85 
    72 
    86 
    73 
    87 @end
    74 @end