improved slot binding.

This commit is contained in:
Kelvin Sherlock 2020-08-20 00:00:56 -04:00
parent 7b6d4de5b1
commit 49363d6efd
4 changed files with 185 additions and 25 deletions

View File

@ -8,7 +8,6 @@
/* Begin PBXBuildFile section */
B60A6E0C24ECE23F004B7EEF /* apple2gs.plist in Resources */ = {isa = PBXBuildFile; fileRef = B60A6E0B24ECE23F004B7EEF /* apple2gs.plist */; };
B60A6E0F24EDFB88004B7EEF /* SlotView2.xib in Resources */ = {isa = PBXBuildFile; fileRef = B60A6E0D24EDFB88004B7EEF /* SlotView2.xib */; };
B60A6E1424EE0AE2004B7EEF /* FlippedView.m in Sources */ = {isa = PBXBuildFile; fileRef = B60A6E1324EE0AE2004B7EEF /* FlippedView.m */; };
B64E15A624E9B34700E8AD3D /* Models.plist in Resources */ = {isa = PBXBuildFile; fileRef = B64E15A424E9B34700E8AD3D /* Models.plist */; };
B64E15A924EA1D5300E8AD3D /* ROMBrowserDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B64E15A824EA1D5300E8AD3D /* ROMBrowserDelegate.m */; };
@ -16,6 +15,10 @@
B64E15B524EA383F00E8AD3D /* apple2gs in Resources */ = {isa = PBXBuildFile; fileRef = B64E15B424EA383F00E8AD3D /* apple2gs */; };
B64E15B824EC912200E8AD3D /* SlotView.xib in Resources */ = {isa = PBXBuildFile; fileRef = B64E15B624EC912200E8AD3D /* SlotView.xib */; };
B65593B124ECB61800722E0C /* SlotViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B65593B024ECB61800722E0C /* SlotViewController.m */; };
B67BD48324EE248C0073E334 /* ace100.plist in Resources */ = {isa = PBXBuildFile; fileRef = B67BD48224EE248C0073E334 /* ace100.plist */; };
B67BD48624EE249D0073E334 /* apple1.plist in Resources */ = {isa = PBXBuildFile; fileRef = B67BD48424EE249D0073E334 /* apple1.plist */; };
B67BD48724EE249D0073E334 /* apple2.plist in Resources */ = {isa = PBXBuildFile; fileRef = B67BD48524EE249D0073E334 /* apple2.plist */; };
B67BD48924EE24A40073E334 /* apple3.plist in Resources */ = {isa = PBXBuildFile; fileRef = B67BD48824EE24A40073E334 /* apple3.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 */; };
@ -24,7 +27,6 @@
/* Begin PBXFileReference section */
B60A6E0B24ECE23F004B7EEF /* apple2gs.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = apple2gs.plist; sourceTree = "<group>"; };
B60A6E0E24EDFB88004B7EEF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = MA2ME/MA2ME/Base.lproj/SlotView2.xib; sourceTree = "<group>"; };
B60A6E1224EE0AE2004B7EEF /* FlippedView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FlippedView.h; sourceTree = "<group>"; };
B60A6E1324EE0AE2004B7EEF /* FlippedView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlippedView.m; sourceTree = "<group>"; };
B64E15A524E9B34700E8AD3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Base; path = Base.lproj/Models.plist; sourceTree = "<group>"; };
@ -36,6 +38,10 @@
B64E15B724EC912200E8AD3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = MA2ME/Base.lproj/SlotView.xib; sourceTree = "<group>"; };
B65593AF24ECB61800722E0C /* SlotViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SlotViewController.h; sourceTree = "<group>"; };
B65593B024ECB61800722E0C /* SlotViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SlotViewController.m; sourceTree = "<group>"; };
B67BD48224EE248C0073E334 /* ace100.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ace100.plist; sourceTree = "<group>"; };
B67BD48424EE249D0073E334 /* apple1.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = apple1.plist; sourceTree = "<group>"; };
B67BD48524EE249D0073E334 /* apple2.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = apple2.plist; sourceTree = "<group>"; };
B67BD48824EE24A40073E334 /* apple3.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = apple3.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>"; };
@ -60,6 +66,10 @@
B64E15AF24EA365E00E8AD3D /* Resources */ = {
isa = PBXGroup;
children = (
B67BD48424EE249D0073E334 /* apple1.plist */,
B67BD48524EE249D0073E334 /* apple2.plist */,
B67BD48824EE24A40073E334 /* apple3.plist */,
B67BD48224EE248C0073E334 /* ace100.plist */,
B60A6E0B24ECE23F004B7EEF /* apple2gs.plist */,
B64E15B424EA383F00E8AD3D /* apple2gs */,
B64E15A424E9B34700E8AD3D /* Models.plist */,
@ -72,7 +82,6 @@
children = (
B60A6E1224EE0AE2004B7EEF /* FlippedView.h */,
B60A6E1324EE0AE2004B7EEF /* FlippedView.m */,
B60A6E0D24EDFB88004B7EEF /* SlotView2.xib */,
B65593AF24ECB61800722E0C /* SlotViewController.h */,
B65593B024ECB61800722E0C /* SlotViewController.m */,
B6BA257D24E99BE9005FB8FF /* MA2ME */,
@ -165,12 +174,15 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B67BD48324EE248C0073E334 /* ace100.plist in Resources */,
B67BD48624EE249D0073E334 /* apple1.plist in Resources */,
B6BA258224E99BEB005FB8FF /* Assets.xcassets in Resources */,
B6BA258524E99BEB005FB8FF /* MainMenu.xib in Resources */,
B60A6E0F24EDFB88004B7EEF /* SlotView2.xib in Resources */,
B67BD48924EE24A40073E334 /* apple3.plist in Resources */,
B64E15B824EC912200E8AD3D /* SlotView.xib in Resources */,
B64E15B524EA383F00E8AD3D /* apple2gs in Resources */,
B60A6E0C24ECE23F004B7EEF /* apple2gs.plist in Resources */,
B67BD48724EE249D0073E334 /* apple2.plist in Resources */,
B64E15A624E9B34700E8AD3D /* Models.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -194,14 +206,6 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
B60A6E0D24EDFB88004B7EEF /* SlotView2.xib */ = {
isa = PBXVariantGroup;
children = (
B60A6E0E24EDFB88004B7EEF /* Base */,
);
name = SlotView2.xib;
sourceTree = "<group>";
};
B64E15A424E9B34700E8AD3D /* Models.plist */ = {
isa = PBXVariantGroup;
children = (

View File

@ -154,9 +154,11 @@ static NSString *kMyContext = @"kMyContext";
NSString *model = [item objectForKey: @"Mame"];
[self setMameROM: model];
// [self buildCommandLine];
[_slotDelegate setModel: model];
[_slotController setModel: model];
}
#pragma mark NSBrowser

View File

@ -41,7 +41,15 @@
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="JGU-aq-3uw"/>
<gridRow yPlacement="center" height="30" id="JGU-aq-3uw">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.sl1" id="1io-aZ-v2G">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="gVW-Ya-phU">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.sl2" id="AgS-hm-ePr">
@ -51,11 +59,51 @@
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="3fP-qp-zmi"/>
<gridRow yPlacement="center" height="30" id="86u-5p-UT6"/>
<gridRow yPlacement="center" height="30" id="Wdg-xb-xQx"/>
<gridRow yPlacement="center" height="30" id="ein-Fe-vBw"/>
<gridRow yPlacement="center" height="30" id="qjB-2w-AWE"/>
<gridRow yPlacement="center" height="30" id="3fP-qp-zmi">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.sl3" id="98U-4P-iRh">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="86u-5p-UT6">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.sl4" id="hsy-pm-Qjk">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="Wdg-xb-xQx">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.sl5" id="0QC-RB-278">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="ein-Fe-vBw">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.sl6" id="731-3P-DUy">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="qjB-2w-AWE">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.sl7" id="sew-Ds-4I9">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="EEX-dh-jwn">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.exp" id="EOZ-lS-QHF">
@ -74,10 +122,42 @@
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="wQi-Oz-7Ye"/>
<gridRow yPlacement="center" height="30" id="gr2-eY-995"/>
<gridRow yPlacement="center" height="30" id="1xN-lm-s4l"/>
<gridRow yPlacement="center" height="30" id="M2s-qn-SIT"/>
<gridRow yPlacement="center" height="30" id="wQi-Oz-7Ye">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.rs232" id="AeP-bn-blv">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="gr2-eY-995">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.gameio" id="x3I-Bd-9di">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="1xN-lm-s4l">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.printer" id="T9a-lH-z5K">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</gridRow>
<gridRow yPlacement="center" height="30" id="M2s-qn-SIT">
<connections>
<binding destination="-2" name="hidden" keyPath="machine.modem" id="PSe-R3-S3e">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</gridRow>
</rows>
<columns>
<gridColumn xPlacement="fill" width="100" id="zpB-Rf-dWg"/>

View File

@ -21,7 +21,6 @@
@property (weak) IBOutlet NSPopUpButton *sl5_menu;
@property (weak) IBOutlet NSPopUpButton *sl6_menu;
@property (weak) IBOutlet NSPopUpButton *sl7_menu;
@property (weak) IBOutlet NSPopUpButton *sl8_menu;
@property (weak) IBOutlet NSPopUpButton *exp_menu;
@property (weak) IBOutlet NSPopUpButton *aux_menu;
@property (weak) IBOutlet NSPopUpButton *rs232_menu;
@ -85,6 +84,72 @@
[self setArgs: @[]];
}
-(void)syncMemory {
int ix = 0;
NSArray *items = [_machine objectForKey: @"RAM"];
for (NSDictionary *d in items) {
unsigned size = [(NSNumber *)[d objectForKey: @"value"] unsignedIntValue];
if (size == _memoryBytes) {
[_ram_menu selectItemAtIndex: ix];
[self setMemory: [d objectForKey: @"description"]];
return;
}
++ix;
}
[self setMemoryBytes: 0];
[self setMemory: @""];
[_ram_menu selectItemAtIndex: 0];
/* set to default */
}
-(void)syncSlot: (NSString *)slot button: (NSPopUpButton *)button {
NSString *value = [self valueForKey: slot];
if (![value length]) return;
NSArray *items = [_machine objectForKey: slot];
if (![items count]) {
[self setValue: @"" forKey: slot];
return;
}
int ix = 0;
for (NSDictionary *d in items) {
if ([value isEqualToString: [d objectForKey: @"value"]]) {
[button selectItemAtIndex: ix];
return;
}
++ix;
}
[self setValue: @"" forKey: slot];
[button selectItemAtIndex: 0];
}
-(void)syncSlots {
[self syncMemory];
[self syncSlot: @"sl0" button: _sl0_menu];
[self syncSlot: @"sl1" button: _sl1_menu];
[self syncSlot: @"sl2" button: _sl2_menu];
[self syncSlot: @"sl3" button: _sl3_menu];
[self syncSlot: @"sl4" button: _sl4_menu];
[self syncSlot: @"sl5" button: _sl5_menu];
[self syncSlot: @"sl6" button: _sl6_menu];
[self syncSlot: @"sl7" button: _sl7_menu];
[self syncSlot: @"rs232" button: _rs232_menu];
[self syncSlot: @"aux" button: _aux_menu];
[self syncSlot: @"exp" button: _exp_menu];
[self syncSlot: @"gameio" button: _game_menu];
[self syncSlot: @"modem" button: _modem_menu];
[self syncSlot: @"printer" button: _printer_menu];
}
-(void)loadMachine: (NSString *)model {
NSBundle *bundle = [NSBundle mainBundle];
@ -97,9 +162,18 @@
return;
}
NSDictionary *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];
}
[self setResolution: res];
// n.b. - does content binding propogate immediately?
[self setMachine: d];
[self syncSlots];
[self rebuildArgs];
}
@ -109,8 +183,8 @@
@"sl0", @"sl1", @"sl2", @"sl3",
@"sl4", @"sl5", @"sl6", @"sl7",
@"exp", @"aux",
@"gameio", @"printer", @"modem", @"rs232"
@"exp", @"aux", @"rs232",
@"gameio", @"printer", @"modem",
};
NSInteger tag = [sender tag];