rename key props physical_keycode to keycode
This commit is contained in:
parent
e9a6d5ed5c
commit
c1e4cc93a9
@ -88,9 +88,9 @@ func _on_keyboard_key_press_changed(game_key: GameKey, event: InputEventKey) ->
|
||||
|
||||
if game_key.props.is_unicode():
|
||||
_set_typing_label(char(event.unicode))
|
||||
elif game_key.props.physical_keycode == KEY_SPACE:
|
||||
elif game_key.props.keycode == KEY_SPACE:
|
||||
_set_typing_label(" ")
|
||||
elif game_key.props.physical_keycode == KEY_BACKSPACE:
|
||||
elif game_key.props.keycode == KEY_BACKSPACE:
|
||||
_erase_typing_label()
|
||||
|
||||
|
||||
|
||||
@ -74,8 +74,8 @@ static func instantiate_with_props(
|
||||
node._keyboard = keyboard
|
||||
node.load_props(_props, init_pos, default_angle)
|
||||
|
||||
if _props.physical_keycode != KEY_NONE:
|
||||
node.name += " " + OS.get_keycode_string(_props.physical_keycode)
|
||||
if _props.keycode != KEY_NONE:
|
||||
node.name += " " + OS.get_keycode_string(_props.keycode)
|
||||
if _props.location != KEY_LOCATION_UNSPECIFIED:
|
||||
node.name += (
|
||||
" " + ("Left" if _props.location == KEY_LOCATION_LEFT else "Right")
|
||||
@ -125,11 +125,9 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
var event_key := event as InputEventKey
|
||||
|
||||
if (
|
||||
event_key.physical_keycode != props.physical_keycode
|
||||
event_key.physical_keycode != props.keycode
|
||||
or event_key.echo
|
||||
or (
|
||||
event_key.physical_keycode == KEY_NONE or props.physical_keycode == KEY_NONE
|
||||
)
|
||||
or (event_key.physical_keycode == KEY_NONE or props.keycode == KEY_NONE)
|
||||
or (
|
||||
event_key.location != KEY_LOCATION_UNSPECIFIED
|
||||
and props.location != KEY_LOCATION_UNSPECIFIED
|
||||
@ -189,10 +187,8 @@ func get_default_transform() -> Transform3D:
|
||||
|
||||
func is_adjacent(to: GameKey) -> bool:
|
||||
return (
|
||||
KeyHelper.ADJACENCY_MAP.has(props.physical_keycode)
|
||||
and (
|
||||
to.props.physical_keycode in KeyHelper.ADJACENCY_MAP[props.physical_keycode]
|
||||
)
|
||||
KeyHelper.ADJACENCY_MAP.has(props.keycode)
|
||||
and (to.props.keycode in KeyHelper.ADJACENCY_MAP[props.keycode])
|
||||
)
|
||||
|
||||
|
||||
@ -245,12 +241,8 @@ func _set_labels(chars_dict: Dictionary[KeyProps.Char, String] = {}) -> void:
|
||||
|
||||
|
||||
func _set_labels_text(chars_dict: Dictionary[KeyProps.Char, String]) -> void:
|
||||
if (
|
||||
Engine.is_editor_hint()
|
||||
or props.physical_keycode == KEY_SPACE
|
||||
or not props.is_unicode()
|
||||
):
|
||||
_center_label.text = OS.get_keycode_string(props.physical_keycode)
|
||||
if Engine.is_editor_hint() or props.keycode == KEY_SPACE or not props.is_unicode():
|
||||
_center_label.text = OS.get_keycode_string(props.keycode)
|
||||
return
|
||||
|
||||
if chars_dict:
|
||||
|
||||
@ -132,9 +132,7 @@ func emit_player_finished_move(game_key: GameKey) -> void:
|
||||
func request_key_by_keycode(keycode: Key) -> GameKey:
|
||||
var found_key: GameKey
|
||||
var result := request_keys(
|
||||
func(game_key: GameKey) -> bool:
|
||||
return game_key.props.physical_keycode == keycode,
|
||||
1
|
||||
func(game_key: GameKey) -> bool: return game_key.props.keycode == keycode, 1
|
||||
)
|
||||
if result:
|
||||
found_key = result[0]
|
||||
@ -336,7 +334,7 @@ func _regenerate_keys(layout_rows: Array[Array]) -> void:
|
||||
continue
|
||||
var game_key := node as GameKey
|
||||
var key_props := game_key.props
|
||||
var dict_key := Vector2i(key_props.physical_keycode, key_props.location)
|
||||
var dict_key := Vector2i(key_props.keycode, key_props.location)
|
||||
if current_keys.has(dict_key):
|
||||
current_keys[dict_key].append(game_key)
|
||||
else:
|
||||
@ -355,7 +353,7 @@ func _regenerate_key(
|
||||
angle: float,
|
||||
current_keys: Dictionary[Vector2i, Array]
|
||||
) -> void:
|
||||
var dict_key := Vector2i(key_props.physical_keycode, key_props.location)
|
||||
var dict_key := Vector2i(key_props.keycode, key_props.location)
|
||||
|
||||
if current_keys.has(dict_key):
|
||||
var game_keys := current_keys[dict_key] as Array[GameKey]
|
||||
@ -372,7 +370,7 @@ func _regenerate_key(
|
||||
if game_keys.size() == 0:
|
||||
current_keys.erase(dict_key)
|
||||
else:
|
||||
var props_dict := LayoutConfig.get_key_config_dict(key_props.physical_keycode)
|
||||
var props_dict := LayoutConfig.get_key_config_dict(key_props.keycode)
|
||||
if props_dict:
|
||||
key_props.chars_from_dict(props_dict)
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ func _load_config() -> Error:
|
||||
|
||||
for row: Array[KeyProps] in layout_rows:
|
||||
for key_props in row:
|
||||
var param_key := str(key_props.physical_keycode)
|
||||
var param_key := str(key_props.keycode)
|
||||
if (
|
||||
not key_props.is_unicode()
|
||||
or not _config.has_section_key(SECTION_KEYS, param_key)
|
||||
@ -120,7 +120,7 @@ func _save_config() -> Error:
|
||||
continue
|
||||
|
||||
_config.set_value(
|
||||
SECTION_KEYS, str(key_props.physical_keycode), key_props.chars_to_dict()
|
||||
SECTION_KEYS, str(key_props.keycode), key_props.chars_to_dict()
|
||||
)
|
||||
|
||||
var err := _config.save(CONFIG_PATH)
|
||||
|
||||
@ -25,7 +25,7 @@ enum {
|
||||
NUB,
|
||||
}
|
||||
|
||||
@export var physical_keycode: Key = KEY_NONE
|
||||
@export var keycode: Key = KEY_NONE
|
||||
@export var location: KeyLocation = KEY_LOCATION_UNSPECIFIED
|
||||
|
||||
@export var width: float = 1
|
||||
@ -51,11 +51,11 @@ enum {
|
||||
|
||||
|
||||
func is_unicode() -> bool:
|
||||
return OS.is_keycode_unicode(physical_keycode)
|
||||
return OS.is_keycode_unicode(keycode)
|
||||
|
||||
|
||||
func is_player_pos_key() -> bool:
|
||||
return KeyHelper.ADJACENCY_MAP.has(physical_keycode)
|
||||
return KeyHelper.ADJACENCY_MAP.has(keycode)
|
||||
|
||||
|
||||
func has_secondary_rect() -> bool:
|
||||
@ -76,7 +76,7 @@ func has_pivot_y() -> bool:
|
||||
|
||||
func props_from_dict(dict: Dictionary) -> KeyProps:
|
||||
if dict.has(KEY):
|
||||
physical_keycode = dict[KEY]
|
||||
keycode = dict[KEY]
|
||||
if dict.has(LOC):
|
||||
location = dict[LOC]
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user