add query_keys_by_keycodes method
This commit is contained in:
parent
0ba9de1095
commit
564cf7c168
@ -114,16 +114,6 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
|
||||
|
||||
#region public
|
||||
func query_key_by_keycode(keycode: Key) -> GameKey:
|
||||
var found_key: GameKey
|
||||
var result := query_keys(
|
||||
func(game_key: GameKey) -> bool: return game_key.props.keycode == keycode, 1
|
||||
)
|
||||
if result:
|
||||
found_key = result[0]
|
||||
return found_key
|
||||
|
||||
|
||||
func query_keys(query_func: Callable, limit: int = 0) -> Array[GameKey]:
|
||||
_queried_keys = []
|
||||
_queried_keys_limit = limit
|
||||
@ -138,6 +128,22 @@ func query_keys(query_func: Callable, limit: int = 0) -> Array[GameKey]:
|
||||
return queried_keys
|
||||
|
||||
|
||||
func query_key_by_keycode(keycode: Key) -> GameKey:
|
||||
var found_key: GameKey
|
||||
var result := query_keys(
|
||||
func(game_key: GameKey) -> bool: return game_key.props.keycode == keycode, 1
|
||||
)
|
||||
if result:
|
||||
found_key = result[0]
|
||||
return found_key
|
||||
|
||||
|
||||
func query_keys_by_keycodes(keycodes: Array[Key]) -> Array[GameKey]:
|
||||
return query_keys(
|
||||
func(game_key: GameKey) -> bool: return game_key.props.keycode in keycodes
|
||||
)
|
||||
|
||||
|
||||
func key_query_respond(game_key: GameKey) -> void:
|
||||
if _queried_keys_limit == 0 or _queried_keys.size() < _queried_keys_limit:
|
||||
_queried_keys.append(game_key)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user