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