3547
|
1 |
//
|
|
2 |
// SingleSchemeViewController.m
|
|
3 |
// Hedgewars
|
|
4 |
//
|
|
5 |
// Created by Vittorio on 23/05/10.
|
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
|
7 |
//
|
|
8 |
|
|
9 |
#import "SingleSchemeViewController.h"
|
|
10 |
#import <QuartzCore/QuartzCore.h>
|
|
11 |
#import "CommodityFunctions.h"
|
|
12 |
#import "UIImageExtra.h"
|
|
13 |
|
3573
|
14 |
#define LABEL_TAG 12345
|
|
15 |
#define SLIDER_TAG 54321
|
|
16 |
|
3547
|
17 |
@implementation SingleSchemeViewController
|
|
18 |
@synthesize textFieldBeingEdited, schemeArray, basicSettingList, gameModifierArray;
|
|
19 |
|
|
20 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
|
|
21 |
return rotationManager(interfaceOrientation);
|
|
22 |
}
|
|
23 |
|
|
24 |
#pragma mark -
|
|
25 |
#pragma mark View lifecycle
|
|
26 |
-(void) viewDidLoad {
|
|
27 |
[super viewDidLoad];
|
|
28 |
|
|
29 |
NSArray *mods = [[NSArray alloc] initWithObjects:
|
|
30 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Fort Mode",@""),@"title",
|
|
31 |
NSLocalizedString(@"Defend your fort and destroy the opponents (two team colours max)",@""),@"description",
|
|
32 |
@"Forts",@"image",nil],
|
|
33 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Divide Team",@""),@"title",
|
|
34 |
NSLocalizedString(@"Teams will start on opposite sides of the terrain (two team colours max)",@""),@"description",
|
|
35 |
@"TeamsDivide",@"image",nil],
|
|
36 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Solid Land",@""),@"title",
|
|
37 |
NSLocalizedString(@"Land can not be destroyed",@""),@"description",
|
|
38 |
@"Solid",@"image",nil],
|
|
39 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Add Border",@""),@"title",
|
|
40 |
NSLocalizedString(@"Add an indestructable border around the terrain",@""),@"description",
|
|
41 |
@"Border",@"image",nil],
|
|
42 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Low Gravity",@""),@"title",
|
|
43 |
NSLocalizedString(@"Lower gravity",@""),@"description",
|
|
44 |
@"LowGravity",@"image",nil],
|
|
45 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Laser Sight",@""),@"title",
|
|
46 |
NSLocalizedString(@"Assisted aiming with laser sight",@""),@"description",
|
|
47 |
@"LaserSight",@"image",nil],
|
|
48 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Invulnerable",@""),@"title",
|
|
49 |
NSLocalizedString(@"All hogs have a personal forcefield",@""),@"description",
|
|
50 |
@"Invulnerable",@"image",nil],
|
|
51 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Add Mines",@""),@"title",
|
|
52 |
NSLocalizedString(@"Enable random mines",@""),@"description",
|
|
53 |
@"Mines",@"image",nil],
|
|
54 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Vampirism Mode",@""),@"title",
|
|
55 |
NSLocalizedString(@"Gain 80% of the damage you do back in health",@""),@"description",
|
|
56 |
@"Vampiric",@"image",nil],
|
|
57 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Karma Mode",@""),@"title",
|
|
58 |
NSLocalizedString(@"Share your opponents pain, share their damage",@""),@"description",
|
|
59 |
@"Karma",@"image",nil],
|
|
60 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Artillery Mode",@""),@"title",
|
|
61 |
NSLocalizedString(@"Your hogs are unable to move, test your aim",@""),@"description",
|
|
62 |
@"Artillery",@"image",nil],
|
|
63 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Random Order",@""),@"title",
|
|
64 |
NSLocalizedString(@"Order of play is random instead of in room order",@""),@"description",
|
|
65 |
@"RandomOrder",@"image",nil],
|
|
66 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"King Mode",@""),@"title",
|
|
67 |
NSLocalizedString(@"Play with a King. If he dies, your side loses",@""),@"description",
|
|
68 |
@"King",@"image",nil],
|
|
69 |
[NSDictionary dictionaryWithObjectsAndKeys: NSLocalizedString(@"Place Hedgehogs",@""),@"title",
|
|
70 |
NSLocalizedString(@"Take turns placing your hedgehogs pre-game",@""),@"description",
|
|
71 |
@"PlaceHog",@"image",nil],
|
|
72 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Clan Shares Ammo",@""),@"title",
|
|
73 |
NSLocalizedString(@"Ammo is shared between all clan teams",@""),@"description",
|
|
74 |
@"SharedAmmo",@"image",nil],
|
|
75 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Disable Girders",@""),@"title",
|
|
76 |
NSLocalizedString(@"Disable girders when generating random maps",@""),@"description",
|
|
77 |
@"DisableGirders",@"image",nil],
|
|
78 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Disable Land Objects",@""),@"title",
|
|
79 |
NSLocalizedString(@"Disable land objects when generating maps",@""),@"description",
|
|
80 |
@"DisableLandObjects",@"image",nil],
|
|
81 |
nil];
|
|
82 |
self.gameModifierArray = mods;
|
|
83 |
[mods release];
|
|
84 |
|
|
85 |
NSArray *basicSettings = [[NSArray alloc] initWithObjects:
|
3573
|
86 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Damage Modifier",@""),@"title",@"Damage",@"image",
|
|
87 |
[NSNumber numberWithInt:100],@"default",[NSNumber numberWithInt:10],@"min",[NSNumber numberWithInt:300],@"max",nil],
|
|
88 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Turn Time",@""),@"title",@"Time",@"image",
|
|
89 |
[NSNumber numberWithInt:45],@"default",[NSNumber numberWithInt:1],@"min",[NSNumber numberWithInt:99],@"max",nil],
|
|
90 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Initial Health",@""),@"title",@"Health",@"image",
|
|
91 |
[NSNumber numberWithInt:100],@"default",[NSNumber numberWithInt:50],@"min",[NSNumber numberWithInt:200],@"max",nil],
|
|
92 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Sudden Death Timeout",@""),@"title",@"SuddenDeath",@"image",
|
|
93 |
[NSNumber numberWithInt:15],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:50],@"max",nil],
|
|
94 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Crate Drops",@""),@"title",@"Box",@"image",
|
|
95 |
[NSNumber numberWithInt:5],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:9],@"max",nil],
|
|
96 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Mines Time",@""),@"title",@"Time",@"image",
|
|
97 |
[NSNumber numberWithInt:3],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:3],@"max",nil],
|
|
98 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Mines Number",@""),@"title",@"Mine",@"image",
|
|
99 |
[NSNumber numberWithInt:4],@"default",[NSNumber numberWithInt:1],@"min",[NSNumber numberWithInt:80],@"max",nil],
|
|
100 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Dud Mines Probability",@""),@"title",@"Dud",@"image",
|
|
101 |
[NSNumber numberWithInt:0],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:100],@"max",nil],
|
|
102 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Explosives",@""),@"title",@"Damage",@"image",
|
|
103 |
[NSNumber numberWithInt:2],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:40],@"max",nil],
|
3547
|
104 |
nil];
|
|
105 |
self.basicSettingList = basicSettings;
|
|
106 |
[basicSettings release];
|
|
107 |
}
|
|
108 |
|
|
109 |
// load from file
|
|
110 |
-(void) viewWillAppear:(BOOL) animated {
|
|
111 |
[super viewWillAppear:animated];
|
|
112 |
|
|
113 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title];
|
|
114 |
NSMutableArray *scheme = [[NSMutableArray alloc] initWithContentsOfFile:schemeFile];
|
|
115 |
self.schemeArray = scheme;
|
|
116 |
[scheme release];
|
|
117 |
[schemeFile release];
|
|
118 |
|
|
119 |
[self.tableView reloadData];
|
|
120 |
}
|
|
121 |
|
|
122 |
// save to file
|
|
123 |
-(void) viewWillDisappear:(BOOL) animated {
|
|
124 |
[super viewWillDisappear:animated];
|
|
125 |
|
|
126 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title];
|
|
127 |
[self.schemeArray writeToFile:schemeFile atomically:YES];
|
|
128 |
[schemeFile release];
|
|
129 |
}
|
|
130 |
|
|
131 |
#pragma mark -
|
|
132 |
#pragma mark textfield methods
|
|
133 |
-(void) cancel:(id) sender {
|
|
134 |
if (textFieldBeingEdited != nil)
|
|
135 |
[self.textFieldBeingEdited resignFirstResponder];
|
|
136 |
}
|
|
137 |
|
|
138 |
// set the new value
|
|
139 |
-(BOOL) save:(id) sender {
|
|
140 |
if (textFieldBeingEdited != nil) {
|
|
141 |
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] error:NULL];
|
|
142 |
self.title = self.textFieldBeingEdited.text;
|
|
143 |
[self.schemeArray writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] atomically:YES];
|
|
144 |
[self.textFieldBeingEdited resignFirstResponder];
|
|
145 |
return YES;
|
|
146 |
}
|
|
147 |
return NO;
|
|
148 |
}
|
|
149 |
|
|
150 |
// the textfield is being modified, update the navigation controller
|
|
151 |
-(void) textFieldDidBeginEditing:(UITextField *)aTextField{
|
|
152 |
self.textFieldBeingEdited = aTextField;
|
|
153 |
|
|
154 |
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel",@"from schemes table")
|
|
155 |
style:UIBarButtonItemStylePlain
|
|
156 |
target:self
|
|
157 |
action:@selector(cancel:)];
|
|
158 |
self.navigationItem.leftBarButtonItem = cancelButton;
|
|
159 |
[cancelButton release];
|
|
160 |
|
|
161 |
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save",@"from schemes table")
|
|
162 |
style:UIBarButtonItemStyleDone
|
|
163 |
target:self
|
|
164 |
action:@selector(save:)];
|
|
165 |
self.navigationItem.rightBarButtonItem = saveButton;
|
|
166 |
[saveButton release];
|
|
167 |
}
|
|
168 |
|
|
169 |
// the textfield has been modified, check for empty strings and restore original navigation bar
|
|
170 |
-(void) textFieldDidEndEditing:(UITextField *)aTextField{
|
|
171 |
if ([textFieldBeingEdited.text length] == 0)
|
|
172 |
textFieldBeingEdited.text = [NSString stringWithFormat:@"New Scheme"];
|
|
173 |
|
|
174 |
self.textFieldBeingEdited = nil;
|
|
175 |
self.navigationItem.rightBarButtonItem = self.navigationItem.backBarButtonItem;
|
|
176 |
self.navigationItem.leftBarButtonItem = nil;
|
|
177 |
}
|
|
178 |
|
|
179 |
// limit the size of the field to 64 characters like in original frontend
|
|
180 |
-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
|
|
181 |
int limit = 64;
|
|
182 |
return !([textField.text length] > limit && [string length] > range.length);
|
|
183 |
}
|
|
184 |
|
|
185 |
|
|
186 |
#pragma mark -
|
|
187 |
#pragma mark Table view data source
|
|
188 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
|
|
189 |
return 3;
|
|
190 |
}
|
|
191 |
|
|
192 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
193 |
switch (section) {
|
|
194 |
case 0:
|
|
195 |
return 1;
|
|
196 |
break;
|
|
197 |
case 1:
|
|
198 |
return [self.basicSettingList count];
|
|
199 |
break;
|
|
200 |
case 2:
|
|
201 |
return [self.gameModifierArray count];
|
|
202 |
default:
|
|
203 |
break;
|
|
204 |
}
|
|
205 |
return 0;
|
|
206 |
}
|
|
207 |
|
3573
|
208 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
3547
|
209 |
static NSString *CellIdentifier0 = @"Cell0";
|
|
210 |
static NSString *CellIdentifier1 = @"Cell1";
|
|
211 |
static NSString *CellIdentifier2 = @"Cell2";
|
|
212 |
|
|
213 |
UITableViewCell *cell = nil;
|
|
214 |
NSInteger row = [indexPath row];
|
|
215 |
|
|
216 |
switch ([indexPath section]) {
|
|
217 |
case 0:
|
3573
|
218 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
|
3547
|
219 |
if (cell == nil) {
|
|
220 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
|
|
221 |
reuseIdentifier:CellIdentifier0] autorelease];
|
|
222 |
// create a uitextfield for each row, expand it to take the maximum size
|
|
223 |
UITextField *aTextField = [[UITextField alloc]
|
|
224 |
initWithFrame:CGRectMake(5, 12, (cell.frame.size.width + cell.frame.size.width/3) - 42, 25)];
|
|
225 |
aTextField.clearsOnBeginEditing = NO;
|
|
226 |
aTextField.returnKeyType = UIReturnKeyDone;
|
|
227 |
aTextField.adjustsFontSizeToFitWidth = YES;
|
|
228 |
aTextField.delegate = self;
|
|
229 |
aTextField.tag = [indexPath row];
|
|
230 |
aTextField.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize] + 2];
|
|
231 |
aTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
|
232 |
[aTextField addTarget:self action:@selector(save:) forControlEvents:UIControlEventEditingDidEndOnExit];
|
|
233 |
[cell.contentView addSubview:aTextField];
|
|
234 |
[aTextField release];
|
|
235 |
}
|
|
236 |
|
|
237 |
for (UIView *oneView in cell.contentView.subviews) {
|
|
238 |
if ([oneView isMemberOfClass:[UITextField class]]) {
|
|
239 |
// we find the uitextfied and we'll use its tag to understand which one is being edited
|
|
240 |
UITextField *textFieldFound = (UITextField *)oneView;
|
|
241 |
textFieldFound.text = self.title;
|
|
242 |
}
|
|
243 |
}
|
|
244 |
cell.detailTextLabel.text = nil;
|
|
245 |
cell.imageView.image = nil;
|
|
246 |
break;
|
|
247 |
case 1:
|
3573
|
248 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1];
|
|
249 |
NSDictionary *detail = [self.basicSettingList objectAtIndex:row];
|
|
250 |
// need to offset this section (see format in CommodityFunctions.m and above)
|
|
251 |
NSInteger gmSize = [self.gameModifierArray count];
|
3547
|
252 |
if (cell == nil) {
|
3573
|
253 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
|
3547
|
254 |
reuseIdentifier:CellIdentifier1] autorelease];
|
3573
|
255 |
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(260, 12, 150, 23)];
|
|
256 |
slider.maximumValue = [[detail objectForKey:@"max"] floatValue];
|
|
257 |
slider.minimumValue = [[detail objectForKey:@"min"] floatValue];
|
|
258 |
slider.tag = row+gmSize;
|
|
259 |
[slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
|
|
260 |
[cell.contentView addSubview:slider];
|
|
261 |
[slider release];
|
|
262 |
|
|
263 |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 7, 200, 30)];
|
|
264 |
label.tag = LABEL_TAG;
|
|
265 |
label.backgroundColor = [UIColor clearColor];
|
|
266 |
label.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
|
|
267 |
[cell.contentView addSubview:label];
|
|
268 |
[label release];
|
3547
|
269 |
}
|
|
270 |
|
|
271 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/icon%@.png",BTN_DIRECTORY(),[[self.basicSettingList objectAtIndex:row] objectForKey:@"image"]]];
|
|
272 |
cell.imageView.image = [img scaleToSize:CGSizeMake(40, 40)];
|
|
273 |
[img release];
|
3573
|
274 |
|
|
275 |
UILabel *cellLabel = (UILabel *)[cell.contentView viewWithTag:LABEL_TAG];
|
|
276 |
cellLabel.text = [[self.basicSettingList objectAtIndex:row] objectForKey:@"title"];
|
|
277 |
|
|
278 |
UISlider *cellSlider = (UISlider *)[cell.contentView viewWithTag:row+gmSize];
|
|
279 |
cellSlider.value = [[self.schemeArray objectAtIndex:row+gmSize] floatValue];
|
|
280 |
|
|
281 |
// forced to use this weird format otherwise the label disappears when size of the text is bigger than the original
|
|
282 |
cell.detailTextLabel.text = [NSString stringWithFormat:@"%0.3d",[[self.schemeArray objectAtIndex:row+gmSize] intValue]];
|
3547
|
283 |
break;
|
|
284 |
case 2:
|
3573
|
285 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier2];
|
3547
|
286 |
if (cell == nil) {
|
|
287 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
|
|
288 |
reuseIdentifier:CellIdentifier2] autorelease];
|
|
289 |
UISwitch *onOff = [[UISwitch alloc] init];
|
|
290 |
onOff.tag = row;
|
|
291 |
[onOff addTarget:self action:@selector(toggleSwitch:) forControlEvents:UIControlEventValueChanged];
|
|
292 |
cell.accessoryView = onOff;
|
|
293 |
[onOff release];
|
|
294 |
}
|
|
295 |
|
|
296 |
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/btn%@.png",BTN_DIRECTORY(),[[self.gameModifierArray objectAtIndex:row] objectForKey:@"image"]]];
|
|
297 |
cell.imageView.image = image;
|
|
298 |
[image release];
|
|
299 |
[cell.imageView.layer setCornerRadius:7.0f];
|
3573
|
300 |
[cell.imageView.layer setBorderWidth:1];
|
3547
|
301 |
[cell.imageView.layer setMasksToBounds:YES];
|
|
302 |
cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"];
|
|
303 |
cell.detailTextLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"description"];
|
|
304 |
[(UISwitch *)cell.accessoryView setOn:[[self.schemeArray objectAtIndex:row] boolValue] animated:NO];
|
|
305 |
}
|
|
306 |
|
|
307 |
return cell;
|
|
308 |
}
|
|
309 |
|
|
310 |
-(void) toggleSwitch:(id) sender {
|
|
311 |
UISwitch *theSwitch = (UISwitch *)sender;
|
|
312 |
[self.schemeArray replaceObjectAtIndex:theSwitch.tag withObject:[NSNumber numberWithBool:theSwitch.on]];
|
|
313 |
}
|
|
314 |
|
3573
|
315 |
-(void) sliderChanged:(id) sender {
|
|
316 |
// need to offset this section (see format in CommodityFunctions.m and above)
|
|
317 |
NSInteger gmSize = [self.gameModifierArray count];
|
|
318 |
// the slider that changed is sent as object
|
|
319 |
UISlider *theSlider = (UISlider *)sender;
|
|
320 |
// create the indexPath of the row of the slider
|
|
321 |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:theSlider.tag-gmSize inSection:1];
|
|
322 |
// get its cell
|
|
323 |
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
|
|
324 |
// grab the associated label
|
|
325 |
UILabel *label = (UILabel *)cell.detailTextLabel;
|
|
326 |
// modify it
|
|
327 |
label.text = [NSString stringWithFormat:@"%0.3d",(int)theSlider.value];
|
|
328 |
// save changes in the main array (remember that you need to offset it)
|
|
329 |
[self.schemeArray replaceObjectAtIndex:theSlider.tag withObject:[NSNumber numberWithInt:(int)theSlider.value]];
|
|
330 |
NSLog(@"%@",self.schemeArray);
|
|
331 |
}
|
3547
|
332 |
|
|
333 |
#pragma mark -
|
|
334 |
#pragma mark Table view delegate
|
|
335 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
3573
|
336 |
UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath];
|
|
337 |
UISwitch *sw = nil;
|
|
338 |
UISlider *cellSlider = nil;
|
3547
|
339 |
|
3573
|
340 |
switch ([indexPath section]) {
|
|
341 |
case 0:
|
|
342 |
for (UIView *oneView in cell.contentView.subviews) {
|
|
343 |
if ([oneView isMemberOfClass:[UITextField class]]) {
|
|
344 |
textFieldBeingEdited = (UITextField *)oneView;
|
|
345 |
[textFieldBeingEdited becomeFirstResponder];
|
|
346 |
}
|
3547
|
347 |
}
|
3573
|
348 |
break;
|
|
349 |
case 1:
|
|
350 |
cellSlider = (UISlider *)[cell.contentView viewWithTag:[indexPath row]+[self.gameModifierArray count]];
|
|
351 |
[cellSlider setValue:[[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] floatValue] animated:YES];
|
|
352 |
[self sliderChanged:cellSlider];
|
|
353 |
//cell.detailTextLabel.text = [[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] stringValue];
|
|
354 |
break;
|
|
355 |
case 2:
|
|
356 |
sw = (UISwitch *)cell.accessoryView;
|
|
357 |
[sw setOn:!sw.on animated:YES];
|
|
358 |
[self toggleSwitch:sw];
|
|
359 |
break;
|
|
360 |
default:
|
|
361 |
break;
|
3547
|
362 |
}
|
3573
|
363 |
|
3547
|
364 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
365 |
}
|
|
366 |
|
|
367 |
|
|
368 |
#pragma mark -
|
|
369 |
#pragma mark Memory management
|
|
370 |
-(void) didReceiveMemoryWarning {
|
|
371 |
[super didReceiveMemoryWarning];
|
|
372 |
}
|
|
373 |
|
|
374 |
-(void) viewDidUnload {
|
|
375 |
self.textFieldBeingEdited = nil;
|
|
376 |
self.schemeArray = nil;
|
|
377 |
self.basicSettingList = nil;
|
|
378 |
self.gameModifierArray = nil;
|
|
379 |
[super viewDidUnload];
|
|
380 |
MSG_DIDUNLOAD();
|
|
381 |
}
|
|
382 |
|
|
383 |
-(void) dealloc {
|
|
384 |
[textFieldBeingEdited release];
|
|
385 |
[schemeArray release];
|
|
386 |
[basicSettingList release];
|
|
387 |
[gameModifierArray release];
|
|
388 |
[super dealloc];
|
|
389 |
}
|
|
390 |
|
|
391 |
|
|
392 |
@end
|
|
393 |
|