WIP pomodoro mode for Habit Puzzles (#172)
This commit is contained in:
BIN
projects/flixel-desktop-habit-puzzle-game/assets/ding.wav
Normal file
BIN
projects/flixel-desktop-habit-puzzle-game/assets/ding.wav
Normal file
Binary file not shown.
@@ -0,0 +1,12 @@
|
|||||||
|
package;
|
||||||
|
|
||||||
|
import flixel.FlxG;
|
||||||
|
import flixel.text.FlxText;
|
||||||
|
import kiss_flixel.SimpleWindow;
|
||||||
|
import kiss.Prelude;
|
||||||
|
import flixel.system.FlxSound;
|
||||||
|
import flixel.util.FlxColor;
|
||||||
|
using StringTools;
|
||||||
|
|
||||||
|
@:build(kiss.Kiss.build())
|
||||||
|
class FlxPomTimer extends FlxText {}
|
@@ -0,0 +1,33 @@
|
|||||||
|
(savedVar :Bool workMode false)
|
||||||
|
(savedVar :Float timerValue 0)
|
||||||
|
(savedVar :Float workMin 25)
|
||||||
|
(savedVar :Float breakMin 5)
|
||||||
|
(savedVar :Float longBreakMin 10)
|
||||||
|
(savedVar :Int totalPoms 0)
|
||||||
|
(prop :FlxSound dingSound)
|
||||||
|
|
||||||
|
(prop &mut :Void->Void onFinishedPom)
|
||||||
|
|
||||||
|
(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)")
|
||||||
|
|
||||||
|
(method new []
|
||||||
|
(super (fHalf FlxG.width) 0 (getText) SimpleWindow.textSize)
|
||||||
|
(set color FlxColor.ORANGE)
|
||||||
|
(set dingSound (FlxG.sound.load "assets/ding.wav")))
|
||||||
|
|
||||||
|
(method &override :Void update [:Float elapsed]
|
||||||
|
(super.update elapsed)
|
||||||
|
(-= timerValue elapsed)
|
||||||
|
(#when debug
|
||||||
|
(when FlxG.keys.justPressed.P
|
||||||
|
(set timerValue 0)))
|
||||||
|
(when (<= timerValue 0)
|
||||||
|
(when workMode
|
||||||
|
(+= totalPoms 1)
|
||||||
|
(when onFinishedPom
|
||||||
|
(onFinishedPom)))
|
||||||
|
(set workMode !workMode)
|
||||||
|
(dingSound.play)
|
||||||
|
(set timerValue (* 60 (if workMode workMin (if (= 0 (% totalPoms 4)) longBreakMin breakMin)))))
|
||||||
|
(set text (getText)))
|
@@ -4,6 +4,7 @@
|
|||||||
(prop :Array<Entry> bonusEntries [])
|
(prop :Array<Entry> bonusEntries [])
|
||||||
(prop :Array<Entry> todoEntries [])
|
(prop :Array<Entry> todoEntries [])
|
||||||
(prop :kiss.List<RewardFile> rewardFiles [])
|
(prop :kiss.List<RewardFile> rewardFiles [])
|
||||||
|
(prop &mut :Int pomodoroPoints 0)
|
||||||
|
|
||||||
(defNew [&prop :String textFile]
|
(defNew [&prop :String textFile]
|
||||||
(let [s (Stream.fromFile textFile)
|
(let [s (Stream.fromFile textFile)
|
||||||
@@ -23,6 +24,8 @@
|
|||||||
(set lastHeader "TODO"))
|
(set lastHeader "TODO"))
|
||||||
((Some "FILES")
|
((Some "FILES")
|
||||||
(set lastHeader "FILES"))
|
(set lastHeader "FILES"))
|
||||||
|
((Some "POMODORO")
|
||||||
|
(set lastHeader "POMODORO"))
|
||||||
((when (apply = (concat ["-"] (line.split ""))) (Some line))
|
((when (apply = (concat ["-"] (line.split ""))) (Some line))
|
||||||
(continue))
|
(continue))
|
||||||
((Some "") (continue))
|
((Some "") (continue))
|
||||||
@@ -40,6 +43,7 @@
|
|||||||
startingPoints (Std.parseInt (parts.pop))
|
startingPoints (Std.parseInt (parts.pop))
|
||||||
path (parts.join " ")]
|
path (parts.join " ")]
|
||||||
(objectWith path startingPoints puzzleWidth puzzleHeight piecesPerPoint skipped))))
|
(objectWith path startingPoints puzzleWidth puzzleHeight piecesPerPoint skipped))))
|
||||||
|
((when (= lastHeader "POMODORO") (Some line)) (set pomodoroPoints (Std.parseInt line)))
|
||||||
((Some line)
|
((Some line)
|
||||||
(let [topPriority (line.startsWith "! ")]
|
(let [topPriority (line.startsWith "! ")]
|
||||||
(when topPriority (set line (line.substr 2)))
|
(when topPriority (set line (line.substr 2)))
|
||||||
@@ -127,7 +131,7 @@
|
|||||||
(filter (allEntries) isNotDeleted))
|
(filter (allEntries) isNotDeleted))
|
||||||
|
|
||||||
(method :Int totalPoints []
|
(method :Int totalPoints []
|
||||||
(apply + (for l (flatten (for e (allEntries) e.labels)) l.points)))
|
(+ pomodoroPoints (apply + (for l (flatten (for e (allEntries) e.labels)) l.points))))
|
||||||
|
|
||||||
(function stringify [:Entry e]
|
(function stringify [:Entry e]
|
||||||
(e.toString))
|
(e.toString))
|
||||||
@@ -146,6 +150,7 @@
|
|||||||
(+= content (.join (map bonusEntries stringify) "\n") "\n")
|
(+= content (.join (map bonusEntries stringify) "\n") "\n")
|
||||||
(+= content "\nTODO\n----\n")
|
(+= content "\nTODO\n----\n")
|
||||||
(+= content (.join (map todoEntries stringify) "\n") "\n")
|
(+= content (.join (map todoEntries stringify) "\n") "\n")
|
||||||
|
(+= content "\nPOMODORO\n--------\n${pomodoroPoints}\n")
|
||||||
(+= content "\nFILES\n-----\n")
|
(+= content "\nFILES\n-----\n")
|
||||||
(+= content (.join (map rewardFiles stringifyRewardFile) "\n") "\n")
|
(+= content (.join (map rewardFiles stringifyRewardFile) "\n") "\n")
|
||||||
(File.saveContent textFile
|
(File.saveContent textFile
|
||||||
@@ -281,6 +286,10 @@
|
|||||||
(set e.type (Interval days (.toString (DateTime.now)))))))
|
(set e.type (Interval days (.toString (DateTime.now)))))))
|
||||||
(save))
|
(save))
|
||||||
|
|
||||||
|
(method addPomPoint []
|
||||||
|
(+= pomodoroPoints 1)
|
||||||
|
(save))
|
||||||
|
|
||||||
(var tallyUnit 5)
|
(var tallyUnit 5)
|
||||||
(function pointsStr [points]
|
(function pointsStr [points]
|
||||||
(let [&mut str "" symbols ["+" "*" "\$"]]
|
(let [&mut str "" symbols ["+" "*" "\$"]]
|
||||||
|
@@ -45,6 +45,7 @@ import jigsawx.Jigsawx;
|
|||||||
import jigsawx.math.Vec2;
|
import jigsawx.math.Vec2;
|
||||||
import kiss_flixel.DragToSelectPlugin;
|
import kiss_flixel.DragToSelectPlugin;
|
||||||
import re_flex.R;
|
import re_flex.R;
|
||||||
|
import FlxPomTimer;
|
||||||
|
|
||||||
typedef StartPuzzleFunc = (Int, Int) -> Void;
|
typedef StartPuzzleFunc = (Int, Int) -> Void;
|
||||||
|
|
||||||
|
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
(defAlias &ident textSize SimpleWindow.textSize)
|
(defAlias &ident textSize SimpleWindow.textSize)
|
||||||
|
|
||||||
|
(prop &mut :FlxPomTimer pomTimer null)
|
||||||
|
|
||||||
(method &override :Void create []
|
(method &override :Void create []
|
||||||
(set FlxG.sound.soundTrayEnabled false)
|
(set FlxG.sound.soundTrayEnabled false)
|
||||||
(add logTexts)
|
(add logTexts)
|
||||||
@@ -31,6 +33,8 @@
|
|||||||
(FlxG.plugins.add (new FlxMouseControl))
|
(FlxG.plugins.add (new FlxMouseControl))
|
||||||
(set FlxMouseControl.sortIndex "priorityID")
|
(set FlxMouseControl.sortIndex "priorityID")
|
||||||
(set bgColor FlxColor.TRANSPARENT)
|
(set bgColor FlxColor.TRANSPARENT)
|
||||||
|
(set pomTimer (new FlxPomTimer))
|
||||||
|
(set pomTimer.cameras [uiCamera])
|
||||||
(super.create))
|
(super.create))
|
||||||
|
|
||||||
(defAlias &ident KEYBOARD_SCROLL_SPEED (keyboardScrollSpeed))
|
(defAlias &ident KEYBOARD_SCROLL_SPEED (keyboardScrollSpeed))
|
||||||
@@ -256,6 +260,7 @@
|
|||||||
|
|
||||||
(method :Void setModel [m &opt :RewardFile currentRewardFile]
|
(method :Void setModel [m &opt :RewardFile currentRewardFile]
|
||||||
(set model m)
|
(set model m)
|
||||||
|
(set pomTimer.onFinishedPom ->:Void {(model.addPomPoint) (refreshModel)})
|
||||||
|
|
||||||
(let [p (m.totalPoints)
|
(let [p (m.totalPoints)
|
||||||
&mut i 0
|
&mut i 0
|
||||||
@@ -368,6 +373,21 @@
|
|||||||
(defAndCall method toggleLowerPriority
|
(defAndCall method toggleLowerPriority
|
||||||
(set model.showLowerPriority !model.showLowerPriority)
|
(set model.showLowerPriority !model.showLowerPriority)
|
||||||
(refreshModel))))
|
(refreshModel))))
|
||||||
|
(prop &mut pomRunning false)
|
||||||
|
(if pomRunning
|
||||||
|
(_makeText "Stop Pomodoro Timer Mode" m.pomodoroPoints
|
||||||
|
->_ {
|
||||||
|
(set pomRunning 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)
|
||||||
|
}) )
|
||||||
(set entryWindow.textColor (FlxColor.RED.getDarkened))
|
(set entryWindow.textColor (FlxColor.RED.getDarkened))
|
||||||
(_makeText "Delete a habit or task" 0
|
(_makeText "Delete a habit or task" 0
|
||||||
->_
|
->_
|
||||||
@@ -391,6 +411,7 @@
|
|||||||
(entryWindow.hide)
|
(entryWindow.hide)
|
||||||
(model.skipRewardFile)
|
(model.skipRewardFile)
|
||||||
(setModel model)))))
|
(setModel model)))))
|
||||||
|
|
||||||
(set entryWindow.textColor FlxColor.ORANGE)
|
(set entryWindow.textColor FlxColor.ORANGE)
|
||||||
(map (m.activeDailyEntries) makeText)
|
(map (m.activeDailyEntries) makeText)
|
||||||
(set entryWindow.textColor FlxColor.GREEN)
|
(set entryWindow.textColor FlxColor.GREEN)
|
||||||
@@ -690,7 +711,6 @@
|
|||||||
(let [bubblePoints (dictGet jig.bubblePoints compass)]
|
(let [bubblePoints (dictGet jig.bubblePoints compass)]
|
||||||
(unless bubblePoints
|
(unless bubblePoints
|
||||||
(return (new FlxRect 0 0 0 0)))
|
(return (new FlxRect 0 0 0 0)))
|
||||||
(printLocalNulls)
|
|
||||||
(let [ros (roughOptimalScale)
|
(let [ros (roughOptimalScale)
|
||||||
pointsX (for point bubblePoints point.x)
|
pointsX (for point bubblePoints point.x)
|
||||||
pointsY (for point bubblePoints point.y)
|
pointsY (for point bubblePoints point.y)
|
||||||
|
Reference in New Issue
Block a user