fix player menu controller zone navigation

This commit is contained in:
Alexander Sellite 2026-08-15 22:43:35 -04:00
parent e12ed54ab8
commit 3d086b19e4
4 changed files with 228 additions and 18 deletions

View file

@ -738,19 +738,7 @@ func _handle_controller_ownership_input(event: InputEvent) -> bool:
func _handle_active_page_controller_input(event: InputEvent) -> bool:
var handled: bool = false
match _current_section:
Section.LOGBOOK:
handled = _catalog_logbook.handle_controller_input(event)
Section.NET:
handled = _the_net_page.handle_controller_input(event)
Section.MAIL:
handled = _mail_page.handle_controller_input(event)
Section.PROFILE:
handled = _profile_page.handle_controller_input(event)
Section.PLAYERS:
handled = _players_page.handle_controller_input(event)
if handled:
if _dispatch_active_page_controller_input(event):
return true
var button_event := event as InputEventJoypadButton
if (
@ -762,11 +750,35 @@ func _handle_active_page_controller_input(event: InputEvent) -> bool:
JOY_BUTTON_B,
)
):
# Child pages use ui_cancel for their zone transitions. Retry a mapped
# B press as that semantic action before treating it as a request to
# close the entire player menu.
if not event.is_action_pressed("ui_cancel"):
var cancel_event := InputEventAction.new()
cancel_event.action = &"ui_cancel"
cancel_event.pressed = true
if _dispatch_active_page_controller_input(cancel_event):
return true
close_menu()
return true
return false
func _dispatch_active_page_controller_input(event: InputEvent) -> bool:
match _current_section:
Section.LOGBOOK:
return _catalog_logbook.handle_controller_input(event)
Section.NET:
return _the_net_page.handle_controller_input(event)
Section.MAIL:
return _mail_page.handle_controller_input(event)
Section.PROFILE:
return _profile_page.handle_controller_input(event)
Section.PLAYERS:
return _players_page.handle_controller_input(event)
return false
func _activate_inventory_selection() -> void:
if _try_enter_notepad_controller_ownership():
return
@ -1733,6 +1745,11 @@ func _set_descendant_focus_disabled(root: Node) -> void:
func _reserve_visible_secondary_navigation() -> void:
# Inventory organizer tabs have dedicated left/right ownership. Other pages
# manage their own controller zones, and their toggle buttons are content,
# not secondary navigation that should be disabled here.
if not _is_inventory_section(_current_section):
return
var navigation_cluster := get_node_or_null("%NavigationCluster") as Control
var grouped_buttons: Dictionary = {}
_collect_visible_toggle_buttons(self, navigation_cluster, grouped_buttons)

View file

@ -217,7 +217,13 @@ func consume_escape() -> bool:
func handle_controller_input(event: InputEvent) -> bool:
if not _profile_active or not _profile_interactive:
return false
if event.is_action_pressed("ui_cancel"):
var cancel_pressed := _event_matches_controller_press(
event,
&"ui_cancel",
ControllerMappingManagerType.ROLE_B,
JOY_BUTTON_B,
)
if cancel_pressed:
if _discard_confirmation.visible:
_close_discard_confirmation()
return true
@ -242,9 +248,15 @@ func handle_controller_input(event: InputEvent) -> bool:
return true
if _controller_zone == ControllerZone.ACCOUNT:
return false
var accept_pressed := _event_matches_controller_press(
event,
&"ui_accept",
ControllerMappingManagerType.ROLE_A,
JOY_BUTTON_A,
)
if (
_controller_zone == ControllerZone.CATEGORIES
and event.is_action_pressed("ui_accept")
and accept_pressed
):
var focused_category := get_viewport().gui_get_focus_owner() as Button
if focused_category != null and _category_list.is_ancestor_of(
@ -258,7 +270,7 @@ func handle_controller_input(event: InputEvent) -> bool:
return true
if (
_controller_zone == ControllerZone.OPTIONS
and event.is_action_pressed("ui_accept")
and accept_pressed
):
var groups: Array = _controller_option_groups()
if _controller_option_depth < groups.size() - 1:
@ -272,6 +284,22 @@ func handle_controller_input(event: InputEvent) -> bool:
return false
func _event_matches_controller_press(
event: InputEvent,
action: StringName,
role: StringName,
fallback_button: JoyButton,
) -> bool:
if event.is_action_pressed(action):
return true
var button_event := event as InputEventJoypadButton
if button_event == null or not button_event.pressed:
return false
if _controller_mapping_manager != null:
return _controller_mapping_manager.event_matches_role(event, role)
return button_event.button_index == fallback_button
func _process(delta: float) -> void:
if (
not _profile_active
@ -384,7 +412,13 @@ func _focus_controller_zone() -> void:
controls = _color_picker_controller_controls()
for control: Control in controls:
var button := control as BaseButton
if button != null and button.button_pressed:
if (
button != null
and button.button_pressed
and button.focus_mode != Control.FOCUS_NONE
and button.is_visible_in_tree()
and not button.disabled
):
button.grab_focus()
return
for control: Control in controls:
@ -724,7 +758,7 @@ func _enter_controller_customization() -> void:
return
_controller_zone = ControllerZone.CATEGORIES
_controller_option_depth = 0
_apply_controller_zone_focus()
_apply_controller_zone_focus.call_deferred()
call_deferred("_focus_controller_zone")