mirror of
https://github.com/ksherlock/ample.git
synced 2025-01-09 00:29:58 +00:00
Preferences Window Controller
validate the Mame executable path option for system mame (doesn't do anything yet...)
This commit is contained in:
parent
3cbc69bf38
commit
337b3eb1f2
@ -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 = "<group>"; };
|
||||
B65593AF24ECB61800722E0C /* SlotViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SlotViewController.h; sourceTree = "<group>"; };
|
||||
B65593B024ECB61800722E0C /* SlotViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SlotViewController.m; sourceTree = "<group>"; };
|
||||
B66236A724FD9A34006CABD7 /* PreferencesWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PreferencesWindowController.h; sourceTree = "<group>"; };
|
||||
B66236A824FD9A34006CABD7 /* PreferencesWindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PreferencesWindowController.m; sourceTree = "<group>"; };
|
||||
B67BD48424EE249D0073E334 /* apple1.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = apple1.plist; sourceTree = "<group>"; };
|
||||
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 = "<group>"; };
|
||||
@ -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;
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -6,9 +6,10 @@
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSWindowController">
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="PreferencesWindowController">
|
||||
<connections>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="SHw-b5-d6g"/>
|
||||
<outlet property="pathField" destination="Oz5-Xb-btk" id="EnV-kr-0XI"/>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="xJa-tx-X62"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
@ -23,7 +24,7 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Oz5-Xb-btk">
|
||||
<rect key="frame" x="98" y="229" width="362" height="21"/>
|
||||
<rect key="frame" x="98" y="181" width="362" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="vDR-2V-qxd">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
@ -31,11 +32,12 @@
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<action selector="pathChanged:" target="-2" id="RRj-dC-q2y"/>
|
||||
<binding destination="yvB-HG-64y" name="value" keyPath="values.MamePath" id="H3O-1l-peo"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Qmb-Ag-Xyr">
|
||||
<rect key="frame" x="18" y="232" width="74" height="16"/>
|
||||
<rect key="frame" x="18" y="184" width="74" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="MAME Path" id="Xcq-4g-Wlw">
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -44,7 +46,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KAN-P2-ydI">
|
||||
<rect key="frame" x="96" y="205" width="217" height="18"/>
|
||||
<rect key="frame" x="96" y="234" width="217" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="check" title="Close log window on normal exit" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="QMz-O0-06U">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
@ -54,6 +56,17 @@
|
||||
<binding destination="yvB-HG-64y" name="value" keyPath="values.AutoCloseLogWindow" id="q0L-GA-wM2"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="j7D-jC-17Q">
|
||||
<rect key="frame" x="96" y="208" width="137" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="check" title="Use System MAME" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="V61-mz-QFo">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="yvB-HG-64y" name="value" keyPath="values.UseSystemMame" id="jIh-qD-e5H"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="140" y="147"/>
|
||||
|
@ -2,6 +2,8 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>UseSystemMame</key>
|
||||
<true/>
|
||||
<key>AutoCloseLogWindow</key>
|
||||
<true/>
|
||||
<key>MamePath</key>
|
||||
|
17
Ample/PreferencesWindowController.h
Normal file
17
Ample/PreferencesWindowController.h
Normal file
@ -0,0 +1,17 @@
|
||||
//
|
||||
// PreferencesWindowController.h
|
||||
// Ample
|
||||
//
|
||||
// Created by Kelvin Sherlock on 8/31/2020.
|
||||
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface PreferencesWindowController : NSWindowController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
51
Ample/PreferencesWindowController.m
Normal file
51
Ample/PreferencesWindowController.m
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user