author | smxx |
Sun, 31 Jan 2010 22:15:53 +0000 | |
changeset 2733 | 52a5a160566f |
parent 2723 | eaa6ac1e95ea |
child 2740 | 03df0573a9fd |
permissions | -rw-r--r-- |
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
1 |
// |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
2 |
// SettingsViewController.m |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
3 |
// hwengine |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
4 |
// |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
5 |
// Created by Vittorio on 08/01/10. |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved. |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
7 |
// |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
8 |
|
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
9 |
#import "SettingsViewController.h" |
2696 | 10 |
#import "SDL_uikitappdelegate.h" |
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
11 |
|
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
12 |
@implementation SettingsViewController |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
13 |
|
2720 | 14 |
@synthesize username, password, musicSwitch, soundsSwitch, altDamageSwitch, |
15 |
volumeSlider, volumeLabel, table, volumeCell, buttonContainer; |
|
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
16 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
17 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
18 |
-(void) loadView { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
19 |
self.musicSwitch = [[UISwitch alloc] init]; |
2702
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
20 |
self.soundsSwitch = [[UISwitch alloc] init]; |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
21 |
self.altDamageSwitch = [[UISwitch alloc] init]; |
2702
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
22 |
[self.soundsSwitch addTarget:self action:@selector(sameValueSwitch) forControlEvents:UIControlEventValueChanged]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
23 |
[self.musicSwitch addTarget:self action:@selector(checkValueSwitch) forControlEvents:UIControlEventValueChanged]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
24 |
|
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
25 |
[super loadView]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
26 |
} |
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
27 |
|
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
28 |
-(void) viewDidLoad { |
2698 | 29 |
NSString *filePath = [[SDLUIKitDelegate sharedAppDelegate] dataFilePath:@"settings.plist"]; |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
30 |
|
2720 | 31 |
needsReset = NO; |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
32 |
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
33 |
NSMutableDictionary *data = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath]; |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
34 |
username.text = [data objectForKey:@"username"]; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
35 |
password.text = [data objectForKey:@"password"]; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
36 |
if (1 == [[data objectForKey:@"music"] intValue]) { |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
37 |
musicSwitch.on = YES; |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
38 |
} else { |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
39 |
musicSwitch.on = NO; |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
40 |
} |
2702
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
41 |
if (1 == [[data objectForKey:@"sounds"] intValue]) { |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
42 |
soundsSwitch.on = YES; |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
43 |
} else { |
2702
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
44 |
soundsSwitch.on = NO; |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
45 |
} |
2696 | 46 |
if (1 == [[data objectForKey:@"alternate"] intValue]) { |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
47 |
altDamageSwitch.on = YES; |
2696 | 48 |
} else { |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
49 |
altDamageSwitch.on = NO; |
2696 | 50 |
} |
51 |
||
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
52 |
[volumeSlider setValue:[[data objectForKey:@"volume"] intValue] animated:NO]; |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
53 |
[data release]; |
2696 | 54 |
} else { |
55 |
[NSException raise:@"File NOT found" format:@"The file settings.plist was not found at %@", filePath]; |
|
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
56 |
} |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
57 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
58 |
NSString *tmpVol = [[NSString alloc] initWithFormat:@"%d", (int) volumeSlider.value]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
59 |
volumeLabel.text = tmpVol; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
60 |
[tmpVol release]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
61 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
62 |
username.textColor = [UIColor grayColor]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
63 |
password.textColor = [UIColor grayColor]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
64 |
volumeLabel.textColor = [UIColor grayColor]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
65 |
table.backgroundColor = [UIColor clearColor]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
66 |
table.allowsSelection = NO; |
2720 | 67 |
buttonContainer.backgroundColor = [UIColor clearColor]; |
68 |
table.tableFooterView = buttonContainer; |
|
69 |
||
2696 | 70 |
[super viewDidLoad]; |
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
71 |
} |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
72 |
|
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
73 |
-(void) viewDidUnload { |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
74 |
self.username = nil; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
75 |
self.password = nil; |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
76 |
self.musicSwitch = nil; |
2702
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
77 |
self.soundsSwitch = nil; |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
78 |
self.altDamageSwitch = nil; |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
79 |
self.volumeLabel = nil; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
80 |
self.volumeSlider = nil; |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
81 |
self.table = nil; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
82 |
self.volumeCell = nil; |
2720 | 83 |
self.buttonContainer = nil; |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
84 |
[super viewDidUnload]; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
85 |
} |
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
86 |
|
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
87 |
//- (void)applicationWillTerminate:(NSNotification *)notification { |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
88 |
-(void) viewWillDisappear:(BOOL)animated { |
2720 | 89 |
if (!needsReset) { |
90 |
NSMutableDictionary *saveDict = [[NSMutableDictionary alloc] init]; |
|
91 |
NSString *tmpMus = (musicSwitch.on) ? @"1" : @"0"; |
|
92 |
NSString *tmpEff = (soundsSwitch.on) ? @"1" : @"0"; |
|
93 |
NSString *tmpAlt = (altDamageSwitch.on) ? @"1" : @"0"; |
|
94 |
||
95 |
[saveDict setObject:username.text forKey:@"username"]; |
|
96 |
[saveDict setObject:password.text forKey:@"password"]; |
|
97 |
[saveDict setObject:tmpMus forKey:@"music"]; |
|
98 |
[saveDict setObject:tmpEff forKey:@"sounds"]; |
|
99 |
[saveDict setObject:tmpAlt forKey:@"alternate"]; |
|
100 |
[saveDict setObject:volumeLabel.text forKey:@"volume"]; |
|
101 |
||
102 |
[saveDict writeToFile:[[SDLUIKitDelegate sharedAppDelegate] dataFilePath:@"settings.plist"] atomically:YES]; |
|
103 |
[saveDict release]; |
|
104 |
} |
|
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
105 |
[super viewWillDisappear:animated]; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
106 |
} |
2702
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
107 |
|
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
108 |
-(void) dealloc { |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
109 |
[username release]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
110 |
[password release]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
111 |
[musicSwitch release]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
112 |
[soundsSwitch release]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
113 |
[altDamageSwitch release]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
114 |
[volumeLabel release]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
115 |
[volumeSlider release]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
116 |
[table release]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
117 |
[volumeCell release]; |
2720 | 118 |
[buttonContainer release]; |
2702
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
119 |
[super dealloc]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
120 |
} |
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
121 |
/* |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
122 |
// Override to allow orientations other than the default portrait orientation. |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
123 |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
124 |
// Return YES for supported orientations |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
125 |
return (interfaceOrientation == UIInterfaceOrientationPortrait); |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
126 |
} |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
127 |
*/ |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
128 |
|
2696 | 129 |
// makes the keyboard go away when background is tapped |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
130 |
-(IBAction) backgroundTap: (id)sender { |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
131 |
[username resignFirstResponder]; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
132 |
[password resignFirstResponder]; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
133 |
} |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
134 |
|
2696 | 135 |
// makes the keyboard go away when "Done" is tapped |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
136 |
-(IBAction) textFieldDoneEditing: (id)sender { |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
137 |
[sender resignFirstResponder]; |
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
138 |
} |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
139 |
|
2702
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
140 |
// update the value of the label when slider is updated |
2694
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
141 |
-(IBAction) sliderChanged: (id) sender { |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
142 |
UISlider *slider = (UISlider *)sender; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
143 |
int progress = slider.value; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
144 |
NSString *newLabel = [[NSString alloc] initWithFormat:@"%d",progress]; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
145 |
self.volumeLabel.text = newLabel; |
dcd248e04f3d
can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents:
2687
diff
changeset
|
146 |
[newLabel release]; |
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
147 |
} |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
148 |
|
2702
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
149 |
// set music off when sound is turned off |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
150 |
-(void) sameValueSwitch { |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
151 |
if (YES == self.musicSwitch.on) { |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
152 |
[musicSwitch setOn:NO animated:YES]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
153 |
} |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
154 |
} |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
155 |
|
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
156 |
// don't enable music when sound is off |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
157 |
-(void) checkValueSwitch { |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
158 |
if (NO == self.soundsSwitch.on) { |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
159 |
[musicSwitch setOn:!musicSwitch.on animated:YES]; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
160 |
} |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
161 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
162 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
163 |
#pragma mark - |
2720 | 164 |
#pragma mark UIActionSheet Methods |
165 |
-(IBAction) deleteData: (id)sender { |
|
2723 | 166 |
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"") |
2720 | 167 |
delegate:self |
2723 | 168 |
cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"") |
169 |
destructiveButtonTitle:NSLocalizedString(@"As sure as I can be!", @"") |
|
2720 | 170 |
otherButtonTitles:nil]; |
171 |
[actionSheet showInView:self.view]; |
|
172 |
[actionSheet release]; |
|
173 |
} |
|
174 |
||
175 |
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex { |
|
176 |
if ([actionSheet cancelButtonIndex] != buttonIndex) { |
|
177 |
needsReset = YES; |
|
178 |
||
2723 | 179 |
// get the documents dirctory |
2720 | 180 |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); |
181 |
NSString *documentsDirectory = [paths objectAtIndex:0]; |
|
182 |
||
183 |
// get the content of the directory |
|
184 |
NSFileManager *fm = [NSFileManager defaultManager]; |
|
185 |
NSArray *dirContent = [fm directoryContentsAtPath:documentsDirectory]; |
|
186 |
NSError *error; |
|
187 |
||
188 |
// delete data |
|
189 |
for (NSString *fileName in dirContent) { |
|
190 |
[fm removeItemAtPath:[documentsDirectory stringByAppendingPathComponent:fileName] error:&error]; |
|
191 |
} |
|
192 |
||
193 |
// force resetting |
|
2723 | 194 |
UIAlertView *anAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Hit Home Button to Exit", @"") |
195 |
message:NSLocalizedString(@"\nEverything is gone!\nNow you need to restart the game...", @"") |
|
2720 | 196 |
delegate:self |
197 |
cancelButtonTitle:nil |
|
198 |
otherButtonTitles:nil]; |
|
199 |
[anAlert show]; |
|
200 |
[anAlert release]; |
|
201 |
} |
|
202 |
} |
|
203 |
||
204 |
#pragma mark - |
|
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
205 |
#pragma mark TableView Methods |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
206 |
#define kNetworkFields 0 |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
207 |
#define kAudioFields 1 |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
208 |
#define kOtherFields 2 |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
209 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
210 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
211 |
return 3; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
212 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
213 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
214 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
215 |
switch (section) { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
216 |
case kNetworkFields: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
217 |
return 2; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
218 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
219 |
case kAudioFields: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
220 |
return 3; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
221 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
222 |
case kOtherFields: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
223 |
return 1; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
224 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
225 |
default: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
226 |
NSLog(@"Warning: unset case value for numberOfRowsInSection!"); |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
227 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
228 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
229 |
return 0; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
230 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
231 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
232 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
233 |
static NSString *cellIdentifier = @"systemSettingsCell"; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
234 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
235 |
UITableViewCell *cell; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
236 |
if ( !(kAudioFields == [indexPath section] && 2 == [indexPath row]) ){ |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
237 |
cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
238 |
if (nil == cell) { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
239 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
240 |
reuseIdentifier:cellIdentifier] autorelease]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
241 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
242 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
243 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
244 |
switch ([indexPath section]) { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
245 |
case kNetworkFields: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
246 |
switch ([indexPath row]) { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
247 |
case 0: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
248 |
cell.textLabel.text = NSLocalizedString(@"Nickname", @""); |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
249 |
cell.accessoryView = username; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
250 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
251 |
case 1: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
252 |
cell.textLabel.text = NSLocalizedString(@"Password", @""); |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
253 |
cell.accessoryView = password; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
254 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
255 |
default: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
256 |
NSLog(@"Warning: unset case value in kNetworkFields section!"); |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
257 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
258 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
259 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
260 |
case kAudioFields: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
261 |
switch ([indexPath row]) { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
262 |
case 0: |
2702
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
263 |
cell.accessoryView = soundsSwitch; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
264 |
cell.textLabel.text = NSLocalizedString(@"Sound", @""); |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
265 |
break; |
48fc46a922fd
rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents:
2701
diff
changeset
|
266 |
case 1: |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
267 |
cell.accessoryView = musicSwitch; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
268 |
cell.textLabel.text = NSLocalizedString(@"Music", @""); |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
269 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
270 |
case 2: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
271 |
cell = volumeCell; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
272 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
273 |
default: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
274 |
NSLog(@"Warning: unset case value in kAudioFields section!"); |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
275 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
276 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
277 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
278 |
case kOtherFields: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
279 |
cell.accessoryView = altDamageSwitch; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
280 |
cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @""); |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
281 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
282 |
default: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
283 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
284 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
285 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
286 |
return cell; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
287 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
288 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
289 |
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
290 |
UIView *containerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)] autorelease]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
291 |
UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(10, 20, 300, 40)] autorelease]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
292 |
headerLabel.textColor = [UIColor lightGrayColor]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
293 |
headerLabel.shadowColor = [UIColor blackColor]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
294 |
headerLabel.shadowOffset = CGSizeMake(0, 1); |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
295 |
headerLabel.font = [UIFont boldSystemFontOfSize:20]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
296 |
headerLabel.backgroundColor = [UIColor clearColor]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
297 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
298 |
switch (section) { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
299 |
case kNetworkFields: |
2723 | 300 |
headerLabel.text = NSLocalizedString(@"Network Configuration", @""); |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
301 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
302 |
case kAudioFields: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
303 |
headerLabel.text = NSLocalizedString(@"Audio Preferences", @""); |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
304 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
305 |
case kOtherFields: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
306 |
headerLabel.text = NSLocalizedString(@"Other Settings", @""); |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
307 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
308 |
default: |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
309 |
NSLog(@"Warning: unset case value in titleForHeaderInSection!"); |
2723 | 310 |
headerLabel.text = @"!"; |
2701
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
311 |
break; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
312 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
313 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
314 |
[containerView addSubview:headerLabel]; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
315 |
return containerView; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
316 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
317 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
318 |
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
319 |
if (kAudioFields == [indexPath section] && 2 == [indexPath row]) |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
320 |
return volumeCell.frame.size.height; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
321 |
else |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
322 |
return table.rowHeight; |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
323 |
} |
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
324 |
|
3a8560c00f78
settings tab has now a very nice iphone-like interface
koda
parents:
2698
diff
changeset
|
325 |
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { |
2720 | 326 |
return 57.0; |
2687
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
327 |
} |
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
328 |
|
28b8330b8af1
add stub files for other views and prevent useless crashes
koda
parents:
diff
changeset
|
329 |
@end |