Merge images-window into master

This commit is contained in:
Kelvin Sherlock 2020-09-25 20:50:35 -04:00
commit 13d78a94ed
17 changed files with 789 additions and 61 deletions

View File

@ -79,6 +79,14 @@
B63C1BA8250192E600511A71 /* zijini.plist in Resources */ = {isa = PBXBuildFile; fileRef = B63C1BA7250192E600511A71 /* zijini.plist */; };
B63C1BA9250192E600511A71 /* zijini.plist in Resources */ = {isa = PBXBuildFile; fileRef = B63C1BA7250192E600511A71 /* zijini.plist */; };
B64979C224EF6703008ABD20 /* MediaViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B64979C124EF6703008ABD20 /* MediaViewController.m */; };
B64AF1EE250EC35B00A09B9B /* DiskImages.xib in Resources */ = {isa = PBXBuildFile; fileRef = B64AF1EC250EC35B00A09B9B /* DiskImages.xib */; };
B64AF1EF250EC35B00A09B9B /* DiskImages.xib in Resources */ = {isa = PBXBuildFile; fileRef = B64AF1EC250EC35B00A09B9B /* DiskImages.xib */; };
B64AF1F2250ECB2E00A09B9B /* DiskImagesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F1250ECB2E00A09B9B /* DiskImagesWindowController.m */; };
B64AF1F3250ECB2E00A09B9B /* DiskImagesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F1250ECB2E00A09B9B /* DiskImagesWindowController.m */; };
B64AF1F6250ED5E400A09B9B /* TableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F5250ED5E400A09B9B /* TableCellView.m */; };
B64AF1F7250ED5E400A09B9B /* TableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F5250ED5E400A09B9B /* TableCellView.m */; };
B64AF1FA250EF6A500A09B9B /* Transformers.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F9250EF6A500A09B9B /* Transformers.m */; };
B64AF1FB250EF6A500A09B9B /* Transformers.m in Sources */ = {isa = PBXBuildFile; fileRef = B64AF1F9250EF6A500A09B9B /* Transformers.m */; };
B64E15A924EA1D5300E8AD3D /* MachineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B64E15A824EA1D5300E8AD3D /* MachineViewController.m */; };
B66236A924FD9A34006CABD7 /* PreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B66236A824FD9A34006CABD7 /* PreferencesWindowController.m */; };
B66236B524FDA527006CABD7 /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = B66236B224FDA522006CABD7 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@ -282,6 +290,13 @@
B63C1BA7250192E600511A71 /* zijini.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = zijini.plist; sourceTree = "<group>"; };
B64979C024EF6703008ABD20 /* MediaViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaViewController.h; sourceTree = "<group>"; };
B64979C124EF6703008ABD20 /* MediaViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MediaViewController.m; sourceTree = "<group>"; };
B64AF1ED250EC35B00A09B9B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/DiskImages.xib; sourceTree = "<group>"; };
B64AF1F0250ECB2E00A09B9B /* DiskImagesWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DiskImagesWindowController.h; sourceTree = "<group>"; };
B64AF1F1250ECB2E00A09B9B /* DiskImagesWindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DiskImagesWindowController.m; sourceTree = "<group>"; };
B64AF1F4250ED5E400A09B9B /* TableCellView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TableCellView.h; sourceTree = "<group>"; };
B64AF1F5250ED5E400A09B9B /* TableCellView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TableCellView.m; sourceTree = "<group>"; };
B64AF1F8250EF6A500A09B9B /* Transformers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Transformers.h; sourceTree = "<group>"; };
B64AF1F9250EF6A500A09B9B /* Transformers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Transformers.m; sourceTree = "<group>"; };
B64E15A724EA1D5300E8AD3D /* MachineViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MachineViewController.h; sourceTree = "<group>"; };
B64E15A824EA1D5300E8AD3D /* MachineViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MachineViewController.m; sourceTree = "<group>"; };
B65593AF24ECB61800722E0C /* SlotViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SlotViewController.h; sourceTree = "<group>"; };
@ -450,16 +465,14 @@
B6BA257D24E99BE9005FB8FF /* Ample */ = {
isa = PBXGroup;
children = (
B6E9A17E25088B1B005E7525 /* NewSlotViewController.h */,
B6E9A17F25088B1B005E7525 /* NewSlotViewController.m */,
B63C1B9125008A2700511A71 /* DownloadWindowController.h */,
B63C1B9225008A2700511A71 /* DownloadWindowController.m */,
B6BA257E24E99BE9005FB8FF /* AppDelegate.h */,
B6BA257F24E99BE9005FB8FF /* AppDelegate.m */,
B63C1B8924FF4B7100511A71 /* Ample.h */,
B63C1B8A24FF4BF700511A71 /* Ample.m */,
B6D6DE3F24FADFAC00661A5F /* LaunchWindowController.h */,
B6D6DE4024FADFAC00661A5F /* LaunchWindowController.m */,
B64AF1F4250ED5E400A09B9B /* TableCellView.h */,
B64AF1F5250ED5E400A09B9B /* TableCellView.m */,
B6E9A17E25088B1B005E7525 /* NewSlotViewController.h */,
B6E9A17F25088B1B005E7525 /* NewSlotViewController.m */,
B65593B024ECB61800722E0C /* SlotViewController.m */,
B65593AF24ECB61800722E0C /* SlotViewController.h */,
B64979C024EF6703008ABD20 /* MediaViewController.h */,
@ -470,12 +483,11 @@
B60A6E1224EE0AE2004B7EEF /* FlippedView.h */,
B608E17D2502FE0C00D53465 /* TransparentScroller.h */,
B608E17E2502FE0C00D53465 /* TransparentScroller.m */,
B6004DED24FB05D600D38596 /* LogWindowController.h */,
B6004DEE24FB05D600D38596 /* LogWindowController.m */,
B66236A724FD9A34006CABD7 /* PreferencesWindowController.h */,
B66236A824FD9A34006CABD7 /* PreferencesWindowController.m */,
B6BA563A251685DA00B0C47D /* Window Controllers */,
B6B9EA652506A5550080E70D /* EjectButton.h */,
B6B9EA642506A5550080E70D /* EjectButton.m */,
B64AF1F8250EF6A500A09B9B /* Transformers.h */,
B64AF1F9250EF6A500A09B9B /* Transformers.m */,
B6BA258124E99BEB005FB8FF /* Assets.xcassets */,
B64E15AF24EA365E00E8AD3D /* Resources */,
B6BA258624E99BEB005FB8FF /* Info.plist */,
@ -488,6 +500,23 @@
path = Ample;
sourceTree = "<group>";
};
B6BA563A251685DA00B0C47D /* Window Controllers */ = {
isa = PBXGroup;
children = (
B64AF1F0250ECB2E00A09B9B /* DiskImagesWindowController.h */,
B64AF1F1250ECB2E00A09B9B /* DiskImagesWindowController.m */,
B63C1B9125008A2700511A71 /* DownloadWindowController.h */,
B63C1B9225008A2700511A71 /* DownloadWindowController.m */,
B6D6DE3F24FADFAC00661A5F /* LaunchWindowController.h */,
B6D6DE4024FADFAC00661A5F /* LaunchWindowController.m */,
B6004DED24FB05D600D38596 /* LogWindowController.h */,
B6004DEE24FB05D600D38596 /* LogWindowController.m */,
B66236A724FD9A34006CABD7 /* PreferencesWindowController.h */,
B66236A824FD9A34006CABD7 /* PreferencesWindowController.m */,
);
name = "Window Controllers";
sourceTree = "<group>";
};
B6D6DE4224FAEE8900661A5F /* Nibs */ = {
isa = PBXGroup;
children = (
@ -500,6 +529,7 @@
B61099E524F5F230005CB652 /* MediaView.xib */,
B6D6DE3724FAC8B500661A5F /* Preferences.xib */,
B61099E324F5F230005CB652 /* SlotView.xib */,
B64AF1EC250EC35B00A09B9B /* DiskImages.xib */,
);
name = Nibs;
sourceTree = "<group>";
@ -648,6 +678,7 @@
B6109A2B24F5F377005CB652 /* elppa.plist in Resources */,
B63C1B8E25004C6D00511A71 /* mame-data.tgz in Resources */,
B6DDECCE2505A86E0093587A /* eject-16x16@3x.png in Resources */,
B64AF1EE250EC35B00A09B9B /* DiskImages.xib in Resources */,
B6109A3B24F5F377005CB652 /* apple2gsr1.plist in Resources */,
B63C1B9625008A2700511A71 /* DownloadWindow.xib in Resources */,
B6D6DE3B24FACF4F00661A5F /* Defaults.plist in Resources */,
@ -691,6 +722,7 @@
B6E4B5C424FDE2670094A35C /* LogWindow.xib in Resources */,
B6E4B5C524FDE2670094A35C /* Assets.xcassets in Resources */,
B6E4B5C624FDE2670094A35C /* apple2e.plist in Resources */,
B64AF1EF250EC35B00A09B9B /* DiskImages.xib in Resources */,
B63C1BA2250192D800511A71 /* cecg.plist in Resources */,
B6E4B5C724FDE2670094A35C /* am100.plist in Resources */,
B6E4B5C824FDE2670094A35C /* laser2c.plist in Resources */,
@ -768,7 +800,10 @@
B6BA258024E99BE9005FB8FF /* AppDelegate.m in Sources */,
B6004DF024FB05D600D38596 /* LogWindowController.m in Sources */,
B66236A924FD9A34006CABD7 /* PreferencesWindowController.m in Sources */,
B64AF1F2250ECB2E00A09B9B /* DiskImagesWindowController.m in Sources */,
B64AF1F6250ED5E400A09B9B /* TableCellView.m in Sources */,
B63C1B9425008A2700511A71 /* DownloadWindowController.m in Sources */,
B64AF1FA250EF6A500A09B9B /* Transformers.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -777,12 +812,15 @@
buildActionMask = 2147483647;
files = (
B608E1802502FE0C00D53465 /* TransparentScroller.m in Sources */,
B64AF1FB250EF6A500A09B9B /* Transformers.m in Sources */,
B6E4B5B024FDE2670094A35C /* main.m in Sources */,
B63C1B8C24FF4BF700511A71 /* Ample.m in Sources */,
B64AF1F3250ECB2E00A09B9B /* DiskImagesWindowController.m in Sources */,
B6B9EA672506A5550080E70D /* EjectButton.m in Sources */,
B6E4B5B124FDE2670094A35C /* LaunchWindowController.m in Sources */,
B6E4B5B224FDE2670094A35C /* MachineViewController.m in Sources */,
B6E4B5B324FDE2670094A35C /* MediaViewController.m in Sources */,
B64AF1F7250ED5E400A09B9B /* TableCellView.m in Sources */,
B6E4B5B424FDE2670094A35C /* FlippedView.m in Sources */,
B6E4B5B524FDE2670094A35C /* AppDelegate.m in Sources */,
B6E4B5B624FDE2670094A35C /* LogWindowController.m in Sources */,
@ -810,6 +848,14 @@
name = MediaView.xib;
sourceTree = "<group>";
};
B64AF1EC250EC35B00A09B9B /* DiskImages.xib */ = {
isa = PBXVariantGroup;
children = (
B64AF1ED250EC35B00A09B9B /* Base */,
);
name = DiskImages.xib;
sourceTree = "<group>";
};
B66236BF24FDB7A6006CABD7 /* Credits.rtf */ = {
isa = PBXVariantGroup;
children = (

View File

@ -10,6 +10,8 @@
#import "LaunchWindowController.h"
#import "PreferencesWindowController.h"
#import "DownloadWindowController.h"
#import "DiskImagesWindowController.h"
#import "Transformers.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *installWindow;
@ -20,6 +22,7 @@
NSWindowController *_prefs;
NSWindowController *_launcher;
NSWindowController *_downloader;
NSWindowController *_diskImages;
}
@ -31,6 +34,8 @@
NSDictionary *dict;
RegisterTransformers();
path = [bundle pathForResource: @"Defaults" ofType: @"plist"];
dict = [NSDictionary dictionaryWithContentsOfFile: path];
@ -41,7 +46,10 @@
_diskImages = [DiskImagesWindowController sharedInstance]; //[DiskImagesWindowController new];
if ([self installMameComponents]) {
[self displayLaunchWindow];
}
@ -112,6 +120,7 @@
}
[win close];
[self displayLaunchWindow];
[self displayROMS: nil];
});
}];
@ -143,12 +152,18 @@
}
- (IBAction)downloadROMS:(id)sender {
- (IBAction)displayROMS:(id)sender {
if (!_downloader) {
_downloader = [DownloadWindowController new];
_downloader = [DownloadWindowController sharedInstance];
}
[_downloader showWindow: sender];
}
- (IBAction)displayRecentDiskImages:(id)sender {
if (!_diskImages) {
_diskImages = [DiskImagesWindowController sharedInstance];
}
[_diskImages showWindow: sender];
}
@end

View File

@ -0,0 +1,154 @@
<?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>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="DiskImagesWindowController">
<connections>
<outlet property="arrayController" destination="vmp-9h-Z5R" id="WYF-Xq-BnN"/>
<outlet property="tableView" destination="J5l-1d-030" id="3hU-ho-1ag"/>
<outlet property="window" destination="R7r-B9-Bw0" id="hDE-Qa-m4g"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Recent Disk Images" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" frameAutosaveName="RecentDiskImagesWindow" animationBehavior="default" titlebarAppearsTransparent="YES" id="R7r-B9-Bw0" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" rightStrut="YES"/>
<rect key="contentRect" x="200" y="172" width="300" height="400"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" focusRingType="none" id="Kkg-Tp-4m1">
<rect key="frame" x="0.0" y="0.0" width="300" height="400"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView focusRingType="none" fixedFrame="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="24" horizontalPageScroll="10" verticalLineScroll="24" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" findBarPosition="belowContent" translatesAutoresizingMaskIntoConstraints="NO" id="ivr-XT-BPS">
<rect key="frame" x="-1" y="-1" width="302" height="402"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="1jn-uc-06s">
<rect key="frame" x="0.0" y="0.0" width="302" height="402"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView focusRingType="none" verticalHuggingPriority="750" ambiguous="YES" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" selectionHighlightStyle="sourceList" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="22" rowSizeStyle="automatic" viewBased="YES" id="J5l-1d-030">
<rect key="frame" x="0.0" y="0.0" width="302" height="402"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="_sourceListBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="282" minWidth="40" maxWidth="1000" id="1rF-M3-pYV">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="erY-fh-OHK">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="AJH-gH-E8G">
<rect key="frame" x="1" y="1" width="282" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="esO-OR-AcY">
<rect key="frame" x="6" y="5" width="196" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" sendsActionOnEndEditing="YES" title="Image Name.2mg" id="xgc-u7-sFX">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="AJH-gH-E8G" name="value" keyPath="objectValue.path" id="S0h-hl-OPM">
<dictionary key="options">
<string key="NSValueTransformerName">FilePathTransformer</string>
</dictionary>
</binding>
<binding destination="AJH-gH-E8G" name="toolTip" keyPath="objectValue.path" id="gXq-2p-MpM"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wzl-mV-Pmp">
<rect key="frame" x="206" y="3" width="75" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" sendsActionOnEndEditing="YES" alignment="right" title="32MB" id="QYB-us-igD">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="AJH-gH-E8G" name="value" keyPath="objectValue.size" id="omG-8X-flx">
<dictionary key="options">
<string key="NSValueTransformerName">FileSizeTransformer</string>
</dictionary>
</binding>
</connections>
</textField>
</subviews>
<connections>
<outlet property="textField" destination="esO-OR-AcY" id="9mX-Yt-vpg"/>
</connections>
</tableCellView>
</prototypeCellViews>
<connections>
<binding destination="vmp-9h-Z5R" name="value" keyPath="arrangedObjects.selection" id="32X-Ez-K7S"/>
</connections>
</tableColumn>
</tableColumns>
<connections>
<binding destination="vmp-9h-Z5R" name="content" keyPath="arrangedObjects" id="GHn-tz-ash"/>
<outlet property="dataSource" destination="-2" id="PRV-Rt-UuC"/>
<outlet property="delegate" destination="-2" id="WuV-c9-o5I"/>
<outlet property="menu" destination="bCS-1z-UOZ" id="UCb-2v-WrM"/>
</connections>
</tableView>
</subviews>
<nil key="backgroundColor"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="ynD-Kb-eb3">
<rect key="frame" x="-100" y="-100" width="223" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="Dbq-yF-MKx">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
</subviews>
</view>
<connections>
<outlet property="delegate" destination="-2" id="1Hn-2t-Vzj"/>
</connections>
<point key="canvasLocation" x="-188" y="143"/>
</window>
<arrayController id="vmp-9h-Z5R">
<connections>
<binding destination="-2" name="contentArray" keyPath="self.content" id="UTv-za-ry7"/>
</connections>
</arrayController>
<menu id="bCS-1z-UOZ">
<items>
<menuItem title="Show in Finder" tag="1" id="roc-SG-geJ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="showInFinder:" target="-2" id="ViY-7R-MNV"/>
</connections>
</menuItem>
<menuItem title="Eject" tag="2" id="eJ1-Kd-hnR">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="eject:" target="-2" id="c6U-xB-EnM"/>
</connections>
</menuItem>
</items>
<connections>
<outlet property="delegate" destination="-2" id="22a-3e-eaK"/>
</connections>
<point key="canvasLocation" x="-667" y="170"/>
</menu>
</objects>
</document>

View File

@ -14,7 +14,7 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="ROMs" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<window title="ROMs" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" frameAutosaveName="DownloadManagerWindow" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="196" y="240" width="400" height="500"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>

View File

@ -19,7 +19,7 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Ample" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="Vze-YF-m6e">
<window title="Ample" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" frameAutosaveName="LaunchWindow" animationBehavior="default" id="Vze-YF-m6e">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="335" y="390" width="718" height="795"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>

View File

@ -402,7 +402,13 @@
<menuItem title="Manage ROMs…" id="St3-qR-2Y8">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="downloadROMS:" target="Voe-Tx-rLC" id="jFm-nv-kRC"/>
<action selector="displayROMS:" target="Voe-Tx-rLC" id="jFm-nv-kRC"/>
</connections>
</menuItem>
<menuItem title="Recent Disk Images…" id="QY9-lF-kDy">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="displayRecentDiskImages:" target="Voe-Tx-rLC" id="9W1-nJ-8eJ"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>

View File

@ -10,5 +10,7 @@
<true/>
<key>MamePath</key>
<string>/usr/local/bin/mame</string>
<key>NSQuitAlwaysKeepsWindows</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,28 @@
//
// DiskImagesWindowController.h
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import <Cocoa/Cocoa.h>
NS_ASSUME_NONNULL_BEGIN
@interface DiskImagesWindowController : NSWindowController <NSWindowRestoration>
+(instancetype)sharedInstance;
@end
@interface DiskImagesWindowController (TableView) <NSTableViewDelegate, NSTableViewDataSource>
@end
@interface DiskImagesWindowController (Menu) <NSMenuDelegate>
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,319 @@
//
// DiskImagesWindowController.m
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import "DiskImagesWindowController.h"
#import "TableCellView.h"
#import "Ample.h"
@interface DiskImagesWindowController ()
@property (weak) IBOutlet NSTableView *tableView;
@property (strong) IBOutlet NSArrayController *arrayController;
@property (strong) NSMutableArray *content;
@end
@implementation DiskImagesWindowController {
BOOL _dirty;
NSSet *_extensions;
NSTimer *_timer;
}
+(instancetype)sharedInstance {
static DiskImagesWindowController *me;
if (!me) {
me = [self new];
}
return me;
}
+ (void)restoreWindowWithIdentifier:(NSUserInterfaceItemIdentifier)identifier state:(NSCoder *)state completionHandler:(void (^)(NSWindow *, NSError *))completionHandler {
NSLog(@"restore disk images window");
NSWindowController *controller = [self sharedInstance];
NSWindow *w = [controller window];
[w restoreStateWithCoder: state];
completionHandler(w, nil);
}
-(instancetype)init {
if ((self = [super init])) {
[self loadRecentDiskImages];
_extensions = [NSSet setWithObjects:
@"2img", @"2mg", @"chd", @"dc", @"do", @"dsk", @"hd", @"hdv", @"image", @"nib", @"po", @"wav", @"woz", @"iso", nil
];
}
return self;
}
-(NSString *)windowNibName {
return @"DiskImages";
}
- (void)windowDidLoad {
if (!_content)
[self setContent: [NSMutableArray new]];
[super windowDidLoad];
NSWindow *window = [self window];
[window setRestorable: YES];
[window setRestorationClass: [self class]];
[_tableView registerForDraggedTypes: @[NSPasteboardTypeFileURL]];
[_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.
}
-(void)loadRecentDiskImages {
// NSError *error;
NSURL *sd = SupportDirectory();
NSURL *url = [sd URLByAppendingPathComponent: @"RecentDiskImages.plist"];
NSData *data = [NSData dataWithContentsOfURL: url];
if (data) {
_content = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListMutableContainers format:nil error: nil];
}
if (!_content)
_content = [NSMutableArray new];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver: self selector: @selector(diskImageAdded:) name: @"DiskImageAdded" object: nil];
[nc addObserver: self selector: @selector(willTerminate:) name: NSApplicationWillTerminateNotification object: nil];
}
-(void)diskImageAdded: (NSNotification *)notification {
NSURL *url = [notification object];
if (!url) return;
[self addFile: url];
}
-(void)markDirty {
_dirty = YES;
if (_timer) [_timer invalidate];
_timer = [NSTimer scheduledTimerWithTimeInterval: 5 * 60 repeats: NO block: ^(NSTimer *t) {
self->_timer = nil;
[self saveFile];
}];
}
-(void)saveFile {
[_timer invalidate];
_timer = nil;
NSURL *sd = SupportDirectory();
NSURL *url = [sd URLByAppendingPathComponent: @"RecentDiskImages.plist"];
if (_content && url) {
[_content writeToURL: url atomically: YES];
}
_dirty = NO;
}
-(void)willTerminate: (NSNotification *)notification {
// if dirty, write data....
if (!_dirty) return;
[self saveFile];
}
-(BOOL)addFile: (NSObject *)pathOrURL {
NSString *path = nil;
NSURL *url = nil;
if ([pathOrURL isKindOfClass: [NSString class]]) {
path = (NSString *)pathOrURL;
} else if ([pathOrURL isKindOfClass: [NSURL class]]){
url = (NSURL *)pathOrURL;
path = [NSString stringWithCString: [url fileSystemRepresentation] encoding: NSUTF8StringEncoding];
}
if (!path) return NO;
// todo -- check if file is in the list already...
BOOL found = NO;
// should really compare the volume id / ino I suppose.
for (NSMutableDictionary *d in _content) {
NSString *s = [d objectForKey: @"path"];
if ([path compare: s] == NSOrderedSame) {
found = YES;
[d setObject: [NSDate new] forKey: @"date"];
[self markDirty];
break;
}
}
if (found) return NO;
NSFileManager *fm = [NSFileManager defaultManager];
NSError *error;
NSDictionary *attr = [fm attributesOfItemAtPath: path error: &error];
if (error) {
NSLog(@"%@ : %@", path, error);
return NO;
}
NSNumber *size = [attr objectForKey: NSFileSize];
NSMutableDictionary *d = [NSMutableDictionary dictionaryWithObjectsAndKeys:
path, @"path",
size, @"size",
[NSDate new], @"date",
nil];
@synchronized (self) {
if (_arrayController)
[_arrayController addObject: d];
else
[_content addObject: d];
}
[self markDirty];
return YES;
}
-(NSMutableDictionary *)clickedItem {
NSInteger row = [_tableView clickedRow];
if (row < 0) return nil;
NSTableCellView *v = [_tableView viewAtColumn: 0 row: row makeIfNecessary: NO];
return [v objectValue];
}
#pragma mark - IBActions
- (IBAction)showInFinder:(id)sender {
NSMutableDictionary *item = [self clickedItem];
if (!item) return;
NSString *path = [item objectForKey: @"path"];
NSURL *url = [NSURL fileURLWithPath: path];
if (!url) return;
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
[ws activateFileViewerSelectingURLs: @[url]];
}
- (IBAction)eject:(id)sender {
NSMutableDictionary *item = [self clickedItem];
if (!item) return;
@synchronized (self) {
if (_arrayController) {
[_arrayController removeObject: item];
} else {
[_content removeObject: item];
}
[self markDirty];
}
}
@end
@implementation DiskImagesWindowController (TableView)
#if 0
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
return 5; //[_data count];
}
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
NSTableCellView *v = [tableView makeViewWithIdentifier: @"PathCell" owner: self];
return v;
}
#endif
-(id<NSPasteboardWriting>)tableView:(NSTableView *)tableView pasteboardWriterForRow:(NSInteger)row {
id objects = [_arrayController arrangedObjects];
NSDictionary *d = [objects objectAtIndex: row];
NSString *path = [d objectForKey: @"path"];
NSURL *url = [NSURL fileURLWithPath: path];
return url;
#if 0
NSPasteboardItem *item = [NSPasteboardItem new];
[item setString: [url absoluteString] forType: NSPasteboardTypeFileURL]; // FileURL
[item setString: path forType: NSPasteboardTypeString]; // for Terminal.app
return item;
#endif
}
-(NSDragOperation)tableView:(NSTableView *)tableView validateDrop:(id<NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)dropOperation {
if ([info draggingSource] == _tableView) return NSDragOperationNone;
// option key will ignore all filetype restrictions.
if ([NSEvent modifierFlags] & NSEventModifierFlagOption) return NSDragOperationCopy;
// this only checks the first dragged item...
NSPasteboard * pb = [info draggingPasteboard];
NSURL *url = [NSURL URLFromPasteboard: pb];
NSString *ext = [url pathExtension];
ext = [ext lowercaseString];
if ([_extensions containsObject: ext])
return NSDragOperationCopy;
return NSDragOperationNone;
}
-(BOOL)tableView:(NSTableView *)tableView acceptDrop:(id<NSDraggingInfo>)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)dropOperation {
if ([info draggingSource] == _tableView) return NO;
NSPasteboard * pb = [info draggingPasteboard];
BOOL ok = NO;
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];
if (!s) continue;
NSURL *url = [NSURL URLWithString: s];
if (!url) continue;
ok |= [self addFile: url];
}
return ok;
}
@end

View File

@ -10,7 +10,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface DownloadWindowController : NSWindowController
@interface DownloadWindowController : NSWindowController <NSWindowRestoration>
@property NSString *currentROM;
@property NSInteger currentCount;
@ -18,6 +18,9 @@ NS_ASSUME_NONNULL_BEGIN
@property NSInteger errorCount;
@property BOOL active;
+(instancetype)sharedInstance;
@end
@interface DownloadWindowController (URL) <NSURLSessionTaskDelegate, NSURLSessionDownloadDelegate>

View File

@ -52,12 +52,38 @@ enum {
NSMutableDictionary *_taskIndex;
}
+(instancetype)sharedInstance {
static DownloadWindowController *me = nil;
if (!me) {
me = [self new];
}
return me;
}
+ (void)restoreWindowWithIdentifier:(nonnull NSUserInterfaceItemIdentifier)identifier state:(nonnull NSCoder *)state completionHandler:(nonnull void (^)(NSWindow * _Nullable, NSError * _Nullable))completionHandler {
NSLog(@"restore rom manager window");
NSWindowController *controller = [DownloadWindowController sharedInstance];
NSWindow *w = [controller window];
[w restoreStateWithCoder: state];
completionHandler(w, nil);
}
#if 0
- (void)encodeWithCoder:(nonnull NSCoder *)coder {
}
#endif
-(NSString *)windowNibName {
return @"DownloadWindow";
}
- (void)windowDidLoad {
[super windowDidLoad];
NSWindow *window = [self window];
[window setRestorable: YES];
[window setRestorationClass: [self class]];
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
@ -303,6 +329,7 @@ enum {
*/
NSLog(@"%@", src);
}
@end
@implementation DownloadWindowController (Table)

View File

@ -26,10 +26,4 @@ NS_ASSUME_NONNULL_BEGIN
@interface TablePathView : NSTableCellView
@property (weak) IBOutlet NSPathControl *pathControl;
@property (weak) IBOutlet NSButton *ejectButton;
@property (weak) IBOutlet NSImageView *dragHandle;
@end
NS_ASSUME_NONNULL_END

View File

@ -7,42 +7,7 @@
//
#import "MediaViewController.h"
@implementation TablePathView {
NSTrackingRectTag _trackingRect;
}
#if 0
-(void)awakeFromNib {
// this is apparently necessary for setTintColor to work.
NSImage *img;
img = [_ejectButton image];
[img setTemplate: YES];
img = [_ejectButton alternateImage];
[img setTemplate: YES];
}
#endif
-(void)viewDidMoveToSuperview {
return;
if (_trackingRect) {
[self removeTrackingRect: _trackingRect];
}
NSRect rect = [_dragHandle frame];
_trackingRect = [self addTrackingRect: rect owner: self userData: NULL assumeInside:NO];
}
-(void)mouseEntered:(NSEvent *)event {
[_dragHandle setHidden: NO];
}
-(void)mouseExited:(NSEvent *)event {
[_dragHandle setHidden: YES];
}
@end
#import "TableCellView.h"
@protocol MediaNode
@ -286,7 +251,7 @@
b = [[MediaCategory alloc] initWithTitle: @"3.5\" Floppies"];
c = [[MediaCategory alloc] initWithTitle: @"Hard Drives"];
d = [[MediaCategory alloc] initWithTitle: @"CD-ROMs"];
e = [[MediaCategory alloc] initWithTitle: @"Casettes"];
e = [[MediaCategory alloc] initWithTitle: @"Cassettes"];
_data[0] = a;
@ -526,7 +491,7 @@ static NSString *kDragType = @"private.ample.media";
NSInteger indexes[2] = { 0, 0 };
indexes[0] = [cat index];
indexes[1] = [item index];
NSData *data =[NSData dataWithBytes: indexes length: sizeof(indexes)];
NSData *data = [NSData dataWithBytes: indexes length: sizeof(indexes)];
[pasteboard setData: data forType: kDragType];
return YES;
@ -646,6 +611,14 @@ static NSString *kDragType = @"private.ample.media";
- (IBAction)pathAction:(id)sender {
// need to update the eject button...
NSURL *url = [(NSPathControl *)sender URL];
if (url) {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName: @"DiskImageAdded" object: url];
}
[self rebuildArgs];
}
@end

22
Ample/TableCellView.h Normal file
View File

@ -0,0 +1,22 @@
//
// TableCellView.h
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import <Cocoa/Cocoa.h>
//NS_ASSUME_NONNULL_BEGIN
@interface TablePathView : NSTableCellView
@property (weak) IBOutlet NSPathControl *pathControl;
@property (weak) IBOutlet NSButton *ejectButton;
@property (weak) IBOutlet NSImageView *dragHandle;
@property BOOL movable;
@end
//NS_ASSUME_NONNULL_END

47
Ample/TableCellView.m Normal file
View File

@ -0,0 +1,47 @@
//
// TableCellView.m
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import "TableCellView.h"
@implementation TablePathView {
NSTrackingRectTag _trackingRect;
}
#if 0
-(void)awakeFromNib {
// this is apparently necessary for setTintColor to work.
NSImage *img;
img = [_ejectButton image];
[img setTemplate: YES];
img = [_ejectButton alternateImage];
[img setTemplate: YES];
}
#endif
-(void)viewDidMoveToSuperview {
return;
if (_trackingRect) {
[self removeTrackingRect: _trackingRect];
}
NSRect rect = [_dragHandle frame];
_trackingRect = [self addTrackingRect: rect owner: self userData: NULL assumeInside:NO];
}
-(void)mouseEntered:(NSEvent *)event {
[_dragHandle setHidden: NO];
}
-(void)mouseExited:(NSEvent *)event {
[_dragHandle setHidden: YES];
}
@end

24
Ample/Transformers.h Normal file
View File

@ -0,0 +1,24 @@
//
// Transformers.h
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import <Foundation/Foundation.h>
void RegisterTransformers(void);
NS_ASSUME_NONNULL_BEGIN
@interface FilePathTransformer : NSValueTransformer
@end
@interface FileSizeTransformer : NSValueTransformer
@end
NS_ASSUME_NONNULL_END

68
Ample/Transformers.m Normal file
View File

@ -0,0 +1,68 @@
//
// Transformers.m
// Ample
//
// Created by Kelvin Sherlock on 9/13/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import "Transformers.h"
@implementation FilePathTransformer
+ (Class)transformedValueClass {
return [NSString class];
}
+ (BOOL)allowsReverseTransformation {
return NO;
}
- (id)transformedValue:(id)value {
if (!value) return value;
return [(NSString *)value lastPathComponent];
}
@end
@implementation FileSizeTransformer
+ (Class)transformedValueClass {
return [NSString class];
}
+ (BOOL)allowsReverseTransformation {
return NO;
}
- (id)transformedValue:(id)value {
if (!value) return value;
if (![value respondsToSelector: @selector(integerValue)]) {
[NSException raise: NSInternalInconsistencyException
format: @"Value (%@) does not respond to -integerValue.",
[value class]];
}
NSInteger size = [(NSNumber *)value integerValue];
if (size < 0) return nil;
if (size < 1024*1024) return [NSString stringWithFormat: @"%.1fKB", (float)size / 1024];
if (size < 1024*1024*1024) return [NSString stringWithFormat: @"%.1fMB", (float)size / (1024*1024)];
return [NSString stringWithFormat: @"%.1fGB", (float)size / (1024*1024*1024)];
}
@end
void RegisterTransformers(void) {
NSValueTransformer *t;
t = [FileSizeTransformer new];
[NSValueTransformer setValueTransformer: t forName: @"FileSizeTransformer"];
t = [FilePathTransformer new];
[NSValueTransformer setValueTransformer: t forName: @"FilePathTransformer"];
}