author | unc0rr |
Sun, 06 Jun 2010 15:29:33 +0000 | |
changeset 3500 | af8390d807d6 |
parent 3490 | 016b3172b645 |
permissions | -rw-r--r-- |
3305 | 1 |
// |
2 |
// SingleTeamViewController.m |
|
3 |
// HedgewarsMobile |
|
4 |
// |
|
5 |
// Created by Vittorio on 02/04/10. |
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved. |
|
7 |
// |
|
8 |
||
9 |
#import "SingleTeamViewController.h" |
|
10 |
#import "HogHatViewController.h" |
|
3340 | 11 |
#import "GravesViewController.h" |
12 |
#import "VoicesViewController.h" |
|
13 |
#import "FortsViewController.h" |
|
3325 | 14 |
#import "FlagsViewController.h" |
3340 | 15 |
#import "LevelViewController.h" |
3325 | 16 |
#import "CommodityFunctions.h" |
3352 | 17 |
#import "UIImageExtra.h" |
3305 | 18 |
|
3330 | 19 |
#define TEAMNAME_TAG 1234 |
20 |
||
3305 | 21 |
@implementation SingleTeamViewController |
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
22 |
@synthesize teamDictionary, normalHogSprite, secondaryItems, textFieldBeingEdited, teamName; |
3325 | 23 |
|
3305 | 24 |
|
3335 | 25 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
26 |
return rotationManager(interfaceOrientation); |
|
3325 | 27 |
} |
3305 | 28 |
|
3329 | 29 |
|
30 |
#pragma mark - |
|
31 |
#pragma mark textfield methods |
|
32 |
-(void) cancel:(id) sender { |
|
33 |
if (textFieldBeingEdited != nil) |
|
34 |
[self.textFieldBeingEdited resignFirstResponder]; |
|
35 |
} |
|
36 |
||
37 |
// set the new value |
|
3330 | 38 |
-(BOOL) save:(id) sender { |
3332 | 39 |
NSInteger index = textFieldBeingEdited.tag; |
3340 | 40 |
|
3329 | 41 |
if (textFieldBeingEdited != nil) { |
3332 | 42 |
if (TEAMNAME_TAG == index) { |
3330 | 43 |
[self.teamDictionary setObject:textFieldBeingEdited.text forKey:@"teamname"]; |
44 |
} else { |
|
3340 | 45 |
//replace the old value with the new one |
46 |
NSMutableDictionary *hog = [[teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:index]; |
|
47 |
[hog setObject:textFieldBeingEdited.text forKey:@"hogname"]; |
|
3330 | 48 |
} |
3329 | 49 |
|
50 |
isWriteNeeded = YES; |
|
51 |
[self.textFieldBeingEdited resignFirstResponder]; |
|
3330 | 52 |
return YES; |
3329 | 53 |
} |
3330 | 54 |
return NO; |
3329 | 55 |
} |
56 |
||
57 |
// the textfield is being modified, update the navigation controller |
|
3330 | 58 |
-(void) textFieldDidBeginEditing:(UITextField *)aTextField{ |
3329 | 59 |
self.textFieldBeingEdited = aTextField; |
3332 | 60 |
|
3329 | 61 |
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel",@"from the hog name table") |
62 |
style:UIBarButtonItemStylePlain |
|
63 |
target:self |
|
64 |
action:@selector(cancel:)]; |
|
65 |
self.navigationItem.leftBarButtonItem = cancelButton; |
|
66 |
[cancelButton release]; |
|
67 |
||
68 |
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save",@"from the hog name table") |
|
69 |
style:UIBarButtonItemStyleDone |
|
70 |
target:self |
|
71 |
action:@selector(save:)]; |
|
72 |
self.navigationItem.rightBarButtonItem = saveButton; |
|
73 |
[saveButton release]; |
|
74 |
} |
|
75 |
||
76 |
// the textfield has been modified, check for empty strings and restore original navigation bar |
|
77 |
-(void) textFieldDidEndEditing:(UITextField *)aTextField{ |
|
78 |
if ([textFieldBeingEdited.text length] == 0) |
|
79 |
textFieldBeingEdited.text = [NSString stringWithFormat:@"hedgehog %d",textFieldBeingEdited.tag]; |
|
80 |
||
3332 | 81 |
self.textFieldBeingEdited = nil; |
3329 | 82 |
self.navigationItem.rightBarButtonItem = self.navigationItem.backBarButtonItem; |
83 |
self.navigationItem.leftBarButtonItem = nil; |
|
84 |
} |
|
85 |
||
86 |
// limit the size of the field to 64 characters like in original frontend |
|
87 |
-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { |
|
88 |
int limit = 64; |
|
89 |
return !([textField.text length] > limit && [string length] > range.length); |
|
90 |
} |
|
91 |
||
92 |
||
3305 | 93 |
#pragma mark - |
94 |
#pragma mark View lifecycle |
|
3340 | 95 |
-(void) viewDidLoad { |
3305 | 96 |
[super viewDidLoad]; |
3340 | 97 |
|
3329 | 98 |
// labels for the entries |
3339 | 99 |
NSArray *array = [[NSArray alloc] initWithObjects: |
3340 | 100 |
NSLocalizedString(@"Grave",@""), |
101 |
NSLocalizedString(@"Voice",@""), |
|
102 |
NSLocalizedString(@"Fort",@""), |
|
103 |
NSLocalizedString(@"Flag",@""), |
|
104 |
NSLocalizedString(@"Level",@""),nil]; |
|
3305 | 105 |
self.secondaryItems = array; |
106 |
[array release]; |
|
3315 | 107 |
|
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
108 |
// load the base hog image, drawing will occure in cellForRow... |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
109 |
NSString *normalHogFile = [[NSString alloc] initWithFormat:@"%@/Hedgehog.png",GRAPHICS_DIRECTORY()]; |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
110 |
UIImage *hogSprite = [[UIImage alloc] initWithContentsOfFile:normalHogFile andCutAt:CGRectMake(96, 0, 32, 32)]; |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
111 |
[normalHogFile release]; |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
112 |
self.normalHogSprite = hogSprite; |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
113 |
[hogSprite release]; |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
114 |
|
3315 | 115 |
// listen if any childController modifies the plist and write it if needed |
116 |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setWriteNeeded) name:@"setWriteNeedTeams" object:nil]; |
|
117 |
isWriteNeeded = NO; |
|
118 |
} |
|
119 |
||
3340 | 120 |
-(void) viewWillAppear:(BOOL)animated { |
3315 | 121 |
[super viewWillAppear:animated]; |
3323 | 122 |
|
3329 | 123 |
// load data about the team and write if there has been a change |
3330 | 124 |
if (isWriteNeeded) |
125 |
[self writeFile]; |
|
126 |
||
3328
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
127 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.title]; |
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
128 |
NSMutableDictionary *teamDict = [[NSMutableDictionary alloc] initWithContentsOfFile:teamFile]; |
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
129 |
self.teamDictionary = teamDict; |
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
130 |
[teamDict release]; |
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
131 |
[teamFile release]; |
3330 | 132 |
|
133 |
self.teamName = self.title; |
|
134 |
||
3315 | 135 |
[self.tableView reloadData]; |
3305 | 136 |
} |
137 |
||
3329 | 138 |
// write on file if there has been a change |
3328
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
139 |
-(void) viewWillDisappear:(BOOL)animated { |
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
140 |
[super viewWillDisappear:animated]; |
3340 | 141 |
|
142 |
// end the editing of the current field |
|
143 |
if (textFieldBeingEdited != nil) { |
|
144 |
[self save:nil]; |
|
145 |
} |
|
146 |
||
3330 | 147 |
if (isWriteNeeded) |
148 |
[self writeFile]; |
|
3328
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
149 |
} |
3329 | 150 |
|
3340 | 151 |
#pragma mark - |
3325 | 152 |
// needed by other classes to warn about a user change |
3315 | 153 |
-(void) setWriteNeeded { |
154 |
isWriteNeeded = YES; |
|
155 |
} |
|
156 |
||
3330 | 157 |
-(void) writeFile { |
158 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.title]; |
|
159 |
||
160 |
NSString *newTeamName = [self.teamDictionary objectForKey:@"teamname"]; |
|
161 |
if (![newTeamName isEqualToString:self.teamName]) { |
|
162 |
//delete old |
|
163 |
[[NSFileManager defaultManager] removeItemAtPath:teamFile error:NULL]; |
|
164 |
[teamFile release]; |
|
165 |
self.title = newTeamName; |
|
166 |
self.teamName = newTeamName; |
|
167 |
teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),newTeamName]; |
|
168 |
} |
|
169 |
||
170 |
[self.teamDictionary writeToFile:teamFile atomically:YES]; |
|
171 |
NSLog(@"writing: %@",teamDictionary); |
|
172 |
isWriteNeeded = NO; |
|
173 |
[teamFile release]; |
|
174 |
} |
|
175 |
||
3305 | 176 |
#pragma mark - |
177 |
#pragma mark Table view data source |
|
178 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
179 |
return 3; |
|
180 |
} |
|
181 |
||
182 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
3312 | 183 |
NSInteger rows = 0; |
3305 | 184 |
switch (section) { |
3325 | 185 |
case 0: // team name |
3305 | 186 |
rows = 1; |
187 |
break; |
|
3325 | 188 |
case 1: // team members |
189 |
rows = MAX_HOGS; |
|
3305 | 190 |
break; |
3325 | 191 |
case 2: // team details |
192 |
rows = [self.secondaryItems count]; |
|
3305 | 193 |
break; |
194 |
default: |
|
195 |
break; |
|
196 |
} |
|
197 |
return rows; |
|
198 |
} |
|
199 |
||
200 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
3340 | 201 |
static NSString *CellIdentifier0 = @"Cell0"; |
202 |
static NSString *CellIdentifier1 = @"Cell1"; |
|
203 |
static NSString *CellIdentifier2 = @"Cell2"; |
|
204 |
||
205 |
NSArray *hogArray; |
|
3364 | 206 |
UITableViewCell *cell = nil; |
3340 | 207 |
NSInteger row = [indexPath row]; |
3352 | 208 |
UIImage *accessoryImage; |
3305 | 209 |
|
3340 | 210 |
switch ([indexPath section]) { |
211 |
case 0: |
|
212 |
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
|
213 |
if (cell == nil) { |
|
214 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
|
215 |
reuseIdentifier:CellIdentifier0] autorelease]; |
|
216 |
// create a uitextfield for each row, expand it to take the maximum size |
|
217 |
UITextField *aTextField = [[UITextField alloc] |
|
218 |
initWithFrame:CGRectMake(5, 12, (cell.frame.size.width + cell.frame.size.width/3) - 42, 25)]; |
|
219 |
aTextField.clearsOnBeginEditing = NO; |
|
220 |
aTextField.returnKeyType = UIReturnKeyDone; |
|
221 |
aTextField.adjustsFontSizeToFitWidth = YES; |
|
222 |
aTextField.delegate = self; |
|
223 |
aTextField.tag = [indexPath row]; |
|
224 |
aTextField.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize] + 2]; |
|
225 |
aTextField.clearButtonMode = UITextFieldViewModeWhileEditing; |
|
226 |
[aTextField addTarget:self action:@selector(save:) forControlEvents:UIControlEventEditingDidEndOnExit]; |
|
227 |
[cell.contentView addSubview:aTextField]; |
|
228 |
[aTextField release]; |
|
3330 | 229 |
} |
230 |
||
3315 | 231 |
cell.imageView.image = nil; |
3330 | 232 |
cell.accessoryType = UITableViewCellAccessoryNone; |
233 |
for (UIView *oneView in cell.contentView.subviews) { |
|
234 |
if ([oneView isMemberOfClass:[UITextField class]]) { |
|
235 |
// we find the uitextfied and we'll use its tag to understand which one is being edited |
|
236 |
UITextField *textFieldFound = (UITextField *)oneView; |
|
237 |
textFieldFound.text = [self.teamDictionary objectForKey:@"teamname"]; |
|
238 |
textFieldFound.tag = TEAMNAME_TAG; |
|
239 |
} |
|
240 |
} |
|
3305 | 241 |
break; |
242 |
case 1: |
|
3340 | 243 |
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
244 |
if (cell == nil) { |
|
245 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
|
246 |
reuseIdentifier:CellIdentifier1] autorelease]; |
|
247 |
||
248 |
// create a uitextfield for each row, expand it to take the maximum size |
|
249 |
UITextField *aTextField = [[UITextField alloc] |
|
250 |
initWithFrame:CGRectMake(42, 12, (cell.frame.size.width + cell.frame.size.width/3) - 42, 25)]; |
|
251 |
aTextField.clearsOnBeginEditing = NO; |
|
252 |
aTextField.returnKeyType = UIReturnKeyDone; |
|
253 |
aTextField.adjustsFontSizeToFitWidth = YES; |
|
254 |
aTextField.delegate = self; |
|
255 |
aTextField.tag = [indexPath row]; |
|
256 |
aTextField.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize] + 2]; |
|
257 |
aTextField.clearButtonMode = UITextFieldViewModeWhileEditing; |
|
258 |
[aTextField addTarget:self action:@selector(save:) forControlEvents:UIControlEventEditingDidEndOnExit]; |
|
259 |
[cell.contentView addSubview:aTextField]; |
|
260 |
[aTextField release]; |
|
261 |
} |
|
262 |
||
3315 | 263 |
hogArray = [self.teamDictionary objectForKey:@"hedgehogs"]; |
3340 | 264 |
|
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
265 |
NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@.png", HATS_DIRECTORY(), [[hogArray objectAtIndex:row] objectForKey:@"hat"]]; |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
266 |
UIImage *hatSprite = [[UIImage alloc] initWithContentsOfFile: hatFile andCutAt:CGRectMake(0, 0, 32, 32)]; |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
267 |
[hatFile release]; |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
268 |
cell.imageView.image = [self.normalHogSprite mergeWith:hatSprite atPoint:CGPointMake(0, -5)]; |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
269 |
[hatSprite release]; |
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
270 |
|
3329 | 271 |
for (UIView *oneView in cell.contentView.subviews) { |
272 |
if ([oneView isMemberOfClass:[UITextField class]]) { |
|
273 |
// we find the uitextfied and we'll use its tag to understand which one is being edited |
|
274 |
UITextField *textFieldFound = (UITextField *)oneView; |
|
275 |
textFieldFound.text = [[hogArray objectAtIndex:row] objectForKey:@"hogname"]; |
|
276 |
} |
|
277 |
} |
|
3340 | 278 |
|
3328
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
279 |
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; |
3305 | 280 |
break; |
281 |
case 2: |
|
3340 | 282 |
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2]; |
283 |
if (cell == nil) { |
|
284 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
|
285 |
reuseIdentifier:CellIdentifier2] autorelease]; |
|
286 |
} |
|
287 |
||
3305 | 288 |
cell.textLabel.text = [self.secondaryItems objectAtIndex:row]; |
3328
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
289 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
3325 | 290 |
switch (row) { |
3352 | 291 |
case 0: // grave |
292 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", |
|
293 |
GRAVES_DIRECTORY(),[teamDictionary objectForKey:@"grave"]] |
|
294 |
andCutAt:CGRectMake(0,0,32,32)]; |
|
295 |
cell.imageView.image = accessoryImage; |
|
296 |
[accessoryImage release]; |
|
297 |
break; |
|
298 |
case 2: // fort |
|
299 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@L.png", |
|
300 |
FORTS_DIRECTORY(),[teamDictionary objectForKey:@"fort"]]]; |
|
301 |
cell.imageView.image = [accessoryImage scaleToSize:CGSizeMake(42, 42)]; |
|
302 |
[accessoryImage release]; |
|
303 |
break; |
|
304 |
||
3325 | 305 |
case 3: // flags |
3352 | 306 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", |
307 |
FLAGS_DIRECTORY(),[teamDictionary objectForKey:@"flag"]]]; |
|
308 |
cell.imageView.image = accessoryImage; |
|
309 |
[accessoryImage release]; |
|
310 |
break; |
|
311 |
case 4: // level |
|
312 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%d.png", |
|
313 |
BOTLEVELS_DIRECTORY(),[[[[teamDictionary objectForKey:@"hedgehogs"] |
|
314 |
objectAtIndex:0] objectForKey:@"level"] |
|
315 |
intValue]]]; |
|
316 |
cell.imageView.image = accessoryImage; |
|
317 |
[accessoryImage release]; |
|
3325 | 318 |
break; |
319 |
default: |
|
320 |
cell.imageView.image = nil; |
|
321 |
break; |
|
322 |
} |
|
3305 | 323 |
break; |
324 |
} |
|
325 |
||
326 |
return cell; |
|
327 |
} |
|
328 |
||
329 |
||
330 |
#pragma mark - |
|
331 |
#pragma mark Table view delegate |
|
3329 | 332 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
3325 | 333 |
NSInteger row = [indexPath row]; |
3340 | 334 |
NSInteger section = [indexPath section]; |
3365
37ac593e9027
wow all these files only for land preview and seed generation
koda
parents:
3364
diff
changeset
|
335 |
UITableViewController *nextController = nil; |
3330 | 336 |
UITableViewCell *cell; |
3340 | 337 |
|
3352 | 338 |
if (2 == section) { |
339 |
switch (row) { |
|
340 |
case 0: // grave |
|
341 |
if (nil == gravesViewController) |
|
342 |
gravesViewController = [[GravesViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
343 |
||
344 |
nextController = gravesViewController; |
|
345 |
break; |
|
346 |
case 1: // voice |
|
347 |
if (nil == voicesViewController) |
|
348 |
voicesViewController = [[VoicesViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
349 |
||
350 |
nextController = voicesViewController; |
|
351 |
break; |
|
352 |
case 2: // fort |
|
353 |
if (nil == fortsViewController) |
|
354 |
fortsViewController = [[FortsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
355 |
||
356 |
nextController = fortsViewController; |
|
357 |
break; |
|
358 |
case 3: // flag |
|
359 |
if (nil == flagsViewController) |
|
360 |
flagsViewController = [[FlagsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
361 |
||
362 |
nextController = flagsViewController; |
|
363 |
break; |
|
364 |
case 4: // level |
|
365 |
if (nil == levelViewController) |
|
366 |
levelViewController = [[LevelViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
367 |
||
368 |
nextController = levelViewController; |
|
369 |
break; |
|
370 |
} |
|
371 |
||
372 |
nextController.title = [secondaryItems objectAtIndex:row]; |
|
373 |
[nextController setTeamDictionary:teamDictionary]; |
|
374 |
[self.navigationController pushViewController:nextController animated:YES]; |
|
375 |
} else { |
|
376 |
cell = [aTableView cellForRowAtIndexPath:indexPath]; |
|
377 |
for (UIView *oneView in cell.contentView.subviews) { |
|
378 |
if ([oneView isMemberOfClass:[UITextField class]]) { |
|
379 |
textFieldBeingEdited = (UITextField *)oneView; |
|
380 |
[textFieldBeingEdited becomeFirstResponder]; |
|
3340 | 381 |
} |
3352 | 382 |
} |
383 |
[aTableView deselectRowAtIndexPath:indexPath animated:NO]; |
|
3325 | 384 |
} |
3340 | 385 |
|
3305 | 386 |
} |
387 |
||
3329 | 388 |
// action to perform when you want to change a hog hat |
3340 | 389 |
-(void) tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { |
390 |
if (nil == hogHatViewController) { |
|
391 |
hogHatViewController = [[HogHatViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
3328
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
392 |
} |
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
393 |
|
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
394 |
// cache the dictionary file of the team, so that other controllers can modify it |
3340 | 395 |
hogHatViewController.teamDictionary = self.teamDictionary; |
396 |
hogHatViewController.selectedHog = [indexPath row]; |
|
3328
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
397 |
|
3340 | 398 |
[self.navigationController pushViewController:hogHatViewController animated:YES]; |
3328
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
399 |
} |
fe87c2242984
fix the save of the team and rearrange hat/name modification
koda
parents:
3325
diff
changeset
|
400 |
|
3305 | 401 |
|
402 |
#pragma mark - |
|
403 |
#pragma mark Memory management |
|
404 |
-(void) didReceiveMemoryWarning { |
|
405 |
// Releases the view if it doesn't have a superview. |
|
406 |
[super didReceiveMemoryWarning]; |
|
407 |
// Relinquish ownership any cached data, images, etc that aren't in use. |
|
3490 | 408 |
if (hogHatViewController.view.superview == nil) |
409 |
hogHatViewController = nil; |
|
410 |
if (gravesViewController.view.superview == nil) |
|
411 |
gravesViewController = nil; |
|
412 |
if (voicesViewController.view.superview == nil) |
|
413 |
voicesViewController = nil; |
|
414 |
if (fortsViewController.view.superview == nil) |
|
415 |
fortsViewController = nil; |
|
416 |
if (flagsViewController.view.superview == nil) |
|
417 |
flagsViewController = nil; |
|
418 |
if (levelViewController.view.superview == nil) |
|
419 |
levelViewController = nil; |
|
3305 | 420 |
} |
421 |
||
422 |
-(void) viewDidUnload { |
|
3329 | 423 |
self.teamDictionary = nil; |
424 |
self.textFieldBeingEdited = nil; |
|
3330 | 425 |
self.teamName = nil; |
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
426 |
self.normalHogSprite = nil; |
3325 | 427 |
self.secondaryItems = nil; |
3340 | 428 |
hogHatViewController = nil; |
429 |
flagsViewController = nil; |
|
430 |
fortsViewController = nil; |
|
431 |
gravesViewController = nil; |
|
3352 | 432 |
levelViewController = nil; |
3315 | 433 |
[super viewDidUnload]; |
3490 | 434 |
MSG_DIDUNLOAD(); |
3305 | 435 |
} |
436 |
||
437 |
-(void) dealloc { |
|
3329 | 438 |
[teamDictionary release]; |
439 |
[textFieldBeingEdited release]; |
|
3330 | 440 |
[teamName release]; |
3374
0d522416d97f
lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents:
3365
diff
changeset
|
441 |
[normalHogSprite release]; |
3305 | 442 |
[secondaryItems release]; |
3340 | 443 |
[hogHatViewController release]; |
444 |
[fortsViewController release]; |
|
445 |
[gravesViewController release]; |
|
446 |
[flagsViewController release]; |
|
3352 | 447 |
[levelViewController release]; |
3305 | 448 |
[super dealloc]; |
449 |
} |
|
450 |
||
451 |
||
452 |
@end |
|
453 |