author | koda |
Tue, 25 Oct 2011 22:51:10 +0200 | |
changeset 6208 | b831679e9467 |
parent 6078 | 8c0cc07731e5 |
child 6210 | 923c8414e3af |
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 |
||
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5700
diff
changeset
|
24 |
|
3547 | 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 { |
|
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
6000
diff
changeset
|
35 |
self.navigationItem.title = @"Edit game options"; |
3547 | 36 |
[super viewDidLoad]; |
37 |
} |
|
38 |
||
39 |
-(void) viewWillAppear:(BOOL)animated { |
|
40 |
[self.tableView setContentOffset:CGPointMake(0,0) animated:NO]; |
|
41 |
[super viewWillAppear:animated]; |
|
42 |
} |
|
43 |
||
44 |
-(void) viewWillDisappear:(BOOL)animated { |
|
5224
6e8fbbfb0de5
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents:
5207
diff
changeset
|
45 |
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; |
6e8fbbfb0de5
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents:
5207
diff
changeset
|
46 |
[userDefaults synchronize]; |
6e8fbbfb0de5
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents:
5207
diff
changeset
|
47 |
if ([[userDefaults objectForKey:@"music"] boolValue] == NO) |
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5700
diff
changeset
|
48 |
[AudioManagerController stopBackgroundMusic]; |
5224
6e8fbbfb0de5
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents:
5207
diff
changeset
|
49 |
|
3697 | 50 |
[super viewWillDisappear:animated]; |
3547 | 51 |
} |
52 |
||
53 |
#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
|
54 |
-(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
|
55 |
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
|
56 |
UISwitch *theOtherSwitch = nil; |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
57 |
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
3697 | 58 |
|
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 |
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
|
60 |
case 10: //soundSwitch |
5224
6e8fbbfb0de5
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents:
5207
diff
changeset
|
61 |
// setting this off will turn off also the switch below (music) |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
62 |
[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
|
63 |
[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
|
64 |
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
|
65 |
[theOtherSwitch setOn:NO animated:YES]; |
5370
a3f87be7b09a
ios: disble logging, stop music correctly in preferences, move script command before seed, try using reatin instead of if
koda
parents:
5224
diff
changeset
|
66 |
|
a3f87be7b09a
ios: disble logging, stop music correctly in preferences, move script command before seed, try using reatin instead of if
koda
parents:
5224
diff
changeset
|
67 |
if (theOtherSwitch.on) |
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5700
diff
changeset
|
68 |
[AudioManagerController pauseBackgroundMusic]; |
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 |
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
|
70 |
case 20: //musicSwitch |
5224
6e8fbbfb0de5
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents:
5207
diff
changeset
|
71 |
// if switch above (sound) is off, never turn on |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
72 |
if (NO == [[settings objectForKey:@"sound"] boolValue]) { |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
73 |
[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
|
74 |
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
|
75 |
[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
|
76 |
} else |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
77 |
[settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"music"]; |
5224
6e8fbbfb0de5
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents:
5207
diff
changeset
|
78 |
|
6e8fbbfb0de5
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents:
5207
diff
changeset
|
79 |
if (theSwitch.on) |
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5700
diff
changeset
|
80 |
[AudioManagerController playBackgroundMusic]; |
5224
6e8fbbfb0de5
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents:
5207
diff
changeset
|
81 |
else |
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5700
diff
changeset
|
82 |
[AudioManagerController pauseBackgroundMusic]; |
5224
6e8fbbfb0de5
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents:
5207
diff
changeset
|
83 |
|
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
|
84 |
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
|
85 |
case 30: //alternateSwitch |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
86 |
[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
|
87 |
break; |
5451
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
88 |
case 90: //synched weapons/scheme |
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
89 |
[settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"sync_ws"]; |
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
90 |
break; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
91 |
case 60: //classic menu |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
92 |
[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
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
break; |
3547 | 97 |
} |
98 |
} |
|
99 |
||
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
|
100 |
-(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
|
101 |
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
102 |
|
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
|
103 |
if (tagValue == 40) |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
104 |
[settings setObject:textString forKey:@"username"]; |
5206 | 105 |
else |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
106 |
[settings setObject:[textString MD5hash] forKey:@"password"]; |
3547 | 107 |
} |
108 |
||
109 |
#pragma mark - |
|
110 |
#pragma mark TableView Methods |
|
111 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
112 |
return 3; |
|
113 |
} |
|
114 |
||
4539 | 115 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger )section { |
3547 | 116 |
switch (section) { |
3660 | 117 |
case 0: // user and pass |
5451
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
118 |
return 1; // set 2 here to show the password field |
3547 | 119 |
break; |
3660 | 120 |
case 1: // audio |
3547 | 121 |
return 2; |
122 |
break; |
|
5451
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
123 |
case 2: // other options |
5664
dfc574d7f49e
ok this makes no sense now, remove 'enhanced' option from ios
koda
parents:
5662
diff
changeset
|
124 |
return 3; |
3547 | 125 |
break; |
126 |
default: |
|
3935 | 127 |
DLog(@"Nope"); |
3547 | 128 |
break; |
129 |
} |
|
130 |
return 0; |
|
131 |
} |
|
132 |
||
133 |
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { |
|
134 |
NSString *sectionTitle = nil; |
|
135 |
switch (section) { |
|
3660 | 136 |
case 0: |
3803 | 137 |
sectionTitle = NSLocalizedString(@"Main Configuration", @""); |
3547 | 138 |
break; |
3660 | 139 |
case 1: |
3547 | 140 |
sectionTitle = NSLocalizedString(@"Audio Preferences", @""); |
141 |
break; |
|
3660 | 142 |
case 2: |
3547 | 143 |
sectionTitle = NSLocalizedString(@"Other Settings", @""); |
144 |
break; |
|
145 |
default: |
|
3660 | 146 |
DLog(@"Nope"); |
3547 | 147 |
break; |
148 |
} |
|
149 |
return sectionTitle; |
|
150 |
} |
|
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 *)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
|
153 |
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
|
154 |
static NSString *cellIdentifier1 = @"Cell1"; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
NSInteger section = [indexPath section]; |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
158 |
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
3697 | 159 |
|
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
|
160 |
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
|
161 |
EditableCellView *editableCell = nil; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
162 |
UISwitch *switchContent = nil; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
163 |
switch(section) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
164 |
case 0: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
165 |
editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:cellIdentifier0]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
166 |
if (nil == editableCell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
167 |
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
|
168 |
editableCell.minimumCharacters = 0; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
169 |
editableCell.delegate = self; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
170 |
editableCell.textField.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; |
4341 | 171 |
editableCell.textField.textColor = [UIColor blackColor]; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
172 |
} |
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 |
if (row == 0) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
175 |
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
|
176 |
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
|
177 |
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
|
178 |
editableCell.textField.secureTextEntry = NO; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
179 |
editableCell.tag = 40; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
180 |
} else { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
181 |
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
|
182 |
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
|
183 |
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
|
184 |
editableCell.textField.secureTextEntry = YES; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
185 |
editableCell.tag = 50; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
186 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
187 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
188 |
editableCell.accessoryView = nil; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
189 |
cell = editableCell; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
190 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
191 |
case 1: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
192 |
cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier1]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
193 |
if (nil == cell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
194 |
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
|
195 |
UISwitch *theSwitch = [[UISwitch alloc] init]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
196 |
[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
|
197 |
cell.accessoryView = theSwitch; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
198 |
[theSwitch release]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
199 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
200 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
201 |
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
|
202 |
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
|
203 |
cell.textLabel.text = NSLocalizedString(@"Sound", @""); |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
204 |
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
|
205 |
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
|
206 |
} 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
|
207 |
cell.textLabel.text = NSLocalizedString(@"Music", @""); |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
5206
diff
changeset
|
208 |
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
|
209 |
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
|
210 |
} |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
211 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
212 |
case 2: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
213 |
cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier2]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
214 |
if (nil == cell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
215 |
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
|
216 |
UISwitch *theSwitch = [[UISwitch alloc] init]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
217 |
[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
|
218 |
cell.accessoryView = theSwitch; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
219 |
[theSwitch release]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
220 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
221 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
222 |
switchContent = (UISwitch *)cell.accessoryView; |
5451
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
223 |
cell.detailTextLabel.adjustsFontSizeToFitWidth = YES; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
224 |
switch (row) { |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
225 |
case 0: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
226 |
cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
227 |
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
|
228 |
switchContent.on = [[settings objectForKey:@"alternate"] boolValue]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
229 |
switchContent.tag = 30; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
230 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
231 |
case 1: |
5451
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
232 |
cell.textLabel.text = NSLocalizedString(@"Sync Schemes and Weapons", @""); |
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
233 |
cell.detailTextLabel.text = NSLocalizedString(@"Choosing a Scheme will select its associated Weapon", @""); |
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
234 |
switchContent.on = [[settings objectForKey:@"sync_ws"] boolValue]; |
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
235 |
switchContent.tag = 90; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
236 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
237 |
case 2: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
238 |
cell.textLabel.text = NSLocalizedString(@"Classic Ammo Menu", @""); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
239 |
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
|
240 |
switchContent.on = [[settings objectForKey:@"classic_menu"] boolValue]; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
241 |
switchContent.tag = 60; |
5451
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
242 |
// remove this when classic ammomenu works on iphone as well |
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
243 |
if (IS_IPAD() == NO) |
e359a79e3d08
rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents:
5370
diff
changeset
|
244 |
switchContent.enabled = NO; |
4540
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
245 |
break; |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
246 |
default: |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
247 |
DLog(@"Nope"); |
9b614e420de5
add two preferences for enabling/disabling blurry land and multitasking
koda
parents:
4539
diff
changeset
|
248 |
break; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
249 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
250 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
251 |
default: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
252 |
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
|
253 |
} |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
254 |
|
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
|
255 |
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
|
256 |
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
|
257 |
cell.imageView.image = nil; |
3697 | 258 |
|
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
|
259 |
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
|
260 |
} |
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 |
|
3547 | 262 |
#pragma mark - |
263 |
#pragma mark Table view delegate |
|
264 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
5700
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5664
diff
changeset
|
265 |
[self.tableView deselectRowAtIndexPath:indexPath animated:YES]; |
3660 | 266 |
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
|
267 |
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
|
268 |
[cell replyKeyboard]; |
3547 | 269 |
} |
270 |
} |
|
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
|
271 |
|
3547 | 272 |
|
273 |
#pragma mark - |
|
274 |
#pragma mark Memory management |
|
275 |
-(void) didReceiveMemoryWarning { |
|
276 |
[super didReceiveMemoryWarning]; |
|
277 |
} |
|
278 |
||
279 |
-(void) viewDidUnload { |
|
280 |
[super viewDidUnload]; |
|
281 |
} |
|
282 |
||
283 |
-(void) dealloc { |
|
284 |
[super dealloc]; |
|
285 |
} |
|
286 |
||
287 |
@end |