Skip to content

Commit

Permalink
add gui option to completely disable the log window.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksherlock committed May 25, 2024
2 parents 4a6ba96 + fb7b2f3 commit 60586a9
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 9 deletions.
1 change: 1 addition & 0 deletions Ample/Ample.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern NSString *kMamePath;
extern NSString *kMameWorkingDirectory;
extern NSString *kAutoCloseLogWindow;
extern NSString *kMameComponentsDate;
extern NSString *kUseLogWindow;

extern NSString *kDownloadURL;
extern NSString *kDownloadExtension;
Expand Down
1 change: 1 addition & 0 deletions Ample/Ample.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
NSString *kMamePath = @"MamePath";
NSString *kMameWorkingDirectory = @"MameWorkingDirectory";
NSString *kAutoCloseLogWindow = @"AutoCloseLogWindow";
NSString *kUseLogWindow = @"UseLogWindow";
NSString *kMameComponentsDate = @"MameComponentsDate";
NSString *kDefaultDownloadURL = @"DefaultDownloadURL";
NSString *kDefaultDownloadExtension = @"DefaultDownloadExtension";
Expand Down
27 changes: 19 additions & 8 deletions Ample/Base.lproj/Preferences.xib
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Oz5-Xb-btk">
<rect key="frame" x="138" y="181" width="322" height="21"/>
<rect key="frame" x="138" y="159" width="322" 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"/>
Expand All @@ -40,7 +40,7 @@
</connections>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="l8V-pC-gml">
<rect key="frame" x="138" y="150" width="322" height="21"/>
<rect key="frame" x="138" y="128" width="322" 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="wfj-GY-Qu2">
<font key="font" usesAppearanceFont="YES"/>
Expand All @@ -49,12 +49,12 @@
</textFieldCell>
<connections>
<action selector="wdChanged:" target="-2" id="g1P-8l-ZXi"/>
<binding destination="yvB-HG-64y" name="enabled" keyPath="values.UseCustomMame" id="DeG-OW-Gd2"/>
<binding destination="yvB-HG-64y" name="value" keyPath="values.MameWorkingDirectory" id="Kc9-Pc-XGU"/>
<binding destination="yvB-HG-64y" name="enabled" keyPath="values.UseCustomMame" id="DeG-OW-Gd2"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vTJ-Ez-c1R">
<rect key="frame" x="18" y="153" width="114" height="16"/>
<rect key="frame" x="18" y="131" width="114" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Working Directory" id="UHt-0s-zxA">
<font key="font" metaFont="system"/>
Expand All @@ -63,7 +63,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KAN-P2-ydI">
<rect key="frame" x="136" y="234" width="217" height="18"/>
<rect key="frame" x="136" y="212" 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"/>
Expand All @@ -74,7 +74,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="j7D-jC-17Q">
<rect key="frame" x="136" y="208" width="139" height="18"/>
<rect key="frame" x="136" y="186" width="139" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<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"/>
Expand All @@ -96,17 +96,28 @@
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Qmb-Ag-Xyr">
<rect key="frame" x="58" y="184" width="74" height="16"/>
<rect key="frame" x="58" y="162" 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"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qT7-cc-Phc">
<rect key="frame" x="136" y="234" width="118" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Use log window" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="Adv-KH-abG">
<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.UseLogWindow" id="meK-Jb-s8b"/>
</connections>
</button>
</subviews>
</view>
<point key="canvasLocation" x="140" y="147"/>
<point key="canvasLocation" x="80" y="144"/>
</window>
<userDefaultsController id="KVS-Ag-1un"/>
<userDefaultsController representsSharedInstance="YES" id="yvB-HG-64y"/>
Expand Down
2 changes: 2 additions & 0 deletions Ample/Defaults.plist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<true/>
<key>DefaultDownloadURL</key>
<string>https://archive.org/download/mame-merged/mame-merged</string>
<key>UseLogWindow</key>
<true/>
<key>DefaultDownloadExtension</key>
<string>zip</string>
</dict>
Expand Down
28 changes: 27 additions & 1 deletion Ample/LogWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ -(NSString *)windowNibName {
}


+(id)controllerForTask: (NSTask *)task close: (BOOL)close{
+(id)controllerForTask: (NSTask *)task close: (BOOL)close {
LogWindowController *controller = [[LogWindowController alloc] initWithWindowNibName: @"LogWindow"];
[controller runTask: task close: close];
return controller;
Expand All @@ -43,6 +43,8 @@ +(id)controllerForTask: (NSTask *)task close: (BOOL)close{

+(id)controllerForArgs: (NSArray *)args close: (BOOL)close {

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

NSURL *url = MameURL();

if (!url) {
Expand All @@ -65,6 +67,30 @@ +(id)controllerForArgs: (NSArray *)args close: (BOOL)close {

[task setArguments: args];

if ([defaults boolForKey: kUseLogWindow] == NO) {

NSAlert *alert = nil;
if (@available(macOS 10.13, *)) {
NSError *error = nil;

[task launchAndReturnError: &error];
if (error) {
alert = [NSAlert alertWithError: error];
}
} else {
@try {
[task launch];
} @catch (NSException *exception) {

alert = [NSAlert new];
[alert setMessageText: [exception reason]];
}
}
if (alert) [alert runModal];
return nil;
}


return [LogWindowController controllerForTask: task close: close];

}
Expand Down

0 comments on commit 60586a9

Please sign in to comment.