Skip to content

Commit 38a046e

Browse files
committed
Work on new settings
1 parent ce33a02 commit 38a046e

File tree

47 files changed

+615
-420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+615
-420
lines changed

GUI/Defaults.swift

Lines changed: 50 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -307,18 +307,6 @@ struct Keys {
307307
static let keepAspectRatio = "General.FullscreenKeepAspectRatio"
308308
static let exitOnEsc = "General.FullscreenExitOnEsc"
309309

310-
// Snapshots
311-
static let snapshotStorage = "General.SnapshotStorage"
312-
static let autoSnapshots = "General.AutoSnapshots"
313-
static let autoSnapshotInterval = "General.ScreenshotInterval"
314-
315-
// Screenshots
316-
static let screenshotFormat = "General.ScreenshotFormat"
317-
static let screenshotSource = "General.ScreenshotSource"
318-
static let screenshotCutout = "General.ScreenshotCutout"
319-
static let screenshotWidth = "General.ScreenshotWidth"
320-
static let screenshotHeight = "General.ScreenshotHeight"
321-
322310
// Miscellaneous
323311
static let ejectWithoutAsking = "General.EjectWithoutAsking"
324312
static let detachWithoutAsking = "General.DetachWithoutAsking"
@@ -338,18 +326,6 @@ extension DefaultsProxy {
338326
register(Keys.Gen.keepAspectRatio, false)
339327
register(Keys.Gen.exitOnEsc, true)
340328

341-
// Snapshots
342-
register(Keys.Gen.snapshotStorage, 512)
343-
register(Keys.Gen.autoSnapshots, false)
344-
register(Keys.Gen.autoSnapshotInterval, 20)
345-
346-
// Screenshots
347-
register(Keys.Gen.screenshotFormat, NSBitmapImageRep.FileType.png.rawValue)
348-
register(Keys.Gen.screenshotSource, 0)
349-
register(Keys.Gen.screenshotCutout, 0)
350-
register(Keys.Gen.screenshotWidth, 1200)
351-
register(Keys.Gen.screenshotHeight, 900)
352-
353329
// Misc
354330
register(Keys.Gen.ejectWithoutAsking, false)
355331
register(Keys.Gen.detachWithoutAsking, false)
@@ -364,16 +340,6 @@ extension DefaultsProxy {
364340
let keys = [ Keys.Gen.keepAspectRatio,
365341
Keys.Gen.exitOnEsc,
366342

367-
Keys.Gen.snapshotStorage,
368-
Keys.Gen.autoSnapshots,
369-
Keys.Gen.autoSnapshotInterval,
370-
371-
Keys.Gen.screenshotFormat,
372-
Keys.Gen.screenshotSource,
373-
Keys.Gen.screenshotCutout,
374-
Keys.Gen.screenshotWidth,
375-
Keys.Gen.screenshotHeight,
376-
377343
Keys.Gen.ejectWithoutAsking,
378344
Keys.Gen.detachWithoutAsking,
379345
Keys.Gen.closeWithoutAsking,
@@ -395,16 +361,6 @@ extension Preferences {
395361
defaults.set(Keys.Gen.keepAspectRatio, keepAspectRatio)
396362
defaults.set(Keys.Gen.exitOnEsc, exitOnEsc)
397363

398-
defaults.set(Keys.Gen.snapshotStorage, snapshotStorage)
399-
defaults.set(Keys.Gen.autoSnapshots, autoSnapshots)
400-
defaults.set(Keys.Gen.autoSnapshotInterval, snapshotInterval)
401-
402-
defaults.set(Keys.Gen.screenshotFormat, screenshotFormatIntValue)
403-
defaults.set(Keys.Gen.screenshotSource, screenshotSourceIntValue)
404-
defaults.set(Keys.Gen.screenshotCutout, screenshotCutoutIntValue)
405-
defaults.set(Keys.Gen.screenshotWidth, screenshotWidth)
406-
defaults.set(Keys.Gen.screenshotHeight, screenshotHeight)
407-
408364
defaults.set(Keys.Gen.ejectWithoutAsking, ejectWithoutAsking)
409365
defaults.set(Keys.Gen.detachWithoutAsking, detachWithoutAsking)
410366
defaults.set(Keys.Gen.closeWithoutAsking, closeWithoutAsking)
@@ -421,16 +377,6 @@ extension Preferences {
421377
keepAspectRatio = defaults.bool(Keys.Gen.keepAspectRatio)
422378
exitOnEsc = defaults.bool(Keys.Gen.exitOnEsc)
423379

424-
snapshotStorage = defaults.int(Keys.Gen.snapshotStorage)
425-
autoSnapshots = defaults.bool(Keys.Gen.autoSnapshots)
426-
snapshotInterval = defaults.int(Keys.Gen.autoSnapshotInterval)
427-
428-
screenshotFormatIntValue = defaults.int(Keys.Gen.screenshotFormat)
429-
screenshotSourceIntValue = defaults.int(Keys.Gen.screenshotSource)
430-
screenshotCutoutIntValue = defaults.int(Keys.Gen.screenshotCutout)
431-
screenshotWidth = defaults.int(Keys.Gen.screenshotWidth)
432-
screenshotHeight = defaults.int(Keys.Gen.screenshotHeight)
433-
434380
ejectWithoutAsking = defaults.bool(Keys.Gen.ejectWithoutAsking)
435381
detachWithoutAsking = defaults.bool(Keys.Gen.detachWithoutAsking)
436382
closeWithoutAsking = defaults.bool(Keys.Gen.closeWithoutAsking)
@@ -447,12 +393,17 @@ extension Keys {
447393

448394
struct Cap {
449395

450-
// Videos
451-
static let ffmpegPath = "General.ffmpegPath"
452-
static let captureSource = "General.Source"
453-
static let bitRate = "General.BitRate"
454-
static let aspectX = "General.AspectX"
455-
static let aspectY = "General.AspectY"
396+
// Snapshots
397+
static let snapshotStorage = "Cap.SnapshotStorage"
398+
static let autoSnapshots = "Cap.AutoSnapshots"
399+
static let autoSnapshotInterval = "Cap.ScreenshotInterval"
400+
401+
// Screenshots
402+
static let screenshotFormat = "Cap.ScreenshotFormat"
403+
static let screenshotSource = "Cap.ScreenshotSource"
404+
static let screenshotCutout = "Cap.ScreenshotCutout"
405+
static let screenshotWidth = "Cap.ScreenshotWidth"
406+
static let screenshotHeight = "Cap.ScreenshotHeight"
456407
}
457408
}
458409

@@ -463,23 +414,32 @@ extension DefaultsProxy {
463414

464415
debug(.defaults)
465416

466-
// Videos
467-
register(Keys.Cap.ffmpegPath, "")
468-
register(Keys.Cap.captureSource, 0)
469-
register(Keys.Cap.bitRate, 2048)
470-
register(Keys.Cap.aspectX, 768)
471-
register(Keys.Cap.aspectY, 702)
417+
// Snapshots
418+
register(Keys.Cap.snapshotStorage, 512)
419+
register(Keys.Cap.autoSnapshots, false)
420+
register(Keys.Cap.autoSnapshotInterval, 20)
421+
422+
// Screenshots
423+
register(Keys.Cap.screenshotFormat, NSBitmapImageRep.FileType.png.rawValue)
424+
register(Keys.Cap.screenshotSource, 0)
425+
register(Keys.Cap.screenshotCutout, 0)
426+
register(Keys.Cap.screenshotWidth, 1200)
427+
register(Keys.Cap.screenshotHeight, 900)
472428
}
473429

474430
func removeCapturesUserDefaults() {
475431

476432
debug(.defaults)
477433

478-
let keys = [ Keys.Cap.ffmpegPath,
479-
Keys.Cap.captureSource,
480-
Keys.Cap.bitRate,
481-
Keys.Cap.aspectX,
482-
Keys.Cap.aspectY,
434+
let keys = [ Keys.Cap.snapshotStorage,
435+
Keys.Cap.autoSnapshots,
436+
Keys.Cap.autoSnapshotInterval,
437+
438+
Keys.Cap.screenshotFormat,
439+
Keys.Cap.screenshotSource,
440+
Keys.Cap.screenshotCutout,
441+
Keys.Cap.screenshotWidth,
442+
Keys.Cap.screenshotHeight,
483443
]
484444

485445
for key in keys { removeKey(key) }
@@ -494,12 +454,16 @@ extension Preferences {
494454
debug(.defaults)
495455
let defaults = EmulatorProxy.defaults!
496456

497-
defaults.set(Keys.Cap.ffmpegPath, ffmpegPath)
498-
defaults.set(Keys.Cap.captureSource, captureSourceIntValue)
499-
defaults.set(Keys.Cap.bitRate, bitRate)
500-
defaults.set(Keys.Cap.aspectX, aspectX)
501-
defaults.set(Keys.Cap.aspectY, aspectY)
502-
457+
defaults.set(Keys.Cap.snapshotStorage, snapshotStorage)
458+
defaults.set(Keys.Cap.autoSnapshots, autoSnapshots)
459+
defaults.set(Keys.Cap.autoSnapshotInterval, snapshotInterval)
460+
461+
defaults.set(Keys.Cap.screenshotFormat, screenshotFormatIntValue)
462+
defaults.set(Keys.Cap.screenshotSource, screenshotSourceIntValue)
463+
defaults.set(Keys.Cap.screenshotCutout, screenshotCutoutIntValue)
464+
defaults.set(Keys.Cap.screenshotWidth, screenshotWidth)
465+
defaults.set(Keys.Cap.screenshotHeight, screenshotHeight)
466+
503467
defaults.save()
504468
}
505469

@@ -508,11 +472,15 @@ extension Preferences {
508472
debug(.defaults)
509473
let defaults = EmulatorProxy.defaults!
510474

511-
ffmpegPath = defaults.string(Keys.Cap.ffmpegPath)
512-
captureSourceIntValue = defaults.int(Keys.Cap.captureSource)
513-
bitRate = defaults.int(Keys.Cap.bitRate)
514-
aspectX = defaults.int(Keys.Cap.aspectX)
515-
aspectY = defaults.int(Keys.Cap.aspectY)
475+
snapshotStorage = defaults.int(Keys.Cap.snapshotStorage)
476+
autoSnapshots = defaults.bool(Keys.Cap.autoSnapshots)
477+
snapshotInterval = defaults.int(Keys.Cap.autoSnapshotInterval)
478+
479+
screenshotFormatIntValue = defaults.int(Keys.Cap.screenshotFormat)
480+
screenshotSourceIntValue = defaults.int(Keys.Cap.screenshotSource)
481+
screenshotCutoutIntValue = defaults.int(Keys.Cap.screenshotCutout)
482+
screenshotWidth = defaults.int(Keys.Cap.screenshotWidth)
483+
screenshotHeight = defaults.int(Keys.Cap.screenshotHeight)
516484
}
517485
}
518486

GUI/Dialogs/Settings/SettingsSplitViewController.swift

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import Cocoa
1111

1212
class SettingsSplitViewController: NSSplitViewController {
1313

14+
func instantiate(_ identifier: String) -> Any {
15+
16+
let main = NSStoryboard(name: "Settings", bundle: nil)
17+
return main.instantiateController(withIdentifier: identifier)
18+
}
19+
1420
var windowController: SettingsWindowController? {
1521
view.window?.windowController as? SettingsWindowController
1622
}
@@ -21,23 +27,38 @@ class SettingsSplitViewController: NSSplitViewController {
2127
return splitViewItems.first?.viewController as? SidebarViewController
2228
}
2329

24-
let main = NSStoryboard(name: "Settings", bundle: nil)
30+
// let main = NSStoryboard(name: "Settings", bundle: nil)
2531

2632
lazy var generalVC: GeneralSettingsViewController = {
27-
return main.instantiateController(withIdentifier: "GeneralSettingsViewController") as! GeneralSettingsViewController
33+
instantiate("General") as! GeneralSettingsViewController
34+
}()
35+
lazy var capturesVC: CapturesSettingsViewController = {
36+
instantiate("Captures") as! CapturesSettingsViewController
2837
}()
2938
lazy var controlsVC: ControlsSettingsViewController = {
30-
return main.instantiateController(withIdentifier: "ControlsSettingsViewController") as! ControlsSettingsViewController
39+
instantiate("Controls") as! ControlsSettingsViewController
3140
}()
3241
lazy var devicesVC: DevicesSettingsViewController = {
33-
return main.instantiateController(withIdentifier: "DevicesSettingsViewController") as! DevicesSettingsViewController
42+
instantiate("Devices") as! DevicesSettingsViewController
3443
}()
3544
lazy var romsVC: RomSettingsViewController = {
36-
return main.instantiateController(withIdentifier: "RomSettingsViewController") as! RomSettingsViewController
45+
instantiate("Roms") as! RomSettingsViewController
3746
}()
47+
lazy var hardwareVC = instantiate("Hardware") as! HardwareSettingsViewController
48+
/*
3849
lazy var hardwareVC: HardwareSettingsViewController = {
39-
return main.instantiateController(withIdentifier: "HardwareSettingsViewController") as! HardwareSettingsViewController
50+
instantiate("Hardware") as! HardwareSettingsViewController
4051
}()
52+
*/
53+
lazy var peripheralsVC: PeripheralsSettingsViewController = {
54+
instantiate("Peripherals") as! PeripheralsSettingsViewController
55+
}()
56+
lazy var compatibilityVC: CompatibilitySettingsViewController = {
57+
instantiate("Compatibility") as! CompatibilitySettingsViewController
58+
}()
59+
lazy var performanceVC = instantiate("Performance") as! PerformanceSettingsViewController
60+
lazy var audioVC = instantiate("Audio") as! AudioSettingsViewController
61+
lazy var videoVC = instantiate("Video") as! VideoSettingsViewController
4162

4263
var current: SettingsViewController?
4364

@@ -51,13 +72,20 @@ class SettingsSplitViewController: NSSplitViewController {
5172

5273
private func showContent(for item: SidebarItem) {
5374

54-
switch item.identifier.rawValue {
75+
switch item.title {
76+
77+
case "General": current = generalVC
78+
case "Captures": current = capturesVC
79+
case "Controls": current = controlsVC
80+
case "Devices": current = devicesVC
81+
case "Roms": current = romsVC
82+
case "Hardware": current = hardwareVC
83+
case "Peripherals": current = peripheralsVC
84+
case "Performance": current = performanceVC
85+
case "Compatibility": current = compatibilityVC
86+
case "Audio": current = audioVC
87+
case "Video": current = videoVC
5588

56-
case "general": current = generalVC
57-
case "controls": current = controlsVC
58-
case "devices": current = devicesVC
59-
case "roms": current = romsVC
60-
case "hardware": current = hardwareVC
6189
default: fatalError()
6290
}
6391

@@ -69,12 +97,7 @@ class SettingsSplitViewController: NSSplitViewController {
6997
addSplitViewItem(newItem)
7098
current!.activate()
7199

72-
toolbar!.update(presets: current?.presets ?? [])
73-
74-
/*
75-
current!.view.window?.makeFirstResponder(currentVC)
76-
current!.refresh()
77-
*/
100+
// toolbar!.update(presets: current?.presets ?? [])
78101
}
79102

80103
override func keyDown(with event: NSEvent) {

GUI/Dialogs/Settings/SidebarViewController.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct SidebarItem {
1313

1414
let title: String
1515
let iconName: String
16-
let identifier: NSUserInterfaceItemIdentifier
16+
// let identifier: NSUserInterfaceItemIdentifier
1717
}
1818

1919
class SidebarViewController: NSViewController {
@@ -26,11 +26,17 @@ class SidebarViewController: NSViewController {
2626

2727
let items: [SidebarItem] = [
2828

29-
SidebarItem(title: "General", iconName: "generalPrefs", identifier: .init("general")),
30-
SidebarItem(title: "Controls", iconName: "controlsPrefs", identifier: .init("controls")),
31-
SidebarItem(title: "Devices", iconName: "devicesPrefs", identifier: .init("devices")),
32-
SidebarItem(title: "Roms", iconName: "romPrefs", identifier: .init("roms")),
33-
SidebarItem(title: "Hardware", iconName: "hardwarePrefs", identifier: .init("hardware"))
29+
SidebarItem(title: "General", iconName: "iconGeneral"),
30+
SidebarItem(title: "Captures", iconName: "iconCaptures"),
31+
SidebarItem(title: "Controls", iconName: "iconControls"),
32+
SidebarItem(title: "Devices", iconName: "iconDevices"),
33+
SidebarItem(title: "Roms", iconName: "iconRoms"),
34+
SidebarItem(title: "Hardware", iconName: "iconHardware"),
35+
SidebarItem(title: "Peripherals", iconName: "iconPeripherals"),
36+
SidebarItem(title: "Performance", iconName: "iconPerformance"),
37+
SidebarItem(title: "Compatibility", iconName: "iconCompatibility"),
38+
SidebarItem(title: "Audio", iconName: "iconAudio"),
39+
SidebarItem(title: "Video", iconName: "iconVideo")
3440
]
3541

3642
var selectionHandler: ((SidebarItem) -> Void)?

GUI/Dialogs/Settings/ViewControllers/AudioSettings.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class AudioSettingsViewController: SettingsViewController {
6363

6464
override func refresh() {
6565

66+
super.refresh()
6667
}
6768

6869
//

GUI/Dialogs/Settings/ViewControllers/CapturesSettings.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,14 @@ class CapturesSettingsViewController: SettingsViewController {
3636

3737
override func refresh() {
3838

39-
/*
39+
super.refresh()
40+
4041
// Snapshots
4142
snapshotStorage.integerValue = pref.snapshotStorage
4243
autoSnapshots.state = pref.autoSnapshots ? .on : .off
4344
snapshotInterval.integerValue = pref.snapshotInterval
4445
snapshotInterval.isEnabled = pref.autoSnapshots
4546

46-
// Fullscreen
47-
aspectRatioButton.state = pref.keepAspectRatio ? .on : .off
48-
exitOnEscButton.state = pref.exitOnEsc ? .on : .off
49-
50-
// Miscellaneous
51-
ejectWithoutAskingButton.state = pref.ejectWithoutAsking ? .on : .off
52-
detachWithoutAskingButton.state = pref.detachWithoutAsking ? .on : .off
53-
closeWithoutAskingButton.state = pref.closeWithoutAsking ? .on : .off
54-
pauseInBackground.state = pref.pauseInBackground ? .on : .off
55-
5647
// Screenshots
5748
let framebuffer = pref.screenshotSource == .framebuffer
5849
let custom = pref.screenshotCutout == .custom
@@ -67,7 +58,6 @@ class CapturesSettingsViewController: SettingsViewController {
6758
screenshotHeight.integerValue = pref.screenshotHeight
6859
screenshotHeight.isHidden = !custom || framebuffer
6960
screenshotHeightText.isHidden = !custom || framebuffer
70-
*/
7161
}
7262

7363
//

GUI/Dialogs/Settings/ViewControllers/CompatibilitySettings.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class CompatibilitySettingsViewController: SettingsViewController {
5252

5353
override func refresh() {
5454

55+
super.refresh()
5556
}
5657

5758
//

0 commit comments

Comments
 (0)