author | ninnnu |
Fri, 29 Oct 2010 09:49:29 -0400 | |
changeset 4011 | 99ef85c40294 |
parent 4003 | ca0600ab38bf |
child 4113 | edb30dabf71a |
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]; |
|
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
42 |
NSString *path = nil; |
3547 | 43 |
|
3753 | 44 |
// title, description, image name (+btn) |
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
45 |
path = [NSString stringWithFormat:@"%@/gameFlags_en.plist",IFRONTEND_DIRECTORY()]; |
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
46 |
NSArray *mods = [[NSArray alloc] initWithContentsOfFile:path]; |
3547 | 47 |
self.gameModifierArray = mods; |
48 |
[mods release]; |
|
3697 | 49 |
|
3753 | 50 |
// title, image name (+icon), default value, max value, min value |
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
51 |
path = [NSString stringWithFormat:@"%@/basicFlags_en.plist",IFRONTEND_DIRECTORY()]; |
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
52 |
NSArray *basicSettings = [[NSArray alloc] initWithContentsOfFile:path]; |
3547 | 53 |
self.basicSettingList = basicSettings; |
54 |
[basicSettings release]; |
|
3697 | 55 |
|
3659 | 56 |
self.title = NSLocalizedString(@"Edit scheme preferences",@""); |
3547 | 57 |
} |
58 |
||
59 |
// load from file |
|
60 |
-(void) viewWillAppear:(BOOL) animated { |
|
61 |
[super viewWillAppear:animated]; |
|
3697 | 62 |
|
3659 | 63 |
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
|
64 |
NSMutableDictionary *scheme = [[NSMutableDictionary alloc] initWithContentsOfFile:schemeFile]; |
3621 | 65 |
[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
|
66 |
self.schemeDictionary = scheme; |
3547 | 67 |
[scheme release]; |
3697 | 68 |
|
3547 | 69 |
[self.tableView reloadData]; |
70 |
} |
|
71 |
||
72 |
// save to file |
|
73 |
-(void) viewWillDisappear:(BOOL) animated { |
|
74 |
[super viewWillDisappear:animated]; |
|
3697 | 75 |
|
3659 | 76 |
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
|
77 |
[self.schemeDictionary writeToFile:schemeFile atomically:YES]; |
3547 | 78 |
[schemeFile release]; |
79 |
} |
|
80 |
||
81 |
#pragma mark - |
|
3659 | 82 |
#pragma mark editableCellView delegate |
3547 | 83 |
// set the new value |
3697 | 84 |
-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue { |
3782 | 85 |
if (tagValue == 0) { |
86 |
// delete old file |
|
87 |
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName] error:NULL]; |
|
88 |
// update filename |
|
89 |
self.schemeName = textString; |
|
90 |
// save new file |
|
91 |
[self.schemeDictionary writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName] atomically:YES]; |
|
92 |
} else { |
|
93 |
[self.schemeDictionary setObject:textString forKey:@"description"]; |
|
94 |
} |
|
3547 | 95 |
} |
96 |
||
97 |
#pragma mark - |
|
98 |
#pragma mark Table view data source |
|
99 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
100 |
return 3; |
|
101 |
} |
|
102 |
||
103 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
104 |
switch (section) { |
|
105 |
case 0: |
|
3782 | 106 |
return 2; |
3547 | 107 |
break; |
108 |
case 1: |
|
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
109 |
return [[self.schemeDictionary objectForKey:@"basic"] count]; |
3547 | 110 |
break; |
111 |
case 2: |
|
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
112 |
return [[self.schemeDictionary objectForKey:@"gamemod"] count]; |
3547 | 113 |
default: |
114 |
break; |
|
115 |
} |
|
116 |
return 0; |
|
117 |
} |
|
118 |
||
3573 | 119 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
3547 | 120 |
static NSString *CellIdentifier0 = @"Cell0"; |
121 |
static NSString *CellIdentifier1 = @"Cell1"; |
|
122 |
static NSString *CellIdentifier2 = @"Cell2"; |
|
3697 | 123 |
|
3547 | 124 |
UITableViewCell *cell = nil; |
3659 | 125 |
EditableCellView *editableCell = nil; |
3547 | 126 |
NSInteger row = [indexPath row]; |
3697 | 127 |
|
3547 | 128 |
switch ([indexPath section]) { |
129 |
case 0: |
|
3659 | 130 |
editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
131 |
if (editableCell == nil) { |
|
3697 | 132 |
editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault |
3547 | 133 |
reuseIdentifier:CellIdentifier0] autorelease]; |
3659 | 134 |
editableCell.delegate = self; |
3547 | 135 |
} |
3782 | 136 |
editableCell.tag = row; |
137 |
editableCell.selectionStyle = UITableViewCellSelectionStyleNone; |
|
138 |
editableCell.imageView.image = nil; |
|
3659 | 139 |
editableCell.detailTextLabel.text = nil; |
3782 | 140 |
|
141 |
if (row == 0) { |
|
142 |
editableCell.textField.text = self.schemeName; |
|
143 |
} else { |
|
3825 | 144 |
editableCell.minimumCharacters = 0; |
3782 | 145 |
editableCell.textField.font = [UIFont systemFontOfSize:[UIFont labelFontSize]]; |
146 |
editableCell.textField.text = [self.schemeDictionary objectForKey:@"description"]; |
|
147 |
editableCell.textField.placeholder = NSLocalizedString(@"You can add a description if you wish",@""); |
|
148 |
} |
|
3659 | 149 |
cell = editableCell; |
3547 | 150 |
break; |
151 |
case 1: |
|
3573 | 152 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
153 |
NSDictionary *detail = [self.basicSettingList objectAtIndex:row]; |
|
154 |
// need to offset this section (see format in CommodityFunctions.m and above) |
|
3547 | 155 |
if (cell == nil) { |
3697 | 156 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 |
3547 | 157 |
reuseIdentifier:CellIdentifier1] autorelease]; |
3697 | 158 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3623
diff
changeset
|
159 |
int offset = 0; |
3996 | 160 |
if (IS_IPAD()) |
3659 | 161 |
offset = 50; |
3697 | 162 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3623
diff
changeset
|
163 |
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(offset+260, 12, offset+150, 23)]; |
3573 | 164 |
slider.maximumValue = [[detail objectForKey:@"max"] floatValue]; |
165 |
slider.minimumValue = [[detail objectForKey:@"min"] floatValue]; |
|
166 |
[slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged]; |
|
167 |
[cell.contentView addSubview:slider]; |
|
168 |
[slider release]; |
|
3697 | 169 |
|
3573 | 170 |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 7, 200, 30)]; |
171 |
label.tag = LABEL_TAG; |
|
172 |
label.backgroundColor = [UIColor clearColor]; |
|
173 |
label.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; |
|
174 |
[cell.contentView addSubview:label]; |
|
175 |
[label release]; |
|
3547 | 176 |
} |
3697 | 177 |
|
3547 | 178 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/icon%@.png",BTN_DIRECTORY(),[[self.basicSettingList objectAtIndex:row] objectForKey:@"image"]]]; |
3623 | 179 |
cell.imageView.image = img; |
3547 | 180 |
[img release]; |
3697 | 181 |
|
3573 | 182 |
UILabel *cellLabel = (UILabel *)[cell.contentView viewWithTag:LABEL_TAG]; |
183 |
cellLabel.text = [[self.basicSettingList objectAtIndex:row] objectForKey:@"title"]; |
|
3697 | 184 |
|
3916
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
185 |
// can't use the viewWithTag method because row is dynamic |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
186 |
UISlider *cellSlider = nil; |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
187 |
for (UIView *oneView in cell.contentView.subviews) { |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
188 |
if ([oneView isMemberOfClass:[UISlider class]]) { |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
189 |
cellSlider = (UISlider *)oneView; |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
190 |
break; |
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
191 |
} |
3916
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
192 |
} |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
193 |
cellSlider.tag = SLIDER_TAG + row; |
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
|
194 |
cellSlider.value = [[[self.schemeDictionary objectForKey:@"basic"] objectAtIndex:row] floatValue]; |
3697 | 195 |
|
3573 | 196 |
// 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
|
197 |
NSString *prestring = [NSString stringWithFormat:@"%d",(NSInteger) cellSlider.value]; |
4003
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
4000
diff
changeset
|
198 |
|
3916
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
199 |
// turntime 100 means unlimited time turns (set in GameSetup) |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
200 |
if (row == 1 && (NSInteger) cellSlider.value == 100) |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
201 |
prestring = @"∞"; |
4003
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
4000
diff
changeset
|
202 |
else |
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
4000
diff
changeset
|
203 |
// mines less than 0 means random |
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
4000
diff
changeset
|
204 |
if (row == 5 && (NSInteger) cellSlider.value == -1) |
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
4000
diff
changeset
|
205 |
prestring = NSLocalizedString(@"Rnd",@"Short for 'Random'"); |
3916
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
206 |
|
3574 | 207 |
while ([prestring length] <= 4) |
208 |
prestring = [NSString stringWithFormat:@" %@",prestring]; |
|
209 |
cell.detailTextLabel.text = prestring; |
|
3697 | 210 |
|
3574 | 211 |
cell.selectionStyle = UITableViewCellSelectionStyleBlue; |
3547 | 212 |
break; |
213 |
case 2: |
|
3573 | 214 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier2]; |
3547 | 215 |
if (cell == nil) { |
216 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle |
|
217 |
reuseIdentifier:CellIdentifier2] autorelease]; |
|
218 |
UISwitch *onOff = [[UISwitch alloc] init]; |
|
219 |
[onOff addTarget:self action:@selector(toggleSwitch:) forControlEvents:UIControlEventValueChanged]; |
|
220 |
cell.accessoryView = onOff; |
|
221 |
[onOff release]; |
|
222 |
} |
|
3697 | 223 |
|
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
224 |
UISwitch *switcher = (UISwitch *)cell.accessoryView; |
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
225 |
switcher.tag = SWITCH_TAG + row; |
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
226 |
[switcher setOn:[[[self.schemeDictionary objectForKey:@"gamemod"] objectAtIndex:row] boolValue] animated:NO]; |
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
227 |
|
3547 | 228 |
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/btn%@.png",BTN_DIRECTORY(),[[self.gameModifierArray objectAtIndex:row] objectForKey:@"image"]]]; |
229 |
cell.imageView.image = image; |
|
230 |
[image release]; |
|
231 |
[cell.imageView.layer setCornerRadius:7.0f]; |
|
232 |
[cell.imageView.layer setMasksToBounds:YES]; |
|
233 |
cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"]; |
|
234 |
cell.detailTextLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"description"]; |
|
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
235 |
cell.detailTextLabel.adjustsFontSizeToFitWidth = YES; |
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
236 |
cell.detailTextLabel.minimumFontSize = 6; |
3697 | 237 |
|
3574 | 238 |
cell.selectionStyle = UITableViewCellSelectionStyleNone; |
3547 | 239 |
} |
3697 | 240 |
|
3547 | 241 |
return cell; |
242 |
} |
|
243 |
||
244 |
-(void) toggleSwitch:(id) sender { |
|
245 |
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
|
246 |
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
|
247 |
[array replaceObjectAtIndex:theSwitch.tag-SWITCH_TAG withObject:[NSNumber numberWithBool:theSwitch.on]]; |
3547 | 248 |
} |
249 |
||
3573 | 250 |
-(void) sliderChanged:(id) sender { |
251 |
// the slider that changed is sent as object |
|
252 |
UISlider *theSlider = (UISlider *)sender; |
|
253 |
// 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
|
254 |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:theSlider.tag-SLIDER_TAG inSection:1]; |
3573 | 255 |
// get its cell |
256 |
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; |
|
257 |
// grab the associated label |
|
258 |
UILabel *label = (UILabel *)cell.detailTextLabel; |
|
259 |
// modify it |
|
3916
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
260 |
if ([indexPath row] == 1 && [indexPath section] == 1 && (NSInteger) theSlider.value == 100) |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
261 |
label.text = @"∞"; |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
262 |
else |
4003
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
4000
diff
changeset
|
263 |
if ([indexPath row] == 5 && [indexPath section] == 1 && (NSInteger) theSlider.value == -1) |
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
4000
diff
changeset
|
264 |
label.text = NSLocalizedString(@"Rnd",@"Short for 'Random'"); |
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
4000
diff
changeset
|
265 |
else |
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
4000
diff
changeset
|
266 |
label.text = [NSString stringWithFormat:@"%d",(NSInteger) theSlider.value]; |
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
|
267 |
// 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
|
268 |
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
|
269 |
[array replaceObjectAtIndex:theSlider.tag-SLIDER_TAG withObject:[NSNumber numberWithInt:(NSInteger) theSlider.value]]; |
3573 | 270 |
} |
3547 | 271 |
|
272 |
#pragma mark - |
|
273 |
#pragma mark Table view delegate |
|
274 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
3573 | 275 |
UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath]; |
3659 | 276 |
EditableCellView *editableCell = nil; |
3573 | 277 |
UISlider *cellSlider = nil; |
3697 | 278 |
|
3573 | 279 |
switch ([indexPath section]) { |
280 |
case 0: |
|
3659 | 281 |
editableCell = (EditableCellView *)cell; |
282 |
[editableCell replyKeyboard]; |
|
3573 | 283 |
break; |
284 |
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
|
285 |
cellSlider = (UISlider *)[cell.contentView viewWithTag:[indexPath row]+SLIDER_TAG]; |
3573 | 286 |
[cellSlider setValue:[[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] floatValue] animated:YES]; |
287 |
[self sliderChanged:cellSlider]; |
|
288 |
//cell.detailTextLabel.text = [[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] stringValue]; |
|
289 |
break; |
|
290 |
case 2: |
|
3574 | 291 |
/*sw = (UISwitch *)cell.accessoryView; |
3573 | 292 |
[sw setOn:!sw.on animated:YES]; |
3574 | 293 |
[self toggleSwitch:sw];*/ |
3573 | 294 |
break; |
295 |
default: |
|
296 |
break; |
|
3547 | 297 |
} |
3697 | 298 |
|
3547 | 299 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES]; |
300 |
} |
|
301 |
||
3659 | 302 |
-(NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section { |
303 |
NSString *sectionTitle = nil; |
|
304 |
switch (section) { |
|
305 |
case 0: |
|
306 |
sectionTitle = NSLocalizedString(@"Scheme Name", @""); |
|
307 |
break; |
|
308 |
case 1: |
|
309 |
sectionTitle = NSLocalizedString(@"Game Settings", @""); |
|
310 |
break; |
|
311 |
case 2: |
|
312 |
sectionTitle = NSLocalizedString(@"Game Modifiers", @""); |
|
313 |
break; |
|
314 |
default: |
|
315 |
DLog(@"nope"); |
|
316 |
break; |
|
317 |
} |
|
318 |
return sectionTitle; |
|
319 |
} |
|
3547 | 320 |
|
321 |
#pragma mark - |
|
322 |
#pragma mark Memory management |
|
323 |
-(void) didReceiveMemoryWarning { |
|
324 |
[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
|
325 |
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
|
326 |
self.gameModifierArray = nil; |
3547 | 327 |
} |
328 |
||
329 |
-(void) viewDidUnload { |
|
3659 | 330 |
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
|
331 |
self.schemeDictionary = nil; |
3547 | 332 |
self.basicSettingList = nil; |
333 |
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
|
334 |
MSG_DIDUNLOAD(); |
3547 | 335 |
[super viewDidUnload]; |
336 |
} |
|
337 |
||
338 |
-(void) dealloc { |
|
3659 | 339 |
[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
|
340 |
[schemeDictionary release]; |
3547 | 341 |
[basicSettingList release]; |
342 |
[gameModifierArray release]; |
|
343 |
[super dealloc]; |
|
344 |
} |
|
345 |
||
346 |
@end |