Compare commits

...

4 Commits

9 changed files with 101 additions and 36 deletions

View File

@ -1446,6 +1446,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 0.232;
PRODUCT_BUNDLE_IDENTIFIER = com.ksherlock.ample;
PRODUCT_NAME = "$(TARGET_NAME)";
@ -1466,6 +1467,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 0.232;
PRODUCT_BUNDLE_IDENTIFIER = com.ksherlock.ample;
PRODUCT_NAME = "$(TARGET_NAME)";

View File

@ -96,10 +96,15 @@
@"xfz",
path
];
[task setExecutableURL: [NSURL fileURLWithPath: @"/usr/bin/tar"]];
if (@available(macOS 10.13, *)) {
[task setExecutableURL: [NSURL fileURLWithPath: @"/usr/bin/tar"]];
[task setCurrentDirectoryURL: sd];
} else {
[task setLaunchPath: @"/usr/bin/tar"];
[task setCurrentDirectoryPath: SupportDirectoryPath()];
}
[task setArguments: argv];
[task setCurrentDirectoryURL: sd];
dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC));
[task setTerminationHandler: ^(NSTask *task){

View File

@ -411,8 +411,11 @@ Todo --
-(void)_init {
_backgroundColor = [NSColor windowBackgroundColor];
_selectedColor = [NSColor selectedContentBackgroundColor];
if (@available(macOS 10.14, *)) {
_selectedColor = [NSColor selectedContentBackgroundColor];
} else {
_selectedColor = [NSColor selectedTextBackgroundColor];
}
NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingActiveInActiveApp;
_trackingArea = [[NSTrackingArea alloc] initWithRect: NSZeroRect
options: options

View File

@ -1,16 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
<plugIn identifier="com.apple.WebKit2IBPlugin" version="15705"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="CheatSheetWindowController">
<connections>
<outlet property="_webView" destination="Yc9-xA-jWX" id="rsd-1e-HPk"/>
<outlet property="webView" destination="Yc9-xA-jWX" id="EE3-gk-f71"/>
<outlet property="window" destination="QvC-M9-y7g" id="U2v-sN-OzH"/>
</connections>
</customObject>
@ -23,19 +19,6 @@
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="640" height="640"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<wkWebView hidden="YES" wantsLayer="YES" fixedFrame="YES" allowsLinkPreview="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yc9-xA-jWX">
<rect key="frame" x="0.0" y="0.0" width="640" height="640"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<wkWebViewConfiguration key="configuration">
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<wkPreferences key="preferences" javaScriptCanOpenWindowsAutomatically="NO"/>
</wkWebViewConfiguration>
<connections>
<outlet property="navigationDelegate" destination="-2" id="1WW-1B-FdZ"/>
</connections>
</wkWebView>
</subviews>
</view>
<connections>
<outlet property="delegate" destination="-2" id="u4H-aq-RE2"/>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>

View File

@ -27,6 +27,20 @@
- (void)windowDidLoad {
[super windowDidLoad];
if (!_webView) {
WKWebView *webView;
NSWindow *window = [self window];
CGRect frame = [[window contentView] frame];
webView = [WKWebView new];
[webView setFrame: frame];
[webView setNavigationDelegate: self];
[[window contentView]addSubview: webView];
_webView = webView;
}
[_webView setHidden: YES];
NSBundle *bundle = [NSBundle mainBundle];
NSURL *url = [bundle URLForResource: @"CheatSheet" withExtension: @"html"];

View File

@ -67,8 +67,11 @@
[window setRestorable: YES];
[window setRestorationClass: [self class]];
[_tableView registerForDraggedTypes: @[NSPasteboardTypeFileURL]];
if (@available(macOS 10.13, *)) {
[_tableView registerForDraggedTypes: @[NSPasteboardTypeFileURL]];
} else {
[_tableView registerForDraggedTypes: @[NSURLPboardType]];
}
[_tableView setDraggingSourceOperationMask: NSDragOperationCopy forLocal: NO]; // enable drag/drop to othr apps.
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
@ -95,6 +98,11 @@
[nc addObserver: self selector: @selector(willTerminate:) name: NSApplicationWillTerminateNotification object: nil];
}
-(void)timerCallback: (NSTimer *)timer {
_timer = nil;
[self saveFile];
}
-(void)diskImageAdded: (NSNotification *)notification {
NSURL *url = [notification object];
@ -105,11 +113,15 @@
-(void)markDirty {
_dirty = YES;
if (_timer) [_timer invalidate];
_timer = [NSTimer scheduledTimerWithTimeInterval: 5 * 60 target: self selector: @selector(timerCallback:) userInfo: nil repeats: NO];
#if 0
// 10.12+
_timer = [NSTimer scheduledTimerWithTimeInterval: 5 * 60 repeats: NO block: ^(NSTimer *t) {
self->_timer = nil;
[self saveFile];
}];
#endif
}
-(void)saveFile {
@ -306,11 +318,15 @@
for (NSPasteboardItem *item in [pb pasteboardItems]) {
// need to convert from a string to a url back to a file in case it's a file id url?
NSString *s = [item stringForType: NSPasteboardTypeFileURL];
NSString *s;
if (@available(macOS 10.13, *)) {
s = [item stringForType: NSPasteboardTypeFileURL];
} else {
s = [item stringForType: NSURLPboardType];
}
if (!s) continue;
NSURL *url = [NSURL URLWithString: s];
if (!url) continue;
ok |= [self addFile: url];
}
return ok;

View File

@ -53,9 +53,16 @@ static NSMutableSet *LogWindows;
}
NSTask *task = [NSTask new];
[task setExecutableURL: url];
if (@available(macOS 10.13, *)) {
[task setExecutableURL: url];
[task setCurrentDirectoryURL: MameWorkingDirectory()];
} else {
[task setLaunchPath: MamePath()];
[task setCurrentDirectoryPath: MameWorkingDirectoryPath()];
}
[task setArguments: args];
[task setCurrentDirectoryURL: MameWorkingDirectory()];
return [LogWindowController controllerForTask: task];
}
@ -84,20 +91,39 @@ static NSMutableSet *LogWindows;
if (_task) return nil;
NSError *error = nil;
NSPipe *pipe = [NSPipe pipe];
// window not yet loaded until [self window] called.
const char *path = [[task executableURL] fileSystemRepresentation];
// if (cp) [self appendString: [NSString stringWithFormat: @"MAME path: %s", cp]];
const char *wd = [[task currentDirectoryURL] fileSystemRepresentation];
// if (cp) [self appendString: [NSString stringWithFormat: @"Working Directory: %s", cp]];
const char *path = nil;
const char *wd = nil;
[task setStandardError: pipe];
[task setStandardOutput: pipe];
[task launchAndReturnError: &error];
if (@available(macOS 10.13, *)) {
NSError *error = nil;
path = [[task executableURL] fileSystemRepresentation];
wd = [[task currentDirectoryURL] fileSystemRepresentation];
[task launchAndReturnError: &error];
if (error) {
NSLog(@"NSTask error. Path = %s error = %@", path, error);
}
return error;
} else {
path = [[task launchPath] fileSystemRepresentation];
wd = [[task currentDirectoryPath] fileSystemRepresentation];
@try {
[task launch];
} @catch (NSException *exception) {
NSLog(@"NSTask exception. Path = %s exception = %@", path, exception);
return nil; // ?
}
}
#if 0
if (error) {
// NSURL *url = [task executableURL];
// NSString *path = [NSString stringWithCString: [url fileSystemRepresentation] encoding: NSUTF8StringEncoding];
@ -106,6 +132,7 @@ static NSMutableSet *LogWindows;
// [self appendString: [error description]];
return error;
}
#endif
_task = task;
NSString *title = [NSString stringWithFormat: @"Ample Log - %u", [task processIdentifier]];
[[self window] setTitle: title];

16
embedded/download-sdl.sh Normal file
View File

@ -0,0 +1,16 @@
#!/bin/sh
DMG=SDL2-2.0.14.dmg
URL=https://www.libsdl.org/release/SDL2-2.0.14.dmg
FRAMEWORK=SDL2.framework
if [ -e $FRAMEWORK ] ; then exit 0 ; fi
if [ ! -e $DMG ] ; then curl -OL $URL ; fi
hdiutil attach $DMG -noverify -nobrowse -mountpoint /Volumes/sdl_disk_image
# cp -r /sdl_disk_image/$FRAMEWORK ./
ditto /Volumes/sdl_disk_image/$FRAMEWORK $FRAMEWORK
hdiutil detach /Volumes/sdl_disk_image