Stabilize camera input across fishing and radial menus
This commit is contained in:
parent
6fd1aa0388
commit
8f8398cbcd
4 changed files with 147 additions and 43 deletions
105
ui/game_ui.gd
105
ui/game_ui.gd
|
|
@ -81,6 +81,8 @@ signal shop_backdrop_visibility_changed(is_visible: bool)
|
|||
signal virtual_pointer_mode_changed(is_active: bool)
|
||||
|
||||
const VIRTUAL_MOUSE_INPUT_OWNER: StringName = &"controller_virtual_mouse"
|
||||
const EMOTE_RADIAL_CAMERA_OWNER: StringName = &"emote_radial_menu"
|
||||
const QUICK_RADIAL_CAMERA_OWNER: StringName = &"quick_radial_menu"
|
||||
const VIRTUAL_MOUSE_TRIGGER_THRESHOLD: float = 0.55
|
||||
const VIRTUAL_MOUSE_TRIGGER_RELEASE_THRESHOLD: float = 0.35
|
||||
const VIRTUAL_MOUSE_STICK_DEADZONE: float = 0.18
|
||||
|
|
@ -194,8 +196,6 @@ var _experience_award_queue: Array[Dictionary] = []
|
|||
var _experience_animation_active: bool = false
|
||||
var _experience_animation_generation: int = 0
|
||||
var _experience_panel_rest_y: float = 18.0
|
||||
var _emote_prior_camera_input_enabled: bool = true
|
||||
var _quick_prior_camera_input_enabled: bool = true
|
||||
var _virtual_mouse_active: bool = false
|
||||
var _virtual_mouse_prior_camera_input_enabled: bool = true
|
||||
var _virtual_mouse_prior_mouse_mode: Input.MouseMode = Input.MOUSE_MODE_VISIBLE
|
||||
|
|
@ -581,15 +581,10 @@ func _input(event: InputEvent) -> void:
|
|||
):
|
||||
var emote_is_open: bool = _emote_radial_menu.is_open()
|
||||
if emote_is_open != emote_was_open and _player != null:
|
||||
if emote_is_open:
|
||||
_emote_prior_camera_input_enabled = (
|
||||
_player.is_camera_input_enabled()
|
||||
)
|
||||
_player.set_camera_input_enabled(false)
|
||||
else:
|
||||
_player.set_camera_input_enabled(
|
||||
_emote_prior_camera_input_enabled
|
||||
)
|
||||
_player.set_camera_input_suppressed(
|
||||
EMOTE_RADIAL_CAMERA_OWNER,
|
||||
emote_is_open,
|
||||
)
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
var quick_was_open: bool = _quick_radial_menu.is_open()
|
||||
|
|
@ -599,18 +594,63 @@ func _input(event: InputEvent) -> void:
|
|||
):
|
||||
var quick_is_open: bool = _quick_radial_menu.is_open()
|
||||
if quick_is_open != quick_was_open and _player != null:
|
||||
if quick_is_open:
|
||||
_quick_prior_camera_input_enabled = (
|
||||
_player.is_camera_input_enabled()
|
||||
)
|
||||
_player.set_camera_input_enabled(false)
|
||||
else:
|
||||
_player.set_camera_input_enabled(
|
||||
_quick_prior_camera_input_enabled
|
||||
)
|
||||
_player.set_camera_input_suppressed(
|
||||
QUICK_RADIAL_CAMERA_OWNER,
|
||||
quick_is_open,
|
||||
)
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _reconcile_radial_menu_input() -> void:
|
||||
var blocked: bool = (
|
||||
not _gameplay_ui_enabled
|
||||
or _system_menu_open
|
||||
or _player_menu_open
|
||||
or _shop_open
|
||||
or _storage_open
|
||||
or _chat_input_open
|
||||
or _showcase_active
|
||||
or _virtual_mouse_active
|
||||
)
|
||||
if (
|
||||
_emote_radial_menu != null
|
||||
and _emote_radial_menu.is_open()
|
||||
and (blocked or not Input.is_action_pressed("open_emotes"))
|
||||
):
|
||||
_close_emote_radial_menu()
|
||||
if (
|
||||
_quick_radial_menu != null
|
||||
and _quick_radial_menu.is_open()
|
||||
and (blocked or not Input.is_action_pressed("open_quick_actions"))
|
||||
):
|
||||
_close_quick_radial_menu()
|
||||
|
||||
|
||||
func _close_radial_menus() -> void:
|
||||
_close_emote_radial_menu()
|
||||
_close_quick_radial_menu()
|
||||
|
||||
|
||||
func _close_emote_radial_menu() -> void:
|
||||
if _emote_radial_menu != null and _emote_radial_menu.is_open():
|
||||
_emote_radial_menu.close_menu()
|
||||
if _player != null and is_instance_valid(_player):
|
||||
_player.set_camera_input_suppressed(
|
||||
EMOTE_RADIAL_CAMERA_OWNER,
|
||||
false,
|
||||
)
|
||||
|
||||
|
||||
func _close_quick_radial_menu() -> void:
|
||||
if _quick_radial_menu != null and _quick_radial_menu.is_open():
|
||||
_quick_radial_menu.close_menu()
|
||||
if _player != null and is_instance_valid(_player):
|
||||
_player.set_camera_input_suppressed(
|
||||
QUICK_RADIAL_CAMERA_OWNER,
|
||||
false,
|
||||
)
|
||||
|
||||
|
||||
func _can_use_character_call() -> bool:
|
||||
return (
|
||||
_gameplay_ui_enabled
|
||||
|
|
@ -1356,6 +1396,7 @@ func is_input_mapping_capturing() -> bool:
|
|||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
_reconcile_radial_menu_input()
|
||||
_poll_virtual_mouse_controller_state()
|
||||
_update_virtual_mouse(delta)
|
||||
_update_controller_menu_scroll(delta)
|
||||
|
|
@ -1578,18 +1619,7 @@ func set_gameplay_ui_enabled(enabled: bool) -> void:
|
|||
_refresh_chat_availability()
|
||||
if not enabled:
|
||||
_end_virtual_mouse()
|
||||
if _emote_radial_menu != null and _emote_radial_menu.is_open():
|
||||
_emote_radial_menu.close_menu()
|
||||
if _player != null:
|
||||
_player.set_camera_input_enabled(
|
||||
_emote_prior_camera_input_enabled
|
||||
)
|
||||
if _quick_radial_menu != null and _quick_radial_menu.is_open():
|
||||
_quick_radial_menu.close_menu()
|
||||
if _player != null:
|
||||
_player.set_camera_input_enabled(
|
||||
_quick_prior_camera_input_enabled
|
||||
)
|
||||
_close_radial_menus()
|
||||
if _surface_drawing != null:
|
||||
_surface_drawing.deactivate()
|
||||
close_player_menu_for_session_end()
|
||||
|
|
@ -1658,6 +1688,8 @@ func _refresh_gameplay_hud_visibility() -> void:
|
|||
|
||||
func set_system_menu_open(is_open: bool) -> void:
|
||||
_system_menu_open = is_open
|
||||
if is_open:
|
||||
_close_radial_menus()
|
||||
_refresh_surface_drawing_activation()
|
||||
_refresh_gameplay_hud_visibility()
|
||||
_refresh_chat_availability()
|
||||
|
|
@ -2071,6 +2103,8 @@ func _on_showcase_changed(
|
|||
showcase_visible: bool,
|
||||
) -> void:
|
||||
_showcase_active = showcase_visible
|
||||
if showcase_visible:
|
||||
_close_radial_menus()
|
||||
_refresh_surface_drawing_activation()
|
||||
if not showcase_visible:
|
||||
_set_fishing_panel_showcase_position(false)
|
||||
|
|
@ -2314,6 +2348,7 @@ func _on_player_menu_visibility_changed(is_open: bool) -> void:
|
|||
_chat_ui.set_world_speech_visible(not is_open)
|
||||
if is_open:
|
||||
_end_virtual_mouse()
|
||||
_close_radial_menus()
|
||||
_refresh_surface_drawing_activation()
|
||||
_refresh_gameplay_hud_visibility()
|
||||
if is_open:
|
||||
|
|
@ -2366,6 +2401,8 @@ func _on_shop_exit_started() -> void:
|
|||
|
||||
func _on_shop_visibility_changed(is_open: bool) -> void:
|
||||
_shop_open = is_open
|
||||
if is_open:
|
||||
_close_radial_menus()
|
||||
_refresh_surface_drawing_activation()
|
||||
if is_open:
|
||||
shop_backdrop_visibility_changed.emit(true)
|
||||
|
|
@ -2389,6 +2426,8 @@ func _on_shop_visibility_changed(is_open: bool) -> void:
|
|||
|
||||
func _on_storage_visibility_changed(is_open: bool) -> void:
|
||||
_storage_open = is_open
|
||||
if is_open:
|
||||
_close_radial_menus()
|
||||
_refresh_surface_drawing_activation()
|
||||
_refresh_gameplay_hud_visibility()
|
||||
_refresh_chat_availability()
|
||||
|
|
@ -2544,6 +2583,8 @@ func _emit_interactive_pointer_ui_changed() -> void:
|
|||
|
||||
func _on_chat_text_entry_ownership_changed(active: bool) -> void:
|
||||
_chat_input_open = active
|
||||
if active:
|
||||
_close_radial_menus()
|
||||
_refresh_surface_drawing_activation()
|
||||
_refresh_chat_availability()
|
||||
_emit_interactive_pointer_ui_changed()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue