1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Minor rearrangements, for cleanliness.

This commit is contained in:
Thomas Harte 2021-07-13 22:26:50 -04:00
parent 4ef3005072
commit e689ca92c4

View File

@ -195,7 +195,7 @@ class MachineDocument:
} }
} }
// MARK: - Connections Between Machine and the Outside World // MARK: - Connections Between Machine and the Outside World.
private func setupMachineOutput() { private func setupMachineOutput() {
if let machine = self.machine, let scanTargetView = self.scanTargetView, machine.view != scanTargetView { if let machine = self.machine, let scanTargetView = self.scanTargetView, machine.view != scanTargetView {
@ -400,6 +400,7 @@ class MachineDocument:
} }
// MARK: - MachinePicker Outlets and Actions // MARK: - MachinePicker Outlets and Actions
@IBOutlet var machinePicker: MachinePicker? @IBOutlet var machinePicker: MachinePicker?
@IBOutlet var machinePickerPanel: NSWindow? @IBOutlet var machinePickerPanel: NSWindow?
@IBAction func createMachine(_ sender: NSButton?) { @IBAction func createMachine(_ sender: NSButton?) {
@ -418,6 +419,7 @@ class MachineDocument:
} }
// MARK: - ROMRequester Outlets and Actions // MARK: - ROMRequester Outlets and Actions
@IBOutlet var romRequesterPanel: NSWindow? @IBOutlet var romRequesterPanel: NSWindow?
@IBOutlet var romRequesterText: NSTextField? @IBOutlet var romRequesterText: NSTextField?
@IBOutlet var romReceiverErrorField: NSTextField? @IBOutlet var romReceiverErrorField: NSTextField?
@ -522,7 +524,8 @@ class MachineDocument:
} }
} }
// MARK: Joystick-via-the-keyboard selection // MARK: - Joystick-via-the-keyboard selection.
@IBAction func useKeyboardAsPhysicalKeyboard(_ sender: NSMenuItem?) { @IBAction func useKeyboardAsPhysicalKeyboard(_ sender: NSMenuItem?) {
machine.inputMode = .keyboardPhysical machine.inputMode = .keyboardPhysical
} }
@ -580,6 +583,8 @@ class MachineDocument:
return super.validateUserInterfaceItem(item) return super.validateUserInterfaceItem(item)
} }
// MARK: - Screenshots.
/// Saves a screenshot of the machine's current display. /// Saves a screenshot of the machine's current display.
@IBAction func saveScreenshot(_ sender: AnyObject!) { @IBAction func saveScreenshot(_ sender: AnyObject!) {
// Grab a date formatter and form a file name. // Grab a date formatter and form a file name.
@ -601,6 +606,7 @@ class MachineDocument:
} }
// MARK: - Window Title Updates. // MARK: - Window Title Updates.
private var unadornedWindowTitle = "" private var unadornedWindowTitle = ""
internal func scanTargetViewDidCaptureMouse(_ view: CSScanTargetView) { internal func scanTargetViewDidCaptureMouse(_ view: CSScanTargetView) {
self.windowControllers[0].window?.title = self.unadornedWindowTitle + " (press ⌘+control to release mouse)" self.windowControllers[0].window?.title = self.unadornedWindowTitle + " (press ⌘+control to release mouse)"
@ -702,14 +708,7 @@ class MachineDocument:
} }
} }
// MARK: - Volume Control. // MARK: - In-window panels (i.e. options, volume).
@IBAction func setVolume(_ sender: NSSlider!) {
if let machine = self.machine {
let linearValue = log2(sender.floatValue)
machine.setVolume(linearValue)
setUserDefaultsVolume(linearValue)
}
}
// This class is pure nonsense to work around Xcode's opaque behaviour. // This class is pure nonsense to work around Xcode's opaque behaviour.
// If I make the main class a sub of CAAnimationDelegate then the compiler // If I make the main class a sub of CAAnimationDelegate then the compiler
@ -776,6 +775,16 @@ class MachineDocument:
} }
} }
// MARK: - Volume Control.
@IBAction func setVolume(_ sender: NSSlider!) {
if let machine = self.machine {
let linearValue = log2(sender.floatValue)
machine.setVolume(linearValue)
setUserDefaultsVolume(linearValue)
}
}
// The user's selected volume is stored as 1 - volume in the user defaults in order // The user's selected volume is stored as 1 - volume in the user defaults in order
// to take advantage of the default value being 0. // to take advantage of the default value being 0.
private func userDefaultsVolume() -> Float { private func userDefaultsVolume() -> Float {