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