author | nemo |
Thu, 15 Nov 2018 15:12:18 -0500 | |
changeset 14212 | ca179b615c0b |
parent 13166 | ba5c794adae3 |
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 |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
35 |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
3547 | 36 |
return rotationManager(interfaceOrientation); |
37 |
} |
|
38 |
||
39 |
#pragma mark - |
|
3660 | 40 |
#pragma mark editableCellViewDelegate methods |
3547 | 41 |
// set the new value |
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
42 |
- (void)saveTextFieldValue:(NSString *)textString withTag:(NSInteger)tagValue { |
3660 | 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 |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
60 |
- (void)viewDidLoad { |
3547 | 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; |
|
8441 | 71 |
|
3816 | 72 |
// labels for the subtitles |
73 |
NSArray *moreArray = [[NSArray alloc] initWithObjects: |
|
74 |
NSLocalizedString(@"Mark the death of your fallen warriors",@""), |
|
75 |
NSLocalizedString(@"Pick a slang your hogs will speak",@""), |
|
76 |
NSLocalizedString(@"Select the team invincible fortress (only valid for fort games)",@""), |
|
77 |
NSLocalizedString(@"Choose a charismatic symbol for your team",@""), |
|
78 |
NSLocalizedString(@"Opt for controlling the team or let the AI lead",@""),nil]; |
|
79 |
self.moreSecondaryItems = moreArray; |
|
3547 | 80 |
|
81 |
// load the base hog image, drawing will occure in cellForRow... |
|
5983 | 82 |
NSString *normalHogFile = [[NSString alloc] initWithFormat:@"%@/basehat-hedgehog.png",[[NSBundle mainBundle] resourcePath]]; |
83 |
UIImage *hogSprite = [[UIImage alloc] initWithContentsOfFile:normalHogFile]; |
|
3547 | 84 |
self.normalHogSprite = hogSprite; |
3697 | 85 |
|
3547 | 86 |
// listen if any childController modifies the plist and write it if needed |
87 |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setWriteNeeded) name:@"setWriteNeedTeams" object:nil]; |
|
88 |
isWriteNeeded = NO; |
|
3697 | 89 |
|
3660 | 90 |
self.title = NSLocalizedString(@"Edit team settings",@""); |
3547 | 91 |
} |
92 |
||
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
93 |
- (void)viewWillAppear:(BOOL)animated { |
3547 | 94 |
[super viewWillAppear:animated]; |
3697 | 95 |
|
3660 | 96 |
// load data about the team and write if there has been a change from other childControllers |
3697 | 97 |
if (isWriteNeeded) |
3547 | 98 |
[self writeFile]; |
3697 | 99 |
|
3660 | 100 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName]; |
3547 | 101 |
NSMutableDictionary *teamDict = [[NSMutableDictionary alloc] initWithContentsOfFile:teamFile]; |
102 |
self.teamDictionary = teamDict; |
|
3697 | 103 |
|
3547 | 104 |
[self.tableView reloadData]; |
105 |
} |
|
106 |
||
107 |
// write on file if there has been a change |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
108 |
- (void)viewWillDisappear:(BOOL)animated { |
3547 | 109 |
[super viewWillDisappear:animated]; |
110 |
||
3697 | 111 |
if (isWriteNeeded) |
3660 | 112 |
[self writeFile]; |
3547 | 113 |
} |
114 |
||
115 |
#pragma mark - |
|
116 |
// needed by other classes to warn about a user change |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
117 |
- (void)setWriteNeeded { |
3547 | 118 |
isWriteNeeded = YES; |
119 |
} |
|
120 |
||
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
121 |
- (void)writeFile { |
3660 | 122 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName]; |
123 |
[self.teamDictionary writeToFile:teamFile atomically:YES]; |
|
3547 | 124 |
|
3789
c3eb56754e92
added a smaller version of forts, fixed a couple of regressions
koda
parents:
3783
diff
changeset
|
125 |
//DLog(@"%@",teamDictionary); |
3547 | 126 |
isWriteNeeded = NO; |
127 |
} |
|
128 |
||
129 |
#pragma mark - |
|
130 |
#pragma mark Table view data source |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
131 |
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
3547 | 132 |
return 3; |
133 |
} |
|
134 |
||
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
135 |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
3547 | 136 |
NSInteger rows = 0; |
137 |
switch (section) { |
|
138 |
case 0: // team name |
|
139 |
rows = 1; |
|
140 |
break; |
|
141 |
case 1: // team members |
|
11183
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
142 |
rows = HW_getMaxNumberOfHogs() + 1; // one for 'Select one hat for all hogs' cell |
3547 | 143 |
break; |
144 |
case 2: // team details |
|
145 |
rows = [self.secondaryItems count]; |
|
146 |
break; |
|
147 |
default: |
|
148 |
break; |
|
149 |
} |
|
150 |
return rows; |
|
151 |
} |
|
152 |
||
13166
ba5c794adae3
- Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents:
12872
diff
changeset
|
153 |
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { |
3660 | 154 |
NSString *sectionTitle = nil; |
155 |
switch (section) { |
|
156 |
case 0: |
|
157 |
sectionTitle = NSLocalizedString(@"Team Name", @""); |
|
158 |
break; |
|
159 |
case 1: |
|
160 |
sectionTitle = NSLocalizedString(@"Names and Hats", @""); |
|
161 |
break; |
|
162 |
case 2: |
|
163 |
sectionTitle = NSLocalizedString(@"Team Preferences", @""); |
|
164 |
break; |
|
165 |
default: |
|
166 |
DLog(@"Nope"); |
|
167 |
break; |
|
168 |
} |
|
169 |
return sectionTitle; |
|
170 |
} |
|
171 |
||
3547 | 172 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
173 |
static NSString *CellIdentifier0 = @"Cell0"; |
|
174 |
static NSString *CellIdentifier1 = @"Cell1"; |
|
175 |
static NSString *CellIdentifier2 = @"Cell2"; |
|
11183
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
176 |
static NSString *CellIdentifierDefault = @"CellDefault"; |
3697 | 177 |
|
3547 | 178 |
NSArray *hogArray; |
179 |
UITableViewCell *cell = nil; |
|
3660 | 180 |
EditableCellView *editableCell = nil; |
3547 | 181 |
NSInteger row = [indexPath row]; |
182 |
UIImage *accessoryImage; |
|
3697 | 183 |
|
3547 | 184 |
switch ([indexPath section]) { |
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
185 |
case 0: { |
3660 | 186 |
editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
187 |
if (editableCell == nil) { |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
188 |
editableCell = [[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault |
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
189 |
reuseIdentifier:CellIdentifier0]; |
3660 | 190 |
editableCell.delegate = self; |
191 |
editableCell.tag = TEAMNAME_TAG; |
|
3547 | 192 |
} |
3697 | 193 |
|
3660 | 194 |
editableCell.imageView.image = nil; |
195 |
editableCell.accessoryType = UITableViewCellAccessoryNone; |
|
196 |
editableCell.textField.text = self.teamName; |
|
197 |
||
198 |
cell = editableCell; |
|
3547 | 199 |
break; |
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
200 |
} |
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
201 |
case 1: { |
11183
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
202 |
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
|
203 |
{ |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
204 |
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
|
205 |
if (cell == nil) |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
206 |
{ |
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
207 |
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
208 |
reuseIdentifier:CellIdentifierDefault]; |
11183
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
209 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
210 |
} |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
211 |
|
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
212 |
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
|
213 |
|
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
214 |
break; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
215 |
} |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
216 |
|
3660 | 217 |
editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
218 |
if (editableCell == nil) { |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
219 |
editableCell = [[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault |
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
220 |
reuseIdentifier:CellIdentifier1]; |
3660 | 221 |
editableCell.delegate = self; |
3547 | 222 |
} |
11254
407045ffe343
- Better handling of cell's tag in SingleTeamViewController
antonc27 <antonc27@mail.ru>
parents:
11217
diff
changeset
|
223 |
editableCell.tag = [indexPath row]; |
3697 | 224 |
|
3547 | 225 |
hogArray = [self.teamDictionary objectForKey:@"hedgehogs"]; |
3697 | 226 |
|
3660 | 227 |
// draw the hat on top of the hog |
3547 | 228 |
NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@.png", HATS_DIRECTORY(), [[hogArray objectAtIndex:row] objectForKey:@"hat"]]; |
229 |
UIImage *hatSprite = [[UIImage alloc] initWithContentsOfFile: hatFile andCutAt:CGRectMake(0, 0, 32, 32)]; |
|
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3926
diff
changeset
|
230 |
editableCell.imageView.image = [self.normalHogSprite mergeWith:hatSprite atPoint:CGPointMake(0, 5)]; |
3697 | 231 |
|
3660 | 232 |
editableCell.textField.text = [[hogArray objectAtIndex:row] objectForKey:@"hogname"]; |
233 |
editableCell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; |
|
3697 | 234 |
|
3660 | 235 |
cell = editableCell; |
3547 | 236 |
break; |
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
237 |
} |
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
238 |
case 2: { |
3547 | 239 |
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2]; |
240 |
if (cell == nil) { |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
241 |
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle |
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
242 |
reuseIdentifier:CellIdentifier2]; |
3547 | 243 |
} |
3697 | 244 |
|
3547 | 245 |
cell.textLabel.text = [self.secondaryItems objectAtIndex:row]; |
3816 | 246 |
cell.detailTextLabel.text = [self.moreSecondaryItems objectAtIndex:row]; |
3547 | 247 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
248 |
switch (row) { |
|
249 |
case 0: // grave |
|
250 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", |
|
251 |
GRAVES_DIRECTORY(),[teamDictionary objectForKey:@"grave"]] |
|
252 |
andCutAt:CGRectMake(0,0,32,32)]; |
|
253 |
cell.imageView.image = accessoryImage; |
|
254 |
break; |
|
3816 | 255 |
case 1: // voice |
256 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/HellishBomb.png", |
|
257 |
GRAPHICS_DIRECTORY()]]; |
|
258 |
cell.imageView.image = accessoryImage; |
|
259 |
break; |
|
3547 | 260 |
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
|
261 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@-icon.png", |
3547 | 262 |
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
|
263 |
cell.imageView.image = accessoryImage; |
3547 | 264 |
break; |
265 |
case 3: // flags |
|
266 |
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png", |
|
267 |
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
|
268 |
cell.imageView.image = [accessoryImage scaleToSize:CGSizeMake(26, 18)]; |
6104 | 269 |
cell.imageView.layer.borderWidth = 1; |
270 |
cell.imageView.layer.borderColor = [[UIColor blackColor] CGColor]; |
|
3547 | 271 |
break; |
272 |
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
|
273 |
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
|
274 |
[[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
|
275 |
[[[[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
|
276 |
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
|
277 |
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
|
278 |
cell.imageView.image = accessoryImage; |
3547 | 279 |
break; |
280 |
default: |
|
281 |
cell.imageView.image = nil; |
|
282 |
break; |
|
283 |
} |
|
284 |
break; |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
285 |
} |
3547 | 286 |
} |
3697 | 287 |
|
3547 | 288 |
return cell; |
289 |
} |
|
290 |
||
291 |
||
292 |
#pragma mark - |
|
293 |
#pragma mark Table view delegate |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
294 |
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
3547 | 295 |
NSInteger row = [indexPath row]; |
296 |
NSInteger section = [indexPath section]; |
|
3697 | 297 |
|
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
298 |
if (2 == section) |
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
299 |
{ |
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
300 |
switch (row) |
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
301 |
{ |
3547 | 302 |
case 0: // grave |
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
303 |
{ |
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
304 |
GravesViewController *gravesViewController = [[GravesViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
8441 | 305 |
|
3924 | 306 |
[gravesViewController setTeamDictionary:teamDictionary]; |
307 |
[self.navigationController pushViewController:gravesViewController animated:YES]; |
|
3547 | 308 |
break; |
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
309 |
} |
3547 | 310 |
case 1: // voice |
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
311 |
{ |
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
312 |
VoicesViewController *voicesViewController = [[VoicesViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
8441 | 313 |
|
3924 | 314 |
[voicesViewController setTeamDictionary:teamDictionary]; |
315 |
[self.navigationController pushViewController:voicesViewController animated:YES]; |
|
3547 | 316 |
break; |
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
317 |
} |
3547 | 318 |
case 2: // fort |
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
319 |
{ |
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
320 |
FortsViewController *fortsViewController = [[FortsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
8441 | 321 |
|
3924 | 322 |
[fortsViewController setTeamDictionary:teamDictionary]; |
323 |
[self.navigationController pushViewController:fortsViewController animated:YES]; |
|
3547 | 324 |
break; |
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
325 |
} |
3547 | 326 |
case 3: // flag |
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
327 |
{ |
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
328 |
FlagsViewController *flagsViewController = [[FlagsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
8441 | 329 |
|
3924 | 330 |
[flagsViewController setTeamDictionary:teamDictionary]; |
331 |
[self.navigationController pushViewController:flagsViewController animated:YES]; |
|
3547 | 332 |
break; |
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
333 |
} |
3547 | 334 |
case 4: // level |
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
335 |
{ |
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
336 |
LevelViewController *levelViewController = [[LevelViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
8441 | 337 |
|
3924 | 338 |
[levelViewController setTeamDictionary:teamDictionary]; |
339 |
[self.navigationController pushViewController:levelViewController animated:YES]; |
|
340 |
break; |
|
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
341 |
} |
3924 | 342 |
default: |
343 |
DLog(@"Nope"); |
|
3547 | 344 |
break; |
345 |
} |
|
346 |
} else { |
|
11183
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
347 |
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
|
348 |
// '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
|
349 |
[self showHogHatViewControllerForHogIndex:-1]; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
350 |
} else { |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
351 |
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
|
352 |
[cell replyKeyboard]; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
353 |
[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
|
354 |
} |
3547 | 355 |
} |
356 |
||
357 |
} |
|
358 |
||
359 |
// action to perform when you want to change a hog hat |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
360 |
- (void)tableView:(UITableView *)aTableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { |
3660 | 361 |
// if we are editing the field undo any change before proceeding |
362 |
EditableCellView *cell = (EditableCellView *)[aTableView cellForRowAtIndexPath:indexPath]; |
|
363 |
[cell cancel:nil]; |
|
11183
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
364 |
|
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
365 |
[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
|
366 |
} |
3697 | 367 |
|
11183
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
368 |
- (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
|
369 |
{ |
11217
e68b3e392091
- Big refactoring of front-end Settings for both iPhone and iPad:
antonc27 <antonc27@mail.ru>
parents:
11183
diff
changeset
|
370 |
HogHatViewController *hogHatViewController = [[HogHatViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
11183
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
371 |
|
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
372 |
// 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
|
373 |
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
|
374 |
hogHatViewController.selectedHog = hogIndex; |
b2112ed988cb
- Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
375 |
|
3547 | 376 |
[self.navigationController pushViewController:hogHatViewController animated:YES]; |
377 |
} |
|
378 |
||
379 |
#pragma mark - |
|
380 |
#pragma mark Memory management |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
381 |
|
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11273
diff
changeset
|
382 |
- (void)didReceiveMemoryWarning { |
3547 | 383 |
[super didReceiveMemoryWarning]; |
3660 | 384 |
MSG_MEMCLEAN(); |
3547 | 385 |
} |
386 |
||
387 |
@end |
|
388 |