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