Skip to content

Commit

Permalink
Simplify player input code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bozar committed Sep 10, 2024
1 parent a6d7cc7 commit 934c3a5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 25 deletions.
6 changes: 1 addition & 5 deletions scene/debug/debug_screen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ func _on_PlayerInput_action_pressed(input_tag: StringName) -> void:
InputTag.OPEN_DEBUG_MENU:
_ref_SeedLineEdit.grab_focus()
visible = true
InputTag.REPLAY_GAME:
_set_transfer_data(input_tag)
InputTag.RESTART_GAME:
_set_transfer_data(input_tag)
InputTag.START_NEW_GAME:
InputTag.REPLAY_GAME, InputTag.RESTART_GAME, InputTag.START_NEW_GAME:
_set_transfer_data(input_tag)


Expand Down
18 changes: 4 additions & 14 deletions scene/help/help_screen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,11 @@ func _on_PlayerInput_action_pressed(input_tag: StringName) -> void:
_switch_screen(input_tag)
InputTag.CLOSE_MENU:
visible = false
InputTag.NEXT_SCREEN:
_switch_screen(input_tag)
InputTag.PREVIOUS_SCREEN:
InputTag.PREVIOUS_SCREEN, InputTag.NEXT_SCREEN:
_switch_screen(input_tag)
InputTag.PAGE_DOWN:
_scroll_screen(input_tag)
InputTag.PAGE_UP:
_scroll_screen(input_tag)
InputTag.LINE_DOWN:
_scroll_screen(input_tag)
InputTag.LINE_UP:
_scroll_screen(input_tag)
InputTag.PAGE_TOP:
_scroll_screen(input_tag)
InputTag.PAGE_BOTTOM:
InputTag.PAGE_DOWN, InputTag.PAGE_UP, \
InputTag.LINE_DOWN, InputTag.LINE_UP, \
InputTag.PAGE_TOP, InputTag.PAGE_BOTTOM:
_scroll_screen(input_tag)


Expand Down
1 change: 1 addition & 0 deletions scene/main/player_input.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var _input_flag: int = 0b000_11
var _previous_input_flag: int = _input_flag


# Convert `InputEvent` to `InputTag`, and then broadcast the result.
func _unhandled_input(event: InputEvent) -> void:
# Flags that cannot coexist are grouped in an `if` block.
if _input_flag & FUNCTION_FLAG:
Expand Down
4 changes: 1 addition & 3 deletions scene/main/sprite_root.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ func _on_PlayerInput_action_pressed(input_tag: StringName) -> void:
match input_tag:
InputTag.CLOSE_MENU:
visible = true
InputTag.OPEN_DEBUG_MENU:
visible = false
InputTag.OPEN_HELP_MENU:
InputTag.OPEN_DEBUG_MENU, InputTag.OPEN_HELP_MENU:
visible = false
4 changes: 1 addition & 3 deletions scene/sidebar/sidebar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,5 @@ func _on_PlayerInput_action_pressed(input_tag: StringName) -> void:
match input_tag:
InputTag.CLOSE_MENU:
visible = true
InputTag.OPEN_DEBUG_MENU:
visible = false
InputTag.OPEN_HELP_MENU:
InputTag.OPEN_DEBUG_MENU, InputTag.OPEN_HELP_MENU:
visible = false

0 comments on commit 934c3a5

Please sign in to comment.