From c97033b81c623883e0b74e91319f4d05be157c65 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 8 Apr 2016 13:54:34 +0300 Subject: [PATCH] Console output is now configurable in the Cocoa port as "Developer Mode" --- Cocoa/AppDelegate.h | 1 + Cocoa/AppDelegate.m | 15 +++++++++++---- Cocoa/Document.m | 18 +++++++++++++----- Cocoa/MainMenu.xib | 12 ++++++++++-- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Cocoa/AppDelegate.h b/Cocoa/AppDelegate.h index 69b6e0f..c38bd96 100644 --- a/Cocoa/AppDelegate.h +++ b/Cocoa/AppDelegate.h @@ -2,6 +2,7 @@ @interface AppDelegate : NSObject +- (IBAction)toggleDeveloperMode:(id)sender; @end diff --git a/Cocoa/AppDelegate.m b/Cocoa/AppDelegate.m index d443346..1fe8d99 100644 --- a/Cocoa/AppDelegate.m +++ b/Cocoa/AppDelegate.m @@ -6,12 +6,19 @@ @implementation AppDelegate -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - // Insert code here to initialize your application +- (IBAction)toggleDeveloperMode:(id)sender { + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + [defaults setBool:![defaults boolForKey:@"DeveloperMode"] forKey:@"DeveloperMode"]; } -- (void)applicationWillTerminate:(NSNotification *)aNotification { - // Insert code here to tear down your application +- (BOOL)validateMenuItem:(NSMenuItem *)anItem +{ + if ([anItem action] == @selector(toggleDeveloperMode:)) { + [(NSMenuItem*)anItem setState:[[NSUserDefaults standardUserDefaults] boolForKey:@"DeveloperMode"]]; + return true; + } + + return false; } @end diff --git a/Cocoa/Document.m b/Cocoa/Document.m index 0c1f9ca..7d41360 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -1,6 +1,7 @@ #include #include "AudioClient.h" -#import "Document.h" +#include "Document.h" +#include "AppDelegate.h" #include "gb.h" @interface Document () @@ -234,15 +235,20 @@ static uint32_t rgbEncode(GB_gameboy_t *gb, unsigned char r, unsigned char g, un if([anItem action] == @selector(mute:)) { [(NSMenuItem*)anItem setState:!self.audioClient.isPlaying]; } - if ([anItem action] == @selector(togglePause:)) { + else if ([anItem action] == @selector(togglePause:)) { [(NSMenuItem*)anItem setState:!running]; } - if ([anItem action] == @selector(reset:) && anItem.tag != 0) { + else if ([anItem action] == @selector(reset:) && anItem.tag != 0) { [(NSMenuItem*)anItem setState:(anItem.tag == 1 && !gb.is_cgb) || (anItem.tag == 2 && gb.is_cgb)]; } - if([anItem action] == @selector(toggleBlend:)) { + else if ([anItem action] == @selector(toggleBlend:)) { [(NSMenuItem*)anItem setState:self.view.shouldBlendFrameWithPrevious]; } + else if ([anItem action] == @selector(interrupt:)) { + if (![[NSUserDefaults standardUserDefaults] boolForKey:@"DeveloperMode"]) { + return false; + } + } return [super validateUserInterfaceItem:anItem]; } @@ -307,7 +313,9 @@ static uint32_t rgbEncode(GB_gameboy_t *gb, unsigned char r, unsigned char g, un [self log:"[...]\n"]; } [self.consoleOutput scrollToEndOfDocument:nil]; - [self.consoleWindow orderBack:nil]; + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DeveloperMode"]) { + [self.consoleWindow orderBack:nil]; + } } pendingLogLines--; }); diff --git a/Cocoa/MainMenu.xib b/Cocoa/MainMenu.xib index 79d13ab..fd5a96d 100644 --- a/Cocoa/MainMenu.xib +++ b/Cocoa/MainMenu.xib @@ -1,7 +1,7 @@ - + - + @@ -342,6 +342,13 @@ + + + + + + + @@ -353,6 +360,7 @@ +