diff --git a/Ample.xcodeproj/project.pbxproj b/Ample.xcodeproj/project.pbxproj index c214e07..35b1a3a 100644 --- a/Ample.xcodeproj/project.pbxproj +++ b/Ample.xcodeproj/project.pbxproj @@ -61,6 +61,7 @@ B64E15A924EA1D5300E8AD3D /* MachineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B64E15A824EA1D5300E8AD3D /* MachineViewController.m */; }; B65593B124ECB61800722E0C /* SlotViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B65593B024ECB61800722E0C /* SlotViewController.m */; }; B658DBF324FB58EC0063AB5F /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B6BA258624E99BEB005FB8FF /* Info.plist */; }; + B66236A924FD9A34006CABD7 /* PreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B66236A824FD9A34006CABD7 /* PreferencesWindowController.m */; }; B6BA258024E99BE9005FB8FF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B6BA257F24E99BE9005FB8FF /* AppDelegate.m */; }; B6BA258224E99BEB005FB8FF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B6BA258124E99BEB005FB8FF /* Assets.xcassets */; }; B6BA258524E99BEB005FB8FF /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = B6BA258324E99BEB005FB8FF /* MainMenu.xib */; }; @@ -131,6 +132,8 @@ B64E15A824EA1D5300E8AD3D /* MachineViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MachineViewController.m; sourceTree = ""; }; B65593AF24ECB61800722E0C /* SlotViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SlotViewController.h; sourceTree = ""; }; B65593B024ECB61800722E0C /* SlotViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SlotViewController.m; sourceTree = ""; }; + B66236A724FD9A34006CABD7 /* PreferencesWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PreferencesWindowController.h; sourceTree = ""; }; + B66236A824FD9A34006CABD7 /* PreferencesWindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PreferencesWindowController.m; sourceTree = ""; }; B67BD48424EE249D0073E334 /* apple1.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = apple1.plist; sourceTree = ""; }; B6BA257B24E99BE9005FB8FF /* Ample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Ample.app; sourceTree = BUILT_PRODUCTS_DIR; }; B6BA257E24E99BE9005FB8FF /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -271,6 +274,8 @@ B6D6DE3C24FADF8B00661A5F /* LaunchWindow.xib */, B6004DEF24FB05D600D38596 /* LogWindow.xib */, B6D6DE3724FAC8B500661A5F /* Preferences.xib */, + B66236A724FD9A34006CABD7 /* PreferencesWindowController.h */, + B66236A824FD9A34006CABD7 /* PreferencesWindowController.m */, B61099E524F5F230005CB652 /* MediaView.xib */, B61099E324F5F230005CB652 /* SlotView.xib */, ); @@ -405,6 +410,7 @@ B60A6E1424EE0AE2004B7EEF /* FlippedView.m in Sources */, B6BA258024E99BE9005FB8FF /* AppDelegate.m in Sources */, B6004DF024FB05D600D38596 /* LogWindowController.m in Sources */, + B66236A924FD9A34006CABD7 /* PreferencesWindowController.m in Sources */, B65593B124ECB61800722E0C /* SlotViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Ample/AppDelegate.m b/Ample/AppDelegate.m index 1426754..a41929f 100644 --- a/Ample/AppDelegate.m +++ b/Ample/AppDelegate.m @@ -10,6 +10,7 @@ #import "SlotViewController.h" #import "MediaViewController.h" #import "LaunchWindowController.h" +#import "PreferencesWindowController.h" @interface AppDelegate () @@ -58,7 +59,7 @@ - (IBAction)displayPreferences:(id)sender { if (!_prefs) { - _prefs = [[NSWindowController alloc] initWithWindowNibName: @"Preferences"]; + _prefs = [PreferencesWindowController new]; } [_prefs showWindow: sender]; } diff --git a/Ample/Base.lproj/Preferences.xib b/Ample/Base.lproj/Preferences.xib index 52d23d2..d77c51c 100644 --- a/Ample/Base.lproj/Preferences.xib +++ b/Ample/Base.lproj/Preferences.xib @@ -6,9 +6,10 @@ - + - + + @@ -23,7 +24,7 @@ - + @@ -31,11 +32,12 @@ + - + @@ -44,7 +46,7 @@ + diff --git a/Ample/Defaults.plist b/Ample/Defaults.plist index 8e3cf51..340dd9d 100644 --- a/Ample/Defaults.plist +++ b/Ample/Defaults.plist @@ -2,6 +2,8 @@ + UseSystemMame + AutoCloseLogWindow MamePath diff --git a/Ample/PreferencesWindowController.h b/Ample/PreferencesWindowController.h new file mode 100644 index 0000000..a65f2c8 --- /dev/null +++ b/Ample/PreferencesWindowController.h @@ -0,0 +1,17 @@ +// +// PreferencesWindowController.h +// Ample +// +// Created by Kelvin Sherlock on 8/31/2020. +// Copyright © 2020 Kelvin Sherlock. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface PreferencesWindowController : NSWindowController + +@end + +NS_ASSUME_NONNULL_END diff --git a/Ample/PreferencesWindowController.m b/Ample/PreferencesWindowController.m new file mode 100644 index 0000000..eb97fce --- /dev/null +++ b/Ample/PreferencesWindowController.m @@ -0,0 +1,51 @@ +// +// PreferencesWindowController.m +// Ample +// +// Created by Kelvin Sherlock on 8/31/2020. +// Copyright © 2020 Kelvin Sherlock. All rights reserved. +// + +#import "PreferencesWindowController.h" + +@interface PreferencesWindowController () +@property (weak) IBOutlet NSTextField *pathField; + +@end + +@implementation PreferencesWindowController + +-(NSString *)windowNibName { + return @"Preferences"; +} + +- (void)windowDidLoad { + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + [super windowDidLoad]; + + // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. + + [self validateMamePath: [defaults stringForKey: @"MamePath"]]; + +} + +-(void)validateMamePath: (NSString *)path { + NSFileManager * fm = [NSFileManager defaultManager]; + + if ([path length] == 0 || [fm isExecutableFileAtPath: path]) { + [_pathField setTextColor: [NSColor blackColor]]; + } else { + [_pathField setTextColor: [NSColor redColor]]; + } +} + +- (IBAction)pathChanged:(id)sender { + + NSString *path = [sender stringValue]; + + [self validateMamePath: path]; + +} + + +@end