use pointsStr in habit file/delete screen
This commit is contained in:
@@ -24,4 +24,4 @@
|
|||||||
((Interval days lastDayDone)
|
((Interval days lastDayDone)
|
||||||
"$days ${lastDayDone}: ")
|
"$days ${lastDayDone}: ")
|
||||||
(otherwise ""))$(.join (for label labels
|
(otherwise ""))$(.join (for label labels
|
||||||
"${label.label} $(* "|" label.points)") "/")")
|
"${label.label} $(HabitModel.pointsStr label.points)") "/")")
|
||||||
@@ -110,8 +110,8 @@
|
|||||||
(otherwise (throw "bad header: $lastHeader")))
|
(otherwise (throw "bad header: $lastHeader")))
|
||||||
(for l (line.split "/")
|
(for l (line.split "/")
|
||||||
(object
|
(object
|
||||||
label (StringTools.trim (StringTools.replace l "|" ""))
|
label (StringTools.trim (withoutPointsStr l))
|
||||||
points (count (l.split "") ->c (= c "|"))))
|
points (countPoints l)))
|
||||||
topPriority))))
|
topPriority))))
|
||||||
(otherwise (break))))))
|
(otherwise (break))))))
|
||||||
|
|
||||||
@@ -274,3 +274,25 @@
|
|||||||
(whenLet [(Interval days lastDayDone) e.type]
|
(whenLet [(Interval days lastDayDone) e.type]
|
||||||
(set e.type (Interval days (.toString (DateTime.now)))))))
|
(set e.type (Interval days (.toString (DateTime.now)))))))
|
||||||
(save))
|
(save))
|
||||||
|
|
||||||
|
(var tallyUnit 5)
|
||||||
|
(function pointsStr [points]
|
||||||
|
(let [&mut str "" symbols ["+" "*" "\$"]]
|
||||||
|
(doFor i (reverse (collect (range symbols.length)))
|
||||||
|
(let [scaledTallyUnit (^ tallyUnit i)
|
||||||
|
tallies (Math.floor (/ points scaledTallyUnit))]
|
||||||
|
(+= str (* (nth symbols i) tallies))
|
||||||
|
(-= points (* tallies scaledTallyUnit))))
|
||||||
|
str))
|
||||||
|
|
||||||
|
(function withoutPointsStr [:String label]
|
||||||
|
(doFor c (.split "|+*\$" "") (set label (label.replace c ""))))
|
||||||
|
|
||||||
|
(function countPoints [:String pointStr]
|
||||||
|
(apply + (for char (pointStr.split "")
|
||||||
|
(case char
|
||||||
|
("|" 1)
|
||||||
|
("+" 1)
|
||||||
|
("*" tallyUnit)
|
||||||
|
("\$" (^ tallyUnit 2))
|
||||||
|
(otherwise 0)))))
|
||||||
@@ -139,6 +139,7 @@
|
|||||||
(localVar title
|
(localVar title
|
||||||
"Add a label for this ${typeDescriptor}, or use SHIFT+ENTER to add a ${multipleLabelDescriptor}:")
|
"Add a label for this ${typeDescriptor}, or use SHIFT+ENTER to add a ${multipleLabelDescriptor}:")
|
||||||
(set entryCreationWindow (new SimpleWindow title null null 0.9 0.9))
|
(set entryCreationWindow (new SimpleWindow title null null 0.9 0.9))
|
||||||
|
// TODO don't allow /, +, $, *
|
||||||
(set entryNameText (new FlxInputText 0 0 FlxG.width "" textSize true))
|
(set entryNameText (new FlxInputText 0 0 FlxG.width "" textSize true))
|
||||||
(entryCreationWindow.addControl entryNameText)
|
(entryCreationWindow.addControl entryNameText)
|
||||||
(entryCreationWindow.makeText "Create" FlxColor.LIME ->:Void _ (addCreatedEntry))
|
(entryCreationWindow.makeText "Create" FlxColor.LIME ->:Void _ (addCreatedEntry))
|
||||||
@@ -608,7 +609,7 @@
|
|||||||
|
|
||||||
// TODO configurable text size
|
// TODO configurable text size
|
||||||
(method _makeText [:String s :Int points &opt :Action action]
|
(method _makeText [:String s :Int points &opt :Action action]
|
||||||
(entryWindow.makeText (+ s (pointsStr points)) action))
|
(entryWindow.makeText (+ s (HabitModel.pointsStr points)) action))
|
||||||
|
|
||||||
(method :Void log [:String message]
|
(method :Void log [:String message]
|
||||||
(trace message)
|
(trace message)
|
||||||
@@ -822,15 +823,6 @@
|
|||||||
(method createTaskEntry [] (startAdding Todo))
|
(method createTaskEntry [] (startAdding Todo))
|
||||||
(method createBonusEntry [] (startAdding Bonus))
|
(method createBonusEntry [] (startAdding Bonus))
|
||||||
|
|
||||||
(function pointsStr [points]
|
|
||||||
(let [&mut str "" tallyUnit 5 symbols ["+" "*" "\$"]]
|
|
||||||
(doFor i (reverse (collect (range symbols.length)))
|
|
||||||
(let [scaledTallyUnit (^ tallyUnit i)
|
|
||||||
tallies (Math.floor (/ points scaledTallyUnit))]
|
|
||||||
(+= str (* (nth symbols i) tallies))
|
|
||||||
(-= points (* tallies scaledTallyUnit))))
|
|
||||||
str))
|
|
||||||
|
|
||||||
(method addCreatedEntry []
|
(method addCreatedEntry []
|
||||||
// addEntry() calls save()
|
// addEntry() calls save()
|
||||||
(when (entryNameText.text.trim)
|
(when (entryNameText.text.trim)
|
||||||
|
|||||||
Reference in New Issue
Block a user