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