2 // **********************************************************************
3 // The Cheat - A universal game cheater for Mac OS X
4 // (C) 2003-2005 Chaz McGarvey (BrokenZipper)
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)
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.
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.
21 #import "GeneralPrefs.h"
24 @implementation GeneralPrefs
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
];
36 [ibFadeSmoothlyButton setState
:NSOffState
];
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
]];
43 [ibSwitchVariablesButton setState
:[[NSUserDefaults standardUserDefaults
] boolForKey
:TCSwitchVariablesPref
]];
44 [ibStartEditingVarsButton setState
:[[NSUserDefaults standardUserDefaults
] boolForKey
:TCAutoStartEditingVarsPref
]];
45 [ibStartEditingVarsButton setEnabled
:[ibSwitchVariablesButton state
]];
49 - (IBAction
)ibWindowOrderButton
:(id)sender
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
]];
57 - (IBAction
)ibSetAskForSave
:(id)sender
59 BOOL pref
= [sender state
];
60 [[NSUserDefaults standardUserDefaults
] setBool
:pref forKey
:TCAskForSavePref
];
63 - (IBAction
)ibSetFadeSmoothly
:(id)sender
67 if ( [sender state
] == NSOnState
) {
68 fade
= TCDefaultFadeAnimation
;
73 [[NSUserDefaults standardUserDefaults
] setFloat
:fade forKey
:TCFadeAnimationPref
];
74 gFadeAnimationDuration
= fade
;
77 - (IBAction
)ibDisplayValuesButton
:(id)sender
79 BOOL flag
= [ibDisplayValuesButton state
];
80 [[NSUserDefaults standardUserDefaults
] setBool
:flag forKey
:TCDisplayValuesPref
];
82 [ibValueUpdateField setEnabled
:flag
];
84 // notify currently opened windows of the change
85 [[NSNotificationCenter defaultCenter
] postNotificationName
:TCDisplayValuesChangedNote object
:nil];
88 - (IBAction
)ibSetValueUpdate
:(id)sender
90 float value
= [sender floatValue
];
94 [sender setFloatValue
:value
];
97 [[NSUserDefaults standardUserDefaults
] setFloat
:value forKey
:TCValueUpdatePref
];
99 // notify currently opened windows of the change
100 [[NSNotificationCenter defaultCenter
] postNotificationName
:TCDisplayValuesChangedNote object
:nil];
103 - (IBAction
)ibSetResultsDisplayed
:(id)sender
105 int value
= [ibResultsDisplayedField intValue
];
109 [ibResultsDisplayedField setIntValue
:value
];
112 [[NSUserDefaults standardUserDefaults
] setInteger
:value forKey
:TCHitsDisplayedPref
];
114 // notify currently opened windows of the change
115 [[NSNotificationCenter defaultCenter
] postNotificationName
:TCHitsDisplayedChangedNote object
:nil];
119 - (IBAction
)ibSwitchVariablesButton
:(id)sender
121 BOOL flag
= [ibSwitchVariablesButton state
];
122 [[NSUserDefaults standardUserDefaults
] setBool
:flag forKey
:TCSwitchVariablesPref
];
124 [ibStartEditingVarsButton setEnabled
:[ibSwitchVariablesButton state
]];
126 [ibStartEditingVarsButton setState
:NO
];
127 [[NSUserDefaults standardUserDefaults
] setBool
:NO forKey
:TCAutoStartEditingVarsPref
];
131 - (IBAction
)ibStartEditingVarsButton
:(id)sender
133 BOOL flag
= [ibStartEditingVarsButton state
];
134 [[NSUserDefaults standardUserDefaults
] setBool
:flag forKey
:TCAutoStartEditingVarsPref
];