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) {
|
3574
|
141 |
if ([textFieldBeingEdited.text length] == 0)
|
|
142 |
textFieldBeingEdited.text = self.title;
|
|
143 |
|
3547
|
144 |
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] error:NULL];
|
|
145 |
self.title = self.textFieldBeingEdited.text;
|
|
146 |
[self.schemeArray writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] atomically:YES];
|
|
147 |
[self.textFieldBeingEdited resignFirstResponder];
|
|
148 |
return YES;
|
|
149 |
}
|
|
150 |
return NO;
|
|
151 |
}
|
|
152 |
|
|
153 |
// the textfield is being modified, update the navigation controller
|
|
154 |
-(void) textFieldDidBeginEditing:(UITextField *)aTextField{
|
|
155 |
self.textFieldBeingEdited = aTextField;
|
|
156 |
|
|
157 |
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel",@"from schemes table")
|
|
158 |
style:UIBarButtonItemStylePlain
|
|
159 |
target:self
|
|
160 |
action:@selector(cancel:)];
|
|
161 |
self.navigationItem.leftBarButtonItem = cancelButton;
|
|
162 |
[cancelButton release];
|
|
163 |
|
|
164 |
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save",@"from schemes table")
|
|
165 |
style:UIBarButtonItemStyleDone
|
|
166 |
target:self
|
|
167 |
action:@selector(save:)];
|
|
168 |
self.navigationItem.rightBarButtonItem = saveButton;
|
|
169 |
[saveButton release];
|
|
170 |
}
|
|
171 |
|
|
172 |
// the textfield has been modified, check for empty strings and restore original navigation bar
|
|
173 |
-(void) textFieldDidEndEditing:(UITextField *)aTextField{
|
|
174 |
if ([textFieldBeingEdited.text length] == 0)
|
|
175 |
textFieldBeingEdited.text = [NSString stringWithFormat:@"New Scheme"];
|
|
176 |
|
|
177 |
self.textFieldBeingEdited = nil;
|
|
178 |
self.navigationItem.rightBarButtonItem = self.navigationItem.backBarButtonItem;
|
|
179 |
self.navigationItem.leftBarButtonItem = nil;
|
|
180 |
}
|
|
181 |
|
|
182 |
// limit the size of the field to 64 characters like in original frontend
|
|
183 |
-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
|
|
184 |
int limit = 64;
|
|
185 |
return !([textField.text length] > limit && [string length] > range.length);
|
|
186 |
}
|
|
187 |
|
|
188 |
|
|
189 |
#pragma mark -
|
|
190 |
#pragma mark Table view data source
|
|
191 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
|
|
192 |
return 3;
|
|
193 |
}
|
|
194 |
|
|
195 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
196 |
switch (section) {
|
|
197 |
case 0:
|
|
198 |
return 1;
|
|
199 |
break;
|
|
200 |
case 1:
|
|
201 |
return [self.basicSettingList count];
|
|
202 |
break;
|
|
203 |
case 2:
|
|
204 |
return [self.gameModifierArray count];
|
|
205 |
default:
|
|
206 |
break;
|
|
207 |
}
|
|
208 |
return 0;
|
|
209 |
}
|
|
210 |
|
3573
|
211 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
3547
|
212 |
static NSString *CellIdentifier0 = @"Cell0";
|
|
213 |
static NSString *CellIdentifier1 = @"Cell1";
|
|
214 |
static NSString *CellIdentifier2 = @"Cell2";
|
|
215 |
|
|
216 |
UITableViewCell *cell = nil;
|
|
217 |
NSInteger row = [indexPath row];
|
|
218 |
|
|
219 |
switch ([indexPath section]) {
|
|
220 |
case 0:
|
3573
|
221 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
|
3547
|
222 |
if (cell == nil) {
|
|
223 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
|
|
224 |
reuseIdentifier:CellIdentifier0] autorelease];
|
|
225 |
// create a uitextfield for each row, expand it to take the maximum size
|
|
226 |
UITextField *aTextField = [[UITextField alloc]
|
|
227 |
initWithFrame:CGRectMake(5, 12, (cell.frame.size.width + cell.frame.size.width/3) - 42, 25)];
|
|
228 |
aTextField.clearsOnBeginEditing = NO;
|
|
229 |
aTextField.returnKeyType = UIReturnKeyDone;
|
|
230 |
aTextField.adjustsFontSizeToFitWidth = YES;
|
|
231 |
aTextField.delegate = self;
|
|
232 |
aTextField.tag = [indexPath row];
|
|
233 |
aTextField.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize] + 2];
|
|
234 |
aTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
|
235 |
[aTextField addTarget:self action:@selector(save:) forControlEvents:UIControlEventEditingDidEndOnExit];
|
|
236 |
[cell.contentView addSubview:aTextField];
|
|
237 |
[aTextField release];
|
|
238 |
}
|
|
239 |
|
|
240 |
for (UIView *oneView in cell.contentView.subviews) {
|
|
241 |
if ([oneView isMemberOfClass:[UITextField class]]) {
|
|
242 |
// we find the uitextfied and we'll use its tag to understand which one is being edited
|
|
243 |
UITextField *textFieldFound = (UITextField *)oneView;
|
|
244 |
textFieldFound.text = self.title;
|
|
245 |
}
|
|
246 |
}
|
|
247 |
cell.detailTextLabel.text = nil;
|
|
248 |
cell.imageView.image = nil;
|
3574
|
249 |
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
3547
|
250 |
break;
|
|
251 |
case 1:
|
3573
|
252 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1];
|
|
253 |
NSDictionary *detail = [self.basicSettingList objectAtIndex:row];
|
|
254 |
// need to offset this section (see format in CommodityFunctions.m and above)
|
|
255 |
NSInteger gmSize = [self.gameModifierArray count];
|
3547
|
256 |
if (cell == nil) {
|
3573
|
257 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
|
3547
|
258 |
reuseIdentifier:CellIdentifier1] autorelease];
|
3573
|
259 |
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(260, 12, 150, 23)];
|
|
260 |
slider.maximumValue = [[detail objectForKey:@"max"] floatValue];
|
|
261 |
slider.minimumValue = [[detail objectForKey:@"min"] floatValue];
|
|
262 |
slider.tag = row+gmSize;
|
|
263 |
[slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
|
|
264 |
[cell.contentView addSubview:slider];
|
|
265 |
[slider release];
|
|
266 |
|
|
267 |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 7, 200, 30)];
|
|
268 |
label.tag = LABEL_TAG;
|
|
269 |
label.backgroundColor = [UIColor clearColor];
|
|
270 |
label.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
|
|
271 |
[cell.contentView addSubview:label];
|
|
272 |
[label release];
|
3547
|
273 |
}
|
|
274 |
|
|
275 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/icon%@.png",BTN_DIRECTORY(),[[self.basicSettingList objectAtIndex:row] objectForKey:@"image"]]];
|
|
276 |
cell.imageView.image = [img scaleToSize:CGSizeMake(40, 40)];
|
|
277 |
[img release];
|
3573
|
278 |
|
|
279 |
UILabel *cellLabel = (UILabel *)[cell.contentView viewWithTag:LABEL_TAG];
|
|
280 |
cellLabel.text = [[self.basicSettingList objectAtIndex:row] objectForKey:@"title"];
|
|
281 |
|
|
282 |
UISlider *cellSlider = (UISlider *)[cell.contentView viewWithTag:row+gmSize];
|
|
283 |
cellSlider.value = [[self.schemeArray objectAtIndex:row+gmSize] floatValue];
|
|
284 |
|
|
285 |
// forced to use this weird format otherwise the label disappears when size of the text is bigger than the original
|
3574
|
286 |
NSString *prestring = [NSString stringWithFormat:@"%d",[[self.schemeArray objectAtIndex:row+gmSize] intValue]];
|
|
287 |
while ([prestring length] <= 4)
|
|
288 |
prestring = [NSString stringWithFormat:@" %@",prestring];
|
|
289 |
cell.detailTextLabel.text = prestring;
|
|
290 |
|
|
291 |
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
|
3547
|
292 |
break;
|
|
293 |
case 2:
|
3573
|
294 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier2];
|
3547
|
295 |
if (cell == nil) {
|
|
296 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
|
|
297 |
reuseIdentifier:CellIdentifier2] autorelease];
|
|
298 |
UISwitch *onOff = [[UISwitch alloc] init];
|
|
299 |
onOff.tag = row;
|
|
300 |
[onOff addTarget:self action:@selector(toggleSwitch:) forControlEvents:UIControlEventValueChanged];
|
|
301 |
cell.accessoryView = onOff;
|
|
302 |
[onOff release];
|
|
303 |
}
|
|
304 |
|
|
305 |
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/btn%@.png",BTN_DIRECTORY(),[[self.gameModifierArray objectAtIndex:row] objectForKey:@"image"]]];
|
|
306 |
cell.imageView.image = image;
|
|
307 |
[image release];
|
|
308 |
[cell.imageView.layer setCornerRadius:7.0f];
|
3573
|
309 |
[cell.imageView.layer setBorderWidth:1];
|
3547
|
310 |
[cell.imageView.layer setMasksToBounds:YES];
|
|
311 |
cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"];
|
|
312 |
cell.detailTextLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"description"];
|
|
313 |
[(UISwitch *)cell.accessoryView setOn:[[self.schemeArray objectAtIndex:row] boolValue] animated:NO];
|
3574
|
314 |
|
|
315 |
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
3547
|
316 |
}
|
|
317 |
|
|
318 |
return cell;
|
|
319 |
}
|
|
320 |
|
|
321 |
-(void) toggleSwitch:(id) sender {
|
|
322 |
UISwitch *theSwitch = (UISwitch *)sender;
|
|
323 |
[self.schemeArray replaceObjectAtIndex:theSwitch.tag withObject:[NSNumber numberWithBool:theSwitch.on]];
|
|
324 |
}
|
|
325 |
|
3573
|
326 |
-(void) sliderChanged:(id) sender {
|
|
327 |
// need to offset this section (see format in CommodityFunctions.m and above)
|
|
328 |
NSInteger gmSize = [self.gameModifierArray count];
|
|
329 |
// the slider that changed is sent as object
|
|
330 |
UISlider *theSlider = (UISlider *)sender;
|
|
331 |
// create the indexPath of the row of the slider
|
|
332 |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:theSlider.tag-gmSize inSection:1];
|
|
333 |
// get its cell
|
|
334 |
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
|
|
335 |
// grab the associated label
|
|
336 |
UILabel *label = (UILabel *)cell.detailTextLabel;
|
|
337 |
// modify it
|
3574
|
338 |
label.text = [NSString stringWithFormat:@"%d",(int)theSlider.value];
|
3573
|
339 |
// save changes in the main array (remember that you need to offset it)
|
|
340 |
[self.schemeArray replaceObjectAtIndex:theSlider.tag withObject:[NSNumber numberWithInt:(int)theSlider.value]];
|
|
341 |
}
|
3547
|
342 |
|
|
343 |
#pragma mark -
|
|
344 |
#pragma mark Table view delegate
|
|
345 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
3573
|
346 |
UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath];
|
|
347 |
UISwitch *sw = nil;
|
|
348 |
UISlider *cellSlider = nil;
|
3547
|
349 |
|
3573
|
350 |
switch ([indexPath section]) {
|
|
351 |
case 0:
|
|
352 |
for (UIView *oneView in cell.contentView.subviews) {
|
|
353 |
if ([oneView isMemberOfClass:[UITextField class]]) {
|
|
354 |
textFieldBeingEdited = (UITextField *)oneView;
|
|
355 |
[textFieldBeingEdited becomeFirstResponder];
|
|
356 |
}
|
3547
|
357 |
}
|
3573
|
358 |
break;
|
|
359 |
case 1:
|
|
360 |
cellSlider = (UISlider *)[cell.contentView viewWithTag:[indexPath row]+[self.gameModifierArray count]];
|
|
361 |
[cellSlider setValue:[[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] floatValue] animated:YES];
|
|
362 |
[self sliderChanged:cellSlider];
|
|
363 |
//cell.detailTextLabel.text = [[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] stringValue];
|
|
364 |
break;
|
|
365 |
case 2:
|
3574
|
366 |
/*sw = (UISwitch *)cell.accessoryView;
|
3573
|
367 |
[sw setOn:!sw.on animated:YES];
|
3574
|
368 |
[self toggleSwitch:sw];*/
|
3573
|
369 |
break;
|
|
370 |
default:
|
|
371 |
break;
|
3547
|
372 |
}
|
3573
|
373 |
|
3547
|
374 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
375 |
}
|
|
376 |
|
|
377 |
|
|
378 |
#pragma mark -
|
|
379 |
#pragma mark Memory management
|
|
380 |
-(void) didReceiveMemoryWarning {
|
|
381 |
[super didReceiveMemoryWarning];
|
|
382 |
}
|
|
383 |
|
|
384 |
-(void) viewDidUnload {
|
|
385 |
self.textFieldBeingEdited = nil;
|
|
386 |
self.schemeArray = nil;
|
|
387 |
self.basicSettingList = nil;
|
|
388 |
self.gameModifierArray = nil;
|
|
389 |
[super viewDidUnload];
|
|
390 |
MSG_DIDUNLOAD();
|
|
391 |
}
|
|
392 |
|
|
393 |
-(void) dealloc {
|
|
394 |
[textFieldBeingEdited release];
|
|
395 |
[schemeArray release];
|
|
396 |
[basicSettingList release];
|
|
397 |
[gameModifierArray release];
|
|
398 |
[super dealloc];
|
|
399 |
}
|
|
400 |
|
|
401 |
|
|
402 |
@end
|
|
403 |
|