From bfc6b466d240ffd500410b82b032afdb4eed83f0 Mon Sep 17 00:00:00 2001 From: Russell Matney Date: Mon, 15 Jan 2024 17:53:24 -0500 Subject: [PATCH] feat: latin kbd inputs, better action icon spacing wip: placeholders for joy button/motion inputs --- project.godot | 21 ++++++++++++++++++++- src/menus/ActionInputIcon.gd | 18 +++++++++++++----- src/menus/ActionInputIcon.tscn | 1 - src/menus/EditActionRow.gd | 13 ++++++++++++- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/project.godot b/project.godot index c6f2e953..8a9f031b 100644 --- a/project.godot +++ b/project.godot @@ -33,6 +33,20 @@ enabled=PackedStringArray("res://addons/AsepriteWizard/plugin.cfg", "res://addon [input] +ui_accept={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194309,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194310,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null) +] +} +ui_cancel={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null) +] +} ui_left={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) @@ -72,27 +86,32 @@ ui_down={ ui_undo={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"command_or_control_autoremap":true,"alt_pressed":false,"shift_pressed":false,"pressed":false,"keycode":90,"physical_keycode":0,"key_label":0,"unicode":90,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":90,"key_label":0,"unicode":122,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":90,"physical_keycode":0,"key_label":0,"unicode":122,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null) ] } pause={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":false,"script":null) ] } restart={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":82,"physical_keycode":0,"key_label":0,"unicode":82,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":false,"script":null) ] } close={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":81,"physical_keycode":0,"key_label":0,"unicode":113,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null) ] } debug_toggle={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":80,"physical_keycode":0,"key_label":0,"unicode":112,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":4,"pressure":0.0,"pressed":false,"script":null) ] } diff --git a/src/menus/ActionInputIcon.gd b/src/menus/ActionInputIcon.gd index 23ace6ba..75e7857b 100644 --- a/src/menus/ActionInputIcon.gd +++ b/src/menus/ActionInputIcon.gd @@ -28,7 +28,6 @@ func render_icon(): set_visible(false) return set_visible(true) - Log.pr("rendering input icon for text", input_text) var input_key = "" var mods = [] @@ -49,14 +48,23 @@ func render_icon(): for m in mods: var mod_text = get_literal_text(m) key = "%s%s" % [mod_text, key] - mod_width += 80 + if m in ["Shift"]: + mod_width += 90 + elif m in ["Ctrl"]: + mod_width += 80 + else: + mod_width += 80 text = key - if input_text in ["Space", "Enter"]: - set_custom_minimum_size(Vector2(80 + mod_width, 0)) + if input_text in ["Space"]: + set_custom_minimum_size(Vector2(110 + mod_width, 0)) + elif input_text in ["Enter"]: + set_custom_minimum_size(Vector2(90 + mod_width, 0)) + elif input_text in ["Escape"]: + set_custom_minimum_size(Vector2(70 + mod_width, 0)) else: - set_custom_minimum_size(Vector2(32 + mod_width, 0)) + set_custom_minimum_size(Vector2(50 + mod_width, 0)) var ignores = ["", "Kp Enter"] diff --git a/src/menus/ActionInputIcon.tscn b/src/menus/ActionInputIcon.tscn index 65a32310..8c008778 100644 --- a/src/menus/ActionInputIcon.tscn +++ b/src/menus/ActionInputIcon.tscn @@ -16,4 +16,3 @@ text = "a" fit_content = true scroll_active = false script = ExtResource("2_lnakd") -input_text = "" diff --git a/src/menus/EditActionRow.gd b/src/menus/EditActionRow.gd index e8f8090a..ad0557e5 100644 --- a/src/menus/EditActionRow.gd +++ b/src/menus/EditActionRow.gd @@ -20,7 +20,6 @@ func render_action_icons(): U.remove_children(action_inputs) Log.pr("\n\nicons for", action_name) - Log.pr("kbd inputs", keyboard_inputs) for inp in keyboard_inputs: var icon = input_icon_scene.instantiate() var key_str_mods = OS.get_keycode_string(inp.get_keycode_with_modifiers()) @@ -29,6 +28,18 @@ func render_action_icons(): action_inputs.add_child(icon) Log.pr("joy inputs", joypad_inputs) + for inp in joypad_inputs: + var icon = input_icon_scene.instantiate() + if "axis" in inp: + var joy_axis_idx = inp.axis + Log.pr("joy_axis_idx", joy_axis_idx) + icon.input_text = "Joystick left" + else: + var joy_button_idx = inp.button_index + Log.pr("joy_button_idx", joy_button_idx) + icon.input_text = "B Button" + # TODO if no action icon is found, we ought to remove the icon + action_inputs.add_child(icon) # TODO pull controller icons for the given inputs