Skip to content

Commit

Permalink
feat: expand input map, support button-credit scroll
Browse files Browse the repository at this point in the history
The input map now supports playing with either joystick, and using
rb/lb/rt/lt to undo/restart.

the credits can now be scrolled with b/y instead of just up/down.
annoyingly the joystick up/down is not detected, but dpads work fine.
  • Loading branch information
russmatney committed Feb 7, 2024
1 parent 999b403 commit 603e3a6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
3 changes: 3 additions & 0 deletions addons/core/Trolls.gd
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@ static func is_pause(event):
static func is_close(event):
return is_event(event, "close")

static func is_close_released(event):
return is_released(event, "close")

static func is_debug_toggle(event):
return is_event(event, "debug_toggle")
19 changes: 10 additions & 9 deletions addons/core/credits/Credits.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@ func _ready():

## input ############################################################

var scroll_held = Vector2.ZERO
var scroll_direction = Vector2.ZERO

func _unhandled_input(event):
if Trolls.is_move_up(event):
scroll_held = Vector2.UP
elif Trolls.is_move_down(event):
scroll_held = Vector2.DOWN
if Trolls.is_move_released(event):
scroll_held = Vector2.ZERO
if Trolls.is_move_up(event) or Trolls.is_restart(event):
scroll_direction = Vector2.UP
elif Trolls.is_move_down(event) or Trolls.is_close(event):
scroll_direction = Vector2.DOWN
if Trolls.is_move_released(event) or Trolls.is_close_released(event) \
or Trolls.is_restart_released(event):
scroll_direction = Vector2.ZERO

## process ############################################################

func _process(delta):
if scroll_held != Vector2.ZERO:
match scroll_held:
if scroll_direction != Vector2.ZERO:
match scroll_direction:
Vector2.UP: credits_scroll_container.scroll_vertical -= 30
Vector2.DOWN: credits_scroll_container.scroll_vertical += 30
return
Expand Down
8 changes: 8 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ ui_left={
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"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":65,"physical_keycode":0,"key_label":0,"unicode":97,"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":72,"physical_keycode":0,"key_label":0,"unicode":104,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
]
}
ui_right={
Expand All @@ -84,6 +85,7 @@ ui_right={
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"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":68,"physical_keycode":0,"key_label":0,"unicode":100,"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":76,"physical_keycode":0,"key_label":0,"unicode":108,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
]
}
ui_up={
Expand All @@ -93,6 +95,7 @@ ui_up={
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"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":87,"physical_keycode":0,"key_label":0,"unicode":119,"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":75,"physical_keycode":0,"key_label":0,"unicode":107,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
]
}
ui_down={
Expand All @@ -102,13 +105,16 @@ ui_down={
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"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":83,"physical_keycode":0,"key_label":0,"unicode":115,"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":74,"physical_keycode":0,"key_label":0,"unicode":106,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
]
}
ui_undo={
"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":90,"physical_keycode":0,"key_label":0,"unicode":122,"echo":false,"script":null)
, 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(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":true,"script":null)
]
}
pause={
Expand All @@ -122,6 +128,8 @@ restart={
"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":82,"physical_keycode":0,"key_label":0,"unicode":114,"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)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":5,"axis_value":1.0,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":4,"axis_value":1.0,"script":null)
]
}
close={
Expand Down
3 changes: 3 additions & 0 deletions src/menus/Credits.gd
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,6 @@ func _ready():
super._ready()
main_menu_button.pressed.connect(func():
Navi.nav_to_main_menu())
main_menu_button.grab_focus.call_deferred()
main_menu_button.visibility_changed.connect(func():
main_menu_button.grab_focus())
2 changes: 1 addition & 1 deletion src/menus/worldmap/WorldMapMenu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ color = Color(0.101961, 0.109804, 0.188235, 1)
unique_name_in_owner = true
position = Vector2(832, 418)
scale = Vector2(5, 5)
current_marker = NodePath("@Marker2D@18102")
current_marker = NodePath("@Marker2D@78952")
zoom_scale_min = 5.0
zoom_scale_max = 10.0

Expand Down

0 comments on commit 603e3a6

Please sign in to comment.