30 #define TEAMNAME_TAG 78789 |
30 #define TEAMNAME_TAG 78789 |
31 |
31 |
32 @implementation SingleTeamViewController |
32 @implementation SingleTeamViewController |
33 @synthesize teamDictionary, normalHogSprite, secondaryItems, moreSecondaryItems, teamName; |
33 @synthesize teamDictionary, normalHogSprite, secondaryItems, moreSecondaryItems, teamName; |
34 |
34 |
35 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
35 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
36 return rotationManager(interfaceOrientation); |
36 return rotationManager(interfaceOrientation); |
37 } |
37 } |
38 |
38 |
39 #pragma mark - |
39 #pragma mark - |
40 #pragma mark editableCellViewDelegate methods |
40 #pragma mark editableCellViewDelegate methods |
41 // set the new value |
41 // set the new value |
42 -(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue { |
42 - (void)saveTextFieldValue:(NSString *)textString withTag:(NSInteger)tagValue { |
43 if (TEAMNAME_TAG == tagValue) { |
43 if (TEAMNAME_TAG == tagValue) { |
44 // delete old file |
44 // delete old file |
45 [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName] error:NULL]; |
45 [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName] error:NULL]; |
46 // update filename |
46 // update filename |
47 self.teamName = textString; |
47 self.teamName = textString; |
55 } |
55 } |
56 } |
56 } |
57 |
57 |
58 #pragma mark - |
58 #pragma mark - |
59 #pragma mark View lifecycle |
59 #pragma mark View lifecycle |
60 -(void) viewDidLoad { |
60 - (void)viewDidLoad { |
61 [super viewDidLoad]; |
61 [super viewDidLoad]; |
62 |
62 |
63 // labels for the entries |
63 // labels for the entries |
64 NSArray *array = [[NSArray alloc] initWithObjects: |
64 NSArray *array = [[NSArray alloc] initWithObjects: |
65 NSLocalizedString(@"Grave",@""), |
65 NSLocalizedString(@"Grave",@""), |
66 NSLocalizedString(@"Voice",@""), |
66 NSLocalizedString(@"Voice",@""), |
67 NSLocalizedString(@"Fort",@""), |
67 NSLocalizedString(@"Fort",@""), |
68 NSLocalizedString(@"Flag",@""), |
68 NSLocalizedString(@"Flag",@""), |
69 NSLocalizedString(@"Level",@""),nil]; |
69 NSLocalizedString(@"Level",@""),nil]; |
70 self.secondaryItems = array; |
70 self.secondaryItems = array; |
71 [array release]; |
|
72 |
71 |
73 // labels for the subtitles |
72 // labels for the subtitles |
74 NSArray *moreArray = [[NSArray alloc] initWithObjects: |
73 NSArray *moreArray = [[NSArray alloc] initWithObjects: |
75 NSLocalizedString(@"Mark the death of your fallen warriors",@""), |
74 NSLocalizedString(@"Mark the death of your fallen warriors",@""), |
76 NSLocalizedString(@"Pick a slang your hogs will speak",@""), |
75 NSLocalizedString(@"Pick a slang your hogs will speak",@""), |
77 NSLocalizedString(@"Select the team invincible fortress (only valid for fort games)",@""), |
76 NSLocalizedString(@"Select the team invincible fortress (only valid for fort games)",@""), |
78 NSLocalizedString(@"Choose a charismatic symbol for your team",@""), |
77 NSLocalizedString(@"Choose a charismatic symbol for your team",@""), |
79 NSLocalizedString(@"Opt for controlling the team or let the AI lead",@""),nil]; |
78 NSLocalizedString(@"Opt for controlling the team or let the AI lead",@""),nil]; |
80 self.moreSecondaryItems = moreArray; |
79 self.moreSecondaryItems = moreArray; |
81 [moreArray release]; |
|
82 |
80 |
83 // load the base hog image, drawing will occure in cellForRow... |
81 // load the base hog image, drawing will occure in cellForRow... |
84 NSString *normalHogFile = [[NSString alloc] initWithFormat:@"%@/basehat-hedgehog.png",[[NSBundle mainBundle] resourcePath]]; |
82 NSString *normalHogFile = [[NSString alloc] initWithFormat:@"%@/basehat-hedgehog.png",[[NSBundle mainBundle] resourcePath]]; |
85 UIImage *hogSprite = [[UIImage alloc] initWithContentsOfFile:normalHogFile]; |
83 UIImage *hogSprite = [[UIImage alloc] initWithContentsOfFile:normalHogFile]; |
86 [normalHogFile release]; |
|
87 self.normalHogSprite = hogSprite; |
84 self.normalHogSprite = hogSprite; |
88 [hogSprite release]; |
|
89 |
85 |
90 // listen if any childController modifies the plist and write it if needed |
86 // listen if any childController modifies the plist and write it if needed |
91 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setWriteNeeded) name:@"setWriteNeedTeams" object:nil]; |
87 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setWriteNeeded) name:@"setWriteNeedTeams" object:nil]; |
92 isWriteNeeded = NO; |
88 isWriteNeeded = NO; |
93 |
89 |
94 self.title = NSLocalizedString(@"Edit team settings",@""); |
90 self.title = NSLocalizedString(@"Edit team settings",@""); |
95 } |
91 } |
96 |
92 |
97 -(void) viewWillAppear:(BOOL)animated { |
93 - (void)viewWillAppear:(BOOL)animated { |
98 [super viewWillAppear:animated]; |
94 [super viewWillAppear:animated]; |
99 |
95 |
100 // load data about the team and write if there has been a change from other childControllers |
96 // load data about the team and write if there has been a change from other childControllers |
101 if (isWriteNeeded) |
97 if (isWriteNeeded) |
102 [self writeFile]; |
98 [self writeFile]; |
103 |
99 |
104 NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName]; |
100 NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName]; |
105 NSMutableDictionary *teamDict = [[NSMutableDictionary alloc] initWithContentsOfFile:teamFile]; |
101 NSMutableDictionary *teamDict = [[NSMutableDictionary alloc] initWithContentsOfFile:teamFile]; |
106 self.teamDictionary = teamDict; |
102 self.teamDictionary = teamDict; |
107 [teamDict release]; |
|
108 [teamFile release]; |
|
109 |
103 |
110 [self.tableView reloadData]; |
104 [self.tableView reloadData]; |
111 } |
105 } |
112 |
106 |
113 // write on file if there has been a change |
107 // write on file if there has been a change |
114 -(void) viewWillDisappear:(BOOL)animated { |
108 - (void)viewWillDisappear:(BOOL)animated { |
115 [super viewWillDisappear:animated]; |
109 [super viewWillDisappear:animated]; |
116 |
110 |
117 if (isWriteNeeded) |
111 if (isWriteNeeded) |
118 [self writeFile]; |
112 [self writeFile]; |
119 } |
113 } |
120 |
114 |
121 #pragma mark - |
115 #pragma mark - |
122 // needed by other classes to warn about a user change |
116 // needed by other classes to warn about a user change |
123 -(void) setWriteNeeded { |
117 - (void)setWriteNeeded { |
124 isWriteNeeded = YES; |
118 isWriteNeeded = YES; |
125 } |
119 } |
126 |
120 |
127 -(void) writeFile { |
121 - (void)writeFile { |
128 NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName]; |
122 NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName]; |
129 [self.teamDictionary writeToFile:teamFile atomically:YES]; |
123 [self.teamDictionary writeToFile:teamFile atomically:YES]; |
130 [teamFile release]; |
|
131 |
124 |
132 //DLog(@"%@",teamDictionary); |
125 //DLog(@"%@",teamDictionary); |
133 isWriteNeeded = NO; |
126 isWriteNeeded = NO; |
134 } |
127 } |
135 |
128 |
136 #pragma mark - |
129 #pragma mark - |
137 #pragma mark Table view data source |
130 #pragma mark Table view data source |
138 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
131 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
139 return 3; |
132 return 3; |
140 } |
133 } |
141 |
134 |
142 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
135 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
143 NSInteger rows = 0; |
136 NSInteger rows = 0; |
144 switch (section) { |
137 switch (section) { |
145 case 0: // team name |
138 case 0: // team name |
146 rows = 1; |
139 rows = 1; |
147 break; |
140 break; |
187 EditableCellView *editableCell = nil; |
180 EditableCellView *editableCell = nil; |
188 NSInteger row = [indexPath row]; |
181 NSInteger row = [indexPath row]; |
189 UIImage *accessoryImage; |
182 UIImage *accessoryImage; |
190 |
183 |
191 switch ([indexPath section]) { |
184 switch ([indexPath section]) { |
192 case 0: |
185 case 0: { |
193 editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
186 editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
194 if (editableCell == nil) { |
187 if (editableCell == nil) { |
195 editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault |
188 editableCell = [[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault |
196 reuseIdentifier:CellIdentifier0] autorelease]; |
189 reuseIdentifier:CellIdentifier0]; |
197 editableCell.delegate = self; |
190 editableCell.delegate = self; |
198 editableCell.tag = TEAMNAME_TAG; |
191 editableCell.tag = TEAMNAME_TAG; |
199 } |
192 } |
200 |
193 |
201 editableCell.imageView.image = nil; |
194 editableCell.imageView.image = nil; |
202 editableCell.accessoryType = UITableViewCellAccessoryNone; |
195 editableCell.accessoryType = UITableViewCellAccessoryNone; |
203 editableCell.textField.text = self.teamName; |
196 editableCell.textField.text = self.teamName; |
204 |
197 |
205 cell = editableCell; |
198 cell = editableCell; |
206 break; |
199 break; |
207 case 1: |
200 } |
|
201 case 1: { |
208 if ([indexPath row] == HW_getMaxNumberOfHogs()) |
202 if ([indexPath row] == HW_getMaxNumberOfHogs()) |
209 { |
203 { |
210 cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierDefault]; |
204 cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierDefault]; |
211 if (cell == nil) |
205 if (cell == nil) |
212 { |
206 { |
213 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
207 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
214 reuseIdentifier:CellIdentifierDefault] autorelease]; |
208 reuseIdentifier:CellIdentifierDefault]; |
215 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
209 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
216 } |
210 } |
217 |
211 |
218 cell.textLabel.text = NSLocalizedString(@"Select one hat for all hogs", nil); |
212 cell.textLabel.text = NSLocalizedString(@"Select one hat for all hogs", nil); |
219 |
213 |
220 break; |
214 break; |
221 } |
215 } |
222 |
216 |
223 editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
217 editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
224 if (editableCell == nil) { |
218 if (editableCell == nil) { |
225 editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault |
219 editableCell = [[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault |
226 reuseIdentifier:CellIdentifier1] autorelease]; |
220 reuseIdentifier:CellIdentifier1]; |
227 editableCell.delegate = self; |
221 editableCell.delegate = self; |
228 } |
222 } |
229 editableCell.tag = [indexPath row]; |
223 editableCell.tag = [indexPath row]; |
230 |
224 |
231 hogArray = [self.teamDictionary objectForKey:@"hedgehogs"]; |
225 hogArray = [self.teamDictionary objectForKey:@"hedgehogs"]; |
232 |
226 |
233 // draw the hat on top of the hog |
227 // draw the hat on top of the hog |
234 NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@.png", HATS_DIRECTORY(), [[hogArray objectAtIndex:row] objectForKey:@"hat"]]; |
228 NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@.png", HATS_DIRECTORY(), [[hogArray objectAtIndex:row] objectForKey:@"hat"]]; |
235 UIImage *hatSprite = [[UIImage alloc] initWithContentsOfFile: hatFile andCutAt:CGRectMake(0, 0, 32, 32)]; |
229 UIImage *hatSprite = [[UIImage alloc] initWithContentsOfFile: hatFile andCutAt:CGRectMake(0, 0, 32, 32)]; |
236 [hatFile release]; |
|
237 editableCell.imageView.image = [self.normalHogSprite mergeWith:hatSprite atPoint:CGPointMake(0, 5)]; |
230 editableCell.imageView.image = [self.normalHogSprite mergeWith:hatSprite atPoint:CGPointMake(0, 5)]; |
238 [hatSprite release]; |
|
239 |
231 |
240 editableCell.textField.text = [[hogArray objectAtIndex:row] objectForKey:@"hogname"]; |
232 editableCell.textField.text = [[hogArray objectAtIndex:row] objectForKey:@"hogname"]; |
241 editableCell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; |
233 editableCell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; |
242 |
234 |
243 cell = editableCell; |
235 cell = editableCell; |
244 break; |
236 break; |
245 case 2: |
237 } |
|
238 case 2: { |
246 cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2]; |
239 cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2]; |
247 if (cell == nil) { |
240 if (cell == nil) { |
248 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle |
241 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle |
249 reuseIdentifier:CellIdentifier2] autorelease]; |
242 reuseIdentifier:CellIdentifier2]; |
250 } |
243 } |
251 |
244 |
252 cell.textLabel.text = [self.secondaryItems objectAtIndex:row]; |
245 cell.textLabel.text = [self.secondaryItems objectAtIndex:row]; |
253 cell.detailTextLabel.text = [self.moreSecondaryItems objectAtIndex:row]; |
246 cell.detailTextLabel.text = [self.moreSecondaryItems objectAtIndex:row]; |
254 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
247 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
256 case 0: // grave |
249 case 0: // grave |
257 accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", |
250 accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", |
258 GRAVES_DIRECTORY(),[teamDictionary objectForKey:@"grave"]] |
251 GRAVES_DIRECTORY(),[teamDictionary objectForKey:@"grave"]] |
259 andCutAt:CGRectMake(0,0,32,32)]; |
252 andCutAt:CGRectMake(0,0,32,32)]; |
260 cell.imageView.image = accessoryImage; |
253 cell.imageView.image = accessoryImage; |
261 [accessoryImage release]; |
|
262 break; |
254 break; |
263 case 1: // voice |
255 case 1: // voice |
264 accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/HellishBomb.png", |
256 accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/HellishBomb.png", |
265 GRAPHICS_DIRECTORY()]]; |
257 GRAPHICS_DIRECTORY()]]; |
266 cell.imageView.image = accessoryImage; |
258 cell.imageView.image = accessoryImage; |
267 [accessoryImage release]; |
|
268 break; |
259 break; |
269 case 2: // fort |
260 case 2: // fort |
270 accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@-icon.png", |
261 accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@-icon.png", |
271 FORTS_DIRECTORY(),[teamDictionary objectForKey:@"fort"]]]; |
262 FORTS_DIRECTORY(),[teamDictionary objectForKey:@"fort"]]]; |
272 cell.imageView.image = accessoryImage; |
263 cell.imageView.image = accessoryImage; |
273 [accessoryImage release]; |
|
274 break; |
264 break; |
275 case 3: // flags |
265 case 3: // flags |
276 accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", |
266 accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", |
277 FLAGS_DIRECTORY(),[teamDictionary objectForKey:@"flag"]]]; |
267 FLAGS_DIRECTORY(),[teamDictionary objectForKey:@"flag"]]]; |
278 cell.imageView.image = [accessoryImage scaleToSize:CGSizeMake(26, 18)]; |
268 cell.imageView.image = [accessoryImage scaleToSize:CGSizeMake(26, 18)]; |
279 [accessoryImage release]; |
|
280 cell.imageView.layer.borderWidth = 1; |
269 cell.imageView.layer.borderWidth = 1; |
281 cell.imageView.layer.borderColor = [[UIColor blackColor] CGColor]; |
270 cell.imageView.layer.borderColor = [[UIColor blackColor] CGColor]; |
282 break; |
271 break; |
283 case 4: // level |
272 case 4: // level |
284 accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/bot%d.png", |
273 accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/bot%d.png", |
285 [[NSBundle mainBundle] resourcePath], |
274 [[NSBundle mainBundle] resourcePath], |
286 [[[[teamDictionary objectForKey:@"hedgehogs"] |
275 [[[[teamDictionary objectForKey:@"hedgehogs"] |
287 objectAtIndex:0] objectForKey:@"level"] |
276 objectAtIndex:0] objectForKey:@"level"] |
288 intValue]]]; |
277 intValue]]]; |
289 cell.imageView.image = accessoryImage; |
278 cell.imageView.image = accessoryImage; |
290 [accessoryImage release]; |
|
291 break; |
279 break; |
292 default: |
280 default: |
293 cell.imageView.image = nil; |
281 cell.imageView.image = nil; |
294 break; |
282 break; |
295 } |
283 } |
296 break; |
284 break; |
|
285 } |
297 } |
286 } |
298 |
287 |
299 return cell; |
288 return cell; |
300 } |
289 } |
301 |
290 |
302 |
291 |
303 #pragma mark - |
292 #pragma mark - |
304 #pragma mark Table view delegate |
293 #pragma mark Table view delegate |
305 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
294 - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
306 NSInteger row = [indexPath row]; |
295 NSInteger row = [indexPath row]; |
307 NSInteger section = [indexPath section]; |
296 NSInteger section = [indexPath section]; |
308 |
297 |
309 if (2 == section) |
298 if (2 == section) |
310 { |
299 { |
314 { |
303 { |
315 GravesViewController *gravesViewController = [[GravesViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
304 GravesViewController *gravesViewController = [[GravesViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
316 |
305 |
317 [gravesViewController setTeamDictionary:teamDictionary]; |
306 [gravesViewController setTeamDictionary:teamDictionary]; |
318 [self.navigationController pushViewController:gravesViewController animated:YES]; |
307 [self.navigationController pushViewController:gravesViewController animated:YES]; |
319 [gravesViewController release]; |
|
320 break; |
308 break; |
321 } |
309 } |
322 case 1: // voice |
310 case 1: // voice |
323 { |
311 { |
324 VoicesViewController *voicesViewController = [[VoicesViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
312 VoicesViewController *voicesViewController = [[VoicesViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
325 |
313 |
326 [voicesViewController setTeamDictionary:teamDictionary]; |
314 [voicesViewController setTeamDictionary:teamDictionary]; |
327 [self.navigationController pushViewController:voicesViewController animated:YES]; |
315 [self.navigationController pushViewController:voicesViewController animated:YES]; |
328 [voicesViewController release]; |
|
329 break; |
316 break; |
330 } |
317 } |
331 case 2: // fort |
318 case 2: // fort |
332 { |
319 { |
333 FortsViewController *fortsViewController = [[FortsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
320 FortsViewController *fortsViewController = [[FortsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
334 |
321 |
335 [fortsViewController setTeamDictionary:teamDictionary]; |
322 [fortsViewController setTeamDictionary:teamDictionary]; |
336 [self.navigationController pushViewController:fortsViewController animated:YES]; |
323 [self.navigationController pushViewController:fortsViewController animated:YES]; |
337 [fortsViewController release]; |
|
338 break; |
324 break; |
339 } |
325 } |
340 case 3: // flag |
326 case 3: // flag |
341 { |
327 { |
342 FlagsViewController *flagsViewController = [[FlagsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
328 FlagsViewController *flagsViewController = [[FlagsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
343 |
329 |
344 [flagsViewController setTeamDictionary:teamDictionary]; |
330 [flagsViewController setTeamDictionary:teamDictionary]; |
345 [self.navigationController pushViewController:flagsViewController animated:YES]; |
331 [self.navigationController pushViewController:flagsViewController animated:YES]; |
346 [flagsViewController release]; |
|
347 break; |
332 break; |
348 } |
333 } |
349 case 4: // level |
334 case 4: // level |
350 { |
335 { |
351 LevelViewController *levelViewController = [[LevelViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
336 LevelViewController *levelViewController = [[LevelViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
352 |
337 |
353 [levelViewController setTeamDictionary:teamDictionary]; |
338 [levelViewController setTeamDictionary:teamDictionary]; |
354 [self.navigationController pushViewController:levelViewController animated:YES]; |
339 [self.navigationController pushViewController:levelViewController animated:YES]; |
355 [levelViewController release]; |
|
356 break; |
340 break; |
357 } |
341 } |
358 default: |
342 default: |
359 DLog(@"Nope"); |
343 DLog(@"Nope"); |
360 break; |
344 break; |
388 // cache the dictionary file of the team, so that other controllers can modify it |
372 // cache the dictionary file of the team, so that other controllers can modify it |
389 hogHatViewController.teamDictionary = self.teamDictionary; |
373 hogHatViewController.teamDictionary = self.teamDictionary; |
390 hogHatViewController.selectedHog = hogIndex; |
374 hogHatViewController.selectedHog = hogIndex; |
391 |
375 |
392 [self.navigationController pushViewController:hogHatViewController animated:YES]; |
376 [self.navigationController pushViewController:hogHatViewController animated:YES]; |
393 [hogHatViewController release]; |
|
394 } |
377 } |
395 |
378 |
396 #pragma mark - |
379 #pragma mark - |
397 #pragma mark Memory management |
380 #pragma mark Memory management |
398 -(void) didReceiveMemoryWarning { |
381 |
|
382 - (void)didReceiveMemoryWarning { |
399 [super didReceiveMemoryWarning]; |
383 [super didReceiveMemoryWarning]; |
400 MSG_MEMCLEAN(); |
384 MSG_MEMCLEAN(); |
401 } |
385 } |
402 |
386 |
403 -(void) viewDidUnload { |
|
404 self.teamDictionary = nil; |
|
405 self.teamName = nil; |
|
406 self.normalHogSprite = nil; |
|
407 self.secondaryItems = nil; |
|
408 self.moreSecondaryItems = nil; |
|
409 MSG_DIDUNLOAD(); |
|
410 [super viewDidUnload]; |
|
411 } |
|
412 |
|
413 -(void) dealloc |
|
414 { |
|
415 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
|
416 releaseAndNil(teamDictionary); |
|
417 releaseAndNil(teamName); |
|
418 releaseAndNil(normalHogSprite); |
|
419 releaseAndNil(secondaryItems); |
|
420 releaseAndNil(moreSecondaryItems); |
|
421 [super dealloc]; |
|
422 } |
|
423 |
|
424 |
|
425 @end |
387 @end |
426 |
388 |