mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-26 15:32:04 +00:00
Ensures complete machine picker state is preserved.
This commit is contained in:
parent
c697dd78f0
commit
3ffa9e2751
@ -61,6 +61,7 @@ class MachineDocument:
|
||||
if self.shouldShowNewMachinePanel {
|
||||
self.shouldShowNewMachinePanel = false
|
||||
Bundle.main.loadNibNamed(NSNib.Name(rawValue: "MachinePicker"), owner: self, topLevelObjects: nil)
|
||||
self.machinePicker?.establishStoredOptions()
|
||||
self.windowControllers[0].window?.beginSheet(self.machinePickerPanel!, completionHandler: nil)
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,79 @@ class MachinePicker: NSObject {
|
||||
// MARK: - ZX81 properties
|
||||
@IBOutlet var zx81MemorySizeButton: NSPopUpButton?
|
||||
|
||||
// MARK: - Preferences
|
||||
func establishStoredOptions() {
|
||||
let standardUserDefaults = UserDefaults.standard
|
||||
|
||||
// Machine type
|
||||
if let machineIdentifier = standardUserDefaults.string(forKey: "new.machine") {
|
||||
machineSelector?.selectTabViewItem(withIdentifier: machineIdentifier as Any)
|
||||
}
|
||||
|
||||
// Electron settings
|
||||
electronDFSButton?.state = standardUserDefaults.bool(forKey: "new.electronDFS") ? .on : .off
|
||||
electronADFSButton?.state = standardUserDefaults.bool(forKey: "new.electronADFS") ? .on : .off
|
||||
|
||||
// CPC settings
|
||||
cpcModelTypeButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.cpcModel"))
|
||||
|
||||
// MSX settings
|
||||
msxHasDiskDriveButton?.state = standardUserDefaults.bool(forKey: "new.msxDiskDrive") ? .on : .off
|
||||
|
||||
// Oric settings
|
||||
oricHasMicrodriveButton?.state = standardUserDefaults.bool(forKey: "new.oricMicrodrive") ? .on : .off
|
||||
oricModelTypeButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.oricModel"))
|
||||
|
||||
// Vic-20 settings
|
||||
vic20RegionButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.vic20Region"))
|
||||
vic20MemorySizeButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.vic20MemorySize"))
|
||||
vic20HasC1540Button?.state = standardUserDefaults.bool(forKey: "new.vic20C1540") ? .on : .off
|
||||
|
||||
// ZX80
|
||||
zx80MemorySizeButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.zx80MemorySize"))
|
||||
zx80UsesZX81ROMButton?.state = standardUserDefaults.bool(forKey: "new.zx80UsesZX81ROM") ? .on : .off
|
||||
|
||||
// ZX81
|
||||
zx81MemorySizeButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.zx81MemorySize"))
|
||||
}
|
||||
|
||||
fileprivate func storeOptions() {
|
||||
let standardUserDefaults = UserDefaults.standard
|
||||
|
||||
// Machine type
|
||||
standardUserDefaults.set(machineSelector!.selectedTabViewItem!.identifier as! String, forKey: "new.machine")
|
||||
|
||||
// Electron settings
|
||||
standardUserDefaults.set(electronDFSButton!.state == .on, forKey: "new.electronDFS")
|
||||
standardUserDefaults.set(electronADFSButton!.state == .on, forKey: "new.electronADFS")
|
||||
|
||||
// CPC settings
|
||||
standardUserDefaults.set(cpcModelTypeButton!.selectedTag(), forKey: "new.cpcModel")
|
||||
|
||||
// MSX settings
|
||||
standardUserDefaults.set(msxHasDiskDriveButton?.state == .on, forKey: "new.msxDiskDrive")
|
||||
|
||||
// Oric settings
|
||||
standardUserDefaults.set(oricHasMicrodriveButton?.state == .on, forKey: "new.oricMicrodrive")
|
||||
standardUserDefaults.set(oricModelTypeButton!.selectedTag(), forKey: "new.oricModel")
|
||||
|
||||
// Vic-20 settings
|
||||
standardUserDefaults.set(vic20RegionButton!.selectedTag(), forKey: "new.vic20Region")
|
||||
standardUserDefaults.set(vic20MemorySizeButton!.selectedTag(), forKey: "new.vic20MemorySize")
|
||||
standardUserDefaults.set(vic20HasC1540Button?.state == .on, forKey: "new.vic20C1540")
|
||||
|
||||
// ZX80
|
||||
standardUserDefaults.set(zx80MemorySizeButton!.selectedTag(), forKey: "new.zx80MemorySize")
|
||||
standardUserDefaults.set(zx80UsesZX81ROMButton?.state == .on, forKey: "new.zx80UsesZX81ROM")
|
||||
|
||||
// ZX81
|
||||
standardUserDefaults.set(zx81MemorySizeButton!.selectedTag(), forKey: "new.zx81MemorySize")
|
||||
}
|
||||
|
||||
// MARK: - Machine builder
|
||||
func selectedMachine() -> CSStaticAnalyser {
|
||||
storeOptions()
|
||||
|
||||
switch machineSelector!.selectedTabViewItem!.identifier as! String {
|
||||
case "electron":
|
||||
return CSStaticAnalyser(electronDFS: electronDFSButton!.state == .on, adfs: electronADFSButton!.state == .on)!
|
||||
|
Loading…
x
Reference in New Issue
Block a user