]> Dogcows Code - chaz/thecheat/blob - PreferenceController.m
The Cheat 1.0b4
[chaz/thecheat] / PreferenceController.m
1
2 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 // Project: The Cheat
4 //
5 // File: PreferenceController.m
6 // Created: Wed Sep 24 2003
7 //
8 // Copyright: 2003 Chaz McGarvey. All rights reserved.
9 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10
11 #import "PreferenceController.h"
12
13
14 @implementation PreferenceController
15
16
17 - (id)initWithDelegate:(id)del
18 {
19 if ( self = [super initWithWindowNibName:@"Preferences"] )
20 {
21 [self setWindowFrameAutosaveName:@"TCPreferencWindowPosition"];
22
23 delegate = del;
24 }
25
26 return self;
27 }
28
29 - (void)windowDidLoad
30 {
31 [self initialInterfaceSetup];
32 [self interfaceUpdate];
33 }
34
35
36 - (void)initialInterfaceSetup
37 {
38 [playSoundsButton setState:(TCGlobalPlaySounds)? NSOnState:NSOffState];
39 [windowsOnTopButton setState:(TCGlobalWindowsOnTop)? NSOnState:NSOffState];
40 [allowRemoteButton setState:(TCGlobalAllowRemote)? NSOnState:NSOffState];
41 [listenPortTextField setIntValue:TCGlobalListenPort];
42 [broadcastNameTextField setStringValue:[[NSUserDefaults standardUserDefaults] objectForKey:TCBroadcastNamePref]];
43 }
44
45 - (void)interfaceUpdate
46 {
47 if ( TCGlobalAllowRemote )
48 {
49 [listenPortTextField setEnabled:YES];
50 [broadcastNameTextField setEnabled:YES];
51 }
52 else
53 {
54 [listenPortTextField setEnabled:NO];
55 [broadcastNameTextField setEnabled:NO];
56 }
57 }
58
59
60 - (IBAction)playSoundsButton:(id)sender
61 {
62 if ( [playSoundsButton state] == NSOnState )
63 {
64 TCGlobalPlaySounds = YES;
65 [[NSUserDefaults standardUserDefaults] setBool:YES forKey:TCPlaySoundsPref];
66 }
67 else
68 {
69 TCGlobalPlaySounds = NO;
70 [[NSUserDefaults standardUserDefaults] setBool:NO forKey:TCPlaySoundsPref];
71 }
72 }
73
74 - (IBAction)windowsOnTopButton:(id)sender
75 {
76 if ( [windowsOnTopButton state] == NSOnState )
77 {
78 TCGlobalWindowsOnTop = YES;
79 [[NSUserDefaults standardUserDefaults] setBool:YES forKey:TCWindowsOnTopPref];
80 }
81 else
82 {
83 TCGlobalWindowsOnTop = NO;
84 [[NSUserDefaults standardUserDefaults] setBool:NO forKey:TCWindowsOnTopPref];
85 }
86
87 [[NSNotificationCenter defaultCenter] postNotificationName:@"TCWindowsOnTopChanged" object:nil];
88 }
89
90 - (IBAction)allowRemoteButton:(id)sender
91 {
92 if ( [allowRemoteButton state] == NSOnState )
93 {
94 TCGlobalAllowRemote = YES;
95 [[NSUserDefaults standardUserDefaults] setBool:YES forKey:TCAllowRemotePref];
96 }
97 else
98 {
99 TCGlobalAllowRemote = NO;
100 [[NSUserDefaults standardUserDefaults] setBool:NO forKey:TCAllowRemotePref];
101 }
102
103 [self interfaceUpdate];
104
105 [delegate preferenceAllowRemoteChanged:TCGlobalAllowRemote];
106 }
107
108 - (IBAction)listenPortTextField:(id)sender
109 {
110 TCGlobalListenPort = [listenPortTextField intValue];
111
112 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:TCGlobalListenPort] forKey:TCListenPortPref];
113
114 [delegate preferenceListenPortChanged:TCGlobalListenPort];
115 }
116
117 - (IBAction)broadcastNameTextField:(id)sender
118 {
119 NSString *name = [broadcastNameTextField stringValue];
120
121 [[NSUserDefaults standardUserDefaults] setObject:name forKey:TCBroadcastNamePref];
122
123 [delegate preferenceBroadcastNameChanged:name];
124 }
125
126
127 @end
This page took 0.039335 seconds and 4 git commands to generate.