mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 18:30:21 +00:00
Redistributed ownership of the user defaults key prefix, the Electron now works other than that settings aren't retained.
This commit is contained in:
parent
f1b99263e0
commit
19457621d8
@ -54,8 +54,8 @@
|
||||
4B8FE21E1DA19D5F0090D3CE /* Vic20Options.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B8FE2191DA19D5F0090D3CE /* Vic20Options.xib */; };
|
||||
4B8FE2201DA19D7C0090D3CE /* Atari2600OptionsPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8FE21F1DA19D7C0090D3CE /* Atari2600OptionsPanel.swift */; };
|
||||
4B8FE2221DA19FB20090D3CE /* MachinePanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8FE2211DA19FB20090D3CE /* MachinePanel.swift */; };
|
||||
4B8FE2241DA1DC2D0090D3CE /* Bundle+DataForResource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8FE2231DA1DC2D0090D3CE /* Bundle+DataForResource.swift */; };
|
||||
4B8FE2271DA1DE2D0090D3CE /* NSBundle+DataResource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8FE2261DA1DE2D0090D3CE /* NSBundle+DataResource.m */; };
|
||||
4B8FE2291DA1EDDF0090D3CE /* ElectronOptionsPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8FE2281DA1EDDF0090D3CE /* ElectronOptionsPanel.swift */; };
|
||||
4B92EACA1B7C112B00246143 /* 6502TimingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B92EAC91B7C112B00246143 /* 6502TimingTests.swift */; };
|
||||
4B96F7221D75119A0058BB2D /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B96F7201D75119A0058BB2D /* Tape.cpp */; };
|
||||
4BA22B071D8817CE0008C640 /* Disk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BA22B051D8817CE0008C640 /* Disk.cpp */; };
|
||||
@ -477,9 +477,9 @@
|
||||
4B8FE21A1DA19D5F0090D3CE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = "Clock Signal/Base.lproj/Vic20Options.xib"; sourceTree = SOURCE_ROOT; };
|
||||
4B8FE21F1DA19D7C0090D3CE /* Atari2600OptionsPanel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Atari2600OptionsPanel.swift; sourceTree = "<group>"; };
|
||||
4B8FE2211DA19FB20090D3CE /* MachinePanel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MachinePanel.swift; sourceTree = "<group>"; };
|
||||
4B8FE2231DA1DC2D0090D3CE /* Bundle+DataForResource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Bundle+DataForResource.swift"; sourceTree = "<group>"; };
|
||||
4B8FE2251DA1DE2D0090D3CE /* NSBundle+DataResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSBundle+DataResource.h"; sourceTree = "<group>"; };
|
||||
4B8FE2261DA1DE2D0090D3CE /* NSBundle+DataResource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSBundle+DataResource.m"; sourceTree = "<group>"; };
|
||||
4B8FE2281DA1EDDF0090D3CE /* ElectronOptionsPanel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElectronOptionsPanel.swift; sourceTree = "<group>"; };
|
||||
4B92EAC91B7C112B00246143 /* 6502TimingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 6502TimingTests.swift; sourceTree = "<group>"; };
|
||||
4B96F7201D75119A0058BB2D /* Tape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Tape.cpp; path = ../../StaticAnalyser/Acorn/Tape.cpp; sourceTree = "<group>"; };
|
||||
4B96F7211D75119A0058BB2D /* Tape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Tape.hpp; path = ../../StaticAnalyser/Acorn/Tape.hpp; sourceTree = "<group>"; };
|
||||
@ -1053,6 +1053,7 @@
|
||||
4B55CE561C3B7D360093A61B /* Atari2600Document.swift */,
|
||||
4B8FE21F1DA19D7C0090D3CE /* Atari2600OptionsPanel.swift */,
|
||||
4B55CE571C3B7D360093A61B /* ElectronDocument.swift */,
|
||||
4B8FE2281DA1EDDF0090D3CE /* ElectronOptionsPanel.swift */,
|
||||
4B55CE5E1C3B7D960093A61B /* MachineDocument.swift */,
|
||||
4B8FE2211DA19FB20090D3CE /* MachinePanel.swift */,
|
||||
4B73C7191D036BD90074D992 /* Vic20Document.swift */,
|
||||
@ -1060,7 +1061,6 @@
|
||||
4B8FE2171DA19D5F0090D3CE /* ElectronOptions.xib */,
|
||||
4B8FE2151DA19D5F0090D3CE /* MachineDocument.xib */,
|
||||
4B8FE2191DA19D5F0090D3CE /* Vic20Options.xib */,
|
||||
4B8FE2231DA1DC2D0090D3CE /* Bundle+DataForResource.swift */,
|
||||
);
|
||||
path = Documents;
|
||||
sourceTree = "<group>";
|
||||
@ -2152,7 +2152,6 @@
|
||||
4BA799951D8B656E0045123D /* StaticAnalyser.cpp in Sources */,
|
||||
4BF829601D8F3C87001BAE39 /* CRC.cpp in Sources */,
|
||||
4B55CE591C3B7D360093A61B /* ElectronDocument.swift in Sources */,
|
||||
4B8FE2241DA1DC2D0090D3CE /* Bundle+DataForResource.swift in Sources */,
|
||||
4B4DC82B1D2C27A4003C5BF8 /* SerialBus.cpp in Sources */,
|
||||
4BC3B74F1CD194CC00F86E85 /* Shader.cpp in Sources */,
|
||||
4B8FE2221DA19FB20090D3CE /* MachinePanel.swift in Sources */,
|
||||
@ -2188,6 +2187,7 @@
|
||||
4B2E2D9D1C3A070400138695 /* Electron.cpp in Sources */,
|
||||
4BAB62B81D3302CA00DF5BA0 /* PCMTrack.cpp in Sources */,
|
||||
4B69FB3D1C4D908A00B5F0AA /* Tape.cpp in Sources */,
|
||||
4B8FE2291DA1EDDF0090D3CE /* ElectronOptionsPanel.swift in Sources */,
|
||||
4B55CE5D1C3B7D6F0093A61B /* CSOpenGLView.m in Sources */,
|
||||
4BB697CB1D4B6D3E00248BDF /* TimedEventLoop.cpp in Sources */,
|
||||
4BF1354C1D6D2C300054B2EA /* StaticAnalyser.cpp in Sources */,
|
||||
|
@ -4,16 +4,14 @@
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="ElectronDocument" customModule="Clock_Signal" customModuleProvider="target">
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MachineDocument" customModule="Clock_Signal" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="displayTypeButton" destination="rh8-km-57n" id="4Np-OD-NLO"/>
|
||||
<outlet property="fastLoadingButton" destination="e1J-pw-zGw" id="yck-sy-WRa"/>
|
||||
<outlet property="optionsPanel" destination="ZW7-Bw-4RP" id="JpE-wG-zRR"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Options" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="ZW7-Bw-4RP" customClass="NSPanel">
|
||||
<window title="Options" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="ZW7-Bw-4RP" customClass="ElectronOptionsPanel" customModule="Clock_Signal" customModuleProvider="target">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" utility="YES" HUD="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="83" y="102" width="200" height="83"/>
|
||||
@ -31,7 +29,7 @@
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="setFastLoading:" target="-2" id="CTb-Dn-QiP"/>
|
||||
<action selector="setFastLoading:" target="ZW7-Bw-4RP" id="JmG-Ks-jSh"/>
|
||||
</connections>
|
||||
</button>
|
||||
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rh8-km-57n">
|
||||
@ -47,7 +45,7 @@
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
<connections>
|
||||
<action selector="setDisplayType:" target="-2" id="kgH-SR-fI3"/>
|
||||
<action selector="setDisplayType:" target="ZW7-Bw-4RP" id="PAH-CZ-zlk"/>
|
||||
</connections>
|
||||
</popUpButton>
|
||||
</subviews>
|
||||
@ -60,6 +58,10 @@
|
||||
<constraint firstAttribute="trailing" secondItem="rh8-km-57n" secondAttribute="trailing" constant="20" id="urO-Ac-aqK"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="displayTypeButton" destination="rh8-km-57n" id="FB2-Zg-VKq"/>
|
||||
<outlet property="fastLoadingButton" destination="e1J-pw-zGw" id="jj7-OZ-mOH"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="129" y="46.5"/>
|
||||
</window>
|
||||
</objects>
|
||||
|
@ -6,17 +6,12 @@
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class Atari2600OptionsPanel: MachinePanel {
|
||||
override var machine: CSMachine! {
|
||||
didSet {
|
||||
if let atari2600 = machine as? CSAtari2600 {
|
||||
self.atari2600 = atari2600
|
||||
}
|
||||
var atari2600: CSAtari2600! {
|
||||
get {
|
||||
return self.machine as! CSAtari2600
|
||||
}
|
||||
}
|
||||
var atari2600: CSAtari2600!
|
||||
|
||||
@IBOutlet var resetButton: NSButton!
|
||||
@IBOutlet var selectButton: NSButton!
|
||||
|
@ -1,19 +0,0 @@
|
||||
//
|
||||
// Bundle+DataForResource.swift
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 02/10/2016.
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Bundle {
|
||||
func dataForResource(_ name : String, ofType type: String, inDirectory directory: String) -> Data? {
|
||||
if let path = self.path(forResource: name, ofType: type, inDirectory: directory) {
|
||||
return try? Data(contentsOf: URL(fileURLWithPath: path))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
@ -15,35 +15,6 @@ class ElectronDocument: MachineDocument {
|
||||
return NSSize(width: 11.0, height: 10.0)
|
||||
}
|
||||
|
||||
fileprivate func rom(_ name: String) -> Data? {
|
||||
return dataForResource(name, ofType: "rom", inDirectory: "ROMImages/Electron")
|
||||
}
|
||||
|
||||
override init() {
|
||||
super.init();
|
||||
|
||||
if let os = rom("os"), let basic = rom("basic") {
|
||||
self.electron.setOSROM(os)
|
||||
self.electron.setBASICROM(basic)
|
||||
}
|
||||
if let dfs = rom("DFS-1770-2.20") {
|
||||
self.electron.setDFSROM(dfs)
|
||||
}
|
||||
if let adfs1 = rom("ADFS-E00_1"), let adfs2 = rom("ADFS-E00_2") {
|
||||
var fullADFS = adfs1
|
||||
fullADFS.append(adfs2)
|
||||
self.electron.setADFSROM(fullADFS as Data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: IBActions
|
||||
@IBOutlet var displayTypeButton: NSPopUpButton?
|
||||
@IBAction func setDisplayType(_ sender: NSPopUpButton!) {
|
||||
electron.useTelevisionOutput = (sender.indexOfSelectedItem == 1)
|
||||
UserDefaults.standard.set(sender.indexOfSelectedItem, forKey: self.displayTypeUserDefaultsKey)
|
||||
}
|
||||
|
||||
fileprivate let displayTypeUserDefaultsKey = "electron.displayType"
|
||||
override func establishStoredOptions() {
|
||||
super.establishStoredOptions()
|
||||
|
@ -0,0 +1,21 @@
|
||||
//
|
||||
// ElectronOptionsPanel.swift
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 02/10/2016.
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
class ElectronOptionsPanel: MachinePanel {
|
||||
var electron: CSElectron! {
|
||||
get {
|
||||
return self.machine as! CSElectron
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet var displayTypeButton: NSPopUpButton?
|
||||
@IBAction func setDisplayType(_ sender: NSPopUpButton!) {
|
||||
electron.useTelevisionOutput = (sender.indexOfSelectedItem == 1)
|
||||
// UserDefaults.standard.set(sender.indexOfSelectedItem, forKey: self.displayTypeUserDefaultsKey)
|
||||
}
|
||||
}
|
@ -66,7 +66,6 @@ class MachineDocument:
|
||||
|
||||
setupClockRate()
|
||||
self.machine.delegate = self
|
||||
establishStoredOptions()
|
||||
}
|
||||
|
||||
func machineDidChangeClockRate(_ machine: CSMachine!) {
|
||||
@ -190,36 +189,4 @@ class MachineDocument:
|
||||
$0.setKey(VK_Option, isPressed: newModifiers.modifierFlags.contains(.option))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: IBActions
|
||||
final func prefixedUserDefaultsKey(_ key: String) -> String {
|
||||
return "\(self.name).\(key)"
|
||||
}
|
||||
var fastLoadingUserDefaultsKey: String {
|
||||
get {
|
||||
return prefixedUserDefaultsKey("fastLoading")
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet var fastLoadingButton: NSButton?
|
||||
@IBAction func setFastLoading(_ sender: NSButton!) {
|
||||
if let fastLoadingMachine = machine as? CSFastLoading {
|
||||
let useFastLoadingHack = sender.state == NSOnState
|
||||
fastLoadingMachine.useFastLoadingHack = useFastLoadingHack
|
||||
UserDefaults.standard.set(useFastLoadingHack, forKey: fastLoadingUserDefaultsKey)
|
||||
}
|
||||
}
|
||||
|
||||
func establishStoredOptions() {
|
||||
let standardUserDefaults = UserDefaults.standard
|
||||
standardUserDefaults.register(defaults: [
|
||||
fastLoadingUserDefaultsKey: true
|
||||
])
|
||||
|
||||
if let fastLoadingMachine = machine as? CSFastLoading {
|
||||
let useFastLoadingHack = standardUserDefaults.bool(forKey: self.fastLoadingUserDefaultsKey)
|
||||
fastLoadingMachine.useFastLoadingHack = useFastLoadingHack
|
||||
self.fastLoadingButton?.state = useFastLoadingHack ? NSOnState : NSOffState
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,36 @@ import Cocoa
|
||||
|
||||
class MachinePanel: NSPanel {
|
||||
var machine: CSMachine!
|
||||
|
||||
// MARK: IBActions
|
||||
final func prefixedUserDefaultsKey(_ key: String) -> String {
|
||||
return "\(self.machine.userDefaultsPrefix).\(key)"
|
||||
}
|
||||
var fastLoadingUserDefaultsKey: String {
|
||||
get {
|
||||
return prefixedUserDefaultsKey("fastLoading")
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet var fastLoadingButton: NSButton?
|
||||
@IBAction func setFastLoading(_ sender: NSButton!) {
|
||||
if let fastLoadingMachine = machine as? CSFastLoading {
|
||||
let useFastLoadingHack = sender.state == NSOnState
|
||||
fastLoadingMachine.useFastLoadingHack = useFastLoadingHack
|
||||
UserDefaults.standard.set(useFastLoadingHack, forKey: fastLoadingUserDefaultsKey)
|
||||
}
|
||||
}
|
||||
|
||||
func establishStoredOptions() {
|
||||
let standardUserDefaults = UserDefaults.standard
|
||||
standardUserDefaults.register(defaults: [
|
||||
fastLoadingUserDefaultsKey: true
|
||||
])
|
||||
|
||||
if let fastLoadingMachine = machine as? CSFastLoading {
|
||||
let useFastLoadingHack = standardUserDefaults.bool(forKey: self.fastLoadingUserDefaultsKey)
|
||||
fastLoadingMachine.useFastLoadingHack = useFastLoadingHack
|
||||
self.fastLoadingButton?.state = useFastLoadingHack ? NSOnState : NSOffState
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,8 @@
|
||||
@property (nonatomic, readonly) double clockRate;
|
||||
@property (nonatomic, readonly) BOOL clockIsUnlimited;
|
||||
|
||||
@property (nonatomic, readonly) NSString *userDefaultsPrefix;
|
||||
|
||||
- (void)paste:(NSString *)string;
|
||||
|
||||
@end
|
||||
|
@ -15,7 +15,6 @@
|
||||
- (instancetype)initWithFileAtURL:(NSURL *)url;
|
||||
|
||||
@property(nonatomic, readonly) NSString *optionsPanelNibName;
|
||||
@property(nonatomic, readonly) NSString *userDefaultsPrefix;
|
||||
- (CSMachine *)newMachine;
|
||||
|
||||
@property(nonatomic, readonly) NSString *displayName;
|
||||
|
@ -38,7 +38,7 @@
|
||||
{
|
||||
switch(_target.machine)
|
||||
{
|
||||
case StaticAnalyser::Target::Electron: return nil;
|
||||
case StaticAnalyser::Target::Electron: return @"ElectronOptions";
|
||||
case StaticAnalyser::Target::Vic20: return nil;
|
||||
case StaticAnalyser::Target::Atari2600: return @"Atari2600Options";
|
||||
}
|
||||
@ -56,18 +56,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)userDefaultsPrefix
|
||||
{
|
||||
switch(_target.machine)
|
||||
{
|
||||
case StaticAnalyser::Target::Electron: return @"electron";
|
||||
case StaticAnalyser::Target::Vic20: return @"vic20";
|
||||
case StaticAnalyser::Target::Atari2600: return @"atari2600";
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)applyToMachine:(CSMachine *)machine
|
||||
{
|
||||
[machine applyTarget:_target];
|
||||
|
@ -115,4 +115,6 @@ struct CRTDelegate: public Outputs::CRT::Delegate {
|
||||
[self toggleSwitch:Atari2600SwitchSelect];
|
||||
}
|
||||
|
||||
- (NSString *)userDefaultsPrefix { return @"atari2600"; }
|
||||
|
||||
@end
|
||||
|
@ -148,6 +148,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)userDefaultsPrefix { return @"electron"; }
|
||||
|
||||
#pragma mark - Options
|
||||
|
||||
- (void)setUseFastLoadingHack:(BOOL)useFastLoadingHack {
|
||||
|
@ -182,4 +182,6 @@ using namespace Commodore::Vic20;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)userDefaultsPrefix { return @"vic20"; }
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user