move FlxKeyShortcutHandler to kiss-flixel

This commit is contained in:
2023-07-05 06:39:46 -06:00
parent fae12a7253
commit 77dcc3add7
2 changed files with 0 additions and 59 deletions

View File

@@ -1,13 +0,0 @@
#if flixel
package kiss_tools;
import kiss.Prelude;
import kiss.List;
import kiss_tools.KeyShortcutHandler;
import flixel.input.keyboard.FlxKey;
import flixel.FlxG;
@:build(kiss.Kiss.build())
class FlxKeyShortcutHandler<T> extends KeyShortcutHandler<T> {}
#end

View File

@@ -1,46 +0,0 @@
(var KEY_MAP [
=>"ZERO" "0"
=>"ONE" "1"
=>"TWO" "2"
=>"THREE" "3"
=>"FOUR" "4"
=>"FIVE" "5"
=>"SIX" "6"
=>"SEVEN" "7"
=>"EIGHT" "8"
=>"NINE" "9"
=>"NUMPADZERO" "0"
=>"NUMPADONE" "1"
=>"NUMPADTWO" "2"
=>"NUMPADTHREE" "3"
=>"NUMPADFOUR" "4"
=>"NUMPADFIVE" "5"
=>"NUMPADSIX" "6"
=>"NUMPADSEVEN" "7"
=>"NUMPADEIGHT" "8"
=>"NUMPADNINE" "9"
// TODO there are probably other keys worth converting
])
(defNew []
(super)
(set cancelKey "escape")
// TODO generic error handlers
)
// automatically pass the last pressed key to handle key
(method :Void update []
(let [:FlxKey id (FlxG.keys.firstJustPressed)]
(unless (= id -1)
(let [key (id.toString)]
(case key
("SHIFT" (return))
(otherwise
(handleKey
(case key
((when (KEY_MAP.exists key) key)
(dictGet KEY_MAP key))
((when FlxG.keys.pressed.SHIFT key)
(.toUpperCase key))
(key (.toLowerCase key))
(otherwise (throw "FlxKey.toString returned null!"))))))))))