author | koda |
Wed, 29 Sep 2010 23:50:46 +0200 | |
changeset 3916 | e7d665a4ef42 |
parent 3884 | d7479079a8a8 |
child 3935 | 5ca27a0e9a63 |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
3 |
* Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com> |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
17 |
* |
|
18 |
* File created on 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]; |
3547 | 52 |
} |
53 |
||
54 |
#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
|
55 |
-(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
|
56 |
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
|
57 |
UISwitch *theOtherSwitch = nil; |
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 |
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 |
// 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
|
62 |
[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
|
63 |
[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
|
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]; |
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 |
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
|
67 |
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
|
68 |
// 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
|
69 |
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
|
70 |
[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
|
71 |
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
|
72 |
[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
|
73 |
} 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
|
74 |
[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
|
75 |
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
|
76 |
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
|
77 |
[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
|
78 |
break; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
79 |
case 60: //getReady |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
80 |
[self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"ready"]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
81 |
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
|
82 |
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
|
83 |
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
|
84 |
break; |
3547 | 85 |
} |
86 |
} |
|
87 |
||
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
|
88 |
-(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
|
89 |
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
|
90 |
[self.settingsDictionary setObject:textString forKey:@"username"]; |
3660 | 91 |
else |
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 |
[self.settingsDictionary setObject:textString forKey:@"password"]; |
3547 | 93 |
} |
94 |
||
95 |
#pragma mark - |
|
96 |
#pragma mark TableView Methods |
|
97 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
98 |
return 3; |
|
99 |
} |
|
100 |
||
101 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
102 |
switch (section) { |
|
3660 | 103 |
case 0: // user and pass |
3783 | 104 |
return 1; // set 2 here for the password field |
3547 | 105 |
break; |
3660 | 106 |
case 1: // audio |
3547 | 107 |
return 2; |
108 |
break; |
|
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
109 |
case 2: // other stuff |
3803 | 110 |
return 1; |
3547 | 111 |
break; |
112 |
default: |
|
113 |
break; |
|
114 |
} |
|
115 |
return 0; |
|
116 |
} |
|
117 |
||
118 |
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { |
|
119 |
NSString *sectionTitle = nil; |
|
120 |
switch (section) { |
|
3660 | 121 |
case 0: |
3803 | 122 |
sectionTitle = NSLocalizedString(@"Main Configuration", @""); |
3547 | 123 |
break; |
3660 | 124 |
case 1: |
3547 | 125 |
sectionTitle = NSLocalizedString(@"Audio Preferences", @""); |
126 |
break; |
|
3660 | 127 |
case 2: |
3547 | 128 |
sectionTitle = NSLocalizedString(@"Other Settings", @""); |
129 |
break; |
|
130 |
default: |
|
3660 | 131 |
DLog(@"Nope"); |
3547 | 132 |
break; |
133 |
} |
|
134 |
return sectionTitle; |
|
135 |
} |
|
136 |
||
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
|
137 |
-(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
|
138 |
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
|
139 |
static NSString *cellIdentifier1 = @"Cell1"; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
140 |
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
|
141 |
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
|
142 |
NSInteger section = [indexPath section]; |
3697 | 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 *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
|
145 |
EditableCellView *editableCell = nil; |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
146 |
UISwitch *switchContent = nil; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
147 |
switch(section) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
148 |
case 0: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
149 |
editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:cellIdentifier0]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
150 |
if (nil == editableCell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
151 |
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
|
152 |
editableCell.minimumCharacters = 0; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
153 |
editableCell.delegate = self; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
154 |
editableCell.textField.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
155 |
editableCell.textField.textColor = [UIColor lightGrayColor]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
156 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
157 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
158 |
if (row == 0) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
159 |
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
|
160 |
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
|
161 |
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
|
162 |
editableCell.textField.secureTextEntry = NO; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
163 |
editableCell.tag = 40; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
164 |
} else { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
165 |
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
|
166 |
editableCell.textField.placeholder = NSLocalizedString(@"Insert your password",@""); |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
167 |
editableCell.textField.text = [self.settingsDictionary objectForKey:@"password"]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
168 |
editableCell.textField.secureTextEntry = YES; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
169 |
editableCell.tag = 50; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
170 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
171 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
172 |
editableCell.accessoryView = nil; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
173 |
cell = editableCell; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
174 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
175 |
case 1: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
176 |
cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier1]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
177 |
if (nil == cell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
178 |
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
|
179 |
UISwitch *theSwitch = [[UISwitch alloc] init]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
180 |
[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
|
181 |
cell.accessoryView = theSwitch; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
182 |
[theSwitch release]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
183 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
184 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
185 |
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
|
186 |
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
|
187 |
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
|
188 |
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
|
189 |
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
|
190 |
} 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
|
191 |
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
|
192 |
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
|
193 |
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
|
194 |
} |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
195 |
break; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
196 |
case 2: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
197 |
cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier2]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
198 |
if (nil == cell) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
199 |
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
|
200 |
UISwitch *theSwitch = [[UISwitch alloc] init]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
201 |
[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
|
202 |
cell.accessoryView = theSwitch; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
203 |
[theSwitch release]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
204 |
} |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
205 |
|
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
206 |
switchContent = (UISwitch *)cell.accessoryView; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
207 |
if (row == 0) { |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
208 |
cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @""); |
3884 | 209 |
cell.detailTextLabel.text = NSLocalizedString(@"Damage popups will notify you on every single hit a hedgehog suffers", @""); |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
210 |
switchContent.on = [[self.settingsDictionary objectForKey:@"alternate"] boolValue]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
211 |
switchContent.tag = 30; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
212 |
} else { |
3803 | 213 |
/* |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
214 |
cell.textLabel.text = NSLocalizedString(@"Get Ready Dialogue", @""); |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
215 |
cell.detailTextLabel.text = NSLocalizedString(@"Pause for 5 seconds between turns",@""); |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
216 |
switchContent.on = [[self.settingsDictionary objectForKey:@"ready"] boolValue]; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
217 |
switchContent.tag = 60; |
3803 | 218 |
*/ |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
219 |
} |
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 |
default: |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
222 |
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
|
223 |
} |
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3703
diff
changeset
|
224 |
|
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
|
225 |
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
|
226 |
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
|
227 |
cell.imageView.image = nil; |
3697 | 228 |
|
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
|
229 |
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
|
230 |
} |
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
|
231 |
|
3547 | 232 |
#pragma mark - |
233 |
#pragma mark Table view delegate |
|
234 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
3660 | 235 |
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
|
236 |
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
|
237 |
[cell replyKeyboard]; |
3547 | 238 |
} |
239 |
} |
|
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
|
240 |
|
3547 | 241 |
|
242 |
#pragma mark - |
|
243 |
#pragma mark Memory management |
|
244 |
-(void) didReceiveMemoryWarning { |
|
245 |
[super didReceiveMemoryWarning]; |
|
246 |
} |
|
247 |
||
248 |
-(void) viewDidUnload { |
|
249 |
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
|
250 |
MSG_DIDUNLOAD(); |
3547 | 251 |
[super viewDidUnload]; |
252 |
} |
|
253 |
||
254 |
-(void) dealloc { |
|
255 |
[settingsDictionary release]; |
|
256 |
[super dealloc]; |
|
257 |
} |
|
258 |
||
259 |
@end |