SameBoy/Cocoa/AppDelegate.m

54 lines
1.9 KiB
Mathematica
Raw Normal View History

2016-03-30 20:07:55 +00:00
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
2016-04-13 19:43:16 +00:00
{
NSWindow *preferences_window;
}
- (void) applicationDidFinishLaunching:(NSNotification *)notification
{
#define KEY(x) ({unichar __x = x; [NSString stringWithCharacters:&(__x) length:1];})
[[NSUserDefaults standardUserDefaults] registerDefaults:@{
@"GBRight": KEY(NSRightArrowFunctionKey),
@"GBLeft": KEY(NSLeftArrowFunctionKey),
@"GBUp": KEY(NSUpArrowFunctionKey),
@"GBDown": KEY(NSDownArrowFunctionKey),
@"GBA": @"x",
@"GBB": @"z",
@"GBSelect": @"\x7f",
@"GBStart": @"\r",
@"GBTurbo": @" ",
}];
#undef KEY
}
2016-03-30 20:07:55 +00:00
- (IBAction)toggleDeveloperMode:(id)sender {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:![defaults boolForKey:@"DeveloperMode"] forKey:@"DeveloperMode"];
2016-03-30 20:07:55 +00:00
}
- (BOOL)validateMenuItem:(NSMenuItem *)anItem
{
if ([anItem action] == @selector(toggleDeveloperMode:)) {
[(NSMenuItem*)anItem setState:[[NSUserDefaults standardUserDefaults] boolForKey:@"DeveloperMode"]];
}
2016-04-13 19:43:16 +00:00
return true;
2016-03-30 20:07:55 +00:00
}
2016-04-13 19:43:16 +00:00
- (IBAction) showPreferences: (id) sender
{
NSArray *objects;
if (!_preferencesWindow) {
[[NSBundle mainBundle] loadNibNamed:@"Preferences" owner:self topLevelObjects:&objects];
}
[_preferencesWindow makeKeyAndOrderFront:self];
}
2016-03-30 20:07:55 +00:00
@end