author | unc0rr |
Sun, 17 Apr 2011 22:16:36 +0400 | |
branch | cursor_issues |
changeset 5149 | 9aa840fdf922 |
parent 4976 | 088d40d8aba2 |
child 5206 | db775bddf771 |
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 |
|
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
|
26 |
@synthesize settingsDictionary; |
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 |
|
3663
8c28abf427f5
reduce the number of keywords used and switch to BMP format for screenshots
koda
parents:
3662
diff
changeset
|
42 |
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()]; |
8c28abf427f5
reduce the number of keywords used and switch to BMP format for screenshots
koda
parents:
3662
diff
changeset
|
43 |
self.settingsDictionary = dictionary; |
8c28abf427f5
reduce the number of keywords used and switch to BMP format for screenshots
koda
parents:
3662
diff
changeset
|
44 |
[dictionary release]; |
8c28abf427f5
reduce the number of keywords used and switch to BMP format for screenshots
koda
parents:
3662
diff
changeset
|
45 |
|
3547 | 46 |
[super viewWillAppear:animated]; |
47 |
} |
|
48 |
||
49 |
-(void) viewWillDisappear:(BOOL)animated { |
|
3697 | 50 |
[super viewWillDisappear:animated]; |
3660 | 51 |
[self.settingsDictionary writeToFile:SETTINGS_FILE() atomically:YES]; |
4947 | 52 |
|
53 |
// we save the sound settings to respect that flag everywhere |
|
54 |
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; |
|
55 |
[prefs setObject:[NSNumber numberWithBool:[[self.settingsDictionary objectForKey:@"sound"] boolValue]] forKey:@"audio"]; |
|
56 |
[prefs synchronize]; |
|
3547 | 57 |
} |
58 |
||
59 |
#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
|
60 |
-(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
|
61 |
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
|
62 |
UISwitch *theOtherSwitch = nil; |
3697 | 63 |
|
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
|
64 |
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
|
65 |
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
|
66 |
// this turn off also the switch below |
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 |
[self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"sound"]; |
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 |
[self.settingsDictionary setObject:[NSNumber numberWithBool:NO] forKey:@"music"]; |
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 |
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
|
72 |
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
|
73 |
// if switch above is off, never turn on |
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 |
if (NO == [[self.settingsDictionary objectForKey:@"sound"] boolValue]) { |
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
|
75 |
[self.settingsDictionary setObject:[NSNumber numberWithBool:NO] forKey:@"music"]; |
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 |
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
|
77 |
[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
|
78 |
} 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
|
79 |
[self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"music"]; |
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
|
80 |
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
|
81 |
case 30: //alternateSwitch |
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
|
82 |
[self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"alternate"]; |
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 |
break; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
84 |
case 70: //enhanced graphics |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
85 |
[self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"enhanced"]; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
86 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
87 |
case 80: //nomultitasking |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
88 |
[self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"multitasking"]; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
89 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
90 |
case 60: //classic menu |
3935 | 91 |
[self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"menu"]; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
92 |
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
|
93 |
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
|
94 |
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
|
95 |
break; |
3547 | 96 |
} |
97 |
} |
|
98 |
||
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
|
99 |
-(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
|
100 |
if (tagValue == 40) |
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
|
101 |
[self.settingsDictionary setObject:textString forKey:@"username"]; |
4539 | 102 |
else { |
103 |
[self.settingsDictionary setObject:[NSNumber numberWithInt:[textString length]] forKey:@"password_length"]; |
|
104 |
[self.settingsDictionary setObject:[textString MD5hash] forKey:@"password"]; |
|
105 |
} |
|
3547 | 106 |
} |
107 |
||
108 |
#pragma mark - |
|
109 |
#pragma mark TableView Methods |
|
110 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
111 |
return 3; |
|
112 |
} |
|
113 |
||
4539 | 114 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger )section { |
3547 | 115 |
switch (section) { |
3660 | 116 |
case 0: // user and pass |
3783 | 117 |
return 1; // set 2 here for the password field |
3547 | 118 |
break; |
3660 | 119 |
case 1: // audio |
3547 | 120 |
return 2; |
121 |
break; |
|
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
122 |
case 2: // other stuff |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
123 |
if (IS_IPAD() == YES) |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
124 |
return 4; |
4244 | 125 |
else |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
126 |
return 3; |
3547 | 127 |
break; |
128 |
default: |
|
3935 | 129 |
DLog(@"Nope"); |
3547 | 130 |
break; |
131 |
} |
|
132 |
return 0; |
|
133 |
} |
|
134 |
||
135 |
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { |
|
136 |
NSString *sectionTitle = nil; |
|
137 |
switch (section) { |
|
3660 | 138 |
case 0: |
3803 | 139 |
sectionTitle = NSLocalizedString(@"Main Configuration", @""); |
3547 | 140 |
break; |
3660 | 141 |
case 1: |
3547 | 142 |
sectionTitle = NSLocalizedString(@"Audio Preferences", @""); |
143 |
break; |
|
3660 | 144 |
case 2: |
3547 | 145 |
sectionTitle = NSLocalizedString(@"Other Settings", @""); |
146 |
break; |
|
147 |
default: |
|
3660 | 148 |
DLog(@"Nope"); |
3547 | 149 |
break; |
150 |
} |
|
151 |
return sectionTitle; |
|
152 |
} |
|
153 |
||
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
|
154 |
-(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
|
155 |
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
|
156 |
static NSString *cellIdentifier1 = @"Cell1"; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
157 |
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
|
158 |
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
|
159 |
NSInteger section = [indexPath section]; |
3697 | 160 |
|
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
|
161 |
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
|
162 |
EditableCellView *editableCell = nil; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
163 |
UISwitch *switchContent = nil; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
164 |
switch(section) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
165 |
case 0: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
166 |
editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:cellIdentifier0]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
167 |
if (nil == editableCell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
168 |
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
|
169 |
editableCell.minimumCharacters = 0; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
170 |
editableCell.delegate = self; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
171 |
editableCell.textField.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; |
4341 | 172 |
editableCell.textField.textColor = [UIColor blackColor]; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
173 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
174 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
175 |
if (row == 0) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
176 |
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
|
177 |
editableCell.textField.placeholder = NSLocalizedString(@"Insert your username (if you have one)",@""); |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
178 |
editableCell.textField.text = [self.settingsDictionary objectForKey:@"username"]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
179 |
editableCell.textField.secureTextEntry = NO; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
180 |
editableCell.tag = 40; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
181 |
} else { |
4539 | 182 |
// create a dummy password for setting some visual content for the password |
183 |
int pwdLength = [[self.settingsDictionary objectForKey:@"password_length"] intValue]; |
|
184 |
char *dummyStr = (char *)malloc(sizeof(char)*pwdLength); |
|
185 |
for (int i = 0; i < pwdLength; i++) |
|
186 |
dummyStr[i] = i; |
|
187 |
NSString *dummy = [[NSString alloc] initWithBytes:dummyStr length:pwdLength encoding:NSASCIIStringEncoding]; |
|
188 |
free(dummyStr); |
|
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
189 |
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
|
190 |
editableCell.textField.placeholder = NSLocalizedString(@"Insert your password",@""); |
4539 | 191 |
editableCell.textField.text = dummy; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
192 |
editableCell.textField.secureTextEntry = YES; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
193 |
editableCell.tag = 50; |
4539 | 194 |
[dummy release]; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
195 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
196 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
197 |
editableCell.accessoryView = nil; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
198 |
cell = editableCell; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
199 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
200 |
case 1: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
201 |
cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier1]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
202 |
if (nil == cell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
203 |
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
|
204 |
UISwitch *theSwitch = [[UISwitch alloc] init]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
205 |
[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
|
206 |
cell.accessoryView = theSwitch; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
207 |
[theSwitch release]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
208 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
209 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
210 |
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
|
211 |
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
|
212 |
cell.textLabel.text = NSLocalizedString(@"Sound", @""); |
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
|
213 |
switchContent.on = [[self.settingsDictionary objectForKey:@"sound"] boolValue]; |
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
|
214 |
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
|
215 |
} 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
|
216 |
cell.textLabel.text = NSLocalizedString(@"Music", @""); |
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
|
217 |
switchContent.on = [[self.settingsDictionary objectForKey:@"music"] boolValue]; |
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
|
218 |
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
|
219 |
} |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
220 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
221 |
case 2: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
222 |
cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier2]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
223 |
if (nil == cell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
224 |
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
|
225 |
UISwitch *theSwitch = [[UISwitch alloc] init]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
226 |
[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
|
227 |
cell.accessoryView = theSwitch; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
228 |
[theSwitch release]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
229 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
230 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
231 |
switchContent = (UISwitch *)cell.accessoryView; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
232 |
switch (row) { |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
233 |
case 0: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
234 |
cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
235 |
cell.detailTextLabel.text = NSLocalizedString(@"Damage popups will notify you on every single hit", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
236 |
switchContent.on = [[self.settingsDictionary objectForKey:@"alternate"] boolValue]; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
237 |
switchContent.tag = 30; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
238 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
239 |
case 1: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
240 |
cell.textLabel.text = NSLocalizedString(@"Enanched Graphics Mode", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
241 |
cell.detailTextLabel.text = NSLocalizedString(@"The game will use more memory so it could crash!", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
242 |
switchContent.on = [[self.settingsDictionary objectForKey:@"enhanced"] boolValue]; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
243 |
switchContent.tag = 70; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
244 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
245 |
case 2: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
246 |
cell.textLabel.text = NSLocalizedString(@"Multitasking Enabled", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
247 |
cell.detailTextLabel.text = NSLocalizedString(@"Disable it in case of issues when returing in game", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
248 |
switchContent.on = [[self.settingsDictionary objectForKey:@"multitasking"] boolValue]; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
249 |
switchContent.tag = 80; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
250 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
251 |
case 3: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
252 |
cell.textLabel.text = NSLocalizedString(@"Classic Ammo Menu", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
253 |
cell.detailTextLabel.text = NSLocalizedString(@"Select which style of ammo menu you prefer",@""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
254 |
switchContent.on = [[self.settingsDictionary objectForKey:@"menu"] boolValue]; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
255 |
switchContent.tag = 60; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
256 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
257 |
default: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
258 |
DLog(@"Nope"); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
259 |
break; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
260 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
261 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
262 |
default: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
263 |
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
|
264 |
} |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
265 |
|
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
|
266 |
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
|
267 |
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
|
268 |
cell.imageView.image = nil; |
3697 | 269 |
|
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
|
270 |
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
|
271 |
} |
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
|
272 |
|
3547 | 273 |
#pragma mark - |
274 |
#pragma mark Table view delegate |
|
275 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
3660 | 276 |
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
|
277 |
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
|
278 |
[cell replyKeyboard]; |
3547 | 279 |
} |
280 |
} |
|
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
|
281 |
|
3547 | 282 |
|
283 |
#pragma mark - |
|
284 |
#pragma mark Memory management |
|
285 |
-(void) didReceiveMemoryWarning { |
|
286 |
[super didReceiveMemoryWarning]; |
|
287 |
} |
|
288 |
||
289 |
-(void) viewDidUnload { |
|
290 |
self.settingsDictionary = 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
|
291 |
MSG_DIDUNLOAD(); |
3547 | 292 |
[super viewDidUnload]; |
293 |
} |
|
294 |
||
295 |
-(void) dealloc { |
|
296 |
[settingsDictionary release]; |
|
297 |
[super dealloc]; |
|
298 |
} |
|
299 |
||
300 |
@end |