From 32fa46cd1a471136769c7a3e8aab31194d6fae0a Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sat, 25 Feb 2023 13:27:34 -0700 Subject: [PATCH] pom timer show/hide entry window --- .../source/FlxPomTimer.kiss | 14 ++++++++++++-- .../source/HabitState.kiss | 12 +++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/projects/flixel-desktop-habit-puzzle-game/source/FlxPomTimer.kiss b/projects/flixel-desktop-habit-puzzle-game/source/FlxPomTimer.kiss index 1ea5c7a8..f7edb564 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/FlxPomTimer.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/FlxPomTimer.kiss @@ -7,6 +7,7 @@ (prop :FlxSound dingSound) (prop &mut :Void->Void onFinishedPom) +(prop &mut :Void->Void onStartPom) (method getText [] "$(if workMode "FOCUS ON WORK FOR " "TAKE A BREAK FOR ")$(Std.int (/ timerValue 60)):$(.lpad (Std.string (Std.int (% timerValue 60))) "0" 2)") @@ -20,7 +21,7 @@ (super.update elapsed) (-= timerValue elapsed) (#when debug - (when FlxG.keys.justPressed.P + (when (and FlxG.keys.pressed.CONTROL FlxG.keys.justPressed.P) (set timerValue 0))) (when (<= timerValue 0) (when workMode @@ -29,5 +30,14 @@ (onFinishedPom))) (set workMode !workMode) (dingSound.play) - (set timerValue (* 60 (if workMode workMin (if (= 0 (% totalPoms 4)) longBreakMin breakMin))))) + (set timerValue + (* 60 + (if workMode + { + (when onStartPom (onStartPom)) + workMin + } + (if (= 0 (% totalPoms 4)) + longBreakMin + breakMin))))) (set text (getText))) \ No newline at end of file diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss index bed08965..9b471a4b 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss @@ -71,8 +71,9 @@ (when entryNameText (set entryNameText.hasFocus true)) (super.update elapsed) - (when (and pomWasRunning !pomResumeWindow) + (when (and pomWasRunning !pomResumeWindow !pomStartCheck) (entryWindow.hide) + (set pomStartCheck true) (set pomResumeWindow (SimpleWindow.promptForChoice "A pomodoro timer was interrupted. Resume it now?" [ @@ -287,7 +288,8 @@ (method :Void setModel [m &opt :RewardFile currentRewardFile] (set model m) - (set pomTimer.onFinishedPom ->:Void {(model.addPomPoint) (refreshModel)}) + (set pomTimer.onFinishedPom ->:Void {(model.addPomPoint) (refreshModel) (entryWindow.hide)}) + (set pomTimer.onStartPom ->:Void (entryWindow.show)) (let [p (m.totalPoints) &mut i 0 @@ -401,6 +403,7 @@ (set model.showLowerPriority !model.showLowerPriority) (refreshModel)))) (prop &mut pomRunning false) + (prop &mut pomStartCheck false) (savedVar :Bool pomWasRunning false) (if pomRunning (_makeText "Stop Pomodoro Timer Mode" m.pomodoroPoints @@ -415,8 +418,11 @@ (defAndCall method startPomodoros (set pomRunning true) (set pomWasRunning true) + (if FlxPomTimer.workMode + (entryWindow.show) + (entryWindow.hide)) (add pomTimer) - (refreshModel))) ) + (refreshModel)))) (set entryWindow.textColor (FlxColor.RED.getDarkened)) (_makeText "Delete a habit or task" 0 ->_