author | koda |
Sat, 24 Sep 2011 02:23:15 +0200 | |
changeset 6004 | b92a6626b0e5 |
parent 5982 | 283be2ca54a7 |
child 6078 | 8c0cc07731e5 |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
4976 | 3 |
* Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com> |
3829 | 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 |
|
4211
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
31 |
#define checkValueString(detailString,labelSting,sliderRef); \ |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
32 |
if ([labelSting isEqualToString:@"Turn Time"] && (NSInteger) sliderRef.value == 100) \ |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
33 |
detailString = @"∞"; \ |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
34 |
else if ([labelSting isEqualToString:@"Water Rise Amount"] && (NSInteger) sliderRef.value == 100) \ |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
35 |
detailString = NSLocalizedString(@"Nvr",@"Short for 'Never'"); \ |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
36 |
else if ([labelSting isEqualToString:@"Crate Drop Turns"] && (NSInteger) sliderRef.value == 0) \ |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
37 |
detailString = NSLocalizedString(@"Nvr",@"Short for 'Never'"); \ |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
38 |
else if ([labelSting isEqualToString:@"Mines Time"] && (NSInteger) sliderRef.value == -1) \ |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
39 |
detailString = NSLocalizedString(@"Rnd",@"Short for 'Random'"); \ |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
40 |
else \ |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
41 |
detailString = [NSString stringWithFormat:@"%d",(NSInteger) sliderRef.value]; |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
42 |
|
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
43 |
|
3547 | 44 |
@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
|
45 |
@synthesize schemeName, schemeDictionary, basicSettingList, gameModifierArray; |
3547 | 46 |
|
47 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
48 |
return rotationManager(interfaceOrientation); |
|
49 |
} |
|
50 |
||
51 |
#pragma mark - |
|
52 |
#pragma mark View lifecycle |
|
53 |
-(void) viewDidLoad { |
|
54 |
[super viewDidLoad]; |
|
55 |
||
3753 | 56 |
// title, description, image name (+btn) |
5185
7607a64e1853
remove the trailing _en from scheme data and use the macros available instead of creating a string every time
koda
parents:
5181
diff
changeset
|
57 |
NSArray *mods = [[NSArray alloc] initWithContentsOfFile:GAMEMODS_FILE()]; |
3547 | 58 |
self.gameModifierArray = mods; |
59 |
[mods release]; |
|
3697 | 60 |
|
3753 | 61 |
// title, image name (+icon), default value, max value, min value |
5185
7607a64e1853
remove the trailing _en from scheme data and use the macros available instead of creating a string every time
koda
parents:
5181
diff
changeset
|
62 |
NSArray *basicSettings = [[NSArray alloc] initWithContentsOfFile:BASICFLAGS_FILE()]; |
3547 | 63 |
self.basicSettingList = basicSettings; |
64 |
[basicSettings release]; |
|
3697 | 65 |
|
3659 | 66 |
self.title = NSLocalizedString(@"Edit scheme preferences",@""); |
3547 | 67 |
} |
68 |
||
69 |
// load from file |
|
70 |
-(void) viewWillAppear:(BOOL) animated { |
|
71 |
[super viewWillAppear:animated]; |
|
3697 | 72 |
|
3659 | 73 |
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
|
74 |
NSMutableDictionary *scheme = [[NSMutableDictionary alloc] initWithContentsOfFile:schemeFile]; |
3621 | 75 |
[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
|
76 |
self.schemeDictionary = scheme; |
3547 | 77 |
[scheme release]; |
3697 | 78 |
|
3547 | 79 |
[self.tableView reloadData]; |
80 |
} |
|
81 |
||
82 |
// save to file |
|
83 |
-(void) viewWillDisappear:(BOOL) animated { |
|
84 |
[super viewWillDisappear:animated]; |
|
3697 | 85 |
|
3659 | 86 |
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
|
87 |
[self.schemeDictionary writeToFile:schemeFile atomically:YES]; |
3547 | 88 |
[schemeFile release]; |
89 |
} |
|
90 |
||
91 |
#pragma mark - |
|
3659 | 92 |
#pragma mark editableCellView delegate |
3547 | 93 |
// set the new value |
3697 | 94 |
-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue { |
3782 | 95 |
if (tagValue == 0) { |
96 |
// delete old file |
|
97 |
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName] error:NULL]; |
|
98 |
// update filename |
|
99 |
self.schemeName = textString; |
|
100 |
// save new file |
|
101 |
[self.schemeDictionary writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName] atomically:YES]; |
|
102 |
} else { |
|
103 |
[self.schemeDictionary setObject:textString forKey:@"description"]; |
|
104 |
} |
|
3547 | 105 |
} |
106 |
||
107 |
#pragma mark - |
|
108 |
#pragma mark Table view data source |
|
109 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
110 |
return 3; |
|
111 |
} |
|
112 |
||
113 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
114 |
switch (section) { |
|
115 |
case 0: |
|
3782 | 116 |
return 2; |
3547 | 117 |
break; |
118 |
case 1: |
|
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
119 |
return [[self.schemeDictionary objectForKey:@"basic"] count]; |
3547 | 120 |
break; |
121 |
case 2: |
|
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
122 |
return [[self.schemeDictionary objectForKey:@"gamemod"] count]; |
3547 | 123 |
default: |
124 |
break; |
|
125 |
} |
|
126 |
return 0; |
|
127 |
} |
|
128 |
||
3573 | 129 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
3547 | 130 |
static NSString *CellIdentifier0 = @"Cell0"; |
131 |
static NSString *CellIdentifier1 = @"Cell1"; |
|
132 |
static NSString *CellIdentifier2 = @"Cell2"; |
|
3697 | 133 |
|
3547 | 134 |
UITableViewCell *cell = nil; |
3659 | 135 |
EditableCellView *editableCell = nil; |
3547 | 136 |
NSInteger row = [indexPath row]; |
3697 | 137 |
|
3547 | 138 |
switch ([indexPath section]) { |
139 |
case 0: |
|
3659 | 140 |
editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
141 |
if (editableCell == nil) { |
|
3697 | 142 |
editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault |
3547 | 143 |
reuseIdentifier:CellIdentifier0] autorelease]; |
3659 | 144 |
editableCell.delegate = self; |
3547 | 145 |
} |
3782 | 146 |
editableCell.tag = row; |
147 |
editableCell.selectionStyle = UITableViewCellSelectionStyleNone; |
|
148 |
editableCell.imageView.image = nil; |
|
3659 | 149 |
editableCell.detailTextLabel.text = nil; |
3782 | 150 |
|
151 |
if (row == 0) { |
|
152 |
editableCell.textField.text = self.schemeName; |
|
4284
57a501a69e5f
update iFrontend with new schemes and weaps, fix up smaller glitches
koda
parents:
4213
diff
changeset
|
153 |
editableCell.textField.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; |
3782 | 154 |
} else { |
3825 | 155 |
editableCell.minimumCharacters = 0; |
3782 | 156 |
editableCell.textField.font = [UIFont systemFontOfSize:[UIFont labelFontSize]]; |
157 |
editableCell.textField.text = [self.schemeDictionary objectForKey:@"description"]; |
|
158 |
editableCell.textField.placeholder = NSLocalizedString(@"You can add a description if you wish",@""); |
|
159 |
} |
|
3659 | 160 |
cell = editableCell; |
3547 | 161 |
break; |
162 |
case 1: |
|
3573 | 163 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
164 |
NSDictionary *detail = [self.basicSettingList objectAtIndex:row]; |
|
165 |
// need to offset this section (see format in CommodityFunctions.m and above) |
|
3547 | 166 |
if (cell == nil) { |
3697 | 167 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 |
3547 | 168 |
reuseIdentifier:CellIdentifier1] autorelease]; |
3697 | 169 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3623
diff
changeset
|
170 |
int offset = 0; |
3996 | 171 |
if (IS_IPAD()) |
3659 | 172 |
offset = 50; |
3697 | 173 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3623
diff
changeset
|
174 |
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(offset+260, 12, offset+150, 23)]; |
3573 | 175 |
[slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged]; |
176 |
[cell.contentView addSubview:slider]; |
|
177 |
[slider release]; |
|
3697 | 178 |
|
3573 | 179 |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 7, 200, 30)]; |
180 |
label.tag = LABEL_TAG; |
|
181 |
label.backgroundColor = [UIColor clearColor]; |
|
182 |
label.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; |
|
183 |
[cell.contentView addSubview:label]; |
|
184 |
[label release]; |
|
3547 | 185 |
} |
3697 | 186 |
|
5982
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
187 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/icon%@.png",ICONS_DIRECTORY(), |
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
188 |
[[self.basicSettingList objectAtIndex:row] objectForKey:@"image"]]]; |
3623 | 189 |
cell.imageView.image = img; |
3547 | 190 |
[img release]; |
3697 | 191 |
|
3573 | 192 |
UILabel *cellLabel = (UILabel *)[cell.contentView viewWithTag:LABEL_TAG]; |
193 |
cellLabel.text = [[self.basicSettingList objectAtIndex:row] objectForKey:@"title"]; |
|
5181 | 194 |
cellLabel.adjustsFontSizeToFitWidth = YES; |
3697 | 195 |
|
3916
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
196 |
// 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
|
197 |
UISlider *cellSlider = nil; |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
198 |
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
|
199 |
if ([oneView isMemberOfClass:[UISlider class]]) { |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
200 |
cellSlider = (UISlider *)oneView; |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
201 |
break; |
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
202 |
} |
3916
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
203 |
} |
e7d665a4ef42
implemented endless turns support and added Timeless scheme (also fixed a crasher)
koda
parents:
3829
diff
changeset
|
204 |
cellSlider.tag = SLIDER_TAG + row; |
4211
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
205 |
cellSlider.maximumValue = [[detail objectForKey:@"max"] floatValue]; |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
206 |
cellSlider.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
|
207 |
cellSlider.value = [[[self.schemeDictionary objectForKey:@"basic"] objectAtIndex:row] floatValue]; |
3697 | 208 |
|
4211
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
209 |
NSString *prestring = nil; |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
210 |
checkValueString(prestring,cellLabel.text,cellSlider); |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
211 |
|
4210
caa9b08990eb
revert 4200:dd54999c2822 - it was breaking schemes. koda. just leave this alone until next release
nemo
parents:
4208
diff
changeset
|
212 |
// forced to use this weird format otherwise the label disappears when size of the text is bigger than the original |
3574 | 213 |
while ([prestring length] <= 4) |
214 |
prestring = [NSString stringWithFormat:@" %@",prestring]; |
|
215 |
cell.detailTextLabel.text = prestring; |
|
3697 | 216 |
|
3574 | 217 |
cell.selectionStyle = UITableViewCellSelectionStyleBlue; |
3547 | 218 |
break; |
219 |
case 2: |
|
3573 | 220 |
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier2]; |
3547 | 221 |
if (cell == nil) { |
222 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle |
|
223 |
reuseIdentifier:CellIdentifier2] autorelease]; |
|
224 |
UISwitch *onOff = [[UISwitch alloc] init]; |
|
225 |
[onOff addTarget:self action:@selector(toggleSwitch:) forControlEvents:UIControlEventValueChanged]; |
|
226 |
cell.accessoryView = onOff; |
|
227 |
[onOff release]; |
|
228 |
} |
|
3697 | 229 |
|
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
230 |
UISwitch *switcher = (UISwitch *)cell.accessoryView; |
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
231 |
switcher.tag = SWITCH_TAG + row; |
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
232 |
[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
|
233 |
|
5982
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
234 |
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/btn%@.png",ICONS_DIRECTORY(), |
283be2ca54a7
mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents:
5208
diff
changeset
|
235 |
[[self.gameModifierArray objectAtIndex:row] objectForKey:@"image"]]]; |
3547 | 236 |
cell.imageView.image = image; |
237 |
[image release]; |
|
238 |
[cell.imageView.layer setCornerRadius:7.0f]; |
|
239 |
[cell.imageView.layer setMasksToBounds:YES]; |
|
240 |
cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"]; |
|
241 |
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
|
242 |
cell.detailTextLabel.adjustsFontSizeToFitWidth = YES; |
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3996
diff
changeset
|
243 |
cell.detailTextLabel.minimumFontSize = 6; |
3697 | 244 |
|
3574 | 245 |
cell.selectionStyle = UITableViewCellSelectionStyleNone; |
3547 | 246 |
} |
3697 | 247 |
|
3547 | 248 |
return cell; |
249 |
} |
|
250 |
||
251 |
-(void) toggleSwitch:(id) sender { |
|
252 |
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
|
253 |
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
|
254 |
[array replaceObjectAtIndex:theSwitch.tag-SWITCH_TAG withObject:[NSNumber numberWithBool:theSwitch.on]]; |
3547 | 255 |
} |
256 |
||
3573 | 257 |
-(void) sliderChanged:(id) sender { |
258 |
// the slider that changed is sent as object |
|
259 |
UISlider *theSlider = (UISlider *)sender; |
|
260 |
// 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
|
261 |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:theSlider.tag-SLIDER_TAG inSection:1]; |
3573 | 262 |
// get its cell |
263 |
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; |
|
4211
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
264 |
// grab the associated labels |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
265 |
UILabel *detailLabel = (UILabel *)cell.detailTextLabel; |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
266 |
UILabel *cellLabel = (UILabel *)[cell.contentView viewWithTag:LABEL_TAG]; |
3573 | 267 |
// modify it |
4211
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
268 |
|
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
269 |
checkValueString(detailLabel.text,cellLabel.text,theSlider); |
7dcbd236ca59
this time i got it right, i'm sure of it; TEST ANYWAYS
koda
parents:
4210
diff
changeset
|
270 |
|
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
|
271 |
// 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
|
272 |
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
|
273 |
[array replaceObjectAtIndex:theSlider.tag-SLIDER_TAG withObject:[NSNumber numberWithInt:(NSInteger) theSlider.value]]; |
3573 | 274 |
} |
3547 | 275 |
|
276 |
#pragma mark - |
|
277 |
#pragma mark Table view delegate |
|
278 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
3573 | 279 |
UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath]; |
3659 | 280 |
EditableCellView *editableCell = nil; |
3573 | 281 |
UISlider *cellSlider = nil; |
3697 | 282 |
|
3573 | 283 |
switch ([indexPath section]) { |
284 |
case 0: |
|
3659 | 285 |
editableCell = (EditableCellView *)cell; |
286 |
[editableCell replyKeyboard]; |
|
3573 | 287 |
break; |
288 |
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
|
289 |
cellSlider = (UISlider *)[cell.contentView viewWithTag:[indexPath row]+SLIDER_TAG]; |
3573 | 290 |
[cellSlider setValue:[[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] floatValue] animated:YES]; |
291 |
[self sliderChanged:cellSlider]; |
|
292 |
//cell.detailTextLabel.text = [[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] stringValue]; |
|
293 |
break; |
|
294 |
case 2: |
|
3574 | 295 |
/*sw = (UISwitch *)cell.accessoryView; |
3573 | 296 |
[sw setOn:!sw.on animated:YES]; |
3574 | 297 |
[self toggleSwitch:sw];*/ |
3573 | 298 |
break; |
299 |
default: |
|
300 |
break; |
|
3547 | 301 |
} |
3697 | 302 |
|
3547 | 303 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES]; |
304 |
} |
|
305 |
||
3659 | 306 |
-(NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section { |
307 |
NSString *sectionTitle = nil; |
|
308 |
switch (section) { |
|
309 |
case 0: |
|
310 |
sectionTitle = NSLocalizedString(@"Scheme Name", @""); |
|
311 |
break; |
|
312 |
case 1: |
|
313 |
sectionTitle = NSLocalizedString(@"Game Settings", @""); |
|
314 |
break; |
|
315 |
case 2: |
|
316 |
sectionTitle = NSLocalizedString(@"Game Modifiers", @""); |
|
317 |
break; |
|
318 |
default: |
|
319 |
DLog(@"nope"); |
|
320 |
break; |
|
321 |
} |
|
322 |
return sectionTitle; |
|
323 |
} |
|
3547 | 324 |
|
4113 | 325 |
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { |
326 |
if ([indexPath section] == 2) |
|
327 |
return 56; |
|
328 |
else |
|
329 |
return self.tableView.rowHeight; |
|
330 |
} |
|
331 |
||
3547 | 332 |
#pragma mark - |
333 |
#pragma mark Memory management |
|
334 |
-(void) didReceiveMemoryWarning { |
|
335 |
[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
|
336 |
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
|
337 |
self.gameModifierArray = nil; |
3547 | 338 |
} |
339 |
||
340 |
-(void) viewDidUnload { |
|
3659 | 341 |
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
|
342 |
self.schemeDictionary = nil; |
3547 | 343 |
self.basicSettingList = nil; |
344 |
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
|
345 |
MSG_DIDUNLOAD(); |
3547 | 346 |
[super viewDidUnload]; |
347 |
} |
|
348 |
||
349 |
-(void) dealloc { |
|
5208 | 350 |
releaseAndNil(schemeName); |
351 |
releaseAndNil(schemeDictionary); |
|
352 |
releaseAndNil(basicSettingList); |
|
353 |
releaseAndNil(gameModifierArray); |
|
3547 | 354 |
[super dealloc]; |
355 |
} |
|
356 |
||
357 |
@end |