mirror of
https://github.com/ksherlock/ample.git
synced 2025-01-23 00:33:32 +00:00
first check in.
This commit is contained in:
parent
14099919e9
commit
03b99e39f6
@ -7,6 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
B64E15A624E9B34700E8AD3D /* Models.plist in Resources */ = {isa = PBXBuildFile; fileRef = B64E15A424E9B34700E8AD3D /* Models.plist */; };
|
||||
B6BA258024E99BE9005FB8FF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B6BA257F24E99BE9005FB8FF /* AppDelegate.m */; };
|
||||
B6BA258224E99BEB005FB8FF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B6BA258124E99BEB005FB8FF /* Assets.xcassets */; };
|
||||
B6BA258524E99BEB005FB8FF /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = B6BA258324E99BEB005FB8FF /* MainMenu.xib */; };
|
||||
@ -14,6 +15,7 @@
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
B64E15A524E9B34700E8AD3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Base; path = Base.lproj/Models.plist; sourceTree = "<group>"; };
|
||||
B6BA257B24E99BE9005FB8FF /* MA2ME.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MA2ME.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B6BA257E24E99BE9005FB8FF /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
B6BA257F24E99BE9005FB8FF /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
@ -56,6 +58,7 @@
|
||||
children = (
|
||||
B6BA257E24E99BE9005FB8FF /* AppDelegate.h */,
|
||||
B6BA257F24E99BE9005FB8FF /* AppDelegate.m */,
|
||||
B64E15A424E9B34700E8AD3D /* Models.plist */,
|
||||
B6BA258124E99BEB005FB8FF /* Assets.xcassets */,
|
||||
B6BA258324E99BEB005FB8FF /* MainMenu.xib */,
|
||||
B6BA258624E99BEB005FB8FF /* Info.plist */,
|
||||
@ -124,6 +127,7 @@
|
||||
files = (
|
||||
B6BA258224E99BEB005FB8FF /* Assets.xcassets in Resources */,
|
||||
B6BA258524E99BEB005FB8FF /* MainMenu.xib in Resources */,
|
||||
B64E15A624E9B34700E8AD3D /* Models.plist in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -142,6 +146,14 @@
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
B64E15A424E9B34700E8AD3D /* Models.plist */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
B64E15A524E9B34700E8AD3D /* Base */,
|
||||
);
|
||||
name = Models.plist;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B6BA258324E99BEB005FB8FF /* MainMenu.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate, NSBrowserDelegate>
|
||||
|
||||
|
||||
@end
|
||||
|
@ -8,15 +8,64 @@
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@property (weak) IBOutlet NSWindow *window;
|
||||
|
||||
|
||||
/* kvo */
|
||||
@property NSString *commandLine;
|
||||
|
||||
@property NSString *mameROM;
|
||||
@property BOOL mameWindow;
|
||||
@property BOOL mameNoThrottle;
|
||||
@property BOOL mameDebug;
|
||||
@property BOOL mameSquarePixels;
|
||||
|
||||
@property NSArray *browserItems;
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
static NSString *kMyContext = @"kMyContext";
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||
// Insert code here to initialize your application
|
||||
|
||||
|
||||
/* My Copy of XCode/Interface Builder barfs on NSBrowser. */
|
||||
|
||||
NSBundle *bundle = [NSBundle mainBundle];
|
||||
NSString *path = [bundle pathForResource: @"Models" ofType: @"plist"];
|
||||
_browserItems = [NSArray arrayWithContentsOfFile: path];
|
||||
|
||||
NSView *view = [_window contentView];
|
||||
|
||||
NSRect frame = [view frame];
|
||||
frame.origin.y += frame.size.height - 200;
|
||||
frame.size.height = 200;
|
||||
|
||||
NSBrowser *browser = [[NSBrowser alloc] initWithFrame: frame];
|
||||
|
||||
[browser setMaxVisibleColumns: 2];
|
||||
[browser setTakesTitleFromPreviousColumn: YES];
|
||||
[browser setTitled: NO];
|
||||
[browser setDelegate: self];
|
||||
[browser setAction: @selector(modelClick:)];
|
||||
|
||||
|
||||
|
||||
[view addSubview: browser];
|
||||
[browser setTitled: YES]; // NSBrowser title bug.
|
||||
|
||||
|
||||
[self addObserver: self forKeyPath: @"mameROM" options:0 context: (__bridge void * _Nullable)(kMyContext)];
|
||||
[self addObserver: self forKeyPath: @"mameWindow" options:0 context: (__bridge void * _Nullable)(kMyContext)];
|
||||
[self addObserver: self forKeyPath: @"mameSquarePixels" options:0 context: (__bridge void * _Nullable)(kMyContext)];
|
||||
[self addObserver: self forKeyPath: @"mameDebug" options:0 context: (__bridge void * _Nullable)(kMyContext)];
|
||||
[self addObserver: self forKeyPath: @"mameNoThrottle" options:0 context: (__bridge void * _Nullable)(kMyContext)];
|
||||
[self buildCommandLine];
|
||||
}
|
||||
|
||||
|
||||
@ -25,4 +74,110 @@
|
||||
}
|
||||
|
||||
|
||||
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
|
||||
|
||||
if (context == (__bridge void *)kMyContext && object == self) {
|
||||
[self buildCommandLine];
|
||||
} else {
|
||||
[super observeValueForKeyPath: keyPath ofObject: object change: change context: context];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)buildCommandLine {
|
||||
|
||||
|
||||
if (!_mameROM) {
|
||||
[self setCommandLine: @""];
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableArray *argv = [NSMutableArray new];
|
||||
|
||||
[argv addObject: @"mame"];
|
||||
[argv addObject: _mameROM];
|
||||
|
||||
if (_mameDebug) { [argv addObject: @"-debug"]; }
|
||||
if (_mameWindow) { [argv addObject: @"-window"]; }
|
||||
if (_mameWindow && _mameSquarePixels) {
|
||||
[argv addObject: @"-resolution"];
|
||||
[argv addObject: @"704x462"];
|
||||
[argv addObject: @"-video"];
|
||||
[argv addObject: @"-soft"];
|
||||
[argv addObject: @"-aspect"];
|
||||
[argv addObject: @"704:462"];
|
||||
}
|
||||
|
||||
[self setCommandLine: [argv componentsJoinedByString:@" "]];
|
||||
}
|
||||
|
||||
-(IBAction)modelClick:(id)sender {
|
||||
|
||||
NSDictionary *item = [self itemForBrowser: sender];
|
||||
[self setMameROM: [item objectForKey: @"Mame"]];
|
||||
// [self buildCommandLine];
|
||||
}
|
||||
|
||||
#pragma mark NSBrowser
|
||||
|
||||
-(NSDictionary *)itemForBrowser: (NSBrowser *)browser {
|
||||
|
||||
NSIndexPath *path = [browser selectionIndexPath];
|
||||
|
||||
NSArray *a = _browserItems;
|
||||
NSDictionary *item = nil;
|
||||
|
||||
NSUInteger l = [path length];
|
||||
for (NSUInteger i = 0; i < l; ++i) {
|
||||
NSUInteger ix = [path indexAtPosition: i];
|
||||
if (ix > [a count]) return nil;
|
||||
item = [a objectAtIndex: ix];
|
||||
a = [item objectForKey: @"Children"];
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
-(NSArray *)itemsForBrowser: (NSBrowser *)browser column: (NSInteger) column {
|
||||
|
||||
NSArray *a = _browserItems;
|
||||
for (unsigned i = 0; i < column; ++i) {
|
||||
NSInteger ix = [browser selectedRowInColumn: i];
|
||||
if (ix < 0) return 0;
|
||||
|
||||
NSDictionary *item = [a objectAtIndex: ix];
|
||||
a = [item objectForKey: @"Children"];
|
||||
if (!a) return 0;
|
||||
}
|
||||
return a;
|
||||
|
||||
}
|
||||
|
||||
- (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell atRow:(NSInteger)row column:(NSInteger)column {
|
||||
NSArray *a = [self itemsForBrowser: sender column: column];
|
||||
if (!a || row >= [a count]) return;
|
||||
|
||||
NSDictionary *item = [a objectAtIndex: row];
|
||||
|
||||
NSBrowserCell *bc = (NSBrowserCell *)cell;
|
||||
|
||||
[bc setStringValue: [item objectForKey: @"Name"]];
|
||||
[bc setLeaf: ![item objectForKey: @"Children"]];
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (NSString *)browser:(NSBrowser *)sender titleOfColumn:(NSInteger)column {
|
||||
return column == 0 ? @"Model" : @"Submodel";
|
||||
}
|
||||
|
||||
- (id)browser:(NSBrowser *)browser child:(NSInteger)index ofItem:(id)item {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSInteger)browser:(NSBrowser *)sender numberOfRowsInColumn:(NSInteger)column {
|
||||
|
||||
NSArray *a = [self itemsForBrowser: sender column: column];
|
||||
return [a count];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
@ -1,7 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11134" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<?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>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/>
|
||||
<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="NSApplication">
|
||||
@ -10,8 +12,8 @@
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSApplication"/>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider="">
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate">
|
||||
<connections>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
|
||||
</connections>
|
||||
@ -677,16 +679,88 @@
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
<point key="canvasLocation" x="132" y="154"/>
|
||||
</menu>
|
||||
<window title="MA2ME" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
|
||||
<rect key="contentRect" x="335" y="390" width="718" height="547"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
||||
<view key="contentView" id="EiT-Mj-1SZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="718" height="547"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jf6-4d-ms1">
|
||||
<rect key="frame" x="0.0" y="347" width="718" height="200"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
</customView>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ymx-Ml-AsE">
|
||||
<rect key="frame" x="18" y="323" width="71" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="check" title="Window" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="McP-bf-5Zu">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="Voe-Tx-rLC" name="value" keyPath="self.mameWindow" id="0bg-kj-1JX"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bkv-BK-7TC">
|
||||
<rect key="frame" x="18" y="303" width="62" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="check" title="Debug" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="WPk-zw-UFD">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="Voe-Tx-rLC" name="value" keyPath="self.mameDebug" id="mGk-ML-ncm"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="g2S-iX-zTe">
|
||||
<rect key="frame" x="0.0" y="0.0" width="718" height="52"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="vbg-gA-6dg">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<binding destination="Voe-Tx-rLC" name="value" keyPath="self.commandLine" id="gkK-GV-onk"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ug9-kz-ZSS">
|
||||
<rect key="frame" x="621" y="53" width="85" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="Launch" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="evD-kp-H2u">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QSr-Gw-xV3">
|
||||
<rect key="frame" x="18" y="283" width="91" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="check" title="No Throttle" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="Kgs-UM-HeU">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="Voe-Tx-rLC" name="value" keyPath="self.mameNoThrottle" id="v1f-ka-XkT"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PUB-So-kAo">
|
||||
<rect key="frame" x="131" y="323" width="104" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="check" title="Square Pixels" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="Bj2-i5-4h1">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="Voe-Tx-rLC" name="value" keyPath="self.mameSquarePixels" id="rNk-1d-QZl"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="754" y="211.5"/>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
||||
|
35
MA2ME/Base.lproj/Models.plist
Normal file
35
MA2ME/Base.lproj/Models.plist
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<array>
|
||||
<dict>
|
||||
<key>Name</key>
|
||||
<string>Apple IIgs</string>
|
||||
<key>Mame</key>
|
||||
<string>apple2gs</string>
|
||||
<key>Children</key>
|
||||
<array/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Name</key>
|
||||
<string>Apple IIe</string>
|
||||
<key>Mame</key>
|
||||
<string>apple2e</string>
|
||||
<key>Children</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>Name</key>
|
||||
<string>Apple IIe</string>
|
||||
<key>Mame</key>
|
||||
<string>apple2e</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Name</key>
|
||||
<string>Apple IIe (enhanced)</string>
|
||||
<key>Mame</key>
|
||||
<string>apple2ee</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
</plist>
|
Loading…
x
Reference in New Issue
Block a user