X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=ApplicationController.m;h=aa51eeb4f18a0a810a0daaa6c018327e5be24563;hp=8fed5d61f3d047ce6d46586f86e7ba41811a47ed;hb=320e3065d251e11370e571df5705675937b76521;hpb=c6fb77859e508aaef686b7a5a6a12abe29178708 diff --git a/ApplicationController.m b/ApplicationController.m index 8fed5d6..aa51eeb 100644 --- a/ApplicationController.m +++ b/ApplicationController.m @@ -28,7 +28,6 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification { [drawer open]; self.targetController.enabled = NO; - self.active = NO; [self.jsController setup]; [self.configsController load]; [[NSWorkspace sharedWorkspace].notificationCenter @@ -39,31 +38,19 @@ } - (void)applicationWillTerminate:(NSNotification *)aNotification { - // TODO: Save immediately / shortly after changing and then enable - // sudden termination support. - [configsController save]; + [[NSUserDefaults standardUserDefaults] synchronize]; [[NSWorkspace sharedWorkspace].notificationCenter removeObserver:self name:NSWorkspaceDidActivateApplicationNotification object:nil]; } -// TODO: Active state should probably be in the ConfigsController or -// JoystickController, not here. - -- (BOOL)active { - return active; -} - -- (void)setActive:(BOOL)newActive { - activeButton.label = newActive ? @"Stop" : @"Start"; - activeButton.image = [NSImage imageNamed:newActive ? @"NSStopProgressFreestandingTemplate" : @"NSGoRightTemplate"]; - activeMenuItem.state = newActive; - active = newActive; -} - - (IBAction)toggleActivity:(id)sender { - self.active = !self.active; + BOOL sendRealEvents = !self.jsController.sendingRealEvents; + self.jsController.sendingRealEvents = sendRealEvents; + activeButton.label = sendRealEvents ? @"Stop" : @"Start"; + activeButton.image = [NSImage imageNamed:sendRealEvents ? @"NSStopProgressFreestandingTemplate" : @"NSGoRightTemplate"]; + activeMenuItem.state = sendRealEvents; } - (NSUInteger)firstConfigMenuIndex {