mirror of
https://github.com/ksherlock/ample.git
synced 2024-06-08 18:29:30 +00:00
add drag-drop dock support for launching vgm files
via mame vgmplay
This commit is contained in:
parent
5840c4ae0c
commit
6e7acb88e2
|
@ -13,6 +13,8 @@
|
||||||
#import "DiskImagesWindowController.h"
|
#import "DiskImagesWindowController.h"
|
||||||
#import "Transformers.h"
|
#import "Transformers.h"
|
||||||
|
|
||||||
|
#import "LogWindowController.h"
|
||||||
|
|
||||||
@interface AppDelegate ()
|
@interface AppDelegate ()
|
||||||
@property (weak) IBOutlet NSWindow *installWindow;
|
@property (weak) IBOutlet NSWindow *installWindow;
|
||||||
|
|
||||||
|
@ -139,6 +141,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-(BOOL)application:(NSApplication *)sender openFile:(NSString *)filename {
|
||||||
|
|
||||||
|
NSString *ext = [[filename pathExtension] lowercaseString];
|
||||||
|
|
||||||
|
if ([ext isEqualToString: @"vgm"] || [ext isEqualToString: @"vgz"]) {
|
||||||
|
// run mame...
|
||||||
|
NSArray *args = @[ @"vgmplay", @"-window", @"-nomax", @"-quik", filename ];
|
||||||
|
|
||||||
|
[LogWindowController controllerForArgs: args];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - IBActions
|
#pragma mark - IBActions
|
||||||
|
|
|
@ -4,6 +4,33 @@
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleDocumentTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>vgm</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Video Game Music</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
<key>LSTypeIsPackage</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>vgz</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Video Game Music</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
<key>LSTypeIsPackage</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>$(EXECUTABLE_NAME)</string>
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
|
|
|
@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
@interface LogWindowController : NSWindowController <NSWindowDelegate>
|
@interface LogWindowController : NSWindowController <NSWindowDelegate>
|
||||||
|
|
||||||
+(id)controllerForTask: (NSTask *)task;
|
+(id)controllerForTask: (NSTask *)task;
|
||||||
|
+(id)controllerForArgs: (NSArray *)args;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -36,6 +36,50 @@ static NSMutableSet *LogWindows;
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NSURL *MameURL(void) {
|
||||||
|
|
||||||
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||||
|
NSBundle *bundle = [NSBundle mainBundle];
|
||||||
|
|
||||||
|
if ([defaults boolForKey: kUseCustomMame]) {
|
||||||
|
NSString *path = [defaults stringForKey: kMamePath];
|
||||||
|
if (![path length]) return [NSURL fileURLWithPath: path];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [bundle URLForAuxiliaryExecutable: @"mame64"];
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
+(id)controllerForArgs: (NSArray *)args {
|
||||||
|
|
||||||
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||||
|
|
||||||
|
NSURL *url = MameURL();
|
||||||
|
|
||||||
|
if (!url) {
|
||||||
|
NSAlert *alert = [NSAlert new];
|
||||||
|
|
||||||
|
[alert setMessageText: @"Unable to find MAME executable path"];
|
||||||
|
[alert runModal];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NSTask *task = [NSTask new];
|
||||||
|
[task setExecutableURL: url];
|
||||||
|
[task setArguments: args];
|
||||||
|
|
||||||
|
if (![defaults boolForKey: kUseCustomMame]) {
|
||||||
|
// run in Application Support/Ample.
|
||||||
|
[task setCurrentDirectoryURL: SupportDirectory()];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [LogWindowController controllerForTask: task];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
- (void)windowDidLoad {
|
- (void)windowDidLoad {
|
||||||
[super windowDidLoad];
|
[super windowDidLoad];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user