project_files/HedgewarsMobile/Classes/RestoreViewController.m
changeset 5666 cc79eb30346e
parent 5220 76a2246f18f0
child 5668 36c1d1b789b8
equal deleted inserted replaced
5664:dfc574d7f49e 5666:cc79eb30346e
    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 
    26 @synthesize interfaceBridge;
    27 
    27 
    28 // Override to allow orientations other than the default portrait orientation.
    28 // Override to allow orientations other than the default portrait orientation.
    29 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    29 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    30     return rotationManager(interfaceOrientation);
    30     return rotationManager(interfaceOrientation);
    31 }
    31 }
    34 -(IBAction) buttonReleased:(id) sender {
    34 -(IBAction) buttonReleased:(id) sender {
    35     UIButton *theButton = (UIButton *)sender;
    35     UIButton *theButton = (UIButton *)sender;
    36     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    36     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    37 
    37 
    38     if (theButton.tag != 0) {
    38     if (theButton.tag != 0) {
    39         GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self.parentViewController];
    39         if (self.interfaceBridge == nil) {
       
    40             GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self];
       
    41             self.interfaceBridge = bridge;
       
    42             [bridge release];
       
    43         }
    40         [self.parentViewController dismissModalViewControllerAnimated:NO];
    44         [self.parentViewController dismissModalViewControllerAnimated:NO];
    41         [bridge startSaveGame:[defaults objectForKey:@"savedGamePath"]];
    45         [self.interfaceBridge startSaveGame:[defaults objectForKey:@"savedGamePath"]];
    42         [bridge release];
       
    43     } else {
    46     } else {
    44         [defaults setObject:@"" forKey:@"savedGamePath"];
    47         [defaults setObject:@"" forKey:@"savedGamePath"];
    45         [defaults synchronize];
    48         [defaults synchronize];
    46         [self.parentViewController dismissModalViewControllerAnimated:YES];
    49         [self.parentViewController dismissModalViewControllerAnimated:YES];
    47     }
    50     }
    48 }
       
    49 
       
    50 -(void) didReceiveMemoryWarning {
       
    51     [super didReceiveMemoryWarning];
       
    52 }
    51 }
    53 
    52 
    54 -(void) viewDidLoad {
    53 -(void) viewDidLoad {
    55     NSString *imgName;
    54     NSString *imgName;
    56     if (IS_IPAD())
    55     if (IS_IPAD())
    61     self.view.backgroundColor = [UIColor colorWithPatternImage:img];
    60     self.view.backgroundColor = [UIColor colorWithPatternImage:img];
    62     [img release];
    61     [img release];
    63     [super viewDidLoad];
    62     [super viewDidLoad];
    64 }
    63 }
    65 
    64 
       
    65 -(void) didReceiveMemoryWarning {
       
    66     self.interfaceBridge = nil;
       
    67     [super didReceiveMemoryWarning];
       
    68 }
       
    69 
    66 -(void) viewDidUnload {
    70 -(void) viewDidUnload {
       
    71     self.interfaceBridge = nil;
    67     [super viewDidUnload];
    72     [super viewDidUnload];
    68 }
    73 }
    69 
    74 
    70 -(void) dealloc {
    75 -(void) dealloc {
       
    76     releaseAndNil(interfaceBridge);
    71     [super dealloc];
    77     [super dealloc];
    72 }
    78 }
    73 
    79 
    74 
    80 
    75 @end
    81 @end