diff --git a/MA2ME.xcodeproj/project.pbxproj b/MA2ME.xcodeproj/project.pbxproj index 87789f9..d19dd62 100644 --- a/MA2ME.xcodeproj/project.pbxproj +++ b/MA2ME.xcodeproj/project.pbxproj @@ -63,6 +63,8 @@ B6BA258224E99BEB005FB8FF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B6BA258124E99BEB005FB8FF /* Assets.xcassets */; }; B6BA258524E99BEB005FB8FF /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = B6BA258324E99BEB005FB8FF /* MainMenu.xib */; }; B6BA258824E99BEB005FB8FF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B6BA258724E99BEB005FB8FF /* main.m */; }; + B6D6DE3924FAC8B500661A5F /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = B6D6DE3724FAC8B500661A5F /* Preferences.xib */; }; + B6D6DE3B24FACF4F00661A5F /* Defaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = B6D6DE3A24FACF4F00661A5F /* Defaults.plist */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -133,6 +135,8 @@ B6BA258624E99BEB005FB8FF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B6BA258724E99BEB005FB8FF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; B6BA258924E99BEB005FB8FF /* MA2ME.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MA2ME.entitlements; sourceTree = ""; }; + B6D6DE3824FAC8B500661A5F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/Preferences.xib; sourceTree = ""; }; + B6D6DE3A24FACF4F00661A5F /* Defaults.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Defaults.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -242,9 +246,11 @@ B64E15AB24EA1FD400E8AD3D /* SlotBrowserDelegate.m */, B64E15AF24EA365E00E8AD3D /* Resources */, B6BA258624E99BEB005FB8FF /* Info.plist */, + B6D6DE3A24FACF4F00661A5F /* Defaults.plist */, B6BA258724E99BEB005FB8FF /* main.m */, B6BA258924E99BEB005FB8FF /* MA2ME.entitlements */, B6BA258324E99BEB005FB8FF /* MainMenu.xib */, + B6D6DE3724FAC8B500661A5F /* Preferences.xib */, B61099E524F5F230005CB652 /* MediaView.xib */, B61099E324F5F230005CB652 /* SlotView.xib */, ); @@ -343,6 +349,7 @@ B6109A4324F5F377005CB652 /* agat7.plist in Resources */, B6109A2B24F5F377005CB652 /* elppa.plist in Resources */, B6109A3B24F5F377005CB652 /* apple2gsr1.plist in Resources */, + B6D6DE3B24FACF4F00661A5F /* Defaults.plist in Resources */, B6109A2224F5F377005CB652 /* models.plist in Resources */, B6109A4024F5F377005CB652 /* craft2p.plist in Resources */, B6109A1B24F5F377005CB652 /* uniap2pt.plist in Resources */, @@ -352,6 +359,7 @@ B6109A2A24F5F377005CB652 /* apple3.plist in Resources */, B6109A2124F5F377005CB652 /* apple2ee.plist in Resources */, B6109A3624F5F377005CB652 /* dodo.plist in Resources */, + B6D6DE3924FAC8B500661A5F /* Preferences.xib in Resources */, B61099E724F5F231005CB652 /* SlotView.xib in Resources */, B6109A2924F5F377005CB652 /* apple2gs.plist in Resources */, B6109A1F24F5F377005CB652 /* apple2jp.plist in Resources */, @@ -404,6 +412,14 @@ name = MainMenu.xib; sourceTree = ""; }; + B6D6DE3724FAC8B500661A5F /* Preferences.xib */ = { + isa = PBXVariantGroup; + children = ( + B6D6DE3824FAC8B500661A5F /* Base */, + ); + name = Preferences.xib; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ diff --git a/MA2ME/AppDelegate.h b/MA2ME/AppDelegate.h index e613254..6483083 100644 --- a/MA2ME/AppDelegate.h +++ b/MA2ME/AppDelegate.h @@ -10,6 +10,7 @@ @interface AppDelegate : NSObject +- (IBAction)displayPreferences:(id)sender; @end diff --git a/MA2ME/AppDelegate.m b/MA2ME/AppDelegate.m index 81c580d..25cc7b8 100644 --- a/MA2ME/AppDelegate.m +++ b/MA2ME/AppDelegate.m @@ -34,18 +34,34 @@ @property NSArray *browserItems; @end -@implementation AppDelegate +@implementation AppDelegate { + NSWindowController *_prefs; +} static NSString *kMyContext = @"kMyContext"; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code here to initialize your application + NSBundle *bundle = [NSBundle mainBundle]; + NSString *path; + NSDictionary *dict; + + + path = [bundle pathForResource: @"Defaults" ofType: @"plist"]; + dict = [NSDictionary dictionaryWithContentsOfFile: path]; + + if (dict) + { + [[NSUserDefaults standardUserDefaults] registerDefaults: dict]; + } + + /* My Copy of XCode/Interface Builder barfs on NSBrowser. */ - NSBundle *bundle = [NSBundle mainBundle]; - NSString *path = [bundle pathForResource: @"models" ofType: @"plist"]; + + path = [bundle pathForResource: @"models" ofType: @"plist"]; _browserItems = [NSArray arrayWithContentsOfFile: path]; NSView *view = [_window contentView]; @@ -332,8 +348,13 @@ static NSString * JoinArguments(NSArray *argv) { - (IBAction)launchAction:(id)sender { if (![_args count]) return; + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + + NSString *path = [defaults stringForKey: @"MamePath"]; + if (![path length]) path = @"/usr/local/bin/mame"; + NSError *error = nil; - NSURL *url = [NSURL fileURLWithPath: @"/usr/local/bin/mame"]; + NSURL *url = [NSURL fileURLWithPath: path]; NSTask *task = [NSTask launchedTaskWithExecutableURL: url arguments: _args @@ -347,6 +368,12 @@ static NSString * JoinArguments(NSArray *argv) { if (error) NSLog(@"launchAction: %@", error); } +- (IBAction)displayPreferences:(id)sender { + if (!_prefs) { + _prefs = [[NSWindowController alloc] initWithWindowNibName: @"Preferences"]; + } + [_prefs showWindow: sender]; +} @end diff --git a/MA2ME/Base.lproj/MainMenu.xib b/MA2ME/Base.lproj/MainMenu.xib index ae31839..8e9c763 100644 --- a/MA2ME/Base.lproj/MainMenu.xib +++ b/MA2ME/Base.lproj/MainMenu.xib @@ -37,7 +37,11 @@ - + + + + + @@ -774,6 +778,14 @@ + @@ -782,6 +794,6 @@ - + diff --git a/MA2ME/Base.lproj/Preferences.xib b/MA2ME/Base.lproj/Preferences.xib new file mode 100644 index 0000000..dfe9078 --- /dev/null +++ b/MA2ME/Base.lproj/Preferences.xib @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MA2ME/Defaults.plist b/MA2ME/Defaults.plist new file mode 100644 index 0000000..7282f80 --- /dev/null +++ b/MA2ME/Defaults.plist @@ -0,0 +1,8 @@ + + + + + MamePath + /usr/local/bin/mame + +