This commit is contained in:
Kelvin Sherlock 2020-08-21 18:38:02 -04:00
parent ddf0463a27
commit 52a9f02ab3
8 changed files with 360 additions and 14 deletions

View File

@ -31,6 +31,8 @@
B64979BA24EEC2DA008ABD20 /* las128ex.plist in Resources */ = {isa = PBXBuildFile; fileRef = B64979A324EEC2D9008ABD20 /* las128ex.plist */; };
B64979BB24EEC2DA008ABD20 /* apple2jp.plist in Resources */ = {isa = PBXBuildFile; fileRef = B64979A424EEC2D9008ABD20 /* apple2jp.plist */; };
B64979BC24EEC2DA008ABD20 /* apple2ee.plist in Resources */ = {isa = PBXBuildFile; fileRef = B64979A524EEC2D9008ABD20 /* apple2ee.plist */; };
B64979BF24EF5AEA008ABD20 /* MediaView.xib in Resources */ = {isa = PBXBuildFile; fileRef = B64979BD24EF5AEA008ABD20 /* MediaView.xib */; };
B64979C224EF6703008ABD20 /* MediaViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B64979C124EF6703008ABD20 /* MediaViewController.m */; };
B64E15A624E9B34700E8AD3D /* Models.plist in Resources */ = {isa = PBXBuildFile; fileRef = B64E15A424E9B34700E8AD3D /* Models.plist */; };
B64E15A924EA1D5300E8AD3D /* ROMBrowserDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B64E15A824EA1D5300E8AD3D /* ROMBrowserDelegate.m */; };
B64E15AC24EA1FD400E8AD3D /* SlotBrowserDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B64E15AB24EA1FD400E8AD3D /* SlotBrowserDelegate.m */; };
@ -69,6 +71,9 @@
B64979A324EEC2D9008ABD20 /* las128ex.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = las128ex.plist; sourceTree = "<group>"; };
B64979A424EEC2D9008ABD20 /* apple2jp.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = apple2jp.plist; sourceTree = "<group>"; };
B64979A524EEC2D9008ABD20 /* apple2ee.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = apple2ee.plist; sourceTree = "<group>"; };
B64979BE24EF5AEA008ABD20 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = MA2ME/Base.lproj/MediaView.xib; 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>"; };
B64E15A524E9B34700E8AD3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Base; path = Base.lproj/Models.plist; sourceTree = "<group>"; };
B64E15A724EA1D5300E8AD3D /* ROMBrowserDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ROMBrowserDelegate.h; sourceTree = "<group>"; };
B64E15A824EA1D5300E8AD3D /* ROMBrowserDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ROMBrowserDelegate.m; sourceTree = "<group>"; };
@ -165,6 +170,8 @@
children = (
B6BA257E24E99BE9005FB8FF /* AppDelegate.h */,
B6BA257F24E99BE9005FB8FF /* AppDelegate.m */,
B64979C024EF6703008ABD20 /* MediaViewController.h */,
B64979C124EF6703008ABD20 /* MediaViewController.m */,
B6BA258124E99BEB005FB8FF /* Assets.xcassets */,
B64E15A724EA1D5300E8AD3D /* ROMBrowserDelegate.h */,
B64E15A824EA1D5300E8AD3D /* ROMBrowserDelegate.m */,
@ -176,6 +183,7 @@
B6BA258924E99BEB005FB8FF /* MA2ME.entitlements */,
B6BA258324E99BEB005FB8FF /* MainMenu.xib */,
B64E15B624EC912200E8AD3D /* SlotView.xib */,
B64979BD24EF5AEA008ABD20 /* MediaView.xib */,
);
path = MA2ME;
sourceTree = "<group>";
@ -254,6 +262,7 @@
B64979B324EEC2DA008ABD20 /* laser128.plist in Resources */,
B64979BC24EEC2DA008ABD20 /* apple2ee.plist in Resources */,
B64979B724EEC2DA008ABD20 /* apple2cp.plist in Resources */,
B64979BF24EF5AEA008ABD20 /* MediaView.xib in Resources */,
B64E15B824EC912200E8AD3D /* SlotView.xib in Resources */,
B64979B924EEC2DA008ABD20 /* apple2eefr.plist in Resources */,
B64979B024EEC2DA008ABD20 /* apple2gs.plist in Resources */,
@ -277,6 +286,7 @@
B6BA258824E99BEB005FB8FF /* main.m in Sources */,
B64E15AC24EA1FD400E8AD3D /* SlotBrowserDelegate.m in Sources */,
B64E15A924EA1D5300E8AD3D /* ROMBrowserDelegate.m in Sources */,
B64979C224EF6703008ABD20 /* MediaViewController.m in Sources */,
B60A6E1424EE0AE2004B7EEF /* FlippedView.m in Sources */,
B6BA258024E99BE9005FB8FF /* AppDelegate.m in Sources */,
B65593B124ECB61800722E0C /* SlotViewController.m in Sources */,
@ -286,6 +296,14 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
B64979BD24EF5AEA008ABD20 /* MediaView.xib */ = {
isa = PBXVariantGroup;
children = (
B64979BE24EF5AEA008ABD20 /* Base */,
);
name = MediaView.xib;
sourceTree = "<group>";
};
B64E15A424E9B34700E8AD3D /* Models.plist */ = {
isa = PBXVariantGroup;
children = (

View File

@ -7,18 +7,19 @@
//
#import "AppDelegate.h"
#import "SlotBrowserDelegate.h"
#import "SlotViewController.h"
#import "MediaViewController.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *window;
@property (strong) IBOutlet SlotBrowserDelegate *slotDelegate;
@property (strong) IBOutlet SlotViewController *slotController;
@property (strong) IBOutlet MediaViewController *mediaController;
@property (weak) IBOutlet NSView *modelView;
@property (weak) IBOutlet NSView *slotView;
@property (weak) IBOutlet NSView *mediaView;
/* kvo */
@property NSString *commandLine;
@ -80,6 +81,7 @@ static NSString *kMyContext = @"kMyContext";
#endif
[_slotView addSubview: [_slotController view]];
[_mediaView addSubview: [_mediaController view]];
[self addObserver: self forKeyPath: @"mameROM" options:0 context: (__bridge void * _Nullable)(kMyContext)];
@ -87,6 +89,8 @@ static NSString *kMyContext = @"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)];
[_slotController addObserver: self forKeyPath: @"args" options: 0 context: (__bridge void * _Nullable)(kMyContext)];
[self buildCommandLine];
}
@ -102,7 +106,7 @@ static NSString *kMyContext = @"kMyContext";
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
if (context == (__bridge void *)kMyContext && object == self) {
if (context == (__bridge void *)kMyContext) {
[self buildCommandLine];
} else {
[super observeValueForKeyPath: keyPath ofObject: object change: change context: context];
@ -126,23 +130,35 @@ static NSString *kMyContext = @"kMyContext";
if (_mameWindow) [argv addObject: @"-window"];
// -nounevenstretch -video soft
if (_mameWindow && _mameSquarePixels) {
[argv addObject: @"-skip_gameinfo"];
if (_mameWindow && _mameSquarePixels) {
NSSize screen = [_slotController resolution];
NSString *res = [NSString stringWithFormat: @"%ux%u", (unsigned)screen.width, (unsigned)screen.height];
[argv addObject: @"-nomax"];
[argv addObject: @"-nounevenstretch"];
if ([_mameROM hasPrefix: @"apple2gs"]) {
[argv addObject: @"-resolution"];
[argv addObject: @"704x462"];
[argv addObject: res]; // @"704x462"];
[argv addObject: @"-video"];
[argv addObject: @"soft"];
[argv addObject: @"-aspect"];
[argv addObject: @"704:462"];
} else {
[argv addObject: @"-resolution"];
[argv addObject: @"560x384"];
[argv addObject: res]; // @"560x384"];
}
}
NSArray *args = [_slotController args];
if ([args count]) {
[argv addObjectsFromArray: args];
}
if (_mameNoThrottle) [argv addObject: @"-nothrottle"];
[self setCommandLine: [argv componentsJoinedByString:@" "]];
@ -157,7 +173,6 @@ static NSString *kMyContext = @"kMyContext";
// [self buildCommandLine];
[_slotDelegate setModel: model];
[_slotController setModel: model];
}

View File

@ -15,9 +15,10 @@
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate">
<connections>
<outlet property="mediaController" destination="kiU-IX-LTW" id="HXj-YL-bBX"/>
<outlet property="mediaView" destination="Jcd-jI-Pje" id="d1b-R8-L4a"/>
<outlet property="modelView" destination="jf6-4d-ms1" id="HUy-kg-cCk"/>
<outlet property="slotController" destination="CYF-Xd-EdF" id="14d-v7-98c"/>
<outlet property="slotDelegate" destination="xmI-g8-lsK" id="hrE-aS-P30"/>
<outlet property="slotView" destination="cFJ-CO-Dzm" id="u9o-0O-D5i"/>
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
</connections>
@ -773,11 +774,15 @@
<rect key="frame" x="20" y="169" width="306" height="570"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jcd-jI-Pje" customClass="FlippedView">
<rect key="frame" x="392" y="169" width="306" height="570"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
</customView>
</subviews>
</view>
<point key="canvasLocation" x="769" y="196.5"/>
</window>
<customObject id="xmI-g8-lsK" customClass="SlotBrowserDelegate"/>
<viewController title="Slot View" nibName="SlotView" id="CYF-Xd-EdF" customClass="SlotViewController"/>
<viewController title="Media View" nibName="MediaView" id="kiU-IX-LTW" customClass="MediaViewController"/>
</objects>
</document>

View File

@ -0,0 +1,63 @@
<?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="MediaViewController">
<connections>
<outlet property="view" destination="nVT-kT-bWl" id="NlD-wb-k1B"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="20" horizontalPageScroll="10" verticalLineScroll="20" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="nVT-kT-bWl">
<rect key="frame" x="0.0" y="0.0" width="240" height="500"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="IBD-wb-pch">
<rect key="frame" x="0.0" y="0.0" width="240" height="500"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" selectionHighlightStyle="none" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" indentationPerLevel="16" outlineTableColumn="pBj-py-R6a" id="sIz-DD-PZQ">
<rect key="frame" x="0.0" y="0.0" width="240" height="500"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="2" height="3"/>
<color key="backgroundColor" white="1" alpha="0.0" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn editable="NO" width="116" minWidth="40" maxWidth="1000" id="pBj-py-R6a">
<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="38q-oo-8Mx">
<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"/>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="-2" id="nas-vC-iDM"/>
<outlet property="delegate" destination="-2" id="bEp-a2-QXT"/>
</connections>
</outlineView>
</subviews>
<nil key="backgroundColor"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="9Vz-lW-4GG">
<rect key="frame" x="1" y="119" width="223" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="f8l-nC-KhG">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<point key="canvasLocation" x="-161" y="55"/>
</scrollView>
</objects>
</document>

View File

@ -182,7 +182,9 @@
<font key="font" metaFont="menu"/>
<menu key="menu" id="k8O-sG-Qld">
<items>
<menuItem title="Item 1" state="on" id="92u-m2-3yN"/>
<menuItem title="Item 1" state="on" id="92u-m2-3yN">
<attributedString key="attributedTitle"/>
</menuItem>
<menuItem title="Item 2" id="dPG-tR-M4A"/>
<menuItem title="Item 3" id="q2n-oZ-46s"/>
</items>

View File

@ -0,0 +1,17 @@
//
// MediaViewController.h
// MA2ME
//
// Created by Kelvin Sherlock on 8/20/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import <Cocoa/Cocoa.h>
NS_ASSUME_NONNULL_BEGIN
@interface MediaViewController : NSViewController <NSOutlineViewDelegate, NSOutlineViewDataSource>
@end
NS_ASSUME_NONNULL_END

221
MA2ME/MediaViewController.m Normal file
View File

@ -0,0 +1,221 @@
//
// MediaViewController.m
// MA2ME
//
// Created by Kelvin Sherlock on 8/20/2020.
// Copyright © 2020 Kelvin Sherlock. All rights reserved.
//
#import "MediaViewController.h"
@interface MediaCategory : NSObject {
}
@property NSInteger validCount;
@property NSArray *children; // URLs?
@property NSString *title;
-(NSInteger)count;
-(id)objectAtIndex:(NSInteger)index;
-(BOOL)isGroupItem;
@end
@implementation MediaCategory
-(instancetype)initWithTitle: (NSString *)title {
[self setTitle: title];
return self;
}
-(NSInteger) count {
return [_children count];
}
-(id)objectAtIndex:(NSInteger)index {
return [_children objectAtIndex: index];
}
-(BOOL)isGroupItem {
return YES;
}
-(BOOL)isExpandable {
return YES;
}
-(void)prepareCell: (id)cell {
[(NSTextFieldCell *)cell setTitle: _title];
}
@end
@interface MediaItem : NSObject {
}
@property NSURL *url;
-(NSInteger)count;
-(id)objectAtIndex:(NSInteger)index;
-(BOOL)isGroupItem;
@end
@implementation MediaItem
-(instancetype)initWithURL: (NSURL *)url {
[self setUrl: url];
return self;
}
-(NSInteger) count {
return 0;
}
-(id)objectAtIndex:(NSInteger)index {
return nil;
}
-(BOOL)isGroupItem {
return NO;
}
-(BOOL)isExpandable {
return NO;
}
-(void)prepareCell: (id)cell {
[(NSTextFieldCell *)cell setTitle: @"xxx"];
}
@end
@interface MediaViewController () {
MediaCategory *_data[4];
NSArray *_root;
}
@end
@implementation MediaViewController
-(void)awakeFromNib {
MediaCategory *a, *b, *c, *d;
a = [[MediaCategory alloc] initWithTitle: @"5.25\" Floppies"];
b = [[MediaCategory alloc] initWithTitle: @"3.5\" Floppies"];
c = [[MediaCategory alloc] initWithTitle: @"Hard Drives"];
d = [[MediaCategory alloc] initWithTitle: @"Casettes"];
_data[0] = a;
_data[1] = b;
_data[2] = c;
_data[3] = d;
_root = @[a,b,c,d];
[a setChildren: @[
[MediaItem new],
[MediaItem new],
]];
[b setChildren: @[
[MediaItem new],
[MediaItem new],
]];
[c setChildren: @[
[MediaItem new],
[MediaItem new],
]];
}
- (void)viewDidLoad {
[super viewDidLoad];
//NSOutlineView *view = [self view];
//[view expandItem: nil expandChildren: YES];
// Do view setup here.
}
#pragma mark - NSOutlineViewDelegate
#if 0
- (void)outlineView:(NSOutlineView *)outlineView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row {
}
- (void)outlineView:(NSOutlineView *)outlineView didRemoveRowView:(NSTableRowView *)rowView forRow:(NSInteger)row {
}
//- (NSTableRowView *)outlineView:(NSOutlineView *)outlineView rowViewForItem:(id)item;
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
//NSView *v = [outlineView makeViewWithIdentifier:<#(nonnull NSUserInterfaceItemIdentifier)#> owner: self];
NSView *v = [[NSView alloc]initWithFrame: NSZeroRect];
return v;
}
#endif
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
return [item isExpandable];
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item {
return [item isGroupItem];
}
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item {
[item prepareCell: cell];
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item {
return YES;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowCellExpansionForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
return YES;
}
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
return nil;
}
#pragma mark - NSOutlineViewDataSource
// nil item indicates the root.
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
if (item == nil)
return [_root count];
return [item count];
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
if (item == nil) {
return [_root objectAtIndex: index];
}
return [item objectAtIndex: index];
}
@end

View File

@ -202,11 +202,11 @@ static void SetDefaultMenu(NSArray *items, NSPopUpButton *button) {
return;
}
NSDictionary *r = [d objectForKey: @"resolution"];
NSArray *r = [d objectForKey: @"Resolution"];
NSSize res = NSMakeSize(0, 0);
if (r) {
res.height = [(NSNumber *)[r objectForKey: @"height"] doubleValue];
res.width = [(NSNumber *)[r objectForKey: @"width"] doubleValue];
res.width = [(NSNumber *)[r objectAtIndex: 0 /*@"width"*/] doubleValue];
res.height = [(NSNumber *)[r objectAtIndex: 1 /*@"height"*/] doubleValue];
}
[self setResolution: res];
@ -244,9 +244,14 @@ static void SetDefaultMenu(NSArray *items, NSPopUpButton *button) {
//
NSDictionary *o = [[sender selectedItem] representedObject];
[self setMemory: [o objectForKey: @"description"]];
NSString *title = [o objectForKey: @"description"];
[self setMemory: title];
[self setMemoryBytes: [(NSNumber *)[o objectForKey: @"value"] unsignedIntValue]];
// if pull-down menu
if ([sender pullsDown])
[sender setTitle: title];
[self rebuildArgs];
}