-
Notifications
You must be signed in to change notification settings - Fork 13
/
GeneralPrefs.m
129 lines (100 loc) · 3.96 KB
/
GeneralPrefs.m
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
/*
* The Cheat - The legendary universal game trainer for Mac OS X.
* http://www.brokenzipper.com/trac/wiki/TheCheat
*
* Copyright (c) 2003-2011, Charles McGarvey et al.
*
* Distributable under the terms and conditions of the 2-clause BSD
* license; see the file COPYING for the legal text of the license.
*/
#import "GeneralPrefs.h"
@implementation GeneralPrefs
- (void)awakeFromNib
{
// set initial states
[ibWindowOrderButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCWindowsOnTopPref]];
[ibAskForSaveButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCAskForSavePref]];
if ( [[NSUserDefaults standardUserDefaults] floatForKey:TCFadeAnimationPref] > 0.0 ) {
[ibFadeSmoothlyButton setState:NSOnState];
}
else {
[ibFadeSmoothlyButton setState:NSOffState];
}
[ibDisplayValuesButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCDisplayValuesPref]];
[ibValueUpdateField setFloatValue:[[NSUserDefaults standardUserDefaults] floatForKey:TCValueUpdatePref]];
[ibValueUpdateField setEnabled:[ibDisplayValuesButton state]];
[ibResultsDisplayedField setIntValue:[[NSUserDefaults standardUserDefaults] integerForKey:TCHitsDisplayedPref]];
[ibSwitchVariablesButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCSwitchVariablesPref]];
[ibStartEditingVarsButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCAutoStartEditingVarsPref]];
[ibStartEditingVarsButton setEnabled:[ibSwitchVariablesButton state]];
}
- (IBAction)ibWindowOrderButton:(id)sender
{
BOOL pref = [sender state];
[[NSUserDefaults standardUserDefaults] setBool:pref forKey:TCWindowsOnTopPref];
// notify currently opened windows of the change
[[NSNotificationCenter defaultCenter] postNotificationName:TCWindowsOnTopChangedNote object:[NSNumber numberWithBool:pref]];
}
- (IBAction)ibSetAskForSave:(id)sender
{
BOOL pref = [sender state];
[[NSUserDefaults standardUserDefaults] setBool:pref forKey:TCAskForSavePref];
}
- (IBAction)ibSetFadeSmoothly:(id)sender
{
float fade;
if ( [sender state] == NSOnState ) {
fade = TCDefaultFadeAnimation;
}
else {
fade = 0.0;
}
[[NSUserDefaults standardUserDefaults] setFloat:fade forKey:TCFadeAnimationPref];
gFadeAnimationDuration = fade;
}
- (IBAction)ibDisplayValuesButton:(id)sender
{
BOOL flag = [ibDisplayValuesButton state];
[[NSUserDefaults standardUserDefaults] setBool:flag forKey:TCDisplayValuesPref];
[ibValueUpdateField setEnabled:flag];
// notify currently opened windows of the change
[[NSNotificationCenter defaultCenter] postNotificationName:TCDisplayValuesChangedNote object:nil];
}
- (IBAction)ibSetValueUpdate:(id)sender
{
float value = [sender floatValue];
if ( value < 0.1 ) {
value = 0.1;
[sender setFloatValue:value];
}
[[NSUserDefaults standardUserDefaults] setFloat:value forKey:TCValueUpdatePref];
// notify currently opened windows of the change
[[NSNotificationCenter defaultCenter] postNotificationName:TCDisplayValuesChangedNote object:nil];
}
- (IBAction)ibSetResultsDisplayed:(id)sender
{
int value = [ibResultsDisplayedField intValue];
if ( value < 0 ) {
value = 0;
[ibResultsDisplayedField setIntValue:value];
}
[[NSUserDefaults standardUserDefaults] setInteger:value forKey:TCHitsDisplayedPref];
// notify currently opened windows of the change
[[NSNotificationCenter defaultCenter] postNotificationName:TCHitsDisplayedChangedNote object:nil];
}
- (IBAction)ibSwitchVariablesButton:(id)sender
{
BOOL flag = [ibSwitchVariablesButton state];
[[NSUserDefaults standardUserDefaults] setBool:flag forKey:TCSwitchVariablesPref];
[ibStartEditingVarsButton setEnabled:[ibSwitchVariablesButton state]];
if ( !flag ) {
[ibStartEditingVarsButton setState:NO];
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:TCAutoStartEditingVarsPref];
}
}
- (IBAction)ibStartEditingVarsButton:(id)sender
{
BOOL flag = [ibStartEditingVarsButton state];
[[NSUserDefaults standardUserDefaults] setBool:flag forKey:TCAutoStartEditingVarsPref];
}
@end