Skip to content

Commit

Permalink
make difficulty display more responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-goddard committed Feb 27, 2024
1 parent ae6fc02 commit 60c018e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Minesweeper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1330;
LastUpgradeCheck = 1420;
LastUpgradeCheck = 1520;
TargetAttributes = {
3B5AB53727F96F710059BB0A = {
CreatedOnToolsVersion = 13.3;
Expand Down Expand Up @@ -317,6 +317,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -378,6 +379,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down
1 change: 1 addition & 0 deletions Minesweeper/Settings/GeneralViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GeneralViewController: NSViewController {

@IBAction func toolbarDifficultyCheckboxClicked(_ sender: NSButton) {
Defaults[.toolbarDifficulty].toggle()
NotificationCenter.default.post(name: Notification.Name("SetSubtitle"), object: nil)
}

@IBAction func appearancePopUpChanged(_ sender: NSPopUpButton) {
Expand Down
10 changes: 10 additions & 0 deletions Minesweeper/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()

NotificationCenter.default.addObserver(self, selector: #selector(self.setSubtitle(notification:)), name: Notification.Name("SetSubtitle"), object: nil)

if let view = self.skView {
let rows, cols, mines: Int

Expand Down Expand Up @@ -48,4 +50,12 @@ class ViewController: NSViewController {
view.window!.subtitle = difficulty
}
}

@objc func setSubtitle(notification: Notification) {
if Defaults[.toolbarDifficulty] {
view.window!.subtitle = difficulty
} else {
view.window!.subtitle = ""
}
}
}

0 comments on commit 60c018e

Please sign in to comment.