diff --git a/src/kiss_flixel/SimpleWindow.kiss b/src/kiss_flixel/SimpleWindow.kiss index 9e4b8d7..5e63ab0 100644 --- a/src/kiss_flixel/SimpleWindow.kiss +++ b/src/kiss_flixel/SimpleWindow.kiss @@ -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 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 controls (new FlxTypedGroup) :FlxKeyShortcutHandler 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))) - - (when xKey - (when (= keyHandler.cancelKey xKey) - (set keyHandler.cancelKey null)) - (keyHandler.registerItem "{${xKey}}" closeAction))) + (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)))) // 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))