ample/Ample/AppDelegate.m

317 lines
8.7 KiB
Mathematica
Raw Permalink Normal View History

2020-08-16 16:53:17 +00:00
//
// AppDelegate.m
2020-08-30 03:24:49 +00:00
// Ample
2020-08-16 16:53:17 +00:00
//
// Created by Kelvin Sherlock on 8/16/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import "Ample.h"
2020-08-16 16:53:17 +00:00
#import "AppDelegate.h"
#import "LaunchWindowController.h"
#import "PreferencesWindowController.h"
2020-09-03 04:15:50 +00:00
#import "DownloadWindowController.h"
#import "DiskImagesWindowController.h"
#import "CheatSheetWindowController.h"
#import "BookmarkWindowController.h"
#import "Transformers.h"
Squashed commit of the following: commit 78c81626670fdf41fa6bdd71a4243a89a0746615 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon Jun 7 00:33:48 2021 -0400 check if software set has a particular entry. commit ef5ab6b6948dc3bbbe2947ea099fcacd08435e86 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 22:20:34 2021 -0400 fix scroller background on recent disk images window. commit dee56fa50e87299b396b48361bd0a780aaaaa768 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 21:26:23 2021 -0400 update cheat sheet javascript to work with 10.11 * => functions not supported * NodeList.prototype.forEach not supported. commit b00cc05413f4ebd6d6d58f96e24303008608f3a6 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 17:10:41 2021 -0400 default full machine name for bookmark entry. commit a671cafdc98051b56b12cdd3ccd13c22f54f605a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:39:32 2021 -0400 loading a bookmark wasn't updating the media. commit 3000e0eb1b10bede3345aaab8478e9ec209f328c Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:38:53 2021 -0400 bump copyright year. commit 45222dacd4aa0047fae63a9112509de57139df63 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:38:23 2021 -0400 add reset w/ value for setting the item explicitely. commit cc7fde1253b71c4d8655eb4c010bbf4e61333a15 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:37:48 2021 -0400 add checkboxes for bitbanger/share directory. The general idea is it's easier to toggle a checkbox than to type/retype a path. commit 5674b2d7f6b0e2f0b973197bf3493ad61bf46428 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:43 2021 -0400 commentary on searches with diacritics. commit ec60634dcd9c573130dc34673b4d3fe597ea2b42 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:22 2021 -0400 clean up auto-complete a little bit when setting a value directly. commit 1a182bbdab237c89d355d8294b5a4a64b785783a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 13:08:29 2021 -0400 fix text color when value is set. There are still some bugs relating to multiple copies of the value being stored. commit 49c0bc15c73446259d8cc151cf52d6058644db76 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 12:09:44 2021 -0400 reset all controls first. commit 059797ad85b057e296cc707b4645f839bfccac13 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 10:52:06 2021 -0400 more bookmark loading. commit e5a612d9f8e7414dd15c66dbaa540b637765eeec Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:38 2021 -0400 bookmark - restore the software commit f9411a1e84df7bd46e352cc5ca995b585c2a0523 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:25 2021 -0400 clean up software / name logic. commit f628d99e4a70d65ea8703f3c182103cd3bfea969 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:21:08 2021 -0400 load bookmark... commit 0b248e6aad16cba848f88d294a1366cea5760aa0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:20:42 2021 -0400 stringValue can't be nil. commit 94aac38af45c3c95cb86b176393a469279c2539e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:04:37 2021 -0400 add bookmark menu commit 6215a0df120b6cd97f1ffea2d2db9aaa5ae61f29 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:03:29 2021 -0400 slot view needs to know the machine. commit d348c15dc56d9cee01e5417435dd236e0e541902 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:58 2021 -0400 transformer to enable/disable control based on string length. commit e14336a0094af7aa84e91da69ff59ebb9e8eea9b Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:14 2021 -0400 shut up compiler warning. commit 4baf545245d8d3debf8f436b36b14cca23bf7a33 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:01:15 2021 -0400 bookmark manager commit 0f3e6c83075a145a456728b57a499cfa35707002 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 23:54:29 2021 -0400 more (untested) bookmark code commit 8fdb149eb38952b13c4a78d7a6940c43d90870f1 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:13:43 2021 -0400 start of bookmarking support. Untested. commit 787eac87f6ac13cd677630cbaf2538cecab27b1f Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:12:45 2021 -0400 shut up warnings about content clipping. maybe it's a 10.11 thing. The size was chosen by interface builder.
2021-06-07 04:34:26 +00:00
#import "BookmarkManager.h"
2020-08-16 20:23:51 +00:00
#import "LogWindowController.h"
2020-08-16 16:53:17 +00:00
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *installWindow;
2020-08-16 16:53:17 +00:00
@end
2020-08-29 18:40:34 +00:00
@implementation AppDelegate {
NSWindowController *_prefs;
NSWindowController *_launcher;
2020-09-03 04:15:50 +00:00
NSWindowController *_downloader;
NSWindowController *_diskImages;
NSWindowController *_cheatSheet;
NSWindowController *_bookmarks;
2020-08-29 18:40:34 +00:00
}
2020-08-16 16:53:17 +00:00
2020-08-16 20:23:51 +00:00
2020-08-16 16:53:17 +00:00
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
2020-08-16 20:23:51 +00:00
2020-08-29 18:40:34 +00:00
NSBundle *bundle = [NSBundle mainBundle];
NSString *path;
NSDictionary *dict;
RegisterTransformers();
//BookmarkManager *bm = [BookmarkManager sharedManager];
Squashed commit of the following: commit 78c81626670fdf41fa6bdd71a4243a89a0746615 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon Jun 7 00:33:48 2021 -0400 check if software set has a particular entry. commit ef5ab6b6948dc3bbbe2947ea099fcacd08435e86 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 22:20:34 2021 -0400 fix scroller background on recent disk images window. commit dee56fa50e87299b396b48361bd0a780aaaaa768 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 21:26:23 2021 -0400 update cheat sheet javascript to work with 10.11 * => functions not supported * NodeList.prototype.forEach not supported. commit b00cc05413f4ebd6d6d58f96e24303008608f3a6 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 17:10:41 2021 -0400 default full machine name for bookmark entry. commit a671cafdc98051b56b12cdd3ccd13c22f54f605a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:39:32 2021 -0400 loading a bookmark wasn't updating the media. commit 3000e0eb1b10bede3345aaab8478e9ec209f328c Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 15:38:53 2021 -0400 bump copyright year. commit 45222dacd4aa0047fae63a9112509de57139df63 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:38:23 2021 -0400 add reset w/ value for setting the item explicitely. commit cc7fde1253b71c4d8655eb4c010bbf4e61333a15 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun Jun 6 13:37:48 2021 -0400 add checkboxes for bitbanger/share directory. The general idea is it's easier to toggle a checkbox than to type/retype a path. commit 5674b2d7f6b0e2f0b973197bf3493ad61bf46428 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:43 2021 -0400 commentary on searches with diacritics. commit ec60634dcd9c573130dc34673b4d3fe597ea2b42 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 19:11:22 2021 -0400 clean up auto-complete a little bit when setting a value directly. commit 1a182bbdab237c89d355d8294b5a4a64b785783a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 13:08:29 2021 -0400 fix text color when value is set. There are still some bugs relating to multiple copies of the value being stored. commit 49c0bc15c73446259d8cc151cf52d6058644db76 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 12:09:44 2021 -0400 reset all controls first. commit 059797ad85b057e296cc707b4645f839bfccac13 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat Jun 5 10:52:06 2021 -0400 more bookmark loading. commit e5a612d9f8e7414dd15c66dbaa540b637765eeec Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:38 2021 -0400 bookmark - restore the software commit f9411a1e84df7bd46e352cc5ca995b585c2a0523 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 23:52:25 2021 -0400 clean up software / name logic. commit f628d99e4a70d65ea8703f3c182103cd3bfea969 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:21:08 2021 -0400 load bookmark... commit 0b248e6aad16cba848f88d294a1366cea5760aa0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri Jun 4 00:20:42 2021 -0400 stringValue can't be nil. commit 94aac38af45c3c95cb86b176393a469279c2539e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:04:37 2021 -0400 add bookmark menu commit 6215a0df120b6cd97f1ffea2d2db9aaa5ae61f29 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:03:29 2021 -0400 slot view needs to know the machine. commit d348c15dc56d9cee01e5417435dd236e0e541902 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:58 2021 -0400 transformer to enable/disable control based on string length. commit e14336a0094af7aa84e91da69ff59ebb9e8eea9b Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:02:14 2021 -0400 shut up compiler warning. commit 4baf545245d8d3debf8f436b36b14cca23bf7a33 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Thu Jun 3 23:01:15 2021 -0400 bookmark manager commit 0f3e6c83075a145a456728b57a499cfa35707002 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 23:54:29 2021 -0400 more (untested) bookmark code commit 8fdb149eb38952b13c4a78d7a6940c43d90870f1 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:13:43 2021 -0400 start of bookmarking support. Untested. commit 787eac87f6ac13cd677630cbaf2538cecab27b1f Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Mon May 31 16:12:45 2021 -0400 shut up warnings about content clipping. maybe it's a 10.11 thing. The size was chosen by interface builder.
2021-06-07 04:34:26 +00:00
2020-08-29 18:40:34 +00:00
path = [bundle pathForResource: @"Defaults" ofType: @"plist"];
dict = [NSDictionary dictionaryWithContentsOfFile: path];
if (dict)
{
[[NSUserDefaults standardUserDefaults] registerDefaults: dict];
}
_diskImages = [DiskImagesWindowController sharedInstance]; //[DiskImagesWindowController new];
if ([self installMameComponents]) {
[self displayLaunchWindow];
}
}
-(void)displayLaunchWindow {
if (!_launcher) {
_launcher = [LaunchWindowController new];
}
[_launcher showWindow: nil];
2020-08-16 16:53:17 +00:00
}
-(BOOL)installMameComponents {
/* install the mame data components. */
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSBundle *bundle = [NSBundle mainBundle];
NSURL *sd = SupportDirectory();
NSURL *ample_url = [sd URLByAppendingPathComponent: @"Ample.plist"];
NSMutableDictionary *d = [NSMutableDictionary dictionaryWithContentsOfURL: ample_url];
NSDate *oldDate = [d objectForKey: kMameComponentsDate];
NSDate *newDate = [defaults objectForKey: kMameComponentsDate];
if (![newDate isKindOfClass: [NSDate class]])
newDate = nil;
if (!newDate) return YES; //????
if (oldDate && [oldDate compare: newDate] >= 0) return YES;
#if 0
NSString *path = [bundle pathForResource: @"mame-data" ofType: @"tgz"];
if (!path) return YES; // Ample Lite?
#endif
NSString *ssp = [bundle sharedSupportPath];
NSString *path = [ssp stringByAppendingPathComponent: @"mame-data.tgz"];
if (![[NSFileManager defaultManager] fileExistsAtPath: path])
return YES; // Ample Lite?
NSWindow *win = _installWindow;
[win makeKeyAndOrderFront: nil];
NSTask *task = [NSTask new];
NSArray *argv = @[
@"xfz",
path
];
Updates to work with 10.11 (El Capitan) and newer. There are still a couple minor UI degradations eg: mame cheat sheet, recent disk images window, auto complete window. Squashed commit of the following: commit fb115024f805da38b747fd1905573fabb7bff24e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 18:00:13 2021 -0400 ? commit 8405f4df95ae8f5bc5dc33598dc0b3f8972b32cd Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:43 2021 -0400 tintColor not present before 10.14 commit 86a6102cee4f30cac2972259ef55fda3c32b8f9a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:19 2021 -0400 [menu setItemArray:] apparently has problems before 10.14 commit 65227a00743fbf143c623af8a76698d57bdc4573 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:58:15 2021 -0400 NSCache doesn't like null objects. commit 8a4c3a4662647d5ee0b609bde9f3aaa5c0d99776 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 16:00:05 2021 -0400 organize copy bundle resources. multiple-sized png images are converted to a single tiff (with multiple sizes). This is fine BUT EL capitan grabs the first image so if the @3x image is first, it will be used. commit 44b94cdfd47117864b6529214b1c91a0c2e41327 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 15:57:37 2021 -0400 add NewSlotViewController.m to Ample Lite. commit 2fa1b7418783e48ca625ab3490e43cbff9e5619a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:57:19 2021 -0400 Ample Lite was missing reference to New Slot View nib. commit 65f268e77a65f8c57019702d8f0c2b66577c5ee7 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:56:04 2021 -0400 based on testing, 10.11 still has public.file-url, which is kUTTypeFileURL. 10.13 added NSURLPBoardType as a synonym. commit cde123b16eb336b7695b444931b9e9bb9802d772 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:54:02 2021 -0400 set everything to 10.11 commit e7a670efd3298e8ce1409cde1cce559ba46879f4 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 23:33:31 2021 -0400 script to download SDL2.Framework commit 9f38f2972ab0e38fbdaebb3e3f35281978303519 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:15:32 2021 -0400 WKWebView apparently has a bug prior to 10.12 so it can't be created via a nib. commit e18aea724978b86cb0c04853649aeb613ac225ce Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:14:38 2021 -0400 version checks for features not present in 10.11 commit 07dcf30f5225564ec19d1aad3856828fdeaeb0f0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri May 28 21:30:53 2021 -0400 lower target to 10.11
2021-05-30 22:00:34 +00:00
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];
Updates to work with 10.11 (El Capitan) and newer. There are still a couple minor UI degradations eg: mame cheat sheet, recent disk images window, auto complete window. Squashed commit of the following: commit fb115024f805da38b747fd1905573fabb7bff24e Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 18:00:13 2021 -0400 ? commit 8405f4df95ae8f5bc5dc33598dc0b3f8972b32cd Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:43 2021 -0400 tintColor not present before 10.14 commit 86a6102cee4f30cac2972259ef55fda3c32b8f9a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:59:19 2021 -0400 [menu setItemArray:] apparently has problems before 10.14 commit 65227a00743fbf143c623af8a76698d57bdc4573 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 17:58:15 2021 -0400 NSCache doesn't like null objects. commit 8a4c3a4662647d5ee0b609bde9f3aaa5c0d99776 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 16:00:05 2021 -0400 organize copy bundle resources. multiple-sized png images are converted to a single tiff (with multiple sizes). This is fine BUT EL capitan grabs the first image so if the @3x image is first, it will be used. commit 44b94cdfd47117864b6529214b1c91a0c2e41327 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 15:57:37 2021 -0400 add NewSlotViewController.m to Ample Lite. commit 2fa1b7418783e48ca625ab3490e43cbff9e5619a Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:57:19 2021 -0400 Ample Lite was missing reference to New Slot View nib. commit 65f268e77a65f8c57019702d8f0c2b66577c5ee7 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:56:04 2021 -0400 based on testing, 10.11 still has public.file-url, which is kUTTypeFileURL. 10.13 added NSURLPBoardType as a synonym. commit cde123b16eb336b7695b444931b9e9bb9802d772 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun May 30 13:54:02 2021 -0400 set everything to 10.11 commit e7a670efd3298e8ce1409cde1cce559ba46879f4 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 23:33:31 2021 -0400 script to download SDL2.Framework commit 9f38f2972ab0e38fbdaebb3e3f35281978303519 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:15:32 2021 -0400 WKWebView apparently has a bug prior to 10.12 so it can't be created via a nib. commit e18aea724978b86cb0c04853649aeb613ac225ce Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Sat May 29 22:14:38 2021 -0400 version checks for features not present in 10.11 commit 07dcf30f5225564ec19d1aad3856828fdeaeb0f0 Author: Kelvin Sherlock <ksherlock@gmail.com> Date: Fri May 28 21:30:53 2021 -0400 lower target to 10.11
2021-05-30 22:00:34 +00:00
dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC));
[task setTerminationHandler: ^(NSTask *task){
int st = [task terminationStatus];
// delay so the install window is visible, I think
dispatch_after(when, dispatch_get_main_queue(), ^{
if (st) {
NSAlert *alert = [NSAlert new];
[alert setMessageText: @"An error occurred extracting MAME components"];
[alert runModal];
[win close];
return;
}
if (d) {
[d setObject: newDate forKey: kMameComponentsDate];
[d writeToURL: ample_url atomically: YES];
} else {
[@{ kMameComponentsDate: newDate } writeToURL: ample_url atomically: YES];
}
[win close];
[self displayLaunchWindow];
[self displayROMS: nil];
});
}];
[task launch];
return NO;
}
2020-08-16 16:53:17 +00:00
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
2020-08-16 16:53:17 +00:00
}
2020-08-17 01:22:45 +00:00
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
return YES;
}
2020-08-16 16:53:17 +00:00
-(BOOL)application:(NSApplication *)sender openFile:(NSString *)filename {
NSString *ext = [[filename pathExtension] lowercaseString];
if ([ext isEqualToString: @"vgm"] || [ext isEqualToString: @"vgz"]) {
// run mame...
2020-10-01 03:06:44 +00:00
NSArray *args = @[ @"vgmplay", @"-window", @"-nomax", @"-skip_gameinfo", @"-quik", filename ];
[LogWindowController controllerForArgs: args];
}
return NO;
}
2020-08-16 20:23:51 +00:00
2020-08-26 03:22:08 +00:00
#pragma mark - IBActions
2020-08-29 18:40:34 +00:00
- (IBAction)displayPreferences:(id)sender {
if (!_prefs) {
_prefs = [PreferencesWindowController new];
2020-08-29 18:40:34 +00:00
}
[_prefs showWindow: sender];
}
2020-08-16 20:23:51 +00:00
2020-08-20 00:26:44 +00:00
- (IBAction)displayROMS:(id)sender {
2020-09-03 04:15:50 +00:00
if (!_downloader) {
_downloader = [DownloadWindowController sharedInstance];
2020-09-03 04:15:50 +00:00
}
[_downloader showWindow: sender];
}
- (IBAction)displayRecentDiskImages:(id)sender {
if (!_diskImages) {
_diskImages = [DiskImagesWindowController sharedInstance];
}
[_diskImages showWindow: sender];
}
- (IBAction)displayCheatSheet:(id)sender {
if (!_cheatSheet) {
_cheatSheet = [CheatSheetWindowController new];
}
[_cheatSheet showWindow: sender];
}
2020-10-03 16:46:19 +00:00
- (IBAction)displaySupportDirectory:(id)sender {
NSURL *url = SupportDirectory();
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
[ws openURL: url];
}
2020-10-04 18:53:20 +00:00
- (IBAction)mameDocumentation:(id)sender {
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSURL *url = [NSURL URLWithString: @"https://docs.mamedev.org"];
[ws openURL: url];
}
2020-12-29 23:04:02 +00:00
- (IBAction)mameAppleWiki:(id)sender {
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSURL *url = [NSURL URLWithString: @"https://wiki.mamedev.org/index.php/Driver:Apple_II"];
[ws openURL: url];
}
2021-05-18 21:51:53 +00:00
- (IBAction)mameMac68kWiki:(id)sender {
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSURL *url = [NSURL URLWithString: @"https://wiki.mamedev.org/index.php/Driver:Mac_68K"];
[ws openURL: url];
}
- (IBAction)manageBookmarks: (id)sender {
if (!_bookmarks) {
_bookmarks = [BookmarkWindowController new];
}
[_bookmarks showWindow: sender];
}
2021-05-18 21:51:53 +00:00
2020-12-29 23:04:02 +00:00
-(IBAction)installMameComponents:(id)sender {
/* install the mame data components. */
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSBundle *bundle = [NSBundle mainBundle];
NSURL *sd = SupportDirectory();
NSURL *ample_url = [sd URLByAppendingPathComponent: @"Ample.plist"];
NSMutableDictionary *d = [NSMutableDictionary dictionaryWithContentsOfURL: ample_url];
//NSDate *oldDate = [d objectForKey: kMameComponentsDate];
NSDate *newDate = [defaults objectForKey: kMameComponentsDate];
if (![newDate isKindOfClass: [NSDate class]])
newDate = nil;
NSString *path = [bundle pathForResource: @"mame-data" ofType: @"tgz"];
if (!path) return; // Ample Lite?
NSWindow *win = _installWindow;
[win makeKeyAndOrderFront: nil];
NSTask *task = [NSTask new];
NSArray *argv = @[
@"xfz",
path
];
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];
//dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC));
[task setTerminationHandler: ^(NSTask *task){
int st = [task terminationStatus];
dispatch_async(dispatch_get_main_queue(), ^{
if (st) {
NSAlert *alert = [NSAlert new];
[alert setMessageText: @"An error occurred extracting MAME components"];
[alert runModal];
[win close];
return;
}
if (d) {
[d setObject: newDate forKey: kMameComponentsDate];
[d writeToURL: ample_url atomically: YES];
} else {
[@{ kMameComponentsDate: newDate } writeToURL: ample_url atomically: YES];
}
[win close];
// need to reload the software list data.
});
}];
[task launch];
}
2020-08-16 16:53:17 +00:00
@end