Added gameplay_input manager.
Refactored menus, player, and escape_capsule to utilize new system. Actions defined in Godot project file with default bindings. Player/Vehicles now react to actions and GameplayInput states instead of polling Input directly. They respond to commands via `_handle_gameplay_command` and should not implement _unhandled_input directly. Kept some debugging input handling code in `player.gd` for things like F3/F5/F4/PageUp/PageDown. We may want to move much of this out of `player.gd` into something that handles the gamestate more generally.
This commit is contained in:
@@ -71,10 +71,14 @@ func _ready() -> void:
|
||||
|
||||
visible = false
|
||||
|
||||
## Claims menu input and gives controllers a predictable initial focus.
|
||||
func open_menu(player_ref: Node) -> void:
|
||||
player = player_ref
|
||||
visible = true
|
||||
GameplayInput.set_menu_open(self, true)
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
_update_button_states()
|
||||
close_button.grab_focus()
|
||||
print("Vendor menu opened")
|
||||
|
||||
func _update_button_states() -> void:
|
||||
@@ -112,6 +116,15 @@ func _buy(item_name: String, price: int) -> void:
|
||||
else:
|
||||
print("Not enough credits")
|
||||
|
||||
## Cancels the vendor without allowing the same event to reach gameplay.
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if visible and event.is_action_pressed("ui_cancel"):
|
||||
_on_close_pressed()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
## Releases menu ownership; the adapter clears queued and held commands.
|
||||
func _on_close_pressed() -> void:
|
||||
visible = false
|
||||
GameplayInput.set_menu_open(self, false)
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
Reference in New Issue
Block a user