Fix in-game menu mouse interaction
This commit is contained in:
parent
179dc841b5
commit
8cd3e83285
4 changed files with 56 additions and 4 deletions
|
|
@ -47,7 +47,9 @@ var _settings_manager: SettingsManagerType
|
|||
var _fishing_spot: FishingSpotType
|
||||
var _prior_movement_enabled: bool = true
|
||||
var _prior_camera_enabled: bool = true
|
||||
var _prior_mouse_mode: Input.MouseMode = Input.MOUSE_MODE_VISIBLE
|
||||
var _control_snapshot_stored: bool = false
|
||||
var _mouse_snapshot_stored: bool = false
|
||||
var _confirmation_action: ConfirmationAction = ConfirmationAction.NONE
|
||||
var _action_in_progress: bool = false
|
||||
|
||||
|
|
@ -84,10 +86,13 @@ func open_menu() -> void:
|
|||
return
|
||||
_prior_movement_enabled = _player.is_movement_enabled()
|
||||
_prior_camera_enabled = _player.is_camera_input_enabled()
|
||||
_prior_mouse_mode = Input.mouse_mode
|
||||
_control_snapshot_stored = true
|
||||
_mouse_snapshot_stored = true
|
||||
_player.set_movement_enabled(false)
|
||||
_player.set_camera_input_enabled(false)
|
||||
_fishing_spot.set_local_menu_input_suppressed(INPUT_OWNER, true)
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
_feedback.text = ""
|
||||
_root_panel.show()
|
||||
_settings_panel.hide()
|
||||
|
|
@ -108,11 +113,11 @@ func close_for_title_transition() -> void:
|
|||
|
||||
|
||||
func close_for_water_recovery() -> void:
|
||||
close_menu(CloseReason.WATER_RECOVERY)
|
||||
close_menu(CloseReason.WATER_RECOVERY, false)
|
||||
|
||||
|
||||
func close_menu(
|
||||
_reason: CloseReason,
|
||||
reason: CloseReason,
|
||||
restore_controls: bool = true,
|
||||
) -> void:
|
||||
if not visible:
|
||||
|
|
@ -132,6 +137,7 @@ func close_menu(
|
|||
_restore_controls()
|
||||
else:
|
||||
_control_snapshot_stored = false
|
||||
_apply_mouse_close_policy(reason)
|
||||
|
||||
|
||||
func handle_escape() -> bool:
|
||||
|
|
@ -295,6 +301,23 @@ func _restore_controls() -> void:
|
|||
_control_snapshot_stored = false
|
||||
|
||||
|
||||
func _apply_mouse_close_policy(reason: CloseReason) -> void:
|
||||
if not _mouse_snapshot_stored:
|
||||
return
|
||||
match reason:
|
||||
CloseReason.USER_RETURN, CloseReason.BITE_STARTED:
|
||||
Input.mouse_mode = _prior_mouse_mode
|
||||
CloseReason.WATER_RECOVERY:
|
||||
# Recovery owns local input until it finishes. Keep the current
|
||||
# visible gameplay cursor policy without restoring stale state.
|
||||
pass
|
||||
CloseReason.RETURN_TO_TITLE, CloseReason.RESET_PROGRESS:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
CloseReason.QUIT, CloseReason.TEARDOWN:
|
||||
pass
|
||||
_mouse_snapshot_stored = false
|
||||
|
||||
|
||||
func _on_bite_activated() -> void:
|
||||
if visible:
|
||||
close_menu(CloseReason.BITE_STARTED)
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="SettingsPanel" parent="SettingsCenter" instance=ExtResource("2_settings")]
|
||||
unique_name_in_owner = true
|
||||
|
|
@ -122,6 +123,7 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="ConfirmationPanel" type="PanelContainer" parent="ConfirmationCenter"]
|
||||
unique_name_in_owner = true
|
||||
|
|
|
|||
|
|
@ -75,7 +75,9 @@ var _sort_descending: bool = true
|
|||
var _selected_catch_id: StringName
|
||||
var _prior_movement_enabled: bool = true
|
||||
var _prior_camera_input_enabled: bool = true
|
||||
var _prior_mouse_mode: Input.MouseMode = Input.MOUSE_MODE_VISIBLE
|
||||
var _control_snapshot_stored: bool = false
|
||||
var _mouse_snapshot_stored: bool = false
|
||||
var _menu_generation: int = 0
|
||||
var _confirmation_catch_id: StringName
|
||||
var _confirmation_buyer: FishBuyerProfileType
|
||||
|
|
@ -172,10 +174,13 @@ func open_menu() -> void:
|
|||
_menu_generation += 1
|
||||
_prior_movement_enabled = _player.is_movement_enabled()
|
||||
_prior_camera_input_enabled = _player.is_camera_input_enabled()
|
||||
_prior_mouse_mode = Input.mouse_mode
|
||||
_control_snapshot_stored = true
|
||||
_mouse_snapshot_stored = true
|
||||
_player.set_movement_enabled(false)
|
||||
_player.set_camera_input_enabled(false)
|
||||
_fishing_spot.set_local_menu_input_suppressed(INPUT_OWNER, true)
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
visible = true
|
||||
_refresh_all()
|
||||
_show_section(_current_section)
|
||||
|
|
@ -184,7 +189,7 @@ func open_menu() -> void:
|
|||
|
||||
|
||||
func close_menu(
|
||||
_reason: CloseReason = CloseReason.USER,
|
||||
reason: CloseReason = CloseReason.USER,
|
||||
restore_controls: bool = true,
|
||||
) -> void:
|
||||
if not visible:
|
||||
|
|
@ -199,12 +204,13 @@ func close_menu(
|
|||
_restore_player_controls(closing_generation)
|
||||
else:
|
||||
_control_snapshot_stored = false
|
||||
_apply_mouse_close_policy(reason)
|
||||
_menu_generation += 1
|
||||
menu_visibility_changed.emit(false)
|
||||
|
||||
|
||||
func close_for_water_recovery() -> void:
|
||||
close_menu(CloseReason.WATER_RECOVERY)
|
||||
close_menu(CloseReason.WATER_RECOVERY, false)
|
||||
|
||||
|
||||
func close_for_game_menu() -> void:
|
||||
|
|
@ -234,6 +240,25 @@ func _restore_player_controls(generation: int) -> void:
|
|||
_control_snapshot_stored = false
|
||||
|
||||
|
||||
func _apply_mouse_close_policy(reason: CloseReason) -> void:
|
||||
if not _mouse_snapshot_stored:
|
||||
return
|
||||
match reason:
|
||||
CloseReason.USER, CloseReason.BITE_STARTED:
|
||||
Input.mouse_mode = _prior_mouse_mode
|
||||
CloseReason.GAME_MENU:
|
||||
# The Game Menu immediately assumes visible pointer ownership.
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
CloseReason.WATER_RECOVERY:
|
||||
# Recovery remains authoritative over local input.
|
||||
pass
|
||||
CloseReason.SESSION_END:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
CloseReason.TEARDOWN:
|
||||
pass
|
||||
_mouse_snapshot_stored = false
|
||||
|
||||
|
||||
func _on_bite_activated() -> void:
|
||||
if visible:
|
||||
close_menu(CloseReason.BITE_STARTED)
|
||||
|
|
|
|||
|
|
@ -52,12 +52,14 @@ func setup(
|
|||
) -> void:
|
||||
_save_manager = save_manager
|
||||
_settings_manager = settings_manager
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
_refresh_save_inspection()
|
||||
show()
|
||||
call_deferred("_focus_initial_button")
|
||||
|
||||
|
||||
func reopen() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
_close_confirmation()
|
||||
_settings_panel.hide()
|
||||
_refresh_save_inspection()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue