author | antonc27 <antonc27@mail.ru> |
Fri, 16 Oct 2015 02:54:03 +0200 | |
branch | ios-revival |
changeset 11217 | 6e5fd5ea5acb |
parent 11187 | b2112ed988cb |
child 11221 | e68b3e392091 |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
6700 | 3 |
* Copyright (c) 2009-2012 Vittorio Giovara <vittorio.giovara@gmail.com> |
3829 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
8441
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3829 | 17 |
*/ |
18 |
||
3547 | 19 |
|
20 |
#import "SingleTeamViewController.h" |
|
4478 | 21 |
#import <QuartzCore/QuartzCore.h> |
3547 | 22 |
#import "HogHatViewController.h" |
23 |
#import "GravesViewController.h" |
|
24 |
#import "VoicesViewController.h" |
|
25 |
#import "FortsViewController.h" |
|
26 |
#import "FlagsViewController.h" |
|
27 |
#import "LevelViewController.h" |
|
6078
8c0cc07731e5
headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents:
5983
diff
changeset
|
28 |
|
3547 | 29 |
|
3660 | 30 |
#define TEAMNAME_TAG 78789 |
3547 | 31 |
|
32 |
@implementation SingleTeamViewController |
|
3816 | 33 |
@synthesize teamDictionary, normalHogSprite, secondaryItems, moreSecondaryItems, teamName; |
3547 | 34 |
|
35 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
36 |
return rotationManager(interfaceOrientation); |
|
37 |
} |
|
38 |
||
39 |
#pragma mark - |
|
3660 | 40 |
#pragma mark editableCellViewDelegate methods |
3547 | 41 |
// set the new value |
3660 | 42 |
-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue { |
43 |
if (TEAMNAME_TAG == tagValue) { |
|
44 |
// delete old file |
|
45 |
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName] error:NULL]; |
|
46 |
// update filename |
|
47 |
self.teamName = textString; |
|
48 |
// save new file |
|
49 |
[self writeFile]; |
|
50 |
} else { |
|
51 |
// replace the old value with the new one |
|
52 |
NSMutableDictionary *hog = [[teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:tagValue]; |
|
53 |
[hog setObject:textString forKey:@"hogname"]; |
|
3547 | 54 |
isWriteNeeded = YES; |
55 |
} |
|
56 |
} |
|
57 |
||
58 |
#pragma mark - |
|
59 |
#pragma mark View lifecycle |
|
60 |
-(void) viewDidLoad { |
|
61 |
[super viewDidLoad]; |
|
3697 | 62 |
|
3547 | 63 |
// labels for the entries |
64 |
NSArray *array = [[NSArray alloc] initWithObjects: |
|
65 |
NSLocalizedString(@"Grave",@""), |
|
66 |
NSLocalizedString(@"Voice",@""), |
|
67 |
NSLocalizedString(@"Fort",@""), |
|
68 |
NSLocalizedString(@"Flag",@""), |
|
69 |
NSLocalizedString(@"Level",@""),nil]; |
|
70 |
self.secondaryItems = array; |
|
71 |
[array release]; |
|
8441 | 72 |
|
3816 | 73 |
// labels for the subtitles |
74 |
NSArray *moreArray = [[NSArray alloc] initWithObjects: |
|
75 |
NSLocalizedString(@"Mark the death of your fallen warriors",@""), |
|
76 |
NSLocalizedString(@"Pick a slang your hogs will speak",@""), |
|
77 |
NSLocalizedString(@"Select the team invincible fortress (only valid for fort games)",@""), |
|
78 |
NSLocalizedString(@"Choose a charismatic symbol for your team",@""), |
|
79 |
NSLocalizedString(@"Opt for controlling the team or let the AI lead",@""),nil]; |
|
80 |
self.moreSecondaryItems = moreArray; |
|
81 |
[moreArray release]; |
|
3547 | 82 |
|
83 |
// load the base hog image, drawing will occure in cellForRow... |
|
5983 | 84 |
NSString *normalHogFile = [[NSString alloc] initWithFormat:@"%@/basehat-hedgehog.png",[[NSBundle mainBundle] resourcePath]]; |
85 |
UIImage *hogSprite = [[UIImage alloc] initWithContentsOfFile:normalHogFile]; |
|
3547 | 86 |
[normalHogFile release]; |
87 |
self.normalHogSprite = hogSprite; |
|
88 |
[hogSprite release]; |
|
3697 | 89 |
|
3547 | 90 |
// listen if any childController modifies the plist and write it if needed |
91 |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setWriteNeeded) name:@"setWriteNeedTeams" object:nil]; |
|
92 |
isWriteNeeded = NO; |
|
3697 | 93 |
|
3660 | 94 |
self.title = NSLocalizedString(@"Edit team settings",@""); |
3547 | 95 |
} |
96 |
||
97 |
-(void) viewWillAppear:(BOOL)animated { |
|
98 |
[super viewWillAppear:animated]; |
|
3697 | 99 |
|
3660 | 100 |
// load data about the team and write if there has been a change from other childControllers |
3697 | 101 |
if (isWriteNeeded) |
3547 | 102 |
[self writeFile]; |
3697 | 103 |
|
3660 | 104 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName]; |
3547 | 105 |
NSMutableDictionary *teamDict = [[NSMutableDictionary alloc] initWithContentsOfFile:teamFile]; |
106 |
self.teamDictionary = teamDict; |
|
107 |
[teamDict release]; |
|
108 |
[teamFile release]; |
|
3697 | 109 |
|
3547 | 110 |
[self.tableView reloadData]; |
111 |
} |
|
112 |
||
113 |
// write on file if there has been a change |
|
114 |
-(void) viewWillDisappear:(BOOL)animated { |
|
115 |
[super viewWillDisappear:animated]; |
|
116 |
||
3697 | 117 |
if (isWriteNeeded) |
3660 | 118 |
[self writeFile]; |
3547 | 119 |
} |
120 |
||
121 |
#pragma mark - |
|
122 |
// needed by other classes to warn about a user change |
|
123 |
-(void) setWriteNeeded { |
|
124 |
isWriteNeeded = YES; |
|
125 |
} |
|
126 |
||
127 |
-(void) writeFile { |
|
3660 | 128 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName]; |
129 |
[self.teamDictionary writeToFile:teamFile atomically:YES]; |
|
130 |
[teamFile release]; |
|
3547 | 131 |
|
3789
c3eb56754e92
added a smaller version of forts, fixed a couple of regressions
koda
parents:
3783
diff
changeset
|
132 |
//DLog(@"%@",teamDictionary); |
3547 | 133 |
isWriteNeeded = NO; |
134 |
} |
|
135 |
||
136 |
#pragma mark - |
|
137 |
#pragma mark Table view data source |
|
138 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
139 |
return 3; |
|
140 |
} |
|
141 |
||
142 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
143 |
NSInteger rows = 0; |
|
144 |
switch (section) { |
|
145 |
case 0: // team name |
|
146 |
rows = 1; |
|
147 |
break; |
|
148 |
case 1: // team members |
|
11187
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
149 |
rows = HW_getMaxNumberOfHogs() + 1; // one for 'Select one hat for all hogs' cell |
3547 | 150 |
break; |
151 |
case 2: // team details |
|
152 |
rows = [self.secondaryItems count]; |
|
153 |
break; |
|
154 |
default: |
|
155 |
break; |
|
156 |
} |
|
157 |
return rows; |
|
158 |
} |
|
159 |
||
3660 | 160 |
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { |
161 |
NSString *sectionTitle = nil; |
|
162 |
switch (section) { |
|
163 |
case 0: |
|
164 |
sectionTitle = NSLocalizedString(@"Team Name", @""); |
|
165 |
break; |
|
166 |
case 1: |
|
167 |
sectionTitle = NSLocalizedString(@"Names and Hats", @""); |
|
168 |
break; |
|
169 |
case 2: |
|
170 |
sectionTitle = NSLocalizedString(@"Team Preferences", @""); |
|
171 |
break; |
|
172 |
default: |
|
173 |
DLog(@"Nope"); |
|
174 |
break; |
|
175 |
} |
|
176 |
return sectionTitle; |
|
177 |
} |
|
178 |
||
3547 | 179 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
180 |
static NSString *CellIdentifier0 = @"Cell0"; |
|
181 |
static NSString *CellIdentifier1 = @"Cell1"; |
|
182 |
static NSString *CellIdentifier2 = @"Cell2"; |
|
11187
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
183 |
static NSString *CellIdentifierDefault = @"CellDefault"; |
3697 | 184 |
|
3547 | 185 |
NSArray *hogArray; |
186 |
UITableViewCell *cell = nil; |
|
3660 | 187 |
EditableCellView *editableCell = nil; |
3547 | 188 |
NSInteger row = [indexPath row]; |
189 |
UIImage *accessoryImage; |
|
3697 | 190 |
|
3547 | 191 |
switch ([indexPath section]) { |
192 |
case 0: |
|
3660 | 193 |
editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
194 |
if (editableCell == nil) { |
|
3697 | 195 |
editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault |
3547 | 196 |
reuseIdentifier:CellIdentifier0] autorelease]; |
3660 | 197 |
editableCell.delegate = self; |
198 |
editableCell.tag = TEAMNAME_TAG; |
|
3547 | 199 |
} |
3697 | 200 |
|
3660 | 201 |
editableCell.imageView.image = nil; |
202 |
editableCell.accessoryType = UITableViewCellAccessoryNone; |
|
203 |
editableCell.textField.text = self.teamName; |
|
204 |
||
205 |
cell = editableCell; |
|
3547 | 206 |
break; |
207 |
case 1: |
|
11187
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
208 |
if ([indexPath row] == HW_getMaxNumberOfHogs()) |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
209 |
{ |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
210 |
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierDefault]; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
211 |
if (cell == nil) |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
212 |
{ |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
213 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
214 |
reuseIdentifier:CellIdentifierDefault] autorelease]; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
215 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
216 |
} |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
217 |
|
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
218 |
cell.textLabel.text = NSLocalizedString(@"Select one hat for all hogs", nil); |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
219 |
|
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
220 |
break; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
221 |
} |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
222 |
|
3660 | 223 |
editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
224 |
if (editableCell == nil) { |
|
3697 | 225 |
editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault |
3547 | 226 |
reuseIdentifier:CellIdentifier1] autorelease]; |
3660 | 227 |
editableCell.delegate = self; |
228 |
editableCell.tag = [indexPath row]; |
|
3547 | 229 |
} |
3697 | 230 |
|
3547 | 231 |
hogArray = [self.teamDictionary objectForKey:@"hedgehogs"]; |
3697 | 232 |
|
3660 | 233 |
// draw the hat on top of the hog |
3547 | 234 |
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)]; |
|
236 |
[hatFile release]; |
|
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3926
diff
changeset
|
237 |
editableCell.imageView.image = [self.normalHogSprite mergeWith:hatSprite atPoint:CGPointMake(0, 5)]; |
3547 | 238 |
[hatSprite release]; |
3697 | 239 |
|
3660 | 240 |
editableCell.textField.text = [[hogArray objectAtIndex:row] objectForKey:@"hogname"]; |
241 |
editableCell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; |
|
3697 | 242 |
|
3660 | 243 |
cell = editableCell; |
3547 | 244 |
break; |
245 |
case 2: |
|
246 |
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2]; |
|
247 |
if (cell == nil) { |
|
3816 | 248 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle |
3547 | 249 |
reuseIdentifier:CellIdentifier2] autorelease]; |
250 |
} |
|
3697 | 251 |
|
3547 | 252 |
cell.textLabel.text = [self.secondaryItems objectAtIndex:row]; |
3816 | 253 |
cell.detailTextLabel.text = [self.moreSecondaryItems objectAtIndex:row]; |
3547 | 254 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
255 |
switch (row) { |
|
256 |
case 0: // grave |
|
257 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", |
|
258 |
GRAVES_DIRECTORY(),[teamDictionary objectForKey:@"grave"]] |
|
259 |
andCutAt:CGRectMake(0,0,32,32)]; |
|
260 |
cell.imageView.image = accessoryImage; |
|
261 |
[accessoryImage release]; |
|
262 |
break; |
|
3816 | 263 |
case 1: // voice |
264 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/HellishBomb.png", |
|
265 |
GRAPHICS_DIRECTORY()]]; |
|
266 |
cell.imageView.image = accessoryImage; |
|
267 |
[accessoryImage release]; |
|
268 |
break; |
|
3547 | 269 |
case 2: // fort |
5982
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
270 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@-icon.png", |
3547 | 271 |
FORTS_DIRECTORY(),[teamDictionary objectForKey:@"fort"]]]; |
5982
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
272 |
cell.imageView.image = accessoryImage; |
3547 | 273 |
[accessoryImage release]; |
274 |
break; |
|
275 |
case 3: // flags |
|
276 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", |
|
277 |
FLAGS_DIRECTORY(),[teamDictionary objectForKey:@"flag"]]]; |
|
5982
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
278 |
cell.imageView.image = [accessoryImage scaleToSize:CGSizeMake(26, 18)]; |
3547 | 279 |
[accessoryImage release]; |
6104 | 280 |
cell.imageView.layer.borderWidth = 1; |
281 |
cell.imageView.layer.borderColor = [[UIColor blackColor] CGColor]; |
|
3547 | 282 |
break; |
283 |
case 4: // level |
|
5982
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
284 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/bot%d.png", |
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
285 |
[[NSBundle mainBundle] resourcePath], |
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
286 |
[[[[teamDictionary objectForKey:@"hedgehogs"] |
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
287 |
objectAtIndex:0] objectForKey:@"level"] |
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
288 |
intValue]]]; |
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
289 |
cell.imageView.image = accessoryImage; |
3547 | 290 |
[accessoryImage release]; |
291 |
break; |
|
292 |
default: |
|
293 |
cell.imageView.image = nil; |
|
294 |
break; |
|
295 |
} |
|
296 |
break; |
|
297 |
} |
|
3697 | 298 |
|
3547 | 299 |
return cell; |
300 |
} |
|
301 |
||
302 |
||
303 |
#pragma mark - |
|
304 |
#pragma mark Table view delegate |
|
305 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
306 |
NSInteger row = [indexPath row]; |
|
307 |
NSInteger section = [indexPath section]; |
|
3697 | 308 |
|
3547 | 309 |
if (2 == section) { |
310 |
switch (row) { |
|
311 |
case 0: // grave |
|
312 |
if (nil == gravesViewController) |
|
313 |
gravesViewController = [[GravesViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
8441 | 314 |
|
3924 | 315 |
[gravesViewController setTeamDictionary:teamDictionary]; |
316 |
[self.navigationController pushViewController:gravesViewController animated:YES]; |
|
3547 | 317 |
break; |
318 |
case 1: // voice |
|
319 |
if (nil == voicesViewController) |
|
320 |
voicesViewController = [[VoicesViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
8441 | 321 |
|
3924 | 322 |
[voicesViewController setTeamDictionary:teamDictionary]; |
323 |
[self.navigationController pushViewController:voicesViewController animated:YES]; |
|
3547 | 324 |
break; |
325 |
case 2: // fort |
|
326 |
if (nil == fortsViewController) |
|
327 |
fortsViewController = [[FortsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
8441 | 328 |
|
3924 | 329 |
[fortsViewController setTeamDictionary:teamDictionary]; |
330 |
[self.navigationController pushViewController:fortsViewController animated:YES]; |
|
3547 | 331 |
break; |
332 |
case 3: // flag |
|
3697 | 333 |
if (nil == flagsViewController) |
3547 | 334 |
flagsViewController = [[FlagsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
8441 | 335 |
|
3924 | 336 |
[flagsViewController setTeamDictionary:teamDictionary]; |
337 |
[self.navigationController pushViewController:flagsViewController animated:YES]; |
|
3547 | 338 |
break; |
339 |
case 4: // level |
|
340 |
if (nil == levelViewController) |
|
341 |
levelViewController = [[LevelViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
8441 | 342 |
|
3924 | 343 |
[levelViewController setTeamDictionary:teamDictionary]; |
344 |
[self.navigationController pushViewController:levelViewController animated:YES]; |
|
345 |
break; |
|
346 |
default: |
|
347 |
DLog(@"Nope"); |
|
3547 | 348 |
break; |
349 |
} |
|
350 |
} else { |
|
11187
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
351 |
if (section == 1 && row == HW_getMaxNumberOfHogs()) { |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
352 |
// 'Select one hat for all hogs' selected |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
353 |
[self showHogHatViewControllerForHogIndex:-1]; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
354 |
} else { |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
355 |
EditableCellView *cell = (EditableCellView *)[aTableView cellForRowAtIndexPath:indexPath]; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
356 |
[cell replyKeyboard]; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
357 |
[aTableView deselectRowAtIndexPath:indexPath animated:NO]; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
358 |
} |
3547 | 359 |
} |
360 |
||
361 |
} |
|
362 |
||
363 |
// action to perform when you want to change a hog hat |
|
3660 | 364 |
-(void) tableView:(UITableView *)aTableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { |
365 |
// if we are editing the field undo any change before proceeding |
|
366 |
EditableCellView *cell = (EditableCellView *)[aTableView cellForRowAtIndexPath:indexPath]; |
|
367 |
[cell cancel:nil]; |
|
11187
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
368 |
|
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
369 |
[self showHogHatViewControllerForHogIndex:[indexPath row]]; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
370 |
} |
3697 | 371 |
|
11187
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
372 |
- (void)showHogHatViewControllerForHogIndex:(NSInteger)hogIndex |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
373 |
{ |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
374 |
if (nil == hogHatViewController) |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
375 |
hogHatViewController = [[HogHatViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
376 |
|
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
377 |
// cache the dictionary file of the team, so that other controllers can modify it |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
378 |
hogHatViewController.teamDictionary = self.teamDictionary; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
379 |
hogHatViewController.selectedHog = hogIndex; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
380 |
|
3547 | 381 |
[self.navigationController pushViewController:hogHatViewController animated:YES]; |
382 |
} |
|
383 |
||
384 |
#pragma mark - |
|
385 |
#pragma mark Memory management |
|
386 |
-(void) didReceiveMemoryWarning { |
|
387 |
[super didReceiveMemoryWarning]; |
|
388 |
if (hogHatViewController.view.superview == nil) |
|
389 |
hogHatViewController = nil; |
|
390 |
if (gravesViewController.view.superview == nil) |
|
391 |
gravesViewController = nil; |
|
392 |
if (voicesViewController.view.superview == nil) |
|
393 |
voicesViewController = nil; |
|
394 |
if (fortsViewController.view.superview == nil) |
|
395 |
fortsViewController = nil; |
|
396 |
if (flagsViewController.view.superview == nil) |
|
397 |
flagsViewController = nil; |
|
398 |
if (levelViewController.view.superview == nil) |
|
399 |
levelViewController = nil; |
|
3660 | 400 |
MSG_MEMCLEAN(); |
3547 | 401 |
} |
402 |
||
403 |
-(void) viewDidUnload { |
|
3783 | 404 |
[[NSNotificationCenter defaultCenter] removeObserver:self]; |
3547 | 405 |
self.teamDictionary = nil; |
406 |
self.teamName = nil; |
|
407 |
self.normalHogSprite = nil; |
|
408 |
self.secondaryItems = nil; |
|
3816 | 409 |
self.moreSecondaryItems = nil; |
3547 | 410 |
hogHatViewController = nil; |
3662
a44406f4369b
polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents:
3660
diff
changeset
|
411 |
gravesViewController = nil; |
a44406f4369b
polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents:
3660
diff
changeset
|
412 |
voicesViewController = nil; |
3547 | 413 |
flagsViewController = nil; |
414 |
fortsViewController = nil; |
|
415 |
levelViewController = nil; |
|
3662
a44406f4369b
polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents:
3660
diff
changeset
|
416 |
MSG_DIDUNLOAD(); |
3547 | 417 |
[super viewDidUnload]; |
418 |
} |
|
419 |
||
420 |
-(void) dealloc { |
|
5208 | 421 |
releaseAndNil(teamDictionary); |
422 |
releaseAndNil(teamName); |
|
423 |
releaseAndNil(normalHogSprite); |
|
424 |
releaseAndNil(secondaryItems); |
|
425 |
releaseAndNil(moreSecondaryItems); |
|
426 |
releaseAndNil(hogHatViewController); |
|
427 |
releaseAndNil(gravesViewController); |
|
428 |
releaseAndNil(fortsViewController); |
|
429 |
releaseAndNil(voicesViewController); |
|
430 |
releaseAndNil(flagsViewController); |
|
431 |
releaseAndNil(levelViewController); |
|
3547 | 432 |
[super dealloc]; |
433 |
} |
|
434 |
||
435 |
||
436 |
@end |
|
437 |