SimpleWindow makeXControls when clearing

This commit is contained in:
2022-09-14 21:04:35 +00:00
parent b80f50df56
commit f0fae53fb9

View File

@@ -1,3 +1,5 @@
(loadFrom "kiss-tools" "src/kiss_tools/RefactorUtil.kiss")
// All windows share the same text size
(var &mut textSize 16)
(var :kiss.List<SimpleWindow> windowStack [])
@@ -15,8 +17,8 @@
:FlxColor _textColor
:Float percentWidth
:Float percentHeight
:Bool xButton :String xKey
:ShortcutAction onClose]
:Bool _xButton :String _xKey
:ShortcutAction _onClose]
[:String title (or _title "")
&mut :Float nextControlX 0
@@ -24,6 +26,9 @@
&mut :Int controlsPerColumn 0
:FlxColor titleColor (or _textColor FlxColor.WHITE)
&mut :FlxColor textColor (or _textColor FlxColor.WHITE)
:Bool xButton ?_xButton
:String xKey _xKey
:ShortcutAction onClose _onClose
:FlxTypedGroup<FlxSprite> controls (new FlxTypedGroup)
:FlxKeyShortcutHandler<ShortcutAction> keyHandler (new FlxKeyShortcutHandler)]
@@ -58,21 +63,22 @@
(keyHandler.start)
})
(let [closeAction ->:Void {(hide)(when onClose (onClose))}]
(when xButton
(let [ftext (new FlxText width 0 0 "X" textSize)]
(set ftext.cameras [controlCamera])
(-= ftext.x ftext.width)
(set ftext.color textColor)
(dictSet _colors ftext ftext.color)
(dictSet _actions ftext ->:Void _ (closeAction))
(set xText ftext)
(controls.add xText)))
(defAndCall method makeXControls
(let [closeAction ->:Void {(hide)(when onClose (onClose))}]
(when xButton
(let [ftext (new FlxText width 0 0 "X" textSize)]
(set ftext.cameras [controlCamera])
(-= ftext.x ftext.width)
(set ftext.color textColor)
(dictSet _colors ftext ftext.color)
(dictSet _actions ftext ->:Void _ (closeAction))
(set xText ftext)
(controls.add xText)))
(when xKey
(when (= keyHandler.cancelKey xKey)
(set keyHandler.cancelKey null))
(keyHandler.registerItem "{${xKey}}" closeAction)))
(when xKey
(when (= keyHandler.cancelKey xKey)
(set keyHandler.cancelKey null))
(keyHandler.registerItem "{${xKey}}" closeAction))))
// TODO show which shortcuts' prefixes are partially highlighted?
)
@@ -152,6 +158,7 @@
(_actions.clear)
(controls.clear)
(keyHandler.clear)
(makeXControls)
(set nextControlX 0)
(set nextControlY 0)
(makeText title titleColor))