-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingViewController.m
More file actions
executable file
·132 lines (86 loc) · 3.16 KB
/
SettingViewController.m
File metadata and controls
executable file
·132 lines (86 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//
// SettingViewController.m
// TypingGame
//
// Created by Jacopo Volpin on 17/05/10.
// Copyright 2010 UniPD. All rights reserved.
//
#import "SettingViewController.h"
#import "TypingGameAppDelegate.h"
@implementation SettingViewController
@synthesize menuButton, timeDiff, wordsDiff, name;
-(IBAction)goToMenu: (UIButton *)sender{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Setting saved"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
{
TypingGameAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
//[appDelegate.pref synchronize];
[appDelegate displayView:1];
}
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
TypingGameAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.namePlayer = name.text;
name.text = appDelegate.namePlayer;
[appDelegate.pref setObject:appDelegate.namePlayer forKey:@"namePlayer"];
[name resignFirstResponder];
}
- (IBAction)modifyTimeDiff: (UISegmentedControl *)sender{
TypingGameAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
if( [sender selectedSegmentIndex] == 0 )
appDelegate.timeDiffValue = @"0";
if( [sender selectedSegmentIndex] == 1 )
appDelegate.timeDiffValue = @"1";
if( [sender selectedSegmentIndex] == 2 )
appDelegate.timeDiffValue = @"2";
[appDelegate.pref setObject:appDelegate.timeDiffValue forKey:@"timeDiffValue"];
}
- (IBAction)modifyWordsDiff: (UISegmentedControl *)sender{
TypingGameAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
if( [sender selectedSegmentIndex] == 0 )
appDelegate.wordsDiffValue = @"0";
if( [sender selectedSegmentIndex] == 1 )
appDelegate.wordsDiffValue = @"1";
if( [sender selectedSegmentIndex] == 2 )
appDelegate.wordsDiffValue = @"2";
[appDelegate.pref setObject:appDelegate.wordsDiffValue forKey:@"wordsDiffValue"];
}
- (void)viewDidLoad {
TypingGameAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSString *data = [appDelegate.pref objectForKey:@"timeDiffValue"];
if([data isEqualToString: @"0"])
self.timeDiff.selectedSegmentIndex=0;
if([data isEqualToString: @"1"])
self.timeDiff.selectedSegmentIndex=1;
if([data isEqualToString: @"2"])
self.timeDiff.selectedSegmentIndex=2;
data = [appDelegate.pref objectForKey:@"wordsDiffValue"];
if([data isEqualToString: @"0"])
self.wordsDiff.selectedSegmentIndex=0;
if([data isEqualToString: @"1"])
self.wordsDiff.selectedSegmentIndex=1;
if([data isEqualToString: @"2"])
self.wordsDiff.selectedSegmentIndex=2;
data = [appDelegate.pref objectForKey:@"namePlayer"];
if (data != nil) {
name.text=data;
}
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)dealloc {
[menuButton release];
[timeDiff release];
[wordsDiff release];
[super dealloc];
}
@end