mirror of
https://github.com/ksherlock/ample.git
synced 2024-10-31 15:04:56 +00:00
use an enum to identify special slots types (ram, bios, floppy disk controller)
This commit is contained in:
parent
9b3223478c
commit
6ef3911da7
@ -15,6 +15,12 @@
|
|||||||
@class Slot, SlotOption, SlotTableCellView;
|
@class Slot, SlotOption, SlotTableCellView;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum SlotType {
|
||||||
|
kSlotRAM = 1,
|
||||||
|
kSlotBIOS,
|
||||||
|
kSlotFDC,
|
||||||
|
} SlotType;
|
||||||
|
|
||||||
@interface Slot : NSObject<NSCopying>
|
@interface Slot : NSObject<NSCopying>
|
||||||
|
|
||||||
@property NSInteger defaultIndex;
|
@property NSInteger defaultIndex;
|
||||||
@ -24,6 +30,7 @@
|
|||||||
@property (readonly) NSString *name;
|
@property (readonly) NSString *name;
|
||||||
@property (readonly) NSString *title;
|
@property (readonly) NSString *title;
|
||||||
@property (readonly) NSArray *menuItems;
|
@property (readonly) NSArray *menuItems;
|
||||||
|
@property (readonly) SlotType type;
|
||||||
|
|
||||||
@property (readonly) SlotOption *selectedItem;
|
@property (readonly) SlotOption *selectedItem;
|
||||||
@property (readonly) NSString *selectedValue;
|
@property (readonly) NSString *selectedValue;
|
||||||
|
20
Ample/Slot.m
20
Ample/Slot.m
@ -72,6 +72,18 @@ static NSArray *DeepCopyArray(NSArray *src) {
|
|||||||
|
|
||||||
@implementation Slot
|
@implementation Slot
|
||||||
|
|
||||||
|
@synthesize type = _type;
|
||||||
|
|
||||||
|
|
||||||
|
static NSDictionary *TypeMap = nil;
|
||||||
|
|
||||||
|
+(void)load {
|
||||||
|
TypeMap = @{
|
||||||
|
@"ramsize": @(kSlotRAM),
|
||||||
|
@"smartport": @(kSlotFDC),
|
||||||
|
@"bios": @(kSlotBIOS),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
-(void)reset {
|
-(void)reset {
|
||||||
[self setSelectedIndex: _defaultIndex >= 0 ? _defaultIndex : 0];
|
[self setSelectedIndex: _defaultIndex >= 0 ? _defaultIndex : 0];
|
||||||
@ -129,7 +141,7 @@ static NSArray *DeepCopyArray(NSArray *src) {
|
|||||||
// { 'sl3' : 'uthernet' }
|
// { 'sl3' : 'uthernet' }
|
||||||
|
|
||||||
// special case for smartport since the name isn't used.
|
// special case for smartport since the name isn't used.
|
||||||
if ([_name isEqualToString: @"-smartport"]) {
|
if (_type == kSlotFDC) {
|
||||||
SlotOption *option = [_options objectAtIndex: _selectedIndex];
|
SlotOption *option = [_options objectAtIndex: _selectedIndex];
|
||||||
[option reserialize: dict];
|
[option reserialize: dict];
|
||||||
return;
|
return;
|
||||||
@ -265,6 +277,10 @@ static NSArray *DeepCopyArray(NSArray *src) {
|
|||||||
_name = [data objectForKey: @"name"];
|
_name = [data objectForKey: @"name"];
|
||||||
_title = [data objectForKey: @"description"];
|
_title = [data objectForKey: @"description"];
|
||||||
|
|
||||||
|
NSNumber *x = [TypeMap objectForKey: _name];
|
||||||
|
if (x) _type = [x intValue];
|
||||||
|
|
||||||
|
|
||||||
if (index < 0x10000) {
|
if (index < 0x10000) {
|
||||||
topLevel = YES;
|
topLevel = YES;
|
||||||
_name = [@"-" stringByAppendingString: _name];
|
_name = [@"-" stringByAppendingString: _name];
|
||||||
@ -340,7 +356,7 @@ static NSArray *DeepCopyArray(NSArray *src) {
|
|||||||
// [menu setItemArray: ] doesn't work prior to 10.14, apparently.
|
// [menu setItemArray: ] doesn't work prior to 10.14, apparently.
|
||||||
[menu removeAllItems];
|
[menu removeAllItems];
|
||||||
|
|
||||||
if ([_name isEqualToString: @"-smartport"]) {
|
if (_type == kSlotFDC) {
|
||||||
//[menu setItemArray: @[]];
|
//[menu setItemArray: @[]];
|
||||||
[button setHidden: YES];
|
[button setHidden: YES];
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,7 +112,7 @@ static unsigned RootKey = 0;
|
|||||||
NSInteger index = [item index] - 1;
|
NSInteger index = [item index] - 1;
|
||||||
if (index < 0 || index >= MAX_SLOTS) continue;
|
if (index < 0 || index >= MAX_SLOTS) continue;
|
||||||
|
|
||||||
if ([name isEqualToString: @"-bios"]) continue;
|
if ([item type] == kSlotBIOS) continue;
|
||||||
|
|
||||||
NSString *v = [_slotValues objectForKey: name];
|
NSString *v = [_slotValues objectForKey: name];
|
||||||
if (v) {
|
if (v) {
|
||||||
@ -191,7 +191,7 @@ static unsigned RootKey = 0;
|
|||||||
SlotOption *o = [[sender selectedItem] representedObject];
|
SlotOption *o = [[sender selectedItem] representedObject];
|
||||||
Slot *item = [_root objectAtIndex: index];
|
Slot *item = [_root objectAtIndex: index];
|
||||||
|
|
||||||
if (direct) {
|
if (direct && [item type] != kSlotBIOS) {
|
||||||
NSString *name = [item name];
|
NSString *name = [item name];
|
||||||
NSString *value = [o value];
|
NSString *value = [o value];
|
||||||
[_slotValues setObject: value forKey: name];
|
[_slotValues setObject: value forKey: name];
|
||||||
|
Loading…
Reference in New Issue
Block a user