author | koda |
Sat, 04 Sep 2010 02:09:24 +0200 | |
changeset 3825 | fd6c20cd90e3 |
parent 3782 | dc3531e49e4c |
child 3829 | 81db3c85784b |
permissions | -rw-r--r-- |
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 |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
16 |
#define SWITCH_TAG 67890 |
3573 | 17 |
|
3547 | 18 |
@implementation SingleSchemeViewController |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
19 |
@synthesize schemeName, schemeDictionary, basicSettingList, gameModifierArray; |
3547 | 20 |
|
21 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
22 |
return rotationManager(interfaceOrientation); |
|
23 |
} |
|
24 |
||
25 |
#pragma mark - |
|
26 |
#pragma mark View lifecycle |
|
27 |
-(void) viewDidLoad { |
|
28 |
[super viewDidLoad]; |
|
29 |
||
3753 | 30 |
// title, description, image name (+btn) |
3547 | 31 |
NSArray *mods = [[NSArray alloc] initWithObjects: |
32 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Fort Mode",@""),@"title", |
|
33 |
NSLocalizedString(@"Defend your fort and destroy the opponents (two team colours max)",@""),@"description", |
|
34 |
@"Forts",@"image",nil], |
|
35 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Divide Team",@""),@"title", |
|
36 |
NSLocalizedString(@"Teams will start on opposite sides of the terrain (two team colours max)",@""),@"description", |
|
37 |
@"TeamsDivide",@"image",nil], |
|
38 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Solid Land",@""),@"title", |
|
39 |
NSLocalizedString(@"Land can not be destroyed",@""),@"description", |
|
40 |
@"Solid",@"image",nil], |
|
41 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Add Border",@""),@"title", |
|
42 |
NSLocalizedString(@"Add an indestructable border around the terrain",@""),@"description", |
|
43 |
@"Border",@"image",nil], |
|
44 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Low Gravity",@""),@"title", |
|
45 |
NSLocalizedString(@"Lower gravity",@""),@"description", |
|
46 |
@"LowGravity",@"image",nil], |
|
47 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Laser Sight",@""),@"title", |
|
48 |
NSLocalizedString(@"Assisted aiming with laser sight",@""),@"description", |
|
49 |
@"LaserSight",@"image",nil], |
|
50 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Invulnerable",@""),@"title", |
|
51 |
NSLocalizedString(@"All hogs have a personal forcefield",@""),@"description", |
|
52 |
@"Invulnerable",@"image",nil], |
|
53 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Add Mines",@""),@"title", |
|
54 |
NSLocalizedString(@"Enable random mines",@""),@"description", |
|
55 |
@"Mines",@"image",nil], |
|
56 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Vampirism Mode",@""),@"title", |
|
57 |
NSLocalizedString(@"Gain 80% of the damage you do back in health",@""),@"description", |
|
58 |
@"Vampiric",@"image",nil], |
|
59 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Karma Mode",@""),@"title", |
|
60 |
NSLocalizedString(@"Share your opponents pain, share their damage",@""),@"description", |
|
61 |
@"Karma",@"image",nil], |
|
62 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Artillery Mode",@""),@"title", |
|
63 |
NSLocalizedString(@"Your hogs are unable to move, test your aim",@""),@"description", |
|
64 |
@"Artillery",@"image",nil], |
|
65 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Random Order",@""),@"title", |
|
66 |
NSLocalizedString(@"Order of play is random instead of in room order",@""),@"description", |
|
67 |
@"RandomOrder",@"image",nil], |
|
68 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"King Mode",@""),@"title", |
|
69 |
NSLocalizedString(@"Play with a King. If he dies, your side loses",@""),@"description", |
|
70 |
@"King",@"image",nil], |
|
71 |
[NSDictionary dictionaryWithObjectsAndKeys: NSLocalizedString(@"Place Hedgehogs",@""),@"title", |
|
72 |
NSLocalizedString(@"Take turns placing your hedgehogs pre-game",@""),@"description", |
|
73 |
@"PlaceHog",@"image",nil], |
|
74 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Clan Shares Ammo",@""),@"title", |
|
75 |
NSLocalizedString(@"Ammo is shared between all clan teams",@""),@"description", |
|
76 |
@"SharedAmmo",@"image",nil], |
|
77 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Disable Girders",@""),@"title", |
|
78 |
NSLocalizedString(@"Disable girders when generating random maps",@""),@"description", |
|
79 |
@"DisableGirders",@"image",nil], |
|
80 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Disable Land Objects",@""),@"title", |
|
81 |
NSLocalizedString(@"Disable land objects when generating maps",@""),@"description", |
|
82 |
@"DisableLandObjects",@"image",nil], |
|
3752
73c2d7d5643b
add the new flag, fix a couple of hicups in creating config files, swap animation between settings and lobby
koda
parents:
3697
diff
changeset
|
83 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"AI Survival Mode",@""),@"title", |
73c2d7d5643b
add the new flag, fix a couple of hicups in creating config files, swap animation between settings and lobby
koda
parents:
3697
diff
changeset
|
84 |
NSLocalizedString(@"AI-controlled hogs respawn on death",@""),@"description", |
73c2d7d5643b
add the new flag, fix a couple of hicups in creating config files, swap animation between settings and lobby
koda
parents:
3697
diff
changeset
|
85 |
@"AISurvival",@"image",nil], |
3547 | 86 |
nil]; |
87 |
self.gameModifierArray = mods; |
|
88 |
[mods release]; |
|
3697 | 89 |
|
3753 | 90 |
// title, image name (+icon), default value, max value, min value |
3547 | 91 |
NSArray *basicSettings = [[NSArray alloc] initWithObjects: |
3573 | 92 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Damage Modifier",@""),@"title",@"Damage",@"image", |
93 |
[NSNumber numberWithInt:100],@"default",[NSNumber numberWithInt:10],@"min",[NSNumber numberWithInt:300],@"max",nil], |
|
94 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Turn Time",@""),@"title",@"Time",@"image", |
|
95 |
[NSNumber numberWithInt:45],@"default",[NSNumber numberWithInt:1],@"min",[NSNumber numberWithInt:99],@"max",nil], |
|
96 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Initial Health",@""),@"title",@"Health",@"image", |
|
97 |
[NSNumber numberWithInt:100],@"default",[NSNumber numberWithInt:50],@"min",[NSNumber numberWithInt:200],@"max",nil], |
|
98 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Sudden Death Timeout",@""),@"title",@"SuddenDeath",@"image", |
|
99 |
[NSNumber numberWithInt:15],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:50],@"max",nil], |
|
100 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Crate Drops",@""),@"title",@"Box",@"image", |
|
101 |
[NSNumber numberWithInt:5],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:9],@"max",nil], |
|
102 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Mines Time",@""),@"title",@"Time",@"image", |
|
103 |
[NSNumber numberWithInt:3],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:3],@"max",nil], |
|
104 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Mines Number",@""),@"title",@"Mine",@"image", |
|
105 |
[NSNumber numberWithInt:4],@"default",[NSNumber numberWithInt:1],@"min",[NSNumber numberWithInt:80],@"max",nil], |
|
106 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Dud Mines Probability",@""),@"title",@"Dud",@"image", |
|
107 |
[NSNumber numberWithInt:0],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:100],@"max",nil], |
|
108 |
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Explosives",@""),@"title",@"Damage",@"image", |
|
109 |
[NSNumber numberWithInt:2],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:40],@"max",nil], |
|
3547 | 110 |
nil]; |
111 |
self.basicSettingList = basicSettings; |
|
112 |
[basicSettings release]; |
|
3697 | 113 |
|
3659 | 114 |
self.title = NSLocalizedString(@"Edit scheme preferences",@""); |
3547 | 115 |
} |
116 |
||
117 |
// load from file |
|
118 |
-(void) viewWillAppear:(BOOL) animated { |
|
119 |
[super viewWillAppear:animated]; |
|
3697 | 120 |
|
3659 | 121 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName]; |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
122 |
NSMutableDictionary *scheme = [[NSMutableDictionary alloc] initWithContentsOfFile:schemeFile]; |
3621 | 123 |
[schemeFile release]; |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
124 |
self.schemeDictionary = scheme; |
3547 | 125 |
[scheme release]; |
3697 | 126 |
|
3547 | 127 |
[self.tableView reloadData]; |
128 |
} |
|
129 |
||
130 |
// save to file |
|
131 |
-(void) viewWillDisappear:(BOOL) animated { |
|
132 |
[super viewWillDisappear:animated]; |
|
3697 | 133 |
|
3659 | 134 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName]; |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
135 |
[self.schemeDictionary writeToFile:schemeFile atomically:YES]; |
3547 | 136 |
[schemeFile release]; |
137 |
} |
|
138 |
||
139 |
#pragma mark - |
|
3659 | 140 |
#pragma mark editableCellView delegate |
3547 | 141 |
// set the new value |
3697 | 142 |
-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue { |
3782 | 143 |
if (tagValue == 0) { |
144 |
// delete old file |
|
145 |
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName] error:NULL]; |
|
146 |
// update filename |
|
147 |
self.schemeName = textString; |
|
148 |
// save new file |
|
149 |
[self.schemeDictionary writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName] atomically:YES]; |
|
150 |
} else { |
|
151 |
[self.schemeDictionary setObject:textString forKey:@"description"]; |
|
152 |
} |
|
3547 | 153 |
} |
154 |
||
155 |
#pragma mark - |
|
156 |
#pragma mark Table view data source |
|
157 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
158 |
return 3; |
|
159 |
} |
|
160 |
||
161 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
162 |
switch (section) { |
|
163 |
case 0: |
|
3782 | 164 |
return 2; |
3547 | 165 |
break; |
166 |
case 1: |
|
167 |
return [self.basicSettingList count]; |
|
168 |
break; |
|
169 |
case 2: |
|
170 |
return [self.gameModifierArray count]; |
|
171 |
default: |
|
172 |
break; |
|
173 |
} |
|
174 |
return 0; |
|
175 |
} |
|
176 |
||
3573 | 177 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
3547 | 178 |
static NSString *CellIdentifier0 = @"Cell0"; |
179 |
static NSString *CellIdentifier1 = @"Cell1"; |
|
180 |
static NSString *CellIdentifier2 = @"Cell2"; |
|
3697 | 181 |
|
3547 | 182 |
UITableViewCell *cell = nil; |
3659 | 183 |
EditableCellView *editableCell = nil; |
3547 | 184 |
NSInteger row = [indexPath row]; |
3697 | 185 |
|
3547 | 186 |
switch ([indexPath section]) { |
187 |
case 0: |
|
3659 | 188 |
editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
189 |
if (editableCell == nil) { |
|
3697 | 190 |
editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault |
3547 | 191 |
reuseIdentifier:CellIdentifier0] autorelease]; |
3659 | 192 |
editableCell.delegate = self; |
3547 | 193 |
} |
3782 | 194 |
editableCell.tag = row; |
195 |
editableCell.selectionStyle = UITableViewCellSelectionStyleNone; |
|
196 |
editableCell.imageView.image = nil; |
|
3659 | 197 |
editableCell.detailTextLabel.text = nil; |
3782 | 198 |
|
199 |
if (row == 0) { |
|
200 |
editableCell.textField.text = self.schemeName; |
|
201 |
} else { |
|
3825 | 202 |
editableCell.minimumCharacters = 0; |
3782 | 203 |
editableCell.textField.font = [UIFont systemFontOfSize:[UIFont labelFontSize]]; |
204 |
editableCell.textField.text = [self.schemeDictionary objectForKey:@"description"]; |
|
205 |
editableCell.textField.placeholder = NSLocalizedString(@"You can add a description if you wish",@""); |
|
206 |
} |
|
3659 | 207 |
cell = editableCell; |
3547 | 208 |
break; |
209 |
case 1: |
|
3573 | 210 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
211 |
NSDictionary *detail = [self.basicSettingList objectAtIndex:row]; |
|
212 |
// need to offset this section (see format in CommodityFunctions.m and above) |
|
3547 | 213 |
if (cell == nil) { |
3697 | 214 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 |
3547 | 215 |
reuseIdentifier:CellIdentifier1] autorelease]; |
3697 | 216 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3623
diff
changeset
|
217 |
int offset = 0; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3623
diff
changeset
|
218 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
3659 | 219 |
offset = 50; |
3697 | 220 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3623
diff
changeset
|
221 |
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(offset+260, 12, offset+150, 23)]; |
3573 | 222 |
slider.maximumValue = [[detail objectForKey:@"max"] floatValue]; |
223 |
slider.minimumValue = [[detail objectForKey:@"min"] floatValue]; |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
224 |
slider.tag = SLIDER_TAG+row; |
3573 | 225 |
[slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged]; |
226 |
[cell.contentView addSubview:slider]; |
|
227 |
[slider release]; |
|
3697 | 228 |
|
3573 | 229 |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 7, 200, 30)]; |
230 |
label.tag = LABEL_TAG; |
|
231 |
label.backgroundColor = [UIColor clearColor]; |
|
232 |
label.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; |
|
233 |
[cell.contentView addSubview:label]; |
|
234 |
[label release]; |
|
3547 | 235 |
} |
3697 | 236 |
|
3547 | 237 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/icon%@.png",BTN_DIRECTORY(),[[self.basicSettingList objectAtIndex:row] objectForKey:@"image"]]]; |
3623 | 238 |
cell.imageView.image = img; |
3547 | 239 |
[img release]; |
3697 | 240 |
|
3573 | 241 |
UILabel *cellLabel = (UILabel *)[cell.contentView viewWithTag:LABEL_TAG]; |
242 |
cellLabel.text = [[self.basicSettingList objectAtIndex:row] objectForKey:@"title"]; |
|
3697 | 243 |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
244 |
UISlider *cellSlider = (UISlider *)[cell.contentView viewWithTag:SLIDER_TAG+row]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
245 |
cellSlider.value = [[[self.schemeDictionary objectForKey:@"basic"] objectAtIndex:row] floatValue]; |
3697 | 246 |
|
3573 | 247 |
// forced to use this weird format otherwise the label disappears when size of the text is bigger than the original |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
248 |
NSString *prestring = [NSString stringWithFormat:@"%d",(NSInteger) cellSlider.value]; |
3574 | 249 |
while ([prestring length] <= 4) |
250 |
prestring = [NSString stringWithFormat:@" %@",prestring]; |
|
251 |
cell.detailTextLabel.text = prestring; |
|
3697 | 252 |
|
3574 | 253 |
cell.selectionStyle = UITableViewCellSelectionStyleBlue; |
3547 | 254 |
break; |
255 |
case 2: |
|
3573 | 256 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier2]; |
3547 | 257 |
if (cell == nil) { |
258 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle |
|
259 |
reuseIdentifier:CellIdentifier2] autorelease]; |
|
260 |
UISwitch *onOff = [[UISwitch alloc] init]; |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
261 |
onOff.tag = SWITCH_TAG+row; |
3547 | 262 |
[onOff addTarget:self action:@selector(toggleSwitch:) forControlEvents:UIControlEventValueChanged]; |
263 |
cell.accessoryView = onOff; |
|
264 |
[onOff release]; |
|
265 |
} |
|
3697 | 266 |
|
3547 | 267 |
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/btn%@.png",BTN_DIRECTORY(),[[self.gameModifierArray objectAtIndex:row] objectForKey:@"image"]]]; |
268 |
cell.imageView.image = image; |
|
269 |
[image release]; |
|
270 |
[cell.imageView.layer setCornerRadius:7.0f]; |
|
3573 | 271 |
[cell.imageView.layer setBorderWidth:1]; |
3547 | 272 |
[cell.imageView.layer setMasksToBounds:YES]; |
273 |
cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"]; |
|
274 |
cell.detailTextLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"description"]; |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
275 |
[(UISwitch *)cell.accessoryView setOn:[[[self.schemeDictionary objectForKey:@"gamemod"] objectAtIndex:row] boolValue] animated:NO]; |
3697 | 276 |
|
3574 | 277 |
cell.selectionStyle = UITableViewCellSelectionStyleNone; |
3547 | 278 |
} |
3697 | 279 |
|
3547 | 280 |
return cell; |
281 |
} |
|
282 |
||
283 |
-(void) toggleSwitch:(id) sender { |
|
284 |
UISwitch *theSwitch = (UISwitch *)sender; |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
285 |
NSMutableArray *array = [self.schemeDictionary objectForKey:@"gamemod"]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
286 |
[array replaceObjectAtIndex:theSwitch.tag-SWITCH_TAG withObject:[NSNumber numberWithBool:theSwitch.on]]; |
3547 | 287 |
} |
288 |
||
3573 | 289 |
-(void) sliderChanged:(id) sender { |
290 |
// the slider that changed is sent as object |
|
291 |
UISlider *theSlider = (UISlider *)sender; |
|
292 |
// create the indexPath of the row of the slider |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
293 |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:theSlider.tag-SLIDER_TAG inSection:1]; |
3573 | 294 |
// get its cell |
295 |
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; |
|
296 |
// grab the associated label |
|
297 |
UILabel *label = (UILabel *)cell.detailTextLabel; |
|
298 |
// modify it |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
299 |
label.text = [NSString stringWithFormat:@"%d",(NSInteger) theSlider.value]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
300 |
// save changes in the main array |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
301 |
NSMutableArray *array = [self.schemeDictionary objectForKey:@"basic"]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
302 |
[array replaceObjectAtIndex:theSlider.tag-SLIDER_TAG withObject:[NSNumber numberWithInt:(NSInteger) theSlider.value]]; |
3573 | 303 |
} |
3547 | 304 |
|
305 |
#pragma mark - |
|
306 |
#pragma mark Table view delegate |
|
307 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
3573 | 308 |
UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath]; |
3659 | 309 |
EditableCellView *editableCell = nil; |
3573 | 310 |
UISlider *cellSlider = nil; |
3697 | 311 |
|
3573 | 312 |
switch ([indexPath section]) { |
313 |
case 0: |
|
3659 | 314 |
editableCell = (EditableCellView *)cell; |
315 |
[editableCell replyKeyboard]; |
|
3573 | 316 |
break; |
317 |
case 1: |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
318 |
cellSlider = (UISlider *)[cell.contentView viewWithTag:[indexPath row]+SLIDER_TAG]; |
3573 | 319 |
[cellSlider setValue:[[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] floatValue] animated:YES]; |
320 |
[self sliderChanged:cellSlider]; |
|
321 |
//cell.detailTextLabel.text = [[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] stringValue]; |
|
322 |
break; |
|
323 |
case 2: |
|
3574 | 324 |
/*sw = (UISwitch *)cell.accessoryView; |
3573 | 325 |
[sw setOn:!sw.on animated:YES]; |
3574 | 326 |
[self toggleSwitch:sw];*/ |
3573 | 327 |
break; |
328 |
default: |
|
329 |
break; |
|
3547 | 330 |
} |
3697 | 331 |
|
3547 | 332 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES]; |
333 |
} |
|
334 |
||
3659 | 335 |
-(NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section { |
336 |
NSString *sectionTitle = nil; |
|
337 |
switch (section) { |
|
338 |
case 0: |
|
339 |
sectionTitle = NSLocalizedString(@"Scheme Name", @""); |
|
340 |
break; |
|
341 |
case 1: |
|
342 |
sectionTitle = NSLocalizedString(@"Game Settings", @""); |
|
343 |
break; |
|
344 |
case 2: |
|
345 |
sectionTitle = NSLocalizedString(@"Game Modifiers", @""); |
|
346 |
break; |
|
347 |
default: |
|
348 |
DLog(@"nope"); |
|
349 |
break; |
|
350 |
} |
|
351 |
return sectionTitle; |
|
352 |
} |
|
3547 | 353 |
|
354 |
#pragma mark - |
|
355 |
#pragma mark Memory management |
|
356 |
-(void) didReceiveMemoryWarning { |
|
357 |
[super didReceiveMemoryWarning]; |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
358 |
self.basicSettingList = nil; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
359 |
self.gameModifierArray = nil; |
3547 | 360 |
} |
361 |
||
362 |
-(void) viewDidUnload { |
|
3659 | 363 |
self.schemeName = nil; |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
364 |
self.schemeDictionary = nil; |
3547 | 365 |
self.basicSettingList = nil; |
366 |
self.gameModifierArray = 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
|
367 |
MSG_DIDUNLOAD(); |
3547 | 368 |
[super viewDidUnload]; |
369 |
} |
|
370 |
||
371 |
-(void) dealloc { |
|
3659 | 372 |
[schemeName release]; |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3753
diff
changeset
|
373 |
[schemeDictionary release]; |
3547 | 374 |
[basicSettingList release]; |
375 |
[gameModifierArray release]; |
|
376 |
[super dealloc]; |
|
377 |
} |
|
378 |
||
379 |
@end |