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": @" ",
|
2016-04-28 20:07:05 +00:00
|
|
|
|
|
|
|
@"GBFilter": @"NearestNeighbor",
|
2016-04-13 19:43:16 +00:00
|
|
|
}];
|
|
|
|
#undef KEY
|
|
|
|
}
|
2016-03-30 20:07:55 +00:00
|
|
|
|
2016-04-08 10:54:34 +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
|
|
|
}
|
|
|
|
|
2016-04-08 10:54:34 +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-09-10 16:46:42 +00:00
|
|
|
|
2016-10-01 21:10:09 +00:00
|
|
|
- (BOOL)applicationOpenUntitledFile:(NSApplication *)sender
|
2016-09-10 16:46:42 +00:00
|
|
|
{
|
2016-10-01 21:10:09 +00:00
|
|
|
[[NSDocumentController sharedDocumentController] openDocument:self];
|
|
|
|
return YES;
|
2016-09-10 16:46:42 +00:00
|
|
|
}
|
2016-10-01 21:10:09 +00:00
|
|
|
|
2016-03-30 20:07:55 +00:00
|
|
|
@end
|