author | koda |
Wed, 11 May 2011 01:26:38 +0200 | |
changeset 5206 | db775bddf771 |
parent 4976 | 088d40d8aba2 |
child 5207 | 4c9ae0f484da |
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 08/01/2010. |
|
19 |
*/ |
|
20 |
||
3547 | 21 |
|
22 |
#import "GeneralSettingsViewController.h" |
|
23 |
#import "CommodityFunctions.h" |
|
24 |
||
25 |
@implementation GeneralSettingsViewController |
|
5206 | 26 |
@synthesize settings; |
3547 | 27 |
|
28 |
||
29 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
30 |
return rotationManager(interfaceOrientation); |
|
31 |
} |
|
32 |
||
33 |
#pragma mark - |
|
34 |
#pragma mark View Lifecycle |
|
35 |
-(void) viewDidLoad { |
|
36 |
[super viewDidLoad]; |
|
37 |
} |
|
38 |
||
39 |
-(void) viewWillAppear:(BOOL)animated { |
|
40 |
[self.tableView setContentOffset:CGPointMake(0,0) animated:NO]; |
|
3697 | 41 |
|
5206 | 42 |
self.settings = [NSUserDefaults standardUserDefaults]; |
3663
8c28abf427f5
reduce the number of keywords used and switch to BMP format for screenshots
koda
parents:
3662
diff
changeset
|
43 |
|
3547 | 44 |
[super viewWillAppear:animated]; |
45 |
} |
|
46 |
||
47 |
-(void) viewWillDisappear:(BOOL)animated { |
|
3697 | 48 |
[super viewWillDisappear:animated]; |
5206 | 49 |
[self.settings synchronize]; |
3547 | 50 |
} |
51 |
||
52 |
#pragma mark - |
|
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
|
53 |
-(void) switchValueChanged:(id) sender { |
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
|
54 |
UISwitch *theSwitch = (UISwitch *)sender; |
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
|
55 |
UISwitch *theOtherSwitch = nil; |
3697 | 56 |
|
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
|
57 |
switch (theSwitch.tag) { |
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
|
58 |
case 10: //soundSwitch |
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
|
59 |
// this turn off also the switch below |
5206 | 60 |
[self.settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"sound"]; |
61 |
[self.settings setObject:[NSNumber numberWithBool:NO] forKey:@"music"]; |
|
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
|
62 |
theOtherSwitch = (UISwitch *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:1]].accessoryView; |
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
|
63 |
[theOtherSwitch setOn:NO animated:YES]; |
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
|
64 |
break; |
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
|
65 |
case 20: //musicSwitch |
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
|
66 |
// if switch above is off, never turn on |
5206 | 67 |
if (NO == [[self.settings objectForKey:@"sound"] boolValue]) { |
68 |
[self.settings setObject:[NSNumber numberWithBool:NO] forKey:@"music"]; |
|
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
|
69 |
theOtherSwitch = (UISwitch *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:1]].accessoryView; |
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
|
70 |
[theOtherSwitch setOn:NO animated:YES]; |
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
|
71 |
} else |
5206 | 72 |
[self.settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"music"]; |
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
|
73 |
break; |
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
|
74 |
case 30: //alternateSwitch |
5206 | 75 |
[self.settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"alternate"]; |
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
|
76 |
break; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
77 |
case 70: //enhanced graphics |
5206 | 78 |
[self.settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"enhanced"]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
79 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
80 |
case 80: //nomultitasking |
5206 | 81 |
[self.settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"multitasking"]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
82 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
83 |
case 60: //classic menu |
5206 | 84 |
[self.settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"classic_menu"]; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
85 |
break; |
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
|
86 |
default: |
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
|
87 |
DLog(@"Wrong tag"); |
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
|
88 |
break; |
3547 | 89 |
} |
90 |
} |
|
91 |
||
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
|
92 |
-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue { |
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
|
93 |
if (tagValue == 40) |
5206 | 94 |
[self.settings setObject:textString forKey:@"username"]; |
95 |
else |
|
96 |
[self.settings setObject:[textString MD5hash] forKey:@"password"]; |
|
3547 | 97 |
} |
98 |
||
99 |
#pragma mark - |
|
100 |
#pragma mark TableView Methods |
|
101 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
102 |
return 3; |
|
103 |
} |
|
104 |
||
4539 | 105 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger )section { |
3547 | 106 |
switch (section) { |
3660 | 107 |
case 0: // user and pass |
3783 | 108 |
return 1; // set 2 here for the password field |
3547 | 109 |
break; |
3660 | 110 |
case 1: // audio |
3547 | 111 |
return 2; |
112 |
break; |
|
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
113 |
case 2: // other stuff |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
114 |
if (IS_IPAD() == YES) |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
115 |
return 4; |
4244 | 116 |
else |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
117 |
return 3; |
3547 | 118 |
break; |
119 |
default: |
|
3935 | 120 |
DLog(@"Nope"); |
3547 | 121 |
break; |
122 |
} |
|
123 |
return 0; |
|
124 |
} |
|
125 |
||
126 |
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { |
|
127 |
NSString *sectionTitle = nil; |
|
128 |
switch (section) { |
|
3660 | 129 |
case 0: |
3803 | 130 |
sectionTitle = NSLocalizedString(@"Main Configuration", @""); |
3547 | 131 |
break; |
3660 | 132 |
case 1: |
3547 | 133 |
sectionTitle = NSLocalizedString(@"Audio Preferences", @""); |
134 |
break; |
|
3660 | 135 |
case 2: |
3547 | 136 |
sectionTitle = NSLocalizedString(@"Other Settings", @""); |
137 |
break; |
|
138 |
default: |
|
3660 | 139 |
DLog(@"Nope"); |
3547 | 140 |
break; |
141 |
} |
|
142 |
return sectionTitle; |
|
143 |
} |
|
144 |
||
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
|
145 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
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
|
146 |
static NSString *cellIdentifier0 = @"Cell0"; |
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
|
147 |
static NSString *cellIdentifier1 = @"Cell1"; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
148 |
static NSString *cellIdentifier2 = @"Cell2"; |
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
|
149 |
NSInteger row = [indexPath row]; |
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
|
150 |
NSInteger section = [indexPath section]; |
3697 | 151 |
|
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
|
152 |
UITableViewCell *cell = nil; |
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
|
153 |
EditableCellView *editableCell = nil; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
154 |
UISwitch *switchContent = nil; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
155 |
switch(section) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
156 |
case 0: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
157 |
editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:cellIdentifier0]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
158 |
if (nil == editableCell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
159 |
editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier0] autorelease]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
160 |
editableCell.minimumCharacters = 0; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
161 |
editableCell.delegate = self; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
162 |
editableCell.textField.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; |
4341 | 163 |
editableCell.textField.textColor = [UIColor blackColor]; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
164 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
165 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
166 |
if (row == 0) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
167 |
editableCell.titleLabel.text = NSLocalizedString(@"Nickname","from the settings table"); |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
168 |
editableCell.textField.placeholder = NSLocalizedString(@"Insert your username (if you have one)",@""); |
5206 | 169 |
editableCell.textField.text = [self.settings objectForKey:@"username"]; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
170 |
editableCell.textField.secureTextEntry = NO; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
171 |
editableCell.tag = 40; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
172 |
} else { |
5206 | 173 |
NSString *pwd = [self.settings objectForKey:@"password"]; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
174 |
editableCell.titleLabel.text = NSLocalizedString(@"Password","from the settings table"); |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
175 |
editableCell.textField.placeholder = NSLocalizedString(@"Insert your password",@""); |
5206 | 176 |
editableCell.textField.text = ([pwd length] == 0) ? @"0123456789" : pwd; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
177 |
editableCell.textField.secureTextEntry = YES; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
178 |
editableCell.tag = 50; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
179 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
180 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
181 |
editableCell.accessoryView = nil; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
182 |
cell = editableCell; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
183 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
184 |
case 1: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
185 |
cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier1]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
186 |
if (nil == cell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
187 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier1] autorelease]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
188 |
UISwitch *theSwitch = [[UISwitch alloc] init]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
189 |
[theSwitch addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
190 |
cell.accessoryView = theSwitch; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
191 |
[theSwitch release]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
192 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
193 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
194 |
switchContent = (UISwitch *)cell.accessoryView; |
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
|
195 |
if (row == 0) { |
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
|
196 |
cell.textLabel.text = NSLocalizedString(@"Sound", @""); |
5206 | 197 |
switchContent.on = [[self.settings objectForKey:@"sound"] boolValue]; |
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
|
198 |
switchContent.tag = 10; |
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
|
199 |
} else { |
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
|
200 |
cell.textLabel.text = NSLocalizedString(@"Music", @""); |
5206 | 201 |
switchContent.on = [[self.settings objectForKey:@"music"] boolValue]; |
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
|
202 |
switchContent.tag = 20; |
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
|
203 |
} |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
204 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
205 |
case 2: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
206 |
cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier2]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
207 |
if (nil == cell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
208 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier2] autorelease]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
209 |
UISwitch *theSwitch = [[UISwitch alloc] init]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
210 |
[theSwitch addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
211 |
cell.accessoryView = theSwitch; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
212 |
[theSwitch release]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
213 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
214 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
215 |
switchContent = (UISwitch *)cell.accessoryView; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
216 |
switch (row) { |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
217 |
case 0: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
218 |
cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
219 |
cell.detailTextLabel.text = NSLocalizedString(@"Damage popups will notify you on every single hit", @""); |
5206 | 220 |
switchContent.on = [[self.settings objectForKey:@"alternate"] boolValue]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
221 |
switchContent.tag = 30; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
222 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
223 |
case 1: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
224 |
cell.textLabel.text = NSLocalizedString(@"Enanched Graphics Mode", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
225 |
cell.detailTextLabel.text = NSLocalizedString(@"The game will use more memory so it could crash!", @""); |
5206 | 226 |
switchContent.on = [[self.settings objectForKey:@"enhanced"] boolValue]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
227 |
switchContent.tag = 70; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
228 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
229 |
case 2: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
230 |
cell.textLabel.text = NSLocalizedString(@"Multitasking Enabled", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
231 |
cell.detailTextLabel.text = NSLocalizedString(@"Disable it in case of issues when returing in game", @""); |
5206 | 232 |
switchContent.on = [[self.settings objectForKey:@"multitasking"] boolValue]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
233 |
switchContent.tag = 80; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
234 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
235 |
case 3: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
236 |
cell.textLabel.text = NSLocalizedString(@"Classic Ammo Menu", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
237 |
cell.detailTextLabel.text = NSLocalizedString(@"Select which style of ammo menu you prefer",@""); |
5206 | 238 |
switchContent.on = [[self.settings objectForKey:@"classic_menu"] boolValue]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
239 |
switchContent.tag = 60; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
240 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
241 |
default: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
242 |
DLog(@"Nope"); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
243 |
break; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
244 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
245 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
246 |
default: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
247 |
break; |
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
|
248 |
} |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
249 |
|
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
|
250 |
cell.accessoryType = UITableViewCellAccessoryNone; |
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
|
251 |
cell.selectionStyle = UITableViewCellSelectionStyleNone; |
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
|
252 |
cell.imageView.image = nil; |
3697 | 253 |
|
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
|
254 |
return cell; |
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
|
255 |
} |
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
|
256 |
|
3547 | 257 |
#pragma mark - |
258 |
#pragma mark Table view delegate |
|
259 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
3660 | 260 |
if (0 == [indexPath section]) { |
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
|
261 |
EditableCellView *cell = (EditableCellView *)[aTableView cellForRowAtIndexPath:indexPath]; |
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
|
262 |
[cell replyKeyboard]; |
3547 | 263 |
} |
264 |
} |
|
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
|
265 |
|
3547 | 266 |
|
267 |
#pragma mark - |
|
268 |
#pragma mark Memory management |
|
269 |
-(void) didReceiveMemoryWarning { |
|
270 |
[super didReceiveMemoryWarning]; |
|
271 |
} |
|
272 |
||
273 |
-(void) viewDidUnload { |
|
5206 | 274 |
self.settings = 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
|
275 |
MSG_DIDUNLOAD(); |
3547 | 276 |
[super viewDidUnload]; |
277 |
} |
|
278 |
||
279 |
-(void) dealloc { |
|
5206 | 280 |
[settings release]; |
3547 | 281 |
[super dealloc]; |
282 |
} |
|
283 |
||
284 |
@end |