]> Dogcows Code - chaz/thecheat/blob - GeneralPrefs.m
update contact information and project URL
[chaz/thecheat] / GeneralPrefs.m
1
2 /*
3 * The Cheat - The legendary universal game trainer for Mac OS X.
4 * http://www.brokenzipper.com/trac/wiki/TheCheat
5 *
6 * Copyright (c) 2003-2011, Charles McGarvey et al.
7 *
8 * Distributable under the terms and conditions of the 2-clause BSD
9 * license; see the file COPYING for the legal text of the license.
10 */
11
12 #import "GeneralPrefs.h"
13
14
15 @implementation GeneralPrefs
16
17
18 - (void)awakeFromNib
19 {
20 // set initial states
21 [ibWindowOrderButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCWindowsOnTopPref]];
22 [ibAskForSaveButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCAskForSavePref]];
23 if ( [[NSUserDefaults standardUserDefaults] floatForKey:TCFadeAnimationPref] > 0.0 ) {
24 [ibFadeSmoothlyButton setState:NSOnState];
25 }
26 else {
27 [ibFadeSmoothlyButton setState:NSOffState];
28 }
29 [ibDisplayValuesButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCDisplayValuesPref]];
30 [ibValueUpdateField setFloatValue:[[NSUserDefaults standardUserDefaults] floatForKey:TCValueUpdatePref]];
31 [ibValueUpdateField setEnabled:[ibDisplayValuesButton state]];
32 [ibResultsDisplayedField setIntValue:[[NSUserDefaults standardUserDefaults] integerForKey:TCHitsDisplayedPref]];
33
34 [ibSwitchVariablesButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCSwitchVariablesPref]];
35 [ibStartEditingVarsButton setState:[[NSUserDefaults standardUserDefaults] boolForKey:TCAutoStartEditingVarsPref]];
36 [ibStartEditingVarsButton setEnabled:[ibSwitchVariablesButton state]];
37 }
38
39
40 - (IBAction)ibWindowOrderButton:(id)sender
41 {
42 BOOL pref = [sender state];
43 [[NSUserDefaults standardUserDefaults] setBool:pref forKey:TCWindowsOnTopPref];
44 // notify currently opened windows of the change
45 [[NSNotificationCenter defaultCenter] postNotificationName:TCWindowsOnTopChangedNote object:[NSNumber numberWithBool:pref]];
46 }
47
48 - (IBAction)ibSetAskForSave:(id)sender
49 {
50 BOOL pref = [sender state];
51 [[NSUserDefaults standardUserDefaults] setBool:pref forKey:TCAskForSavePref];
52 }
53
54 - (IBAction)ibSetFadeSmoothly:(id)sender
55 {
56 float fade;
57
58 if ( [sender state] == NSOnState ) {
59 fade = TCDefaultFadeAnimation;
60 }
61 else {
62 fade = 0.0;
63 }
64 [[NSUserDefaults standardUserDefaults] setFloat:fade forKey:TCFadeAnimationPref];
65 gFadeAnimationDuration = fade;
66 }
67
68 - (IBAction)ibDisplayValuesButton:(id)sender
69 {
70 BOOL flag = [ibDisplayValuesButton state];
71 [[NSUserDefaults standardUserDefaults] setBool:flag forKey:TCDisplayValuesPref];
72
73 [ibValueUpdateField setEnabled:flag];
74
75 // notify currently opened windows of the change
76 [[NSNotificationCenter defaultCenter] postNotificationName:TCDisplayValuesChangedNote object:nil];
77 }
78
79 - (IBAction)ibSetValueUpdate:(id)sender
80 {
81 float value = [sender floatValue];
82
83 if ( value < 0.1 ) {
84 value = 0.1;
85 [sender setFloatValue:value];
86 }
87
88 [[NSUserDefaults standardUserDefaults] setFloat:value forKey:TCValueUpdatePref];
89
90 // notify currently opened windows of the change
91 [[NSNotificationCenter defaultCenter] postNotificationName:TCDisplayValuesChangedNote object:nil];
92 }
93
94 - (IBAction)ibSetResultsDisplayed:(id)sender
95 {
96 int value = [ibResultsDisplayedField intValue];
97
98 if ( value < 0 ) {
99 value = 0;
100 [ibResultsDisplayedField setIntValue:value];
101 }
102
103 [[NSUserDefaults standardUserDefaults] setInteger:value forKey:TCHitsDisplayedPref];
104
105 // notify currently opened windows of the change
106 [[NSNotificationCenter defaultCenter] postNotificationName:TCHitsDisplayedChangedNote object:nil];
107 }
108
109
110 - (IBAction)ibSwitchVariablesButton:(id)sender
111 {
112 BOOL flag = [ibSwitchVariablesButton state];
113 [[NSUserDefaults standardUserDefaults] setBool:flag forKey:TCSwitchVariablesPref];
114
115 [ibStartEditingVarsButton setEnabled:[ibSwitchVariablesButton state]];
116 if ( !flag ) {
117 [ibStartEditingVarsButton setState:NO];
118 [[NSUserDefaults standardUserDefaults] setBool:NO forKey:TCAutoStartEditingVarsPref];
119 }
120 }
121
122 - (IBAction)ibStartEditingVarsButton:(id)sender
123 {
124 BOOL flag = [ibStartEditingVarsButton state];
125 [[NSUserDefaults standardUserDefaults] setBool:flag forKey:TCAutoStartEditingVarsPref];
126 }
127
128
129 @end
This page took 0.043047 seconds and 4 git commands to generate.