diff --git a/Ample/Slot.h b/Ample/Slot.h index dee2c1f..7e94492 100644 --- a/Ample/Slot.h +++ b/Ample/Slot.h @@ -15,6 +15,12 @@ @class Slot, SlotOption, SlotTableCellView; +typedef enum SlotType { + kSlotRAM = 1, + kSlotBIOS, + kSlotFDC, +} SlotType; + @interface Slot : NSObject @property NSInteger defaultIndex; @@ -24,6 +30,7 @@ @property (readonly) NSString *name; @property (readonly) NSString *title; @property (readonly) NSArray *menuItems; +@property (readonly) SlotType type; @property (readonly) SlotOption *selectedItem; @property (readonly) NSString *selectedValue; diff --git a/Ample/Slot.m b/Ample/Slot.m index 4b7bb22..5edf8d5 100644 --- a/Ample/Slot.m +++ b/Ample/Slot.m @@ -72,6 +72,18 @@ static NSArray *DeepCopyArray(NSArray *src) { @implementation Slot +@synthesize type = _type; + + +static NSDictionary *TypeMap = nil; + ++(void)load { + TypeMap = @{ + @"ramsize": @(kSlotRAM), + @"smartport": @(kSlotFDC), + @"bios": @(kSlotBIOS), + }; +} -(void)reset { [self setSelectedIndex: _defaultIndex >= 0 ? _defaultIndex : 0]; @@ -129,7 +141,7 @@ static NSArray *DeepCopyArray(NSArray *src) { // { 'sl3' : 'uthernet' } // special case for smartport since the name isn't used. - if ([_name isEqualToString: @"-smartport"]) { + if (_type == kSlotFDC) { SlotOption *option = [_options objectAtIndex: _selectedIndex]; [option reserialize: dict]; return; @@ -264,7 +276,11 @@ static NSArray *DeepCopyArray(NSArray *src) { _name = [data objectForKey: @"name"]; _title = [data objectForKey: @"description"]; - + + NSNumber *x = [TypeMap objectForKey: _name]; + if (x) _type = [x intValue]; + + if (index < 0x10000) { topLevel = YES; _name = [@"-" stringByAppendingString: _name]; @@ -340,7 +356,7 @@ static NSArray *DeepCopyArray(NSArray *src) { // [menu setItemArray: ] doesn't work prior to 10.14, apparently. [menu removeAllItems]; - if ([_name isEqualToString: @"-smartport"]) { + if (_type == kSlotFDC) { //[menu setItemArray: @[]]; [button setHidden: YES]; } else { diff --git a/Ample/SlotViewController.m b/Ample/SlotViewController.m index 9027ea5..9493c13 100644 --- a/Ample/SlotViewController.m +++ b/Ample/SlotViewController.m @@ -112,7 +112,7 @@ static unsigned RootKey = 0; NSInteger index = [item index] - 1; if (index < 0 || index >= MAX_SLOTS) continue; - if ([name isEqualToString: @"-bios"]) continue; + if ([item type] == kSlotBIOS) continue; NSString *v = [_slotValues objectForKey: name]; if (v) { @@ -191,7 +191,7 @@ static unsigned RootKey = 0; SlotOption *o = [[sender selectedItem] representedObject]; Slot *item = [_root objectAtIndex: index]; - if (direct) { + if (direct && [item type] != kSlotBIOS) { NSString *name = [item name]; NSString *value = [o value]; [_slotValues setObject: value forKey: name];