author | koda |
Thu, 12 May 2011 23:00:26 +0200 | |
changeset 5207 | 4c9ae0f484da |
parent 5206 | db775bddf771 |
child 5224 | 6e8fbbfb0de5 |
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 |
|
26 |
||
27 |
||
28 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
29 |
return rotationManager(interfaceOrientation); |
|
30 |
} |
|
31 |
||
32 |
#pragma mark - |
|
33 |
#pragma mark View Lifecycle |
|
34 |
-(void) viewDidLoad { |
|
35 |
[super viewDidLoad]; |
|
36 |
} |
|
37 |
||
38 |
-(void) viewWillAppear:(BOOL)animated { |
|
39 |
[self.tableView setContentOffset:CGPointMake(0,0) animated:NO]; |
|
40 |
[super viewWillAppear:animated]; |
|
41 |
} |
|
42 |
||
43 |
-(void) viewWillDisappear:(BOOL)animated { |
|
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
44 |
[[NSUserDefaults standardUserDefaults] synchronize]; |
3697 | 45 |
[super viewWillDisappear:animated]; |
3547 | 46 |
} |
47 |
||
48 |
#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
|
49 |
-(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
|
50 |
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
|
51 |
UISwitch *theOtherSwitch = nil; |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
52 |
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
3697 | 53 |
|
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
|
54 |
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
|
55 |
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
|
56 |
// this turn off also the switch below |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
57 |
[settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"sound"]; |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
58 |
[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
|
59 |
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
|
60 |
[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
|
61 |
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
|
62 |
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
|
63 |
// if switch above is off, never turn on |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
64 |
if (NO == [[settings objectForKey:@"sound"] boolValue]) { |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
65 |
[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
|
66 |
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
|
67 |
[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
|
68 |
} else |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
69 |
[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
|
70 |
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
|
71 |
case 30: //alternateSwitch |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
72 |
[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
|
73 |
break; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
74 |
case 70: //enhanced graphics |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
75 |
[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
|
76 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
77 |
case 80: //nomultitasking |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
78 |
[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
|
79 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
80 |
case 60: //classic menu |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
81 |
[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
|
82 |
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
|
83 |
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
|
84 |
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
|
85 |
break; |
3547 | 86 |
} |
87 |
} |
|
88 |
||
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
|
89 |
-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue { |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
90 |
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
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 |
if (tagValue == 40) |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
93 |
[settings setObject:textString forKey:@"username"]; |
5206 | 94 |
else |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
95 |
[settings setObject:[textString MD5hash] forKey:@"password"]; |
3547 | 96 |
} |
97 |
||
98 |
#pragma mark - |
|
99 |
#pragma mark TableView Methods |
|
100 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
101 |
return 3; |
|
102 |
} |
|
103 |
||
4539 | 104 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger )section { |
3547 | 105 |
switch (section) { |
3660 | 106 |
case 0: // user and pass |
3783 | 107 |
return 1; // set 2 here for the password field |
3547 | 108 |
break; |
3660 | 109 |
case 1: // audio |
3547 | 110 |
return 2; |
111 |
break; |
|
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
112 |
case 2: // other stuff |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
113 |
if (IS_IPAD() == YES) |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
114 |
return 4; |
4244 | 115 |
else |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
116 |
return 3; |
3547 | 117 |
break; |
118 |
default: |
|
3935 | 119 |
DLog(@"Nope"); |
3547 | 120 |
break; |
121 |
} |
|
122 |
return 0; |
|
123 |
} |
|
124 |
||
125 |
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { |
|
126 |
NSString *sectionTitle = nil; |
|
127 |
switch (section) { |
|
3660 | 128 |
case 0: |
3803 | 129 |
sectionTitle = NSLocalizedString(@"Main Configuration", @""); |
3547 | 130 |
break; |
3660 | 131 |
case 1: |
3547 | 132 |
sectionTitle = NSLocalizedString(@"Audio Preferences", @""); |
133 |
break; |
|
3660 | 134 |
case 2: |
3547 | 135 |
sectionTitle = NSLocalizedString(@"Other Settings", @""); |
136 |
break; |
|
137 |
default: |
|
3660 | 138 |
DLog(@"Nope"); |
3547 | 139 |
break; |
140 |
} |
|
141 |
return sectionTitle; |
|
142 |
} |
|
143 |
||
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
|
144 |
-(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
|
145 |
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
|
146 |
static NSString *cellIdentifier1 = @"Cell1"; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
147 |
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
|
148 |
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
|
149 |
NSInteger section = [indexPath section]; |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
150 |
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
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)",@""); |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
169 |
editableCell.textField.text = [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 { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
173 |
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
|
174 |
editableCell.textField.placeholder = NSLocalizedString(@"Insert your password",@""); |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
175 |
editableCell.textField.text = [settings objectForKey:@"password"]; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
176 |
editableCell.textField.secureTextEntry = YES; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
177 |
editableCell.tag = 50; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
178 |
} |
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 |
editableCell.accessoryView = nil; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
181 |
cell = editableCell; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
182 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
183 |
case 1: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
184 |
cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier1]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
185 |
if (nil == cell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
186 |
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
|
187 |
UISwitch *theSwitch = [[UISwitch alloc] init]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
188 |
[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
|
189 |
cell.accessoryView = theSwitch; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
190 |
[theSwitch release]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
191 |
} |
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 |
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
|
194 |
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
|
195 |
cell.textLabel.text = NSLocalizedString(@"Sound", @""); |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
196 |
switchContent.on = [[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
|
197 |
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
|
198 |
} 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
|
199 |
cell.textLabel.text = NSLocalizedString(@"Music", @""); |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
200 |
switchContent.on = [[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
|
201 |
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
|
202 |
} |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
203 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
204 |
case 2: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
205 |
cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier2]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
206 |
if (nil == cell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
207 |
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
|
208 |
UISwitch *theSwitch = [[UISwitch alloc] init]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
209 |
[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
|
210 |
cell.accessoryView = theSwitch; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
211 |
[theSwitch release]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
212 |
} |
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 |
switchContent = (UISwitch *)cell.accessoryView; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
215 |
switch (row) { |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
216 |
case 0: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
217 |
cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
218 |
cell.detailTextLabel.text = NSLocalizedString(@"Damage popups will notify you on every single hit", @""); |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
219 |
switchContent.on = [[settings objectForKey:@"alternate"] boolValue]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
220 |
switchContent.tag = 30; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
221 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
222 |
case 1: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
223 |
cell.textLabel.text = NSLocalizedString(@"Enanched Graphics Mode", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
224 |
cell.detailTextLabel.text = NSLocalizedString(@"The game will use more memory so it could crash!", @""); |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
225 |
switchContent.on = [[settings objectForKey:@"enhanced"] boolValue]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
226 |
switchContent.tag = 70; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
227 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
228 |
case 2: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
229 |
cell.textLabel.text = NSLocalizedString(@"Multitasking Enabled", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
230 |
cell.detailTextLabel.text = NSLocalizedString(@"Disable it in case of issues when returing in game", @""); |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
231 |
switchContent.on = [[settings objectForKey:@"multitasking"] boolValue]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
232 |
switchContent.tag = 80; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
233 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
234 |
case 3: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
235 |
cell.textLabel.text = NSLocalizedString(@"Classic Ammo Menu", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
236 |
cell.detailTextLabel.text = NSLocalizedString(@"Select which style of ammo menu you prefer",@""); |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
237 |
switchContent.on = [[settings objectForKey:@"classic_menu"] boolValue]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
238 |
switchContent.tag = 60; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
239 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
240 |
default: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
241 |
DLog(@"Nope"); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
242 |
break; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
243 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
244 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
245 |
default: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
246 |
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
|
247 |
} |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
248 |
|
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
|
249 |
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
|
250 |
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
|
251 |
cell.imageView.image = nil; |
3697 | 252 |
|
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
|
253 |
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
|
254 |
} |
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 |
|
3547 | 256 |
#pragma mark - |
257 |
#pragma mark Table view delegate |
|
258 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
3660 | 259 |
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
|
260 |
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
|
261 |
[cell replyKeyboard]; |
3547 | 262 |
} |
263 |
} |
|
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
|
264 |
|
3547 | 265 |
|
266 |
#pragma mark - |
|
267 |
#pragma mark Memory management |
|
268 |
-(void) didReceiveMemoryWarning { |
|
269 |
[super didReceiveMemoryWarning]; |
|
270 |
} |
|
271 |
||
272 |
-(void) viewDidUnload { |
|
273 |
[super viewDidUnload]; |
|
274 |
} |
|
275 |
||
276 |
-(void) dealloc { |
|
277 |
[super dealloc]; |
|
278 |
} |
|
279 |
||
280 |
@end |