Skip to content

Commit

Permalink
feat: latin kbd inputs, better action icon spacing
Browse files Browse the repository at this point in the history
wip: placeholders for joy button/motion inputs
  • Loading branch information
russmatney committed Jan 15, 2024
1 parent 94ff452 commit bfc6b46
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
21 changes: 20 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
]
}

Expand Down
18 changes: 13 additions & 5 deletions src/menus/ActionInputIcon.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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"]

Expand Down
1 change: 0 additions & 1 deletion src/menus/ActionInputIcon.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ text = "a"
fit_content = true
scroll_active = false
script = ExtResource("2_lnakd")
input_text = ""
13 changes: 12 additions & 1 deletion src/menus/EditActionRow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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

0 comments on commit bfc6b46

Please sign in to comment.