-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from andersfischernielsen/preference-window
Implemented settings view controller for transition punishments.
- Loading branch information
Showing
4 changed files
with
168 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// PreferencesViewController.swift | ||
// Traktor Transition Finder | ||
// | ||
// Created by Anders Fischer-Nielsen on 14/06/2019. | ||
// Copyright © 2019 Anders Fischer-Nielsen. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Cocoa | ||
|
||
class PreferencesViewController: NSViewController { | ||
@IBOutlet var badKeyPunishmentSlider: NSSlider! | ||
@IBOutlet var halfTempoPunishmentSlider: NSSlider! | ||
@IBOutlet var badKeyPunishmentLabel: NSTextField! | ||
@IBOutlet var halfTempoPunishmentLabel: NSTextField! | ||
|
||
|
||
@IBAction func badKeyPunishmentSliderChanged(_ sender: Any) { | ||
let value = badKeyPunishmentSlider.doubleValue | ||
UserDefaults.standard.set(value, forKey: "badKeyPunishment") | ||
badKeyPunishmentLabel.stringValue = String(format: "%.2f", value) | ||
|
||
} | ||
|
||
@IBAction func halfTempoPunishmentSliderChanged(_ sender: Any) { | ||
let value = halfTempoPunishmentSlider.doubleValue | ||
UserDefaults.standard.set(value, forKey: "halfTempoPunishment") | ||
halfTempoPunishmentLabel.stringValue = String(format: "%.2f", value) | ||
} | ||
|
||
override func viewDidLoad() { | ||
if (UserDefaults.standard.double(forKey: "badKeyPunishment") != 0) { | ||
badKeyPunishmentLabel.stringValue = String(format: "%.2f", UserDefaults.standard.double(forKey: "badKeyPunishment")) | ||
} | ||
|
||
if (UserDefaults.standard.double(forKey: "halfTempoPunishment") != 0) { | ||
halfTempoPunishmentLabel.stringValue = String(format: "%.2f", UserDefaults.standard.double(forKey: "halfTempoPunishment")) | ||
} | ||
} | ||
} |