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