X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=PreferenceController.m;h=7c0ec13ad805aa28f2954f3466a092004a60f43d;hb=fcdfb47212ad3d7f8ec8ae115ccf4f30b7ace383;hp=fe178fb4b62a3f89a5ddac19585e9a9814d9bb7a;hpb=42cf7bbe564d70233a0d73baee613f209eb00eb6;p=chaz%2Fthecheat diff --git a/PreferenceController.m b/PreferenceController.m index fe178fb..7c0ec13 100644 --- a/PreferenceController.m +++ b/PreferenceController.m @@ -29,7 +29,6 @@ - (void)windowDidLoad { [self initialInterfaceSetup]; - [self interfaceUpdate]; } @@ -37,14 +36,18 @@ { [playSoundsButton setState:(TCGlobalPlaySounds)? NSOnState:NSOffState]; [windowsOnTopButton setState:(TCGlobalWindowsOnTop)? NSOnState:NSOffState]; + [updateAutomaticallyButton setState:(TCGlobalUpdateCheck)? NSOnState:NSOffState]; [allowRemoteButton setState:(TCGlobalAllowRemote)? NSOnState:NSOffState]; [listenPortTextField setIntValue:TCGlobalListenPort]; [broadcastNameTextField setStringValue:[[NSUserDefaults standardUserDefaults] objectForKey:TCBroadcastNamePref]]; + [hitsDisplayedTextField setIntValue:TCGlobalHitsDisplayed]; + + [self interfaceUpdate]; } - (void)interfaceUpdate { - if ( TCGlobalAllowRemote ) + if ( [allowRemoteButton state] ) { [listenPortTextField setEnabled:YES]; [broadcastNameTextField setEnabled:YES]; @@ -57,70 +60,57 @@ } -- (IBAction)playSoundsButton:(id)sender +- (IBAction)change:(id)sender { - if ( [playSoundsButton state] == NSOnState ) - { - TCGlobalPlaySounds = YES; - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:TCPlaySoundsPref]; - } - else - { - TCGlobalPlaySounds = NO; - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:TCPlaySoundsPref]; - } + [self interfaceUpdate]; } -- (IBAction)windowsOnTopButton:(id)sender -{ - if ( [windowsOnTopButton state] == NSOnState ) - { - TCGlobalWindowsOnTop = YES; - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:TCWindowsOnTopPref]; - } - else - { - TCGlobalWindowsOnTop = NO; - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:TCWindowsOnTopPref]; - } - - [[NSNotificationCenter defaultCenter] postNotificationName:@"TCWindowsOnTopChanged" object:nil]; -} -- (IBAction)allowRemoteButton:(id)sender +- (IBAction)revert:(id)sender { - if ( [allowRemoteButton state] == NSOnState ) - { - TCGlobalAllowRemote = YES; - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:TCAllowRemotePref]; - } - else - { - TCGlobalAllowRemote = NO; - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:TCAllowRemotePref]; - } - - [self interfaceUpdate]; - - [delegate preferenceAllowRemoteChanged:TCGlobalAllowRemote]; + [self initialInterfaceSetup]; } -- (IBAction)listenPortTextField:(id)sender +- (IBAction)apply:(id)sender { + TCGlobalPlaySounds = [playSoundsButton state]; + [[NSUserDefaults standardUserDefaults] setBool:TCGlobalPlaySounds forKey:TCPlaySoundsPref]; + + // send window information to the delegate so the necessary adjustments can be made + [delegate preferenceSetWindowsOnTop:[windowsOnTopButton state]]; + + TCGlobalWindowsOnTop = [windowsOnTopButton state]; + [[NSUserDefaults standardUserDefaults] setBool:TCGlobalWindowsOnTop forKey:TCWindowsOnTopPref]; + + TCGlobalUpdateCheck = [updateAutomaticallyButton state]; + [[NSUserDefaults standardUserDefaults] setBool:TCGlobalUpdateCheck forKey:TCUpdateCheckPref]; + + // send server information to the delegate so the server can be updated accordingly + [delegate preferenceSetAllowRemote:[allowRemoteButton state] listenPort:[listenPortTextField intValue] broadcastName:[broadcastNameTextField stringValue]]; + + TCGlobalAllowRemote = [allowRemoteButton state]; + [[NSUserDefaults standardUserDefaults] setBool:TCGlobalAllowRemote forKey:TCAllowRemotePref]; + TCGlobalListenPort = [listenPortTextField intValue]; - [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:TCGlobalListenPort] forKey:TCListenPortPref]; - - [delegate preferenceListenPortChanged:TCGlobalListenPort]; + + [[NSUserDefaults standardUserDefaults] setObject:[broadcastNameTextField stringValue] forKey:TCBroadcastNamePref]; + + TCGlobalHitsDisplayed = [hitsDisplayedTextField intValue]; + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:TCGlobalHitsDisplayed] forKey:TCHitsDisplayedPref]; } -- (IBAction)broadcastNameTextField:(id)sender + +- (IBAction)cancel:(id)sender { - NSString *name = [broadcastNameTextField stringValue]; - - [[NSUserDefaults standardUserDefaults] setObject:name forKey:TCBroadcastNamePref]; + [self initialInterfaceSetup]; + [self close]; +} - [delegate preferenceBroadcastNameChanged:name]; +- (IBAction)save:(id)sender +{ + [self apply:self]; + [self close]; }