project_files/HedgewarsMobile/Classes/SavedGamesViewController.m
changeset 5666 cc79eb30346e
parent 5208 878e551f0b4a
child 5699 1a9a6a7662aa
equal deleted inserted replaced
5664:dfc574d7f49e 5666:cc79eb30346e
    22 #import "SavedGamesViewController.h"
    22 #import "SavedGamesViewController.h"
    23 #import "GameInterfaceBridge.h"
    23 #import "GameInterfaceBridge.h"
    24 #import "CommodityFunctions.h"
    24 #import "CommodityFunctions.h"
    25 
    25 
    26 @implementation SavedGamesViewController
    26 @implementation SavedGamesViewController
    27 @synthesize tableView, listOfSavegames;
    27 @synthesize tableView, listOfSavegames, interfaceBridge;
    28 
    28 
    29 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    29 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    30     return rotationManager(interfaceOrientation);
    30     return rotationManager(interfaceOrientation);
    31 }
    31 }
    32 
    32 
   207     if (self.listOfSavegames == nil)
   207     if (self.listOfSavegames == nil)
   208         [self updateTable];
   208         [self updateTable];
   209 
   209 
   210     [(EditableCellView *)[self.tableView cellForRowAtIndexPath:indexPath] save:nil];
   210     [(EditableCellView *)[self.tableView cellForRowAtIndexPath:indexPath] save:nil];
   211 
   211 
   212     GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self];
   212     if (self.interfaceBridge == nil) {
       
   213         GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self];
       
   214         self.interfaceBridge = bridge;
       
   215         [bridge release];
       
   216     }
   213 
   217 
   214     NSString *filePath = [[NSString alloc] initWithFormat:@"%@/%@",SAVES_DIRECTORY(),[self.listOfSavegames objectAtIndex:[indexPath row]]];
   218     NSString *filePath = [[NSString alloc] initWithFormat:@"%@/%@",SAVES_DIRECTORY(),[self.listOfSavegames objectAtIndex:[indexPath row]]];
   215     [bridge startSaveGame:filePath];
   219     [self.interfaceBridge startSaveGame:filePath];
   216     [filePath release];
   220     [filePath release];
   217 
       
   218     [bridge release];
       
   219 }
   221 }
   220 
   222 
   221 #pragma mark -
   223 #pragma mark -
   222 #pragma mark editableCellView delegate
   224 #pragma mark editableCellView delegate
   223 // rename old file if names differ
   225 // rename old file if names differ
   236 
   238 
   237 #pragma mark -
   239 #pragma mark -
   238 #pragma mark Memory Management
   240 #pragma mark Memory Management
   239 -(void) didReceiveMemoryWarning {
   241 -(void) didReceiveMemoryWarning {
   240     self.listOfSavegames = nil;
   242     self.listOfSavegames = nil;
       
   243     self.interfaceBridge = nil;
   241     MSG_MEMCLEAN();
   244     MSG_MEMCLEAN();
   242     [super didReceiveMemoryWarning];
   245     [super didReceiveMemoryWarning];
   243 }
   246 }
   244 
   247 
   245 -(void) viewDidUnload {
   248 -(void) viewDidUnload {
   246     self.tableView = nil;
   249     self.tableView = nil;
   247     self.listOfSavegames = nil;
   250     self.listOfSavegames = nil;
       
   251     self.interfaceBridge = nil;
   248     MSG_DIDUNLOAD();
   252     MSG_DIDUNLOAD();
   249     [super viewDidUnload];
   253     [super viewDidUnload];
   250 }
   254 }
   251 
   255 
   252 -(void) dealloc {
   256 -(void) dealloc {
   253     releaseAndNil(tableView);
   257     releaseAndNil(tableView);
   254     releaseAndNil(listOfSavegames);
   258     releaseAndNil(listOfSavegames);
       
   259     releaseAndNil(interfaceBridge);
   255     [super dealloc];
   260     [super dealloc];
   256 }
   261 }
   257 
   262 
   258 @end
   263 @end