Console output is now configurable in the Cocoa port as "Developer Mode"

This commit is contained in:
Lior Halphon 2016-04-08 13:54:34 +03:00
parent d580a33a7f
commit c97033b81c
4 changed files with 35 additions and 11 deletions

View File

@ -2,6 +2,7 @@
@interface AppDelegate : NSObject <NSApplicationDelegate>
- (IBAction)toggleDeveloperMode:(id)sender;
@end

View File

@ -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

View File

@ -1,6 +1,7 @@
#include <CoreAudio/CoreAudio.h>
#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,8 +313,10 @@ static uint32_t rgbEncode(GB_gameboy_t *gb, unsigned char r, unsigned char g, un
[self log:"[...]\n"];
}
[self.consoleOutput scrollToEndOfDocument:nil];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DeveloperMode"]) {
[self.consoleWindow orderBack:nil];
}
}
pendingLogLines--;
});
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="14F1509" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8191"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@ -342,6 +342,13 @@
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Developer" id="UVb-cc-at0">
<items>
<menuItem title="Developer Mode" id="Qx6-Tt-zZR">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleDeveloperMode:" target="Voe-Tx-rLC" id="PIc-o3-bzb"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="66c-T0-8pW"/>
<menuItem title="Show Console" id="Wse-UY-Y9l">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
@ -353,6 +360,7 @@
<action selector="clearConsole:" target="-1" id="1UW-8J-Uwl"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="3If-Yf-U7B"/>
<menuItem title="Break Debugger" keyEquivalent="c" id="uBD-GY-Doi">
<modifierMask key="keyEquivalentModifierMask" control="YES"/>
<connections>