author | koda |
Sun, 17 Apr 2011 20:52:56 +0200 | |
changeset 5154 | 851f36579ed4 |
parent 5002 | a9c44a8ffec8 |
child 5156 | 641abe679bf0 |
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 |
4976 | 3 |
* Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com> |
3893
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" |
4763
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
23 |
#import "StatsPageViewController.h" |
3898 | 24 |
#import "CommodityFunctions.h" |
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
25 |
|
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
26 |
@implementation SavedGamesViewController |
3898 | 27 |
@synthesize tableView, listOfSavegames; |
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
28 |
|
3898 | 29 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
30 |
return rotationManager(interfaceOrientation); |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
31 |
} |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
32 |
|
3923
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
33 |
-(void) updateTable { |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
34 |
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
|
35 |
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
|
36 |
self.listOfSavegames = array; |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
37 |
[array release]; |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
38 |
|
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
39 |
[self.tableView reloadData]; |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
40 |
} |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
41 |
|
3898 | 42 |
-(void) viewDidLoad { |
4115 | 43 |
if ([self.tableView respondsToSelector:@selector(setBackgroundView:)]) |
4082 | 44 |
self.tableView.backgroundView = nil; |
45 |
||
46 |
NSString *imgName; |
|
4030 | 47 |
if (IS_IPAD()) |
48 |
imgName = @"mediumBackground~ipad.png"; |
|
49 |
else |
|
50 |
imgName = @"smallerBackground~iphone.png"; |
|
51 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName]; |
|
52 |
self.view.backgroundColor = [UIColor colorWithPatternImage:img]; |
|
53 |
[img release]; |
|
4082 | 54 |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
55 |
[super viewDidLoad]; |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
56 |
} |
3898 | 57 |
|
58 |
-(void) viewWillAppear:(BOOL)animated { |
|
3978 | 59 |
[self updateTable]; |
3898 | 60 |
[super viewWillAppear:animated]; |
61 |
} |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
62 |
|
3923
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
63 |
#pragma mark - |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
64 |
#pragma mark button functions |
3898 | 65 |
-(IBAction) buttonPressed:(id) sender { |
66 |
playSound(@"backSound"); |
|
3903 | 67 |
[self.tableView setEditing:NO animated:YES]; |
3898 | 68 |
[[self parentViewController] dismissModalViewControllerAnimated:YES]; |
69 |
} |
|
70 |
||
3903 | 71 |
-(IBAction) toggleEdit:(id) sender { |
72 |
BOOL isEditing = self.tableView.editing; |
|
73 |
[self.tableView setEditing:!isEditing animated:YES]; |
|
3971 | 74 |
} |
75 |
||
76 |
-(void) duplicateEntry:(id) sender { |
|
77 |
UIButton *button = (UIButton *)sender; |
|
78 |
NSUInteger row = button.tag; |
|
79 |
||
80 |
if (self.listOfSavegames == nil) |
|
81 |
[self updateTable]; |
|
82 |
||
83 |
[(EditableCellView *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0]] save:nil]; |
|
84 |
NSString *currentSaveName = [self.listOfSavegames objectAtIndex:row]; |
|
85 |
NSString *newSaveName = [[currentSaveName stringByDeletingPathExtension] stringByAppendingFormat:@" %d.hws",[self.listOfSavegames count]]; |
|
86 |
||
87 |
NSString *currentFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),currentSaveName]; |
|
88 |
NSString *newFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),newSaveName]; |
|
89 |
[[NSFileManager defaultManager] copyItemAtPath:currentFilePath toPath:newFilePath error:nil]; |
|
90 |
[self.listOfSavegames addObject:newSaveName]; |
|
91 |
[self.listOfSavegames sortUsingSelector:@selector(compare:)]; |
|
92 |
||
93 |
[self.tableView reloadData]; |
|
3923
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
94 |
} |
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
95 |
|
694e6f6e0e30
various classes updates (new version in mainmenu, opt in mapconfig, clear all in savegames)
koda
parents:
3904
diff
changeset
|
96 |
-(IBAction) clearAll:(id) sender { |
3971 | 97 |
NSString *titleStr, *cancelStr, *confirmStr; |
3996 | 98 |
if (IS_IPAD()) { |
3971 | 99 |
titleStr = nil; |
100 |
cancelStr = nil; |
|
101 |
confirmStr = NSLocalizedString(@"Tap to confirm",@""); |
|
102 |
} else { |
|
103 |
titleStr = NSLocalizedString(@"Are you reeeeeally sure?", @""); |
|
104 |
cancelStr = NSLocalizedString(@"Well, maybe not...", @""); |
|
105 |
confirmStr = NSLocalizedString(@"Of course!", @""); |
|
106 |
} |
|
107 |
||
108 |
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:titleStr |
|
109 |
delegate:self |
|
110 |
cancelButtonTitle:cancelStr |
|
111 |
destructiveButtonTitle:confirmStr |
|
112 |
otherButtonTitles:nil]; |
|
4362
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4115
diff
changeset
|
113 |
|
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4115
diff
changeset
|
114 |
if (IS_IPAD()) |
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4115
diff
changeset
|
115 |
[actionSheet showFromBarButtonItem:(UIBarButtonItem *)sender animated:YES]; |
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4115
diff
changeset
|
116 |
else |
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4115
diff
changeset
|
117 |
[actionSheet showInView:self.view]; |
3971 | 118 |
[actionSheet release]; |
119 |
} |
|
120 |
||
121 |
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex { |
|
122 |
if ([actionSheet cancelButtonIndex] != buttonIndex) { |
|
123 |
[[NSFileManager defaultManager] removeItemAtPath:SAVES_DIRECTORY() error:NULL]; |
|
124 |
[[NSFileManager defaultManager] createDirectoryAtPath:SAVES_DIRECTORY() withIntermediateDirectories:NO attributes:nil error:NULL]; |
|
125 |
[self updateTable]; |
|
126 |
} |
|
3903 | 127 |
} |
128 |
||
3898 | 129 |
#pragma mark - |
130 |
#pragma mark Table view data source |
|
131 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
132 |
return 1; |
|
133 |
} |
|
134 |
||
135 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
3971 | 136 |
if (self.listOfSavegames == nil) |
137 |
[self updateTable]; |
|
3898 | 138 |
return [self.listOfSavegames count]; |
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
139 |
} |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
140 |
|
3898 | 141 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
142 |
static NSString *CellIdentifier = @"Cell"; |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
143 |
|
3971 | 144 |
if (self.listOfSavegames == nil) |
145 |
[self updateTable]; |
|
3903 | 146 |
EditableCellView *editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
147 |
if (editableCell == nil) { |
|
148 |
editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
|
149 |
editableCell.delegate = self; |
|
150 |
} |
|
151 |
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
|
152 |
editableCell.respectEditing = YES; |
3903 | 153 |
editableCell.textField.text = [[self.listOfSavegames objectAtIndex:[indexPath row]] stringByDeletingPathExtension]; |
154 |
editableCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
|
155 |
||
156 |
UIImage *addImg = [UIImage imageWithContentsOfFile:@"plus.png"]; |
|
157 |
UIButton *customButton = [UIButton buttonWithType:UIButtonTypeContactAdd]; |
|
158 |
customButton.tag = [indexPath row]; |
|
159 |
[customButton setImage:addImg forState:UIControlStateNormal]; |
|
160 |
[customButton addTarget:self action:@selector(duplicateEntry:) forControlEvents:UIControlEventTouchUpInside]; |
|
161 |
editableCell.editingAccessoryView = customButton; |
|
162 |
||
163 |
return (UITableViewCell *)editableCell; |
|
164 |
} |
|
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
|
165 |
|
3903 | 166 |
-(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
|
167 |
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
|
168 |
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
|
169 |
|
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 |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width*80/100, 100)]; |
4115 | 171 |
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
|
172 |
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
|
173 |
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
|
174 |
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
|
175 |
label.numberOfLines = 5; |
4476
4bf74e158f44
team selection completely refactored, now has animation and more performance
koda
parents:
4362
diff
changeset
|
176 |
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
|
177 |
|
22e4d74240e5
finishing touches to save games handling (help label, dim on overlay, edit text only when table is editable)
koda
parents:
3903
diff
changeset
|
178 |
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
|
179 |
[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
|
180 |
[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
|
181 |
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
|
182 |
} |
3898 | 183 |
|
4115 | 184 |
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { |
185 |
return 125; |
|
186 |
} |
|
187 |
||
3903 | 188 |
-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { |
189 |
NSUInteger row = [indexPath row]; |
|
190 |
[(EditableCellView *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0]] save:nil]; |
|
191 |
||
3971 | 192 |
if (self.listOfSavegames == nil) |
193 |
[self updateTable]; |
|
194 |
||
3903 | 195 |
NSString *saveName = [self.listOfSavegames objectAtIndex:row]; |
196 |
NSString *currentFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),saveName]; |
|
197 |
[[NSFileManager defaultManager] removeItemAtPath:currentFilePath error:nil]; |
|
198 |
[self.listOfSavegames removeObject:saveName]; |
|
199 |
||
200 |
[self.tableView reloadData]; |
|
201 |
} |
|
3898 | 202 |
|
203 |
#pragma mark - |
|
204 |
#pragma mark Table view delegate |
|
205 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
206 |
[self.tableView deselectRowAtIndexPath:indexPath animated:YES]; |
|
3971 | 207 |
if (self.listOfSavegames == nil) |
208 |
[self updateTable]; |
|
209 |
||
3903 | 210 |
[(EditableCellView *)[self.tableView cellForRowAtIndexPath:indexPath] save:nil]; |
211 |
||
3898 | 212 |
NSString *filePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),[self.listOfSavegames objectAtIndex:[indexPath row]]]; |
213 |
||
214 |
NSDictionary *allDataNecessary = [NSDictionary dictionaryWithObjectsAndKeys: |
|
215 |
filePath,@"savefile", |
|
216 |
[NSNumber numberWithBool:NO],@"netgame", |
|
3978 | 217 |
[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:self.interfaceOrientation] forKey:@"orientation"],@"game_dictionary", |
3898 | 218 |
nil]; |
4763
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
219 |
|
4861
91f889289a47
(ios) perform a small change about how to close the game window, should hopefully save memory and avoid crashes (who am i kidding? that's the usual PR talk...)
koda
parents:
4856
diff
changeset
|
220 |
// also modify GameConfigViewController.m |
4763
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
221 |
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
|
222 |
statsPage.modalTransitionStyle = UIModalTransitionStyleCoverVertical; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
223 |
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
|
224 |
statsPage.modalPresentationStyle = UIModalPresentationPageSheet; |
4861
91f889289a47
(ios) perform a small change about how to close the game window, should hopefully save memory and avoid crashes (who am i kidding? that's the usual PR talk...)
koda
parents:
4856
diff
changeset
|
225 |
// avoid showing the stat page immediately, but wait for 3 seconds |
91f889289a47
(ios) perform a small change about how to close the game window, should hopefully save memory and avoid crashes (who am i kidding? that's the usual PR talk...)
koda
parents:
4856
diff
changeset
|
226 |
[self performSelector:@selector(presentModalViewController:animated:) withObject:statsPage afterDelay:3]; |
4763
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
227 |
|
4912
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
228 |
NSArray *stats; |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
229 |
if (IS_DUALHEAD()) { |
5002
a9c44a8ffec8
we get our own AppDelegate, subclassing SDL_UikitAppDelegate so that we don't have to mess with sdl build system
koda
parents:
4976
diff
changeset
|
230 |
stats = [[HedgewarsAppDelegate sharedAppDelegate] startSDLgame:allDataNecessary]; |
4912
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
231 |
[self presentModalViewController:statsPage animated:NO]; |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
232 |
} else { |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
233 |
[self performSelector:@selector(presentModalViewController:animated:) withObject:statsPage afterDelay:3]; |
5002
a9c44a8ffec8
we get our own AppDelegate, subclassing SDL_UikitAppDelegate so that we don't have to mess with sdl build system
koda
parents:
4976
diff
changeset
|
234 |
stats = [[HedgewarsAppDelegate sharedAppDelegate] startSDLgame:allDataNecessary]; |
4912
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
235 |
} |
862b134284b2
change order of statspage/gamerun when running in dual screen
koda
parents:
4861
diff
changeset
|
236 |
|
4856 | 237 |
if ([stats count] <= 1) { |
238 |
DLog(@"%@",stats); |
|
4763
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
239 |
[statsPage dismissModalViewControllerAnimated:NO]; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
240 |
} else { |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
241 |
statsPage.statsArray = stats; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
242 |
[statsPage.tableView reloadData]; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
243 |
[statsPage viewWillAppear:YES]; |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
244 |
} |
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4476
diff
changeset
|
245 |
// 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
|
246 |
[self.tableView reloadData]; |
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
247 |
} |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
248 |
|
3898 | 249 |
#pragma mark - |
3903 | 250 |
#pragma mark editableCellView delegate |
251 |
// rename old file if names differ |
|
252 |
-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue { |
|
3971 | 253 |
if (self.listOfSavegames == nil) |
254 |
[self updateTable]; |
|
3903 | 255 |
NSString *oldFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),[self.listOfSavegames objectAtIndex:tagValue]]; |
256 |
NSString *newFilePath = [NSString stringWithFormat:@"%@/%@.hws",SAVES_DIRECTORY(),textString]; |
|
257 |
||
258 |
if ([oldFilePath isEqualToString:newFilePath] == NO) { |
|
259 |
[[NSFileManager defaultManager] moveItemAtPath:oldFilePath toPath:newFilePath error:nil]; |
|
260 |
[self.listOfSavegames replaceObjectAtIndex:tagValue withObject:[textString stringByAppendingString:@".hws"]]; |
|
261 |
} |
|
262 |
||
263 |
} |
|
264 |
||
265 |
#pragma mark - |
|
3898 | 266 |
#pragma mark Memory Management |
267 |
-(void) didReceiveMemoryWarning { |
|
3971 | 268 |
self.listOfSavegames = nil; |
269 |
MSG_MEMCLEAN(); |
|
3898 | 270 |
[super didReceiveMemoryWarning]; |
271 |
} |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
272 |
|
3898 | 273 |
-(void) viewDidUnload { |
274 |
self.tableView = nil; |
|
275 |
self.listOfSavegames = nil; |
|
3971 | 276 |
MSG_DIDUNLOAD(); |
3898 | 277 |
[super viewDidUnload]; |
278 |
} |
|
279 |
||
280 |
-(void) dealloc { |
|
281 |
[tableView release]; |
|
282 |
[listOfSavegames release]; |
|
3893
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
283 |
[super dealloc]; |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
284 |
} |
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
285 |
|
568bfd083465
allow more flexibility between viewcontrollers, also added stub pages for saved games
koda
parents:
diff
changeset
|
286 |
@end |