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