Change wording on system mame preference.

disable path when using standard mame
new functions to calculate mame executable path.
This commit is contained in:
Kelvin Sherlock 2020-08-31 18:23:48 -04:00
parent 1f47c7be88
commit 348353199f
3 changed files with 53 additions and 13 deletions

View File

@ -33,6 +33,7 @@
</textFieldCell>
<connections>
<action selector="pathChanged:" target="-2" id="RRj-dC-q2y"/>
<binding destination="yvB-HG-64y" name="enabled" keyPath="values.UseCustomMame" id="iex-A9-Db6"/>
<binding destination="yvB-HG-64y" name="value" keyPath="values.MamePath" id="H3O-1l-peo"/>
</connections>
</textField>
@ -57,14 +58,14 @@
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="j7D-jC-17Q">
<rect key="frame" x="96" y="208" width="137" height="18"/>
<rect key="frame" x="96" y="208" width="139" 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">
<buttonCell key="cell" type="check" title="Use Custom 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"/>
<binding destination="yvB-HG-64y" name="value" keyPath="values.UseCustomMame" id="lH4-dm-kQC"/>
</connections>
</button>
</subviews>

View File

@ -2,8 +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>UseCustomMame</key>
<false/>
<key>AutoCloseLogWindow</key>
<true/>
<key>MamePath</key>

View File

@ -91,6 +91,39 @@ static NSString *kContextMachine = @"kContextMachine";
}
}
static NSURL *MameURL(void) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSBundle *bundle = [NSBundle mainBundle];
if ([defaults boolForKey: @"UseSystemMame"]) {
NSString *path = [defaults stringForKey: @"MamePath"];
if (![path length]) return [NSURL fileURLWithPath: path];
}
return [bundle URLForAuxiliaryExecutable: @"mame64"];
return nil;
}
static NSString *MamePath(void) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSBundle *bundle = [NSBundle mainBundle];
NSString *path;
if ([defaults boolForKey: @"UseCustomMame"]) {
path = [defaults stringForKey: @"MamePath"];
if ([path length]) return path;
}
path = [bundle pathForAuxiliaryExecutable: @"mame64"];
if ([path length]) return path;
return nil;
}
static NSString * JoinArguments(NSArray *argv) {
static NSCharacterSet *safe = nil;
@ -110,7 +143,10 @@ static NSString * JoinArguments(NSArray *argv) {
//unsigned ix = 0;
[rv appendString: @"mame"];
//[rv appendString: @"mame"];
NSString *path = MamePath();
path = path ? [path lastPathComponent] : @"mame";
[rv appendString: path];
for (NSString *s in argv) {
[rv appendString: @" "];
NSUInteger l = [s length];
@ -224,17 +260,20 @@ static NSString * JoinArguments(NSArray *argv) {
- (IBAction)launchAction:(id)sender {
if (![_args count]) return;
NSURL *url = MameURL();
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *path = [defaults stringForKey: @"MamePath"];
if (![path length]) path = @"/usr/local/bin/mame";
NSURL *url = [NSURL fileURLWithPath: path];
if (!url) {
NSAlert *alert = [NSAlert new];
[alert setMessageText: @"Unable to find MAME executable path"];
[alert runModal];
return;
}
NSTask *task = [NSTask new];
[task setExecutableURL: url];