author | koda |
Tue, 04 Jan 2011 01:21:30 +0100 | |
changeset 4811 | 3edc0cdcfe03 |
parent 4763 | c228a4841e3f |
child 4856 | dbc256913b35 |
permissions | -rw-r--r-- |
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
1 |
/* |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
3 |
* Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com> |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
4 |
* |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
8 |
* |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
13 |
* |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
17 |
* |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
18 |
* File created on 22/09/2010. |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
19 |
*/ |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
20 |
|
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
21 |
|
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
22 |
#import "SavedGamesViewController.h" |
3898 | 23 |
#import "SDL_uikitappdelegate.h" |
4763
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
24 |
#import "StatsPageViewController.h" |
3898 | 25 |
#import "CommodityFunctions.h" |
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
26 |
|
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
27 |
@implementation SavedGamesViewController |
3898 | 28 |
@synthesize tableView, listOfSavegames; |
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
29 |
|
3898 | 30 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
31 |
return rotationManager(interfaceOrientation); |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
32 |
} |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
33 |
|
3923
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
34 |
-(void) updateTable { |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
35 |
NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:SAVES_DIRECTORY() error:NULL]; |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
36 |
NSMutableArray *array = [[NSMutableArray alloc] initWithArray:contentsOfDir copyItems:YES]; |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
37 |
self.listOfSavegames = array; |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
38 |
[array release]; |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
39 |
|
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
40 |
[self.tableView reloadData]; |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
41 |
} |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
42 |
|
3898 | 43 |
-(void) viewDidLoad { |
4115 | 44 |
if ([self.tableView respondsToSelector:@selector(setBackgroundView:)]) |
4082 | 45 |
self.tableView.backgroundView = nil; |
46 |
||
47 |
NSString *imgName; |
|
4030 | 48 |
if (IS_IPAD()) |
49 |
imgName = @"mediumBackground~ipad.png"; |
|
50 |
else |
|
51 |
imgName = @"smallerBackground~iphone.png"; |
|
52 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName]; |
|
53 |
self.view.backgroundColor = [UIColor colorWithPatternImage:img]; |
|
54 |
[img release]; |
|
4082 | 55 |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
56 |
[super viewDidLoad]; |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
57 |
} |
3898 | 58 |
|
59 |
-(void) viewWillAppear:(BOOL)animated { |
|
3978 | 60 |
[self updateTable]; |
3898 | 61 |
[super viewWillAppear:animated]; |
62 |
} |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
63 |
|
3923
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
64 |
#pragma mark - |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
65 |
#pragma mark button functions |
3898 | 66 |
-(IBAction) buttonPressed:(id) sender { |
67 |
playSound(@"backSound"); |
|
3903 | 68 |
[self.tableView setEditing:NO animated:YES]; |
3898 | 69 |
[[self parentViewController] dismissModalViewControllerAnimated:YES]; |
70 |
} |
|
71 |
||
3903 | 72 |
-(IBAction) toggleEdit:(id) sender { |
73 |
BOOL isEditing = self.tableView.editing; |
|
74 |
[self.tableView setEditing:!isEditing animated:YES]; |
|
3971 | 75 |
} |
76 |
||
77 |
-(void) duplicateEntry:(id) sender { |
|
78 |
UIButton *button = (UIButton *)sender; |
|
79 |
NSUInteger row = button.tag; |
|
80 |
||
81 |
if (self.listOfSavegames == nil) |
|
82 |
[self updateTable]; |
|
83 |
||
84 |
[(EditableCellView *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0]] save:nil]; |
|
85 |
NSString *currentSaveName = [self.listOfSavegames objectAtIndex:row]; |
|
86 |
NSString *newSaveName = [[currentSaveName stringByDeletingPathExtension] stringByAppendingFormat:@" %d.hws",[self.listOfSavegames count]]; |
|
87 |
||
88 |
NSString *currentFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),currentSaveName]; |
|
89 |
NSString *newFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),newSaveName]; |
|
90 |
[[NSFileManager defaultManager] copyItemAtPath:currentFilePath toPath:newFilePath error:nil]; |
|
91 |
[self.listOfSavegames addObject:newSaveName]; |
|
92 |
[self.listOfSavegames sortUsingSelector:@selector(compare:)]; |
|
93 |
||
94 |
//[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:[self.listOfSavegames indexOfObject:newSaveName] inSection:0]] withRowAnimation:UITableViewRowAnimationFade]; |
|
95 |
[self.tableView reloadData]; |
|
3923
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
96 |
} |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
97 |
|
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
98 |
-(IBAction) clearAll:(id) sender { |
3971 | 99 |
NSString *titleStr, *cancelStr, *confirmStr; |
3996 | 100 |
if (IS_IPAD()) { |
3971 | 101 |
titleStr = nil; |
102 |
cancelStr = nil; |
|
103 |
confirmStr = NSLocalizedString(@"Tap to confirm",@""); |
|
104 |
} else { |
|
105 |
titleStr = NSLocalizedString(@"Are you reeeeeally sure?", @""); |
|
106 |
cancelStr = NSLocalizedString(@"Well, maybe not...", @""); |
|
107 |
confirmStr = NSLocalizedString(@"Of course!", @""); |
|
108 |
} |
|
109 |
||
110 |
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:titleStr |
|
111 |
delegate:self |
|
112 |
cancelButtonTitle:cancelStr |
|
113 |
destructiveButtonTitle:confirmStr |
|
114 |
otherButtonTitles:nil]; |
|
4362
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4115
diff
changeset
|
115 |
|
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4115
diff
changeset
|
116 |
if (IS_IPAD()) |
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4115
diff
changeset
|
117 |
[actionSheet showFromBarButtonItem:(UIBarButtonItem *)sender animated:YES]; |
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4115
diff
changeset
|
118 |
else |
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4115
diff
changeset
|
119 |
[actionSheet showInView:self.view]; |
3971 | 120 |
[actionSheet release]; |
121 |
} |
|
122 |
||
123 |
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex { |
|
124 |
if ([actionSheet cancelButtonIndex] != buttonIndex) { |
|
125 |
[[NSFileManager defaultManager] removeItemAtPath:SAVES_DIRECTORY() error:NULL]; |
|
126 |
[[NSFileManager defaultManager] createDirectoryAtPath:SAVES_DIRECTORY() withIntermediateDirectories:NO attributes:nil error:NULL]; |
|
127 |
[self updateTable]; |
|
128 |
} |
|
3903 | 129 |
} |
130 |
||
3898 | 131 |
#pragma mark - |
132 |
#pragma mark Table view data source |
|
133 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
134 |
return 1; |
|
135 |
} |
|
136 |
||
137 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
3971 | 138 |
if (self.listOfSavegames == nil) |
139 |
[self updateTable]; |
|
3898 | 140 |
return [self.listOfSavegames count]; |
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
141 |
} |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
142 |
|
3898 | 143 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
144 |
static NSString *CellIdentifier = @"Cell"; |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
145 |
|
3971 | 146 |
if (self.listOfSavegames == nil) |
147 |
[self updateTable]; |
|
3903 | 148 |
EditableCellView *editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
149 |
if (editableCell == nil) { |
|
150 |
editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
|
151 |
editableCell.delegate = self; |
|
152 |
} |
|
153 |
editableCell.tag = [indexPath row]; |
|
3904
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
154 |
editableCell.respectEditing = YES; |
3903 | 155 |
editableCell.textField.text = [[self.listOfSavegames objectAtIndex:[indexPath row]] stringByDeletingPathExtension]; |
156 |
editableCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
|
157 |
||
158 |
UIImage *addImg = [UIImage imageWithContentsOfFile:@"plus.png"]; |
|
159 |
UIButton *customButton = [UIButton buttonWithType:UIButtonTypeContactAdd]; |
|
160 |
customButton.tag = [indexPath row]; |
|
161 |
[customButton setImage:addImg forState:UIControlStateNormal]; |
|
162 |
[customButton addTarget:self action:@selector(duplicateEntry:) forControlEvents:UIControlEventTouchUpInside]; |
|
163 |
editableCell.editingAccessoryView = customButton; |
|
164 |
||
165 |
return (UITableViewCell *)editableCell; |
|
166 |
} |
|
3904
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
167 |
|
3903 | 168 |
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section { |
3904
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
169 |
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 50)]; |
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
170 |
footer.backgroundColor = [UIColor clearColor]; |
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
171 |
|
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
172 |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width*80/100, 100)]; |
4115 | 173 |
label.center = CGPointMake(self.tableView.frame.size.width/2, 70); |
3904
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
174 |
label.textAlignment = UITextAlignmentCenter; |
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
175 |
label.font = [UIFont systemFontOfSize:16]; |
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
176 |
label.textColor = [UIColor lightGrayColor]; |
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
177 |
label.numberOfLines = 5; |
4476
4bf74e158f44
team selection completely refactored, now has animation and more performance
koda
parents:
4362
diff
changeset
|
178 |
label.text = NSLocalizedString(@"Games are automatically saved and can be resumed by selecting an entry above.\nYou can modify this list by pressing the 'Edit' button.\nCompleted games are removed at the end of the match.",@""); |
3904
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
179 |
|
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
180 |
label.backgroundColor = [UIColor clearColor]; |
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
181 |
[footer addSubview:label]; |
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
182 |
[label release]; |
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
183 |
return [footer autorelease]; |
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
184 |
} |
3898 | 185 |
|
4115 | 186 |
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { |
187 |
return 125; |
|
188 |
} |
|
189 |
||
3903 | 190 |
-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { |
191 |
NSUInteger row = [indexPath row]; |
|
192 |
[(EditableCellView *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0]] save:nil]; |
|
193 |
||
3971 | 194 |
if (self.listOfSavegames == nil) |
195 |
[self updateTable]; |
|
196 |
||
3903 | 197 |
NSString *saveName = [self.listOfSavegames objectAtIndex:row]; |
198 |
NSString *currentFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),saveName]; |
|
199 |
[[NSFileManager defaultManager] removeItemAtPath:currentFilePath error:nil]; |
|
200 |
[self.listOfSavegames removeObject:saveName]; |
|
201 |
||
202 |
[self.tableView reloadData]; |
|
203 |
} |
|
3898 | 204 |
|
205 |
#pragma mark - |
|
206 |
#pragma mark Table view delegate |
|
207 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
208 |
[self.tableView deselectRowAtIndexPath:indexPath animated:YES]; |
|
3971 | 209 |
if (self.listOfSavegames == nil) |
210 |
[self updateTable]; |
|
211 |
||
3903 | 212 |
[(EditableCellView *)[self.tableView cellForRowAtIndexPath:indexPath] save:nil]; |
213 |
||
3898 | 214 |
NSString *filePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),[self.listOfSavegames objectAtIndex:[indexPath row]]]; |
215 |
||
216 |
NSDictionary *allDataNecessary = [NSDictionary dictionaryWithObjectsAndKeys: |
|
217 |
filePath,@"savefile", |
|
218 |
[NSNumber numberWithBool:NO],@"netgame", |
|
3978 | 219 |
[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:self.interfaceOrientation] forKey:@"orientation"],@"game_dictionary", |
3898 | 220 |
nil]; |
4763
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
221 |
|
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
222 |
StatsPageViewController *statsPage = [[StatsPageViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
223 |
statsPage.modalTransitionStyle = UIModalTransitionStyleCoverVertical; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
224 |
if ([statsPage respondsToSelector:@selector(setModalPresentationStyle:)]) |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
225 |
statsPage.modalPresentationStyle = UIModalPresentationPageSheet; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
226 |
[self presentModalViewController:statsPage animated:NO]; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
227 |
|
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
228 |
NSArray *stats = [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary]; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
229 |
if ([stats count] == 0) { |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
230 |
[statsPage dismissModalViewControllerAnimated:NO]; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
231 |
} else { |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
232 |
statsPage.statsArray = stats; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
233 |
[statsPage.tableView reloadData]; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
234 |
[statsPage viewWillAppear:YES]; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
235 |
} |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
236 |
// reload needed because when ending game the entry remains there |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
237 |
[self.tableView reloadData]; |
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
238 |
} |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
239 |
|
3898 | 240 |
#pragma mark - |
3903 | 241 |
#pragma mark editableCellView delegate |
242 |
// rename old file if names differ |
|
243 |
-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue { |
|
3971 | 244 |
if (self.listOfSavegames == nil) |
245 |
[self updateTable]; |
|
3903 | 246 |
NSString *oldFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),[self.listOfSavegames objectAtIndex:tagValue]]; |
247 |
NSString *newFilePath = [NSString stringWithFormat:@"%@/%@.hws",SAVES_DIRECTORY(),textString]; |
|
248 |
||
249 |
if ([oldFilePath isEqualToString:newFilePath] == NO) { |
|
250 |
[[NSFileManager defaultManager] moveItemAtPath:oldFilePath toPath:newFilePath error:nil]; |
|
251 |
[self.listOfSavegames replaceObjectAtIndex:tagValue withObject:[textString stringByAppendingString:@".hws"]]; |
|
252 |
} |
|
253 |
||
254 |
} |
|
255 |
||
256 |
#pragma mark - |
|
3898 | 257 |
#pragma mark Memory Management |
258 |
-(void) didReceiveMemoryWarning { |
|
3971 | 259 |
self.listOfSavegames = nil; |
260 |
MSG_MEMCLEAN(); |
|
3898 | 261 |
[super didReceiveMemoryWarning]; |
262 |
} |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
263 |
|
3898 | 264 |
-(void) viewDidUnload { |
265 |
self.tableView = nil; |
|
266 |
self.listOfSavegames = nil; |
|
3971 | 267 |
MSG_DIDUNLOAD(); |
3898 | 268 |
[super viewDidUnload]; |
269 |
} |
|
270 |
||
271 |
-(void) dealloc { |
|
272 |
[tableView release]; |
|
273 |
[listOfSavegames release]; |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
274 |
[super dealloc]; |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
275 |
} |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
276 |
|
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
277 |
@end |