mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Stop assuming that NSNotification => window.isVisible.
This commit is contained in:
parent
5d154e3d0c
commit
e72cfbf447
@ -144,35 +144,37 @@ class MachineDocument:
|
|||||||
private var interactionMode: InteractionMode = .notStarted
|
private var interactionMode: InteractionMode = .notStarted
|
||||||
|
|
||||||
// Attempting to show a sheet before the window is visible (such as when the NIB is loaded) results in
|
// Attempting to show a sheet before the window is visible (such as when the NIB is loaded) results in
|
||||||
// a sheet mysteriously floating on its own. For now, use windowDidUpdate as a proxy to know that the window
|
// a sheet mysteriously floating on its own. For now, use windowDidUpdate as a proxy to check whether
|
||||||
// is visible, though it's a little premature.
|
// the window is visible.
|
||||||
func windowDidUpdate(_ notification: Notification) {
|
func windowDidUpdate(_ notification: Notification) {
|
||||||
// Grab the regular window title, if it's not already stored.
|
if let window = self.windowControllers[0].window, window.isVisible {
|
||||||
if self.unadornedWindowTitle.count == 0 {
|
// Grab the regular window title, if it's not already stored.
|
||||||
self.unadornedWindowTitle = self.windowControllers[0].window!.title
|
if self.unadornedWindowTitle.count == 0 {
|
||||||
}
|
self.unadornedWindowTitle = window.title
|
||||||
|
|
||||||
// If an interaction mode is not yet in effect, pick the proper one and display the relevant thing.
|
|
||||||
if self.interactionMode == .notStarted {
|
|
||||||
// If a full machine exists, just continue showing it.
|
|
||||||
if self.machine != nil {
|
|
||||||
self.interactionMode = .showingMachine
|
|
||||||
setupMachineOutput()
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a machine has been picked but is not showing, there must be ROMs missing.
|
// If an interaction mode is not yet in effect, pick the proper one and display the relevant thing.
|
||||||
if self.machineDescription != nil {
|
if self.interactionMode == .notStarted {
|
||||||
self.interactionMode = .showingROMRequester
|
// If a full machine exists, just continue showing it.
|
||||||
requestRoms()
|
if self.machine != nil {
|
||||||
return
|
self.interactionMode = .showingMachine
|
||||||
}
|
setupMachineOutput()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// If a machine hasn't even been picked yet, show the machine picker.
|
// If a machine has been picked but is not showing, there must be ROMs missing.
|
||||||
self.interactionMode = .showingMachinePicker
|
if self.machineDescription != nil {
|
||||||
Bundle.main.loadNibNamed("MachinePicker", owner: self, topLevelObjects: nil)
|
self.interactionMode = .showingROMRequester
|
||||||
self.machinePicker?.establishStoredOptions()
|
requestRoms()
|
||||||
self.windowControllers[0].window?.beginSheet(self.machinePickerPanel!, completionHandler: nil)
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a machine hasn't even been picked yet, show the machine picker.
|
||||||
|
self.interactionMode = .showingMachinePicker
|
||||||
|
Bundle.main.loadNibNamed("MachinePicker", owner: self, topLevelObjects: nil)
|
||||||
|
self.machinePicker?.establishStoredOptions()
|
||||||
|
window.beginSheet(self.machinePickerPanel!, completionHandler: nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user