]> Dogcows Code - chaz/thecheat/blob - GeneralPrefs.m
The Cheat 1.2
[chaz/thecheat] / GeneralPrefs.m
1
2 // **********************************************************************
3 // The Cheat - A universal game cheater for Mac OS X
4 // (C) 2003-2005 Chaz McGarvey (BrokenZipper)
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 1, or (at your option)
9 // any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 //
20
21 #import "GeneralPrefs.h"
22
23
24 @implementation GeneralPrefs
25
26
27 - (void)awakeFromNib
28 {
29 // set initial states
30 [ibWindowOrderButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCWindowsOnTopPref]];
31 [ibAskForSaveButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCAskForSavePref]];
32 if ( [[NSUserDefaults standardUserDefaults] floatForKey:TCFadeAnimationPref] > 0.0 ) {
33 [ibFadeSmoothlyButton setState:NSOnState];
34 }
35 else {
36 [ibFadeSmoothlyButton setState:NSOffState];
37 }
38 [ibDisplayValuesButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCDisplayValuesPref]];
39 [ibValueUpdateField setFloatValue:[[NSUserDefaults standardUserDefaults] floatForKey:TCValueUpdatePref]];
40 [ibValueUpdateField setEnabled:[ibDisplayValuesButton state]];
41 [ibResultsDisplayedField setIntValue:[[NSUserDefaults standardUserDefaults] integerForKey:TCHitsDisplayedPref]];
42
43 [ibSwitchVariablesButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCSwitchVariablesPref]];
44 [ibStartEditingVarsButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCAutoStartEditingVarsPref]];
45 [ibStartEditingVarsButton setEnabled:[ibSwitchVariablesButton state]];
46 }
47
48
49 - (IBAction)ibWindowOrderButton:(id)sender
50 {
51 BOOL pref = [sender state];
52 [[NSUserDefaults standardUserDefaults] setBool:pref forKey:TCWindowsOnTopPref];
53 // notify currently opened windows of the change
54 [[NSNotificationCenter defaultCenter] postNotificationName:TCWindowsOnTopChangedNote object:[NSNumber numberWithBool:pref]];
55 }
56
57 - (IBAction)ibSetAskForSave:(id)sender
58 {
59 BOOL pref = [sender state];
60 [[NSUserDefaults standardUserDefaults] setBool:pref forKey:TCAskForSavePref];
61 }
62
63 - (IBAction)ibSetFadeSmoothly:(id)sender
64 {
65 float fade;
66
67 if ( [sender state] == NSOnState ) {
68 fade = TCDefaultFadeAnimation;
69 }
70 else {
71 fade = 0.0;
72 }
73 [[NSUserDefaults standardUserDefaults] setFloat:fade forKey:TCFadeAnimationPref];
74 gFadeAnimationDuration = fade;
75 }
76
77 - (IBAction)ibDisplayValuesButton:(id)sender
78 {
79 BOOL flag = [ibDisplayValuesButton state];
80 [[NSUserDefaults standardUserDefaults] setBool:flag forKey:TCDisplayValuesPref];
81
82 [ibValueUpdateField setEnabled:flag];
83
84 // notify currently opened windows of the change
85 [[NSNotificationCenter defaultCenter] postNotificationName:TCDisplayValuesChangedNote object:nil];
86 }
87
88 - (IBAction)ibSetValueUpdate:(id)sender
89 {
90 float value = [sender floatValue];
91
92 if ( value < 0.1 ) {
93 value = 0.1;
94 [sender setFloatValue:value];
95 }
96
97 [[NSUserDefaults standardUserDefaults] setFloat:value forKey:TCValueUpdatePref];
98
99 // notify currently opened windows of the change
100 [[NSNotificationCenter defaultCenter] postNotificationName:TCDisplayValuesChangedNote object:nil];
101 }
102
103 - (IBAction)ibSetResultsDisplayed:(id)sender
104 {
105 int value = [ibResultsDisplayedField intValue];
106
107 if ( value < 0 ) {
108 value = 0;
109 [ibResultsDisplayedField setIntValue:value];
110 }
111
112 [[NSUserDefaults standardUserDefaults] setInteger:value forKey:TCHitsDisplayedPref];
113
114 // notify currently opened windows of the change
115 [[NSNotificationCenter defaultCenter] postNotificationName:TCHitsDisplayedChangedNote object:nil];
116 }
117
118
119 - (IBAction)ibSwitchVariablesButton:(id)sender
120 {
121 BOOL flag = [ibSwitchVariablesButton state];
122 [[NSUserDefaults standardUserDefaults] setBool:flag forKey:TCSwitchVariablesPref];
123
124 [ibStartEditingVarsButton setEnabled:[ibSwitchVariablesButton state]];
125 if ( !flag ) {
126 [ibStartEditingVarsButton setState:NO];
127 [[NSUserDefaults standardUserDefaults] setBool:NO forKey:TCAutoStartEditingVarsPref];
128 }
129 }
130
131 - (IBAction)ibStartEditingVarsButton:(id)sender
132 {
133 BOOL flag = [ibStartEditingVarsButton state];
134 [[NSUserDefaults standardUserDefaults] setBool:flag forKey:TCAutoStartEditingVarsPref];
135 }
136
137
138 @end
This page took 0.036897 seconds and 4 git commands to generate.