WIP KeyShortcutWindow for NAT flixel

This commit is contained in:
2022-08-10 13:51:12 +00:00
parent 17429ac2c5
commit c9a3792faa
2 changed files with 38 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
package kiss_flixel;
import kiss.Prelude;
import kiss.List;
import kiss_tools.KeyShortcutHandler;
import flixel.util.FlxColor;
@:build(kiss.Kiss.build())
class KeyShortcutWindow<T> extends SimpleWindow {}

View File

@@ -0,0 +1,29 @@
// Wraps a given generic KeyShortcutHandler within
// the FlxKeyShortcutHandler that every SimpleWindow has,
// using the window to display available mappings
// from the currently active prefix map
(defNew [&prop :KeyShortcutHandler<T> innerKeyShortcuts
&prop :T->String elementToStringWithoutBrackets
&opt :String title
:FlxColor bgColor
:FlxColor textColor
:Float percentWidth
:Float percentHeight]
(super title bgColor textColor percentWidth percentHeight)
(set innerKeyShortcuts.onSelectPrefixMap ->map {
(clearControls)
(doFor =>key keyBehavior map
(case keyBehavior
((Final item)
(makeText "[${key}] - $(elementToString item)" null ->_ (innerKeyShortcuts.onSelectItem item)))
((Prefix innerMap)
(makeText "[${key}] - $(count innerMap) more options" null ->_ (innerKeyShortcuts.onSelectPrefixMap innerMap)))
(null null)))}))
(method &override :Void show []
(super.show)
(innerKeyShortcuts.start))
(method &override :Void hide []
(super.hide)
(innerKeyShortcuts.cancel))