Allow creating interval habits
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
(prop &mut :EntryType typeAdding Todo)
|
(prop &mut :EntryType typeAdding Todo)
|
||||||
(prop &mut :Array<String> labelsAdding [])
|
(prop &mut :Array<String> labelsAdding [])
|
||||||
|
(prop &mut :Bool addingLabels false)
|
||||||
(prop &mut :FlxInputText entryNameText)
|
(prop &mut :FlxInputText entryNameText)
|
||||||
|
|
||||||
(prop &mut :DebugLayer debugLayer null)
|
(prop &mut :DebugLayer debugLayer null)
|
||||||
@@ -102,8 +103,9 @@
|
|||||||
(set save.data.storedOrigins (new Map<Int,FlxPoint>))
|
(set save.data.storedOrigins (new Map<Int,FlxPoint>))
|
||||||
(save.flush))))
|
(save.flush))))
|
||||||
|
|
||||||
(when FlxG.keys.justPressed.DELETE
|
(unless (and entryNameText entryNameText.alive)
|
||||||
(Sys.exit 0))
|
(when FlxG.keys.justPressed.DELETE
|
||||||
|
(Sys.exit 0)))
|
||||||
|
|
||||||
// TODO provide a saner/configurable set of bindings to trigger these ui action functions
|
// TODO provide a saner/configurable set of bindings to trigger these ui action functions
|
||||||
{
|
{
|
||||||
@@ -117,9 +119,10 @@
|
|||||||
(dictSet (the Map<Int,FlxPoint> save.data.storedOrigins) (dictGet indexMap s) s.origin))
|
(dictSet (the Map<Int,FlxPoint> save.data.storedOrigins) (dictGet indexMap s) s.origin))
|
||||||
(save.flush))))
|
(save.flush))))
|
||||||
|
|
||||||
(method startAdding [:EntryType type]
|
(method :Void startAdding [:EntryType type]
|
||||||
(set typeAdding type)
|
(set typeAdding type)
|
||||||
(set labelsAdding [])
|
(set labelsAdding [])
|
||||||
|
(set addingLabels true)
|
||||||
(localVar &mut title "Alternating labels for this habit:")
|
(localVar &mut title "Alternating labels for this habit:")
|
||||||
(whenLet [Todo type] (set title "Steps for completing this task:"))
|
(whenLet [Todo type] (set title "Steps for completing this task:"))
|
||||||
(set entryCreationWindow (new SimpleWindow title null null 0.9 0.9))
|
(set entryCreationWindow (new SimpleWindow title null null 0.9 0.9))
|
||||||
@@ -132,10 +135,14 @@
|
|||||||
(set entryNameText.hasFocus true))
|
(set entryNameText.hasFocus true))
|
||||||
|
|
||||||
(when (and entryNameText FlxG.keys.justPressed.ENTER)
|
(when (and entryNameText FlxG.keys.justPressed.ENTER)
|
||||||
(entryCreationWindow.makeText entryNameText.text)
|
(cond
|
||||||
(labelsAdding.push entryNameText.text)
|
(addingLabels
|
||||||
(set entryNameText.text "")
|
(entryCreationWindow.makeText entryNameText.text)
|
||||||
(set entryNameText.caretIndex 0))
|
(labelsAdding.push entryNameText.text)
|
||||||
|
(set entryNameText.text "")
|
||||||
|
(set entryNameText.caretIndex 0))
|
||||||
|
(true
|
||||||
|
(startAddingInterval))))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Left and right arrow keys can switch between unlocked puzzles
|
// Left and right arrow keys can switch between unlocked puzzles
|
||||||
@@ -787,7 +794,23 @@
|
|||||||
(for d (range 28) "$(+ d 1) days before month ends"))]
|
(for d (range 28) "$(+ d 1) days before month ends"))]
|
||||||
(createToggleIndicesType false Monthly (cast texts) 28 "Which days of the month?" 0.9 0.9)))
|
(createToggleIndicesType false Monthly (cast texts) 28 "Which days of the month?" 0.9 0.9)))
|
||||||
|
|
||||||
(method createIntervalEntry [])
|
(method createIntervalEntry []
|
||||||
|
(set entryCreationWindow (new SimpleWindow "After finishing this habit, how many days do you wait before doing it again?" null null 0.9))
|
||||||
|
(set entryNameText (new FlxInputText 0 0 FlxG.width "" textSize true))
|
||||||
|
(set addingLabels false)
|
||||||
|
(entryCreationWindow.addControl entryNameText)
|
||||||
|
(entryCreationWindow.makeText "Confirm" FlxColor.LIME
|
||||||
|
->:Void _
|
||||||
|
(defAndCall method startAddingInterval
|
||||||
|
(try
|
||||||
|
(let [int (Std.parseInt entryNameText.text)]
|
||||||
|
(entryNameText.kill)
|
||||||
|
(set entryNameText null)
|
||||||
|
(entryCreationWindow.hide)
|
||||||
|
(startAdding (Interval int "")))
|
||||||
|
(catch [e] (return)))))
|
||||||
|
(entryCreationWindow.show))
|
||||||
|
|
||||||
(method createTaskEntry [] (startAdding Todo))
|
(method createTaskEntry [] (startAdding Todo))
|
||||||
(method createBonusEntry [] (startAdding Bonus))
|
(method createBonusEntry [] (startAdding Bonus))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user