WIP KeyShortcutWindow for NAT flixel
This commit is contained in:
9
src/kiss_flixel/KeyShortcutWindow.hx
Normal file
9
src/kiss_flixel/KeyShortcutWindow.hx
Normal 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 {}
|
29
src/kiss_flixel/KeyShortcutWindow.kiss
Normal file
29
src/kiss_flixel/KeyShortcutWindow.kiss
Normal 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))
|
Reference in New Issue
Block a user