author | koda |
Mon, 30 Aug 2010 06:33:56 +0200 | |
changeset 3792 | dd9345e74b66 |
parent 3782 | dc3531e49e4c |
child 3825 | fd6c20cd90e3 |
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 { |
|
202 |
editableCell.textField.font = [UIFont systemFontOfSize:[UIFont labelFontSize]]; |
|
203 |
editableCell.textField.text = [self.schemeDictionary objectForKey:@"description"]; |
|
204 |
editableCell.textField.placeholder = NSLocalizedString(@"You can add a description if you wish",@""); |
|
205 |
} |
|
3659 | 206 |
cell = editableCell; |
3547 | 207 |
break; |
208 |
case 1: |
|
3573 | 209 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
210 |
NSDictionary *detail = [self.basicSettingList objectAtIndex:row]; |
|
211 |
// need to offset this section (see format in CommodityFunctions.m and above) |
|
3547 | 212 |
if (cell == nil) { |
3697 | 213 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 |
3547 | 214 |
reuseIdentifier:CellIdentifier1] autorelease]; |
3697 | 215 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3623
diff
changeset
|
216 |
int offset = 0; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3623
diff
changeset
|
217 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
3659 | 218 |
offset = 50; |
3697 | 219 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3623
diff
changeset
|
220 |
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(offset+260, 12, offset+150, 23)]; |
3573 | 221 |
slider.maximumValue = [[detail objectForKey:@"max"] floatValue]; |
222 |
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
|
223 |
slider.tag = SLIDER_TAG+row; |
3573 | 224 |
[slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged]; |
225 |
[cell.contentView addSubview:slider]; |
|
226 |
[slider release]; |
|
3697 | 227 |
|
3573 | 228 |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 7, 200, 30)]; |
229 |
label.tag = LABEL_TAG; |
|
230 |
label.backgroundColor = [UIColor clearColor]; |
|
231 |
label.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; |
|
232 |
[cell.contentView addSubview:label]; |
|
233 |
[label release]; |
|
3547 | 234 |
} |
3697 | 235 |
|
3547 | 236 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/icon%@.png",BTN_DIRECTORY(),[[self.basicSettingList objectAtIndex:row] objectForKey:@"image"]]]; |
3623 | 237 |
cell.imageView.image = img; |
3547 | 238 |
[img release]; |
3697 | 239 |
|
3573 | 240 |
UILabel *cellLabel = (UILabel *)[cell.contentView viewWithTag:LABEL_TAG]; |
241 |
cellLabel.text = [[self.basicSettingList objectAtIndex:row] objectForKey:@"title"]; |
|
3697 | 242 |
|
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
|
243 |
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
|
244 |
cellSlider.value = [[[self.schemeDictionary objectForKey:@"basic"] objectAtIndex:row] floatValue]; |
3697 | 245 |
|
3573 | 246 |
// 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
|
247 |
NSString *prestring = [NSString stringWithFormat:@"%d",(NSInteger) cellSlider.value]; |
3574 | 248 |
while ([prestring length] <= 4) |
249 |
prestring = [NSString stringWithFormat:@" %@",prestring]; |
|
250 |
cell.detailTextLabel.text = prestring; |
|
3697 | 251 |
|
3574 | 252 |
cell.selectionStyle = UITableViewCellSelectionStyleBlue; |
3547 | 253 |
break; |
254 |
case 2: |
|
3573 | 255 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier2]; |
3547 | 256 |
if (cell == nil) { |
257 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle |
|
258 |
reuseIdentifier:CellIdentifier2] autorelease]; |
|
259 |
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
|
260 |
onOff.tag = SWITCH_TAG+row; |
3547 | 261 |
[onOff addTarget:self action:@selector(toggleSwitch:) forControlEvents:UIControlEventValueChanged]; |
262 |
cell.accessoryView = onOff; |
|
263 |
[onOff release]; |
|
264 |
} |
|
3697 | 265 |
|
3547 | 266 |
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/btn%@.png",BTN_DIRECTORY(),[[self.gameModifierArray objectAtIndex:row] objectForKey:@"image"]]]; |
267 |
cell.imageView.image = image; |
|
268 |
[image release]; |
|
269 |
[cell.imageView.layer setCornerRadius:7.0f]; |
|
3573 | 270 |
[cell.imageView.layer setBorderWidth:1]; |
3547 | 271 |
[cell.imageView.layer setMasksToBounds:YES]; |
272 |
cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"]; |
|
273 |
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
|
274 |
[(UISwitch *)cell.accessoryView setOn:[[[self.schemeDictionary objectForKey:@"gamemod"] objectAtIndex:row] boolValue] animated:NO]; |
3697 | 275 |
|
3574 | 276 |
cell.selectionStyle = UITableViewCellSelectionStyleNone; |
3547 | 277 |
} |
3697 | 278 |
|
3547 | 279 |
return cell; |
280 |
} |
|
281 |
||
282 |
-(void) toggleSwitch:(id) sender { |
|
283 |
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
|
284 |
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
|
285 |
[array replaceObjectAtIndex:theSwitch.tag-SWITCH_TAG withObject:[NSNumber numberWithBool:theSwitch.on]]; |
3547 | 286 |
} |
287 |
||
3573 | 288 |
-(void) sliderChanged:(id) sender { |
289 |
// the slider that changed is sent as object |
|
290 |
UISlider *theSlider = (UISlider *)sender; |
|
291 |
// 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
|
292 |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:theSlider.tag-SLIDER_TAG inSection:1]; |
3573 | 293 |
// get its cell |
294 |
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; |
|
295 |
// grab the associated label |
|
296 |
UILabel *label = (UILabel *)cell.detailTextLabel; |
|
297 |
// 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
|
298 |
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
|
299 |
// 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
|
300 |
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
|
301 |
[array replaceObjectAtIndex:theSlider.tag-SLIDER_TAG withObject:[NSNumber numberWithInt:(NSInteger) theSlider.value]]; |
3573 | 302 |
} |
3547 | 303 |
|
304 |
#pragma mark - |
|
305 |
#pragma mark Table view delegate |
|
306 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
3573 | 307 |
UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath]; |
3659 | 308 |
EditableCellView *editableCell = nil; |
3573 | 309 |
UISlider *cellSlider = nil; |
3697 | 310 |
|
3573 | 311 |
switch ([indexPath section]) { |
312 |
case 0: |
|
3659 | 313 |
editableCell = (EditableCellView *)cell; |
314 |
[editableCell replyKeyboard]; |
|
3573 | 315 |
break; |
316 |
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
|
317 |
cellSlider = (UISlider *)[cell.contentView viewWithTag:[indexPath row]+SLIDER_TAG]; |
3573 | 318 |
[cellSlider setValue:[[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] floatValue] animated:YES]; |
319 |
[self sliderChanged:cellSlider]; |
|
320 |
//cell.detailTextLabel.text = [[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] stringValue]; |
|
321 |
break; |
|
322 |
case 2: |
|
3574 | 323 |
/*sw = (UISwitch *)cell.accessoryView; |
3573 | 324 |
[sw setOn:!sw.on animated:YES]; |
3574 | 325 |
[self toggleSwitch:sw];*/ |
3573 | 326 |
break; |
327 |
default: |
|
328 |
break; |
|
3547 | 329 |
} |
3697 | 330 |
|
3547 | 331 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES]; |
332 |
} |
|
333 |
||
3659 | 334 |
-(NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section { |
335 |
NSString *sectionTitle = nil; |
|
336 |
switch (section) { |
|
337 |
case 0: |
|
338 |
sectionTitle = NSLocalizedString(@"Scheme Name", @""); |
|
339 |
break; |
|
340 |
case 1: |
|
341 |
sectionTitle = NSLocalizedString(@"Game Settings", @""); |
|
342 |
break; |
|
343 |
case 2: |
|
344 |
sectionTitle = NSLocalizedString(@"Game Modifiers", @""); |
|
345 |
break; |
|
346 |
default: |
|
347 |
DLog(@"nope"); |
|
348 |
break; |
|
349 |
} |
|
350 |
return sectionTitle; |
|
351 |
} |
|
3547 | 352 |
|
353 |
#pragma mark - |
|
354 |
#pragma mark Memory management |
|
355 |
-(void) didReceiveMemoryWarning { |
|
356 |
[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
|
357 |
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
|
358 |
self.gameModifierArray = nil; |
3547 | 359 |
} |
360 |
||
361 |
-(void) viewDidUnload { |
|
3659 | 362 |
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
|
363 |
self.schemeDictionary = nil; |
3547 | 364 |
self.basicSettingList = nil; |
365 |
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
|
366 |
MSG_DIDUNLOAD(); |
3547 | 367 |
[super viewDidUnload]; |
368 |
} |
|
369 |
||
370 |
-(void) dealloc { |
|
3659 | 371 |
[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
|
372 |
[schemeDictionary release]; |
3547 | 373 |
[basicSettingList release]; |
374 |
[gameModifierArray release]; |
|
375 |
[super dealloc]; |
|
376 |
} |
|
377 |
||
378 |
@end |