From 8e443056a197f79cf37a05c8f84f95b211c1ff5e Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sat, 25 Feb 2023 12:54:53 -0700 Subject: [PATCH] Prompt to resume pomodoro timer --- .../source/HabitState.kiss | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss index d25f5c35..bed08965 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss @@ -71,6 +71,23 @@ (when entryNameText (set entryNameText.hasFocus true)) (super.update elapsed) + (when (and pomWasRunning !pomResumeWindow) + (entryWindow.hide) + (set pomResumeWindow + (SimpleWindow.promptForChoice "A pomodoro timer was interrupted. Resume it now?" + [ + "Yes" + "No" + ] + ->:Void [:String choice] + (case choice + ("Yes" (startPomodoros)(backToEntryWindow)) + ("No" + (set pomWasRunning false) + (backToEntryWindow)) + (never otherwise)) + null null FlxColor.LIME 0.9 0.9 true xKey null null ->[] {(set pomWasRunning false)(backToEntryWindow)}))) + (if (windowIsShown) { (set FlxMouseControl.mouseZone disableMouse) @@ -211,12 +228,13 @@ (prop &mut :SimpleWindow entryEditWindow null) (prop &mut :SimpleWindow entryCreationWindow null) (prop &mut :SimpleWindow priorityWindow null) +(prop &mut :SimpleWindow pomResumeWindow null) (method windowIsShown [] (or (tempWindowIsShown) (and entryWindow (entryWindow.isShown)))) (method tempWindowIsShown [] - (doFor window [puzzlePackChoiceWindow entryDeletionWindow entryCreationWindow priorityWindow entryEditWindow] + (doFor window [puzzlePackChoiceWindow entryDeletionWindow entryCreationWindow priorityWindow entryEditWindow pomResumeWindow] (when (and window (window.isShown)) (return true))) false) @@ -382,21 +400,23 @@ (defAndCall method toggleLowerPriority (set model.showLowerPriority !model.showLowerPriority) (refreshModel)))) - (prop &mut pomRunning false) + (prop &mut pomRunning false) + (savedVar :Bool pomWasRunning false) (if pomRunning (_makeText "Stop Pomodoro Timer Mode" m.pomodoroPoints ->_ { (set pomRunning false) + (set pomWasRunning false) (remove pomTimer) (refreshModel) }) (_makeText "Start Pomodoro Timer Mode" m.pomodoroPoints - ->_ { - // TODO hide puzzle pieces until the pom is over or the mode is stopped - (set pomRunning true) - (add pomTimer) - (refreshModel) - }) ) + ->_ + (defAndCall method startPomodoros + (set pomRunning true) + (set pomWasRunning true) + (add pomTimer) + (refreshModel))) ) (set entryWindow.textColor (FlxColor.RED.getDarkened)) (_makeText "Delete a habit or task" 0 ->_