Normalize cursor handoff across gameplay menus

This commit is contained in:
Alexander Sellite 2026-08-31 05:48:47 -04:00
parent 6578d3e870
commit 3be79fa3fc
5 changed files with 71 additions and 10 deletions

View file

@ -250,7 +250,11 @@ func activate(
_pointer_screen_position = _clamped_pointer_position(
initial_pointer_position
)
_prior_mouse_mode = Input.mouse_mode
# Art-kit activation can occur while the prior right-click camera drag is
# still held. Stop that drag before recording a return mode, then restore
# normal camera availability so right-click continues to work while drawing.
_stop_camera_drag_for_art_kit()
_prior_mouse_mode = _get_restorable_mouse_mode(Input.mouse_mode)
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
_update_aim()
_refresh_stencil_visibility()
@ -266,6 +270,10 @@ func deactivate() -> void:
_eraser_mode = false
_clear_armed_guide_action(false)
_camera_look_active = false
# Do not leave a drag captured when drawing is closed by a menu, hotbar
# change, or session transition. The next camera drag must start on a fresh
# physical right-click press.
_stop_camera_drag_for_art_kit()
_reset_stroke()
_selected_canvas_id = ""
_hovered_canvas_id = ""
@ -273,10 +281,24 @@ func deactivate() -> void:
_aim_hit.clear()
_hide_previews()
_refresh_stencil_visibility()
Input.mouse_mode = _prior_mouse_mode
Input.mouse_mode = _get_restorable_mouse_mode(_prior_mouse_mode)
_emit_hud_state("")
func _stop_camera_drag_for_art_kit() -> void:
if _local_player == null or not is_instance_valid(_local_player):
return
var camera_input_enabled: bool = _local_player.is_camera_input_enabled()
_local_player.set_camera_input_enabled(false)
_local_player.set_camera_input_enabled(camera_input_enabled)
func _get_restorable_mouse_mode(mouse_mode: Input.MouseMode) -> Input.MouseMode:
if mouse_mode == Input.MOUSE_MODE_CAPTURED:
return Input.MOUSE_MODE_VISIBLE
return mouse_mode
func is_active() -> bool:
return _active