Can add multiple labels for bonus and task
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
(fHalf (max rewardSprite.pixels.width rewardSprite.pixels.height)))
|
(fHalf (max rewardSprite.pixels.width rewardSprite.pixels.height)))
|
||||||
|
|
||||||
(prop &mut :EntryType typeAdding Todo)
|
(prop &mut :EntryType typeAdding Todo)
|
||||||
|
(prop &mut :Array<String> labelsAdding [])
|
||||||
(prop &mut :FlxInputText entryNameText)
|
(prop &mut :FlxInputText entryNameText)
|
||||||
|
|
||||||
(prop &mut :DebugLayer debugLayer null)
|
(prop &mut :DebugLayer debugLayer null)
|
||||||
@@ -44,6 +45,8 @@
|
|||||||
(prop &mut t 1)
|
(prop &mut t 1)
|
||||||
(prop :FlxRect disableMouse (new FlxRect 0 0 0 0))
|
(prop :FlxRect disableMouse (new FlxRect 0 0 0 0))
|
||||||
(method &override :Void update [:Float elapsed]
|
(method &override :Void update [:Float elapsed]
|
||||||
|
// workaround for text box somehow losing focus:
|
||||||
|
(when entryNameText (set entryNameText.hasFocus true))
|
||||||
(super.update elapsed)
|
(super.update elapsed)
|
||||||
|
|
||||||
(if (windowIsShown)
|
(if (windowIsShown)
|
||||||
@@ -116,24 +119,24 @@
|
|||||||
|
|
||||||
(method startAdding [:EntryType type]
|
(method startAdding [:EntryType type]
|
||||||
(set typeAdding type)
|
(set typeAdding type)
|
||||||
|
(set labelsAdding [])
|
||||||
|
(localVar &mut title "Alternating labels for this habit:")
|
||||||
|
(whenLet [Todo type] (set title "Steps for completing this task:"))
|
||||||
|
(set entryCreationWindow (new SimpleWindow title null null 0.9 0.9))
|
||||||
(set entryNameText (new FlxInputText 0 0 FlxG.width "" textSize true))
|
(set entryNameText (new FlxInputText 0 0 FlxG.width "" textSize true))
|
||||||
|
(entryCreationWindow.addControl entryNameText)
|
||||||
|
(entryCreationWindow.makeText "Create" FlxColor.LIME ->:Void _ (addCreatedEntry))
|
||||||
(when entryWindow
|
(when entryWindow
|
||||||
(set entryWindow.keyboardEnabled false))
|
(set entryWindow.keyboardEnabled false))
|
||||||
(set entryNameText.cameras [uiCamera])
|
(entryCreationWindow.show)
|
||||||
(set entryNameText.hasFocus true)
|
(set entryNameText.hasFocus true))
|
||||||
(add entryNameText))
|
|
||||||
|
|
||||||
(when (and entryNameText FlxG.keys.justPressed.ENTER)
|
(when (and entryNameText FlxG.keys.justPressed.ENTER)
|
||||||
// addEntry() calls save()
|
(entryCreationWindow.makeText entryNameText.text)
|
||||||
(model.addEntry typeAdding [entryNameText.text])
|
(labelsAdding.push entryNameText.text)
|
||||||
(refreshModel)
|
(set entryNameText.text "")
|
||||||
(entryNameText.kill)
|
(set entryNameText.caretIndex 0))
|
||||||
(set entryNameText null)
|
|
||||||
(when entryWindow
|
|
||||||
(set entryWindow.keyboardEnabled true)
|
|
||||||
(entryWindow.show)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Left and right arrow keys can switch between unlocked puzzles
|
// Left and right arrow keys can switch between unlocked puzzles
|
||||||
(unless (or entryNameText (tempWindowIsShown))
|
(unless (or entryNameText (tempWindowIsShown))
|
||||||
@@ -761,4 +764,17 @@
|
|||||||
tallies (Math.floor (/ points scaledTallyUnit))]
|
tallies (Math.floor (/ points scaledTallyUnit))]
|
||||||
(+= str (* (nth symbols i) tallies))
|
(+= str (* (nth symbols i) tallies))
|
||||||
(-= points (* tallies scaledTallyUnit))))
|
(-= points (* tallies scaledTallyUnit))))
|
||||||
str))
|
str))
|
||||||
|
|
||||||
|
(method addCreatedEntry []
|
||||||
|
// addEntry() calls save()
|
||||||
|
(unless labelsAdding
|
||||||
|
(return))
|
||||||
|
(model.addEntry typeAdding labelsAdding)
|
||||||
|
(refreshModel)
|
||||||
|
(entryNameText.kill)
|
||||||
|
(set entryNameText null)
|
||||||
|
(entryCreationWindow.hide)
|
||||||
|
(when entryWindow
|
||||||
|
(set entryWindow.keyboardEnabled true)
|
||||||
|
(entryWindow.show)))
|
||||||
@@ -50,6 +50,20 @@
|
|||||||
// TODO show which shortcuts' prefixes are partially highlighted?
|
// TODO show which shortcuts' prefixes are partially highlighted?
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO could make a camera on the window so the controls are clipped by the camera
|
||||||
|
|
||||||
|
(method addControl [:FlxSprite control]
|
||||||
|
(set control.x nextControlX)
|
||||||
|
(set control.y nextControlY)
|
||||||
|
(controls.add control)
|
||||||
|
(+= nextControlY control.height)
|
||||||
|
// TODO controls that aren't the same height as text will be able to vertically overflow
|
||||||
|
(when (= 0 (% controls.length controlsPerColumn))
|
||||||
|
(set nextControlY y)
|
||||||
|
(when title (+= nextControlY control.height))
|
||||||
|
(+= nextControlX (apply max
|
||||||
|
(for control (last (groups controls.members controlsPerColumn))
|
||||||
|
control.width)) textSize)))
|
||||||
|
|
||||||
(prop :Map<FlxSprite,Action> _actions (new Map))
|
(prop :Map<FlxSprite,Action> _actions (new Map))
|
||||||
(prop :Map<FlxSprite,FlxColor> _colors (new Map))
|
(prop :Map<FlxSprite,FlxColor> _colors (new Map))
|
||||||
@@ -58,14 +72,7 @@
|
|||||||
(set ftext.color (or color textColor))
|
(set ftext.color (or color textColor))
|
||||||
(dictSet _colors ftext ftext.color)
|
(dictSet _colors ftext ftext.color)
|
||||||
(set ftext.cameras this.cameras)
|
(set ftext.cameras this.cameras)
|
||||||
(controls.add ftext)
|
(addControl ftext)
|
||||||
(+= nextControlY ftext.height)
|
|
||||||
(when (= 0 (% controls.length controlsPerColumn))
|
|
||||||
(set nextControlY y)
|
|
||||||
(when title (+= nextControlY ftext.height))
|
|
||||||
(+= nextControlX (apply max
|
|
||||||
(for control (last (groups controls.members controlsPerColumn))
|
|
||||||
control.width)) textSize))
|
|
||||||
(when onClick
|
(when onClick
|
||||||
(dictSet _actions ftext onClick)
|
(dictSet _actions ftext onClick)
|
||||||
// TODO right click?
|
// TODO right click?
|
||||||
|
|||||||
Reference in New Issue
Block a user