diff options
author | Spartan322 <Megacake1234@gmail.com> | 2024-05-04 16:45:53 +0200 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-05-04 16:45:53 +0200 |
commit | 6bc32dc48c775223310e757072beab2a4bb0e9b4 (patch) | |
tree | 4952dc83ebdf9f3bfffbdc9240eead87b8eac70e /game/addons/keychain/ShortcutEdit.gd | |
parent | bf3df0ee900f406a5a2aa56609ecb89c67055351 (diff) |
Update Keychain to Orama-Interactive/Keychain@5031af557efcff4eb1ae77550e91868ab57cb1c0
Diffstat (limited to 'game/addons/keychain/ShortcutEdit.gd')
-rw-r--r-- | game/addons/keychain/ShortcutEdit.gd | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/game/addons/keychain/ShortcutEdit.gd b/game/addons/keychain/ShortcutEdit.gd index fe4e69f..207ddec 100644 --- a/game/addons/keychain/ShortcutEdit.gd +++ b/game/addons/keychain/ShortcutEdit.gd @@ -2,7 +2,7 @@ extends Control enum { KEYBOARD, MOUSE, JOY_BUTTON, JOY_AXIS } -const MOUSE_BUTTON_NAMES := [ +const MOUSE_BUTTON_NAMES: PackedStringArray = [ "Left Button", "Right Button", "Middle Button", @@ -14,7 +14,7 @@ const MOUSE_BUTTON_NAMES := [ "X Button 2", ] -const JOY_BUTTON_NAMES := [ +const JOY_BUTTON_NAMES: PackedStringArray = [ "DualShock Cross, Xbox A, Nintendo B", "DualShock Circle, Xbox B, Nintendo A", "DualShock Square, Xbox X, Nintendo Y", @@ -40,7 +40,7 @@ const JOY_BUTTON_NAMES := [ "PS4/5 Touchpad", ] -const JOY_AXIS_NAMES := [ +const JOY_AXIS_NAMES: PackedStringArray = [ "(Left Stick Left)", "(Left Stick Right)", "(Left Stick Up)", @@ -107,7 +107,7 @@ func _ready() -> void: profile_option_button.select(Keychain.profile_index) _on_ProfileOptionButton_item_selected(Keychain.profile_index) - if OS.get_name() == "HTML5": + if OS.get_name() == "Web": $VBoxContainer/HBoxContainer/OpenProfileFolder.queue_free() @@ -151,8 +151,6 @@ func _construct_tree() -> void: func _fill_selector_options() -> void: - keyboard_shortcut_selector.entered_shortcut.visible = true - keyboard_shortcut_selector.option_button.visible = false mouse_shortcut_selector.input_type_l.text = "Mouse Button Index:" joy_key_shortcut_selector.input_type_l.text = "Joypad Button Index:" joy_axis_shortcut_selector.input_type_l.text = "Joypad Axis Index:" @@ -171,8 +169,8 @@ func _fill_selector_options() -> void: var joy_axis_option_button: OptionButton = joy_axis_shortcut_selector.option_button var i := 0.0 for option in JOY_AXIS_NAMES: - var sign_symbol = "+" if floor(i) != i else "-" - var text: String = tr("Axis") + " %s %s %s" % [floor(i), sign_symbol, tr(option)] + var sign_symbol := "+" if floori(i) != i else "-" + var text: String = tr("Axis") + " %s %s %s" % [floori(i), sign_symbol, tr(option)] joy_axis_option_button.add_item(text) i += 0.5 @@ -201,19 +199,10 @@ func get_action_name(action: String) -> String: display_name = Keychain.actions[action].display_name if display_name.is_empty(): - display_name = _humanize_snake_case(action) + display_name = Keychain.humanize_snake_case(action) return display_name -func _humanize_snake_case(text: String) -> String: - text = text.replace("_", " ") - var first_letter := text.left(1) - first_letter = first_letter.capitalize() - text = text.right(-1) - text = text.insert(0, first_letter) - return text - - func add_event_tree_item(event: InputEvent, action_tree_item: TreeItem) -> void: var event_class := event.get_class() match event_class: @@ -252,21 +241,10 @@ func add_event_tree_item(event: InputEvent, action_tree_item: TreeItem) -> void: func event_to_str(event: InputEvent) -> String: - var output := "" - if event is InputEventKey: - var scancode: int = 0 - if event.keycode != 0: - scancode = event.get_keycode_with_modifiers() - var physical_str := "" - if scancode == 0: - scancode = event.get_physical_keycode_with_modifiers() - physical_str = " " + tr("(Physical)") - output = OS.get_keycode_string(scancode) + physical_str - - elif event is InputEventMouseButton: - output = tr(MOUSE_BUTTON_NAMES[event.button_index - 1]) - - elif event is InputEventJoypadButton: + var output := event.as_text() + # event.as_text() could be used for these event types as well, but this gives more control + # to the developer as to what strings will be printed + if event is InputEventJoypadButton: var button_index: int = event.button_index output = tr("Button") if button_index >= JOY_BUTTON_NAMES.size(): |