2026-07-25 18:20:49 -04:00
|
|
|
class_name PauseMenu
|
|
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
const INPUT_OWNER: StringName = &"game_menu"
|
2026-07-27 23:44:27 -04:00
|
|
|
const PAUSE_DESKTOP_REFERENCE_SIZE: Vector2 = Vector2(1280.0, 720.0)
|
|
|
|
|
const PAUSE_COMPACT_REFERENCE_SIZE: Vector2 = Vector2(640.0, 480.0)
|
|
|
|
|
const COMPACT_HEIGHT_THRESHOLD: float = 560.0
|
|
|
|
|
const VISIBILITY_FADE_DURATION: float = 0.55
|
2026-07-25 18:20:49 -04:00
|
|
|
const PlayerType = preload("res://player/player.gd")
|
|
|
|
|
const SaveManagerType = preload("res://save/player_save_manager.gd")
|
|
|
|
|
const SettingsManagerType = preload(
|
|
|
|
|
"res://settings/player_settings_manager.gd"
|
|
|
|
|
)
|
|
|
|
|
const SettingsPanelType = preload("res://ui/settings_panel.gd")
|
2026-07-28 14:04:13 -04:00
|
|
|
const BubbleConfirmationPageType = preload(
|
|
|
|
|
"res://ui/components/bubble_menu/bubble_confirmation_page.gd"
|
|
|
|
|
)
|
2026-07-25 18:20:49 -04:00
|
|
|
const FishingSpotType = preload("res://fishing/fishing_spot.gd")
|
2026-07-29 15:01:46 -04:00
|
|
|
const NetworkSessionType = preload("res://network/network_session.gd")
|
|
|
|
|
const SavedServerStoreType = preload("res://network/saved_server_store.gd")
|
|
|
|
|
const JoinGamePageType = preload("res://ui/network/join_game_page.gd")
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
signal return_to_title_requested
|
|
|
|
|
signal reset_progress_requested
|
|
|
|
|
signal quit_requested
|
2026-07-25 20:12:29 -04:00
|
|
|
signal menu_visibility_changed(is_open: bool)
|
2026-07-29 15:01:46 -04:00
|
|
|
signal join_game_requested(endpoint: String)
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
enum ConfirmationAction {
|
|
|
|
|
NONE,
|
|
|
|
|
RETURN_TO_TITLE,
|
|
|
|
|
RESET_PROGRESS,
|
|
|
|
|
QUIT_ANYWAY,
|
2026-07-29 15:01:46 -04:00
|
|
|
JOIN_ANOTHER,
|
2026-07-25 18:20:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum CloseReason {
|
|
|
|
|
USER_RETURN,
|
|
|
|
|
BITE_STARTED,
|
|
|
|
|
WATER_RECOVERY,
|
|
|
|
|
RETURN_TO_TITLE,
|
|
|
|
|
RESET_PROGRESS,
|
|
|
|
|
QUIT,
|
|
|
|
|
TEARDOWN,
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-27 23:44:27 -04:00
|
|
|
@onready var _presentation_scale_root: Control = %PausePresentationScaleRoot
|
|
|
|
|
@onready var _root_page: SettingsBubblePage = %RootPage
|
2026-07-25 18:20:49 -04:00
|
|
|
@onready var _settings_panel: SettingsPanelType = %SettingsPanel
|
2026-07-27 23:44:27 -04:00
|
|
|
@onready var _transition_flurry: BubbleTransitionFlurry = (
|
|
|
|
|
%TransitionBubbleLayer
|
|
|
|
|
)
|
2026-07-28 14:04:13 -04:00
|
|
|
@onready var _confirmation_page: BubbleConfirmationPageType = (
|
|
|
|
|
%ConfirmationPage
|
|
|
|
|
)
|
2026-07-25 18:20:49 -04:00
|
|
|
@onready var _feedback: Label = %FeedbackLabel
|
2026-07-27 23:44:27 -04:00
|
|
|
@onready var _save_button: BubbleButton = %SaveButton
|
2026-07-29 15:01:46 -04:00
|
|
|
@onready var _join_game_page: JoinGamePageType = %JoinGamePage
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
var _player: PlayerType
|
|
|
|
|
var _save_manager: SaveManagerType
|
|
|
|
|
var _settings_manager: SettingsManagerType
|
|
|
|
|
var _fishing_spot: FishingSpotType
|
2026-07-29 15:01:46 -04:00
|
|
|
var _network_session: NetworkSessionType
|
|
|
|
|
var _saved_servers: SavedServerStoreType
|
2026-07-25 18:20:49 -04:00
|
|
|
var _prior_movement_enabled: bool = true
|
|
|
|
|
var _prior_camera_enabled: bool = true
|
2026-07-25 18:56:47 -04:00
|
|
|
var _prior_mouse_mode: Input.MouseMode = Input.MOUSE_MODE_VISIBLE
|
2026-07-25 18:20:49 -04:00
|
|
|
var _control_snapshot_stored: bool = false
|
2026-07-25 18:56:47 -04:00
|
|
|
var _mouse_snapshot_stored: bool = false
|
2026-07-25 18:20:49 -04:00
|
|
|
var _confirmation_action: ConfirmationAction = ConfirmationAction.NONE
|
|
|
|
|
var _action_in_progress: bool = false
|
2026-07-27 23:44:27 -04:00
|
|
|
var _root_transition_active: bool = false
|
|
|
|
|
var _root_transition_generation: int = 0
|
|
|
|
|
var _closing_menu: bool = false
|
2026-07-29 15:01:46 -04:00
|
|
|
var _pending_join_endpoint: String = ""
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
|
%ResumeButton.pressed.connect(resume)
|
|
|
|
|
_save_button.pressed.connect(_save_now)
|
|
|
|
|
%SettingsButton.pressed.connect(_open_settings)
|
2026-07-29 15:01:46 -04:00
|
|
|
%JoinGameButton.pressed.connect(_open_join_game)
|
2026-07-25 18:20:49 -04:00
|
|
|
%ReturnToTitleButton.pressed.connect(_confirm_return_to_title)
|
|
|
|
|
%ResetProgressButton.pressed.connect(_confirm_reset_progress)
|
|
|
|
|
%QuitButton.pressed.connect(_request_quit)
|
2026-07-28 14:04:13 -04:00
|
|
|
_confirmation_page.confirmed.connect(_accept_confirmation)
|
|
|
|
|
_confirmation_page.cancelled.connect(_close_confirmation)
|
2026-07-25 18:20:49 -04:00
|
|
|
_settings_panel.applied.connect(_on_settings_applied)
|
|
|
|
|
_settings_panel.closed.connect(_on_settings_closed)
|
2026-07-30 10:46:15 -04:00
|
|
|
_settings_panel.closing.connect(_on_settings_closing)
|
2026-07-27 23:44:27 -04:00
|
|
|
_settings_panel.navigation_transition_started.connect(
|
|
|
|
|
_emit_transition_flurry
|
|
|
|
|
)
|
2026-07-29 15:01:46 -04:00
|
|
|
_join_game_page.join_requested.connect(_on_join_game_requested)
|
|
|
|
|
_join_game_page.back_requested.connect(_close_join_game)
|
2026-07-28 14:04:13 -04:00
|
|
|
_confirmation_page.hide_page()
|
2026-07-27 23:44:27 -04:00
|
|
|
resized.connect(_update_responsive_pause_stage)
|
|
|
|
|
call_deferred("_update_responsive_pause_stage")
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func setup(
|
|
|
|
|
player: PlayerType,
|
|
|
|
|
save_manager: SaveManagerType,
|
|
|
|
|
settings_manager: SettingsManagerType,
|
|
|
|
|
fishing_spot: FishingSpotType,
|
2026-07-29 15:01:46 -04:00
|
|
|
network_session: NetworkSessionType,
|
|
|
|
|
saved_servers: SavedServerStoreType,
|
2026-07-29 22:18:14 -04:00
|
|
|
server_trust: ServerTrustStore,
|
2026-07-25 18:20:49 -04:00
|
|
|
) -> void:
|
|
|
|
|
_player = player
|
|
|
|
|
_save_manager = save_manager
|
|
|
|
|
_settings_manager = settings_manager
|
|
|
|
|
_fishing_spot = fishing_spot
|
2026-07-29 15:01:46 -04:00
|
|
|
_network_session = network_session
|
|
|
|
|
_saved_servers = saved_servers
|
2026-07-29 22:18:14 -04:00
|
|
|
_join_game_page.setup(network_session, saved_servers, true, server_trust)
|
2026-07-25 18:20:49 -04:00
|
|
|
if not _fishing_spot.bite_activated.is_connected(_on_bite_activated):
|
|
|
|
|
_fishing_spot.bite_activated.connect(_on_bite_activated)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func open_menu() -> void:
|
|
|
|
|
if visible or _player == null:
|
|
|
|
|
return
|
|
|
|
|
_prior_movement_enabled = _player.is_movement_enabled()
|
|
|
|
|
_prior_camera_enabled = _player.is_camera_input_enabled()
|
2026-07-25 18:56:47 -04:00
|
|
|
_prior_mouse_mode = Input.mouse_mode
|
2026-07-25 18:20:49 -04:00
|
|
|
_control_snapshot_stored = true
|
2026-07-25 18:56:47 -04:00
|
|
|
_mouse_snapshot_stored = true
|
2026-07-25 18:20:49 -04:00
|
|
|
_player.set_movement_enabled(false)
|
|
|
|
|
_player.set_camera_input_enabled(false)
|
|
|
|
|
_fishing_spot.set_local_menu_input_suppressed(INPUT_OWNER, true)
|
2026-07-25 18:56:47 -04:00
|
|
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
2026-07-25 18:20:49 -04:00
|
|
|
_feedback.text = ""
|
|
|
|
|
_settings_panel.hide()
|
2026-07-29 15:01:46 -04:00
|
|
|
_join_game_page.close_page()
|
2026-07-28 14:04:13 -04:00
|
|
|
_confirmation_page.hide_page()
|
2026-07-25 18:20:49 -04:00
|
|
|
_confirmation_action = ConfirmationAction.NONE
|
2026-07-27 23:44:27 -04:00
|
|
|
_action_in_progress = false
|
|
|
|
|
_root_page.hide_page()
|
2026-07-25 18:20:49 -04:00
|
|
|
show()
|
2026-07-27 23:44:27 -04:00
|
|
|
_update_responsive_pause_stage()
|
|
|
|
|
_begin_root_entry(false)
|
2026-07-25 20:12:29 -04:00
|
|
|
menu_visibility_changed.emit(true)
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func resume() -> void:
|
2026-07-27 23:44:27 -04:00
|
|
|
if (
|
|
|
|
|
not visible
|
|
|
|
|
or _action_in_progress
|
|
|
|
|
or _root_transition_active
|
|
|
|
|
or _settings_panel.visible
|
|
|
|
|
or _confirmation_action != ConfirmationAction.NONE
|
|
|
|
|
):
|
2026-07-25 18:20:49 -04:00
|
|
|
return
|
2026-07-27 23:44:27 -04:00
|
|
|
_begin_root_exit(_finish_user_close)
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func close_for_title_transition() -> void:
|
|
|
|
|
close_menu(CloseReason.RETURN_TO_TITLE, false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func close_for_water_recovery() -> void:
|
2026-07-25 18:56:47 -04:00
|
|
|
close_menu(CloseReason.WATER_RECOVERY, false)
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func close_menu(
|
2026-07-25 18:56:47 -04:00
|
|
|
reason: CloseReason,
|
2026-07-25 18:20:49 -04:00
|
|
|
restore_controls: bool = true,
|
|
|
|
|
) -> void:
|
|
|
|
|
if not visible:
|
|
|
|
|
return
|
2026-07-27 23:44:27 -04:00
|
|
|
_finish_close(reason, restore_controls)
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func handle_escape() -> bool:
|
|
|
|
|
if not visible:
|
|
|
|
|
return false
|
2026-07-28 14:04:13 -04:00
|
|
|
if _root_transition_active or _confirmation_page.is_transitioning():
|
2026-07-27 23:44:27 -04:00
|
|
|
return true
|
2026-07-28 14:04:13 -04:00
|
|
|
if _confirmation_page.visible:
|
2026-07-25 18:20:49 -04:00
|
|
|
_close_confirmation()
|
2026-07-29 15:01:46 -04:00
|
|
|
elif _join_game_page.visible:
|
|
|
|
|
_close_join_game()
|
2026-07-25 18:20:49 -04:00
|
|
|
elif _settings_panel.visible:
|
2026-07-27 17:33:53 -04:00
|
|
|
_settings_panel.handle_back()
|
2026-07-25 18:20:49 -04:00
|
|
|
else:
|
|
|
|
|
resume()
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _save_now() -> void:
|
2026-07-27 23:44:27 -04:00
|
|
|
if _action_in_progress or _root_transition_active:
|
2026-07-25 18:20:49 -04:00
|
|
|
return
|
|
|
|
|
_action_in_progress = true
|
|
|
|
|
_save_button.disabled = true
|
|
|
|
|
if _save_manager.save_now():
|
2026-07-26 23:20:51 -04:00
|
|
|
_feedback.text = "game saved."
|
2026-07-25 18:20:49 -04:00
|
|
|
else:
|
2026-07-26 23:20:51 -04:00
|
|
|
_feedback.text = "save failed. previous save was preserved."
|
2026-07-25 18:20:49 -04:00
|
|
|
_action_in_progress = false
|
|
|
|
|
call_deferred("_reenable_save_button")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _reenable_save_button() -> void:
|
|
|
|
|
_save_button.disabled = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _open_settings() -> void:
|
2026-07-27 23:44:27 -04:00
|
|
|
if (
|
|
|
|
|
_action_in_progress
|
|
|
|
|
or _root_transition_active
|
|
|
|
|
or _confirmation_action != ConfirmationAction.NONE
|
|
|
|
|
):
|
2026-07-25 18:20:49 -04:00
|
|
|
return
|
2026-07-27 23:44:27 -04:00
|
|
|
_begin_root_exit(_finish_open_settings)
|
|
|
|
|
|
|
|
|
|
|
2026-07-29 15:01:46 -04:00
|
|
|
func _open_join_game() -> void:
|
|
|
|
|
if (
|
|
|
|
|
_action_in_progress
|
|
|
|
|
or _root_transition_active
|
|
|
|
|
or _confirmation_action != ConfirmationAction.NONE
|
|
|
|
|
):
|
|
|
|
|
return
|
|
|
|
|
_begin_root_exit(_finish_open_join_game)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _finish_open_join_game() -> void:
|
|
|
|
|
_join_game_page.open_page()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _close_join_game() -> void:
|
|
|
|
|
_join_game_page.close_page()
|
|
|
|
|
_begin_root_entry(true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_join_game_requested(endpoint: String) -> void:
|
|
|
|
|
if _action_in_progress or _root_transition_active:
|
|
|
|
|
return
|
|
|
|
|
_pending_join_endpoint = endpoint
|
|
|
|
|
_open_confirmation(
|
|
|
|
|
ConfirmationAction.JOIN_ANOTHER,
|
|
|
|
|
"join another game?",
|
|
|
|
|
(
|
|
|
|
|
"your progression will be saved first. "
|
|
|
|
|
+ "current players will be disconnected if you are hosting."
|
|
|
|
|
),
|
|
|
|
|
"save and join",
|
|
|
|
|
false
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func report_network_error(message: String) -> void:
|
|
|
|
|
_feedback.text = message
|
|
|
|
|
if _join_game_page.visible:
|
|
|
|
|
_join_game_page.set_status(message)
|
|
|
|
|
|
|
|
|
|
|
2026-07-27 23:44:27 -04:00
|
|
|
func _finish_open_settings() -> void:
|
2026-07-27 17:33:53 -04:00
|
|
|
_settings_panel.open_panel(
|
|
|
|
|
_settings_manager,
|
2026-07-27 23:44:27 -04:00
|
|
|
SettingsPanelType.PresentationMode.GAMEPLAY_MODAL,
|
|
|
|
|
true
|
2026-07-27 17:33:53 -04:00
|
|
|
)
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_settings_applied() -> void:
|
2026-07-27 23:44:27 -04:00
|
|
|
if _closing_menu:
|
|
|
|
|
return
|
2026-07-26 23:20:51 -04:00
|
|
|
_feedback.text = "settings saved."
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_settings_closed() -> void:
|
2026-07-30 10:46:15 -04:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_settings_closing() -> void:
|
2026-07-27 23:44:27 -04:00
|
|
|
if _closing_menu:
|
|
|
|
|
return
|
2026-07-30 10:46:15 -04:00
|
|
|
await get_tree().create_timer(
|
|
|
|
|
UIMotion.BUBBLE_TRANSITION_OVERLAP_DELAY
|
|
|
|
|
).timeout
|
|
|
|
|
if _settings_panel.visible:
|
|
|
|
|
_begin_root_entry(true)
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _confirm_return_to_title() -> void:
|
|
|
|
|
_open_confirmation(
|
|
|
|
|
ConfirmationAction.RETURN_TO_TITLE,
|
2026-07-26 23:20:51 -04:00
|
|
|
"return to title",
|
|
|
|
|
"unsaved progress will be saved first.",
|
|
|
|
|
"save and return",
|
2026-07-25 18:20:49 -04:00
|
|
|
false
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _confirm_reset_progress() -> void:
|
|
|
|
|
_open_confirmation(
|
|
|
|
|
ConfirmationAction.RESET_PROGRESS,
|
2026-07-26 23:20:51 -04:00
|
|
|
"reset all progression?",
|
2026-07-25 18:20:49 -04:00
|
|
|
(
|
2026-07-26 23:20:51 -04:00
|
|
|
"this permanently deletes your fish, discoveries, "
|
2026-07-25 18:20:49 -04:00
|
|
|
+ "favorites, and wallet balance.\n\n"
|
2026-07-26 23:20:51 -04:00
|
|
|
+ "your settings will be preserved."
|
2026-07-25 18:20:49 -04:00
|
|
|
),
|
2026-07-26 23:20:51 -04:00
|
|
|
"delete all progress",
|
2026-07-25 18:20:49 -04:00
|
|
|
true
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _request_quit() -> void:
|
2026-07-27 23:44:27 -04:00
|
|
|
if _action_in_progress or _root_transition_active:
|
2026-07-25 18:20:49 -04:00
|
|
|
return
|
|
|
|
|
_action_in_progress = true
|
|
|
|
|
var settings_saved: bool = _settings_manager.save_if_dirty()
|
|
|
|
|
var progression_saved: bool = _save_manager.save_if_dirty()
|
|
|
|
|
_action_in_progress = false
|
|
|
|
|
if settings_saved and progression_saved:
|
|
|
|
|
quit_requested.emit()
|
|
|
|
|
return
|
|
|
|
|
_open_confirmation(
|
|
|
|
|
ConfirmationAction.QUIT_ANYWAY,
|
2026-07-26 23:20:51 -04:00
|
|
|
"save failed",
|
|
|
|
|
"some progress or settings could not be saved. quit anyway?",
|
|
|
|
|
"quit anyway",
|
2026-07-25 18:20:49 -04:00
|
|
|
true
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _open_confirmation(
|
|
|
|
|
action: ConfirmationAction,
|
|
|
|
|
title: String,
|
|
|
|
|
message: String,
|
|
|
|
|
confirm_text: String,
|
|
|
|
|
dangerous: bool,
|
|
|
|
|
) -> void:
|
2026-07-27 23:44:27 -04:00
|
|
|
if _action_in_progress or _root_transition_active:
|
2026-07-25 18:20:49 -04:00
|
|
|
return
|
|
|
|
|
_confirmation_action = action
|
2026-07-28 14:04:13 -04:00
|
|
|
_confirmation_page.configure(
|
|
|
|
|
"%s\n\n%s" % [title, message],
|
|
|
|
|
confirm_text,
|
|
|
|
|
"cancel",
|
|
|
|
|
(
|
|
|
|
|
BubbleConfirmationPageType.InitialFocus.CANCEL
|
|
|
|
|
if dangerous
|
|
|
|
|
else BubbleConfirmationPageType.InitialFocus.CONFIRM
|
|
|
|
|
)
|
2026-07-25 18:20:49 -04:00
|
|
|
)
|
2026-07-28 14:04:13 -04:00
|
|
|
_begin_root_exit(_show_confirmation)
|
2026-07-27 23:44:27 -04:00
|
|
|
|
|
|
|
|
|
2026-07-28 14:04:13 -04:00
|
|
|
func _show_confirmation() -> void:
|
|
|
|
|
_confirmation_page.transition_in(
|
2026-07-30 10:46:15 -04:00
|
|
|
0.0,
|
2026-07-28 14:04:13 -04:00
|
|
|
_finish_confirmation_open
|
2026-07-27 23:44:27 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2026-07-28 14:04:13 -04:00
|
|
|
func _finish_confirmation_open() -> void:
|
|
|
|
|
pass
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _close_confirmation() -> void:
|
2026-07-28 14:04:13 -04:00
|
|
|
if _root_transition_active or _confirmation_page.is_transitioning():
|
2026-07-27 23:44:27 -04:00
|
|
|
return
|
2026-07-25 18:20:49 -04:00
|
|
|
_confirmation_action = ConfirmationAction.NONE
|
2026-07-28 14:04:13 -04:00
|
|
|
_emit_transition_flurry()
|
|
|
|
|
_confirmation_page.transition_out(
|
2026-07-30 10:46:15 -04:00
|
|
|
0.0,
|
2026-07-28 14:04:13 -04:00
|
|
|
_finish_confirmation_cancel
|
|
|
|
|
)
|
2026-07-27 23:44:27 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _finish_confirmation_cancel() -> void:
|
2026-07-28 14:04:13 -04:00
|
|
|
_begin_root_entry(true)
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _accept_confirmation() -> void:
|
2026-07-27 23:44:27 -04:00
|
|
|
if (
|
|
|
|
|
_action_in_progress
|
|
|
|
|
or _root_transition_active
|
2026-07-28 14:04:13 -04:00
|
|
|
or _confirmation_page.is_transitioning()
|
2026-07-27 23:44:27 -04:00
|
|
|
):
|
2026-07-25 18:20:49 -04:00
|
|
|
return
|
|
|
|
|
var action: ConfirmationAction = _confirmation_action
|
|
|
|
|
_confirmation_action = ConfirmationAction.NONE
|
|
|
|
|
_action_in_progress = true
|
2026-07-28 14:04:13 -04:00
|
|
|
_confirmation_page.transition_out(
|
|
|
|
|
VISIBILITY_FADE_DURATION,
|
2026-07-27 23:44:27 -04:00
|
|
|
_finish_confirmation_accept.bind(action)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _finish_confirmation_accept(action: ConfirmationAction) -> void:
|
2026-07-25 18:20:49 -04:00
|
|
|
match action:
|
|
|
|
|
ConfirmationAction.RETURN_TO_TITLE:
|
|
|
|
|
if _save_manager.save_now():
|
|
|
|
|
return_to_title_requested.emit()
|
|
|
|
|
else:
|
2026-07-26 23:20:51 -04:00
|
|
|
_feedback.text = "save failed. previous save was preserved."
|
2026-07-27 23:44:27 -04:00
|
|
|
_action_in_progress = false
|
|
|
|
|
_begin_root_entry(false)
|
|
|
|
|
return
|
2026-07-25 18:20:49 -04:00
|
|
|
ConfirmationAction.RESET_PROGRESS:
|
|
|
|
|
reset_progress_requested.emit()
|
|
|
|
|
ConfirmationAction.QUIT_ANYWAY:
|
|
|
|
|
quit_requested.emit()
|
2026-07-29 15:01:46 -04:00
|
|
|
ConfirmationAction.JOIN_ANOTHER:
|
|
|
|
|
_join_game_page.close_page()
|
|
|
|
|
join_game_requested.emit(_pending_join_endpoint)
|
|
|
|
|
_pending_join_endpoint = ""
|
2026-07-25 18:20:49 -04:00
|
|
|
_:
|
2026-07-27 23:44:27 -04:00
|
|
|
_action_in_progress = false
|
|
|
|
|
_begin_root_entry(false)
|
|
|
|
|
return
|
2026-07-25 18:20:49 -04:00
|
|
|
_action_in_progress = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func report_reset_failure() -> void:
|
|
|
|
|
_action_in_progress = false
|
2026-07-27 23:44:27 -04:00
|
|
|
_confirmation_action = ConfirmationAction.NONE
|
2026-07-26 23:20:51 -04:00
|
|
|
_feedback.text = "reset failed. your progression was preserved."
|
2026-07-27 23:44:27 -04:00
|
|
|
if visible:
|
|
|
|
|
_begin_root_entry(false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _begin_root_entry(flurry_already_emitted: bool) -> void:
|
|
|
|
|
if _root_transition_active:
|
|
|
|
|
return
|
|
|
|
|
_root_transition_generation += 1
|
|
|
|
|
_root_transition_active = true
|
|
|
|
|
if not flurry_already_emitted:
|
|
|
|
|
_emit_transition_flurry()
|
|
|
|
|
var generation: int = _root_transition_generation
|
|
|
|
|
_root_page.transition_in(
|
|
|
|
|
true,
|
|
|
|
|
_finish_root_entry.bind(generation),
|
2026-07-30 10:46:15 -04:00
|
|
|
0.0
|
2026-07-27 23:44:27 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _finish_root_entry(generation: int) -> void:
|
|
|
|
|
if generation != _root_transition_generation or not visible:
|
|
|
|
|
return
|
|
|
|
|
_root_transition_active = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _begin_root_exit(completed: Callable) -> void:
|
|
|
|
|
if _root_transition_active or not _root_page.visible:
|
|
|
|
|
return
|
|
|
|
|
_root_transition_generation += 1
|
|
|
|
|
_root_transition_active = true
|
|
|
|
|
_emit_transition_flurry()
|
|
|
|
|
var generation: int = _root_transition_generation
|
|
|
|
|
_root_page.transition_out(
|
2026-07-30 10:46:15 -04:00
|
|
|
_finish_root_exit.bind(generation),
|
|
|
|
|
0.0
|
2026-07-27 23:44:27 -04:00
|
|
|
)
|
2026-07-30 10:46:15 -04:00
|
|
|
await get_tree().create_timer(
|
|
|
|
|
UIMotion.BUBBLE_TRANSITION_OVERLAP_DELAY
|
|
|
|
|
).timeout
|
|
|
|
|
if generation != _root_transition_generation or not visible:
|
|
|
|
|
return
|
|
|
|
|
completed.call()
|
2026-07-27 23:44:27 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _finish_root_exit(
|
|
|
|
|
generation: int,
|
|
|
|
|
) -> void:
|
|
|
|
|
if generation != _root_transition_generation or not visible:
|
|
|
|
|
return
|
|
|
|
|
_root_transition_active = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _finish_user_close() -> void:
|
|
|
|
|
_finish_close(CloseReason.USER_RETURN, true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _finish_close(reason: CloseReason, restore_controls: bool) -> void:
|
|
|
|
|
_closing_menu = true
|
|
|
|
|
if _settings_panel.visible:
|
|
|
|
|
_settings_panel.close_panel(true)
|
|
|
|
|
_closing_menu = false
|
|
|
|
|
_root_transition_generation += 1
|
|
|
|
|
_root_transition_active = false
|
|
|
|
|
_settings_panel.hide()
|
2026-07-29 15:01:46 -04:00
|
|
|
_join_game_page.close_page()
|
2026-07-27 23:44:27 -04:00
|
|
|
_root_page.hide_page()
|
2026-07-28 14:04:13 -04:00
|
|
|
_confirmation_page.hide_page()
|
2026-07-27 23:44:27 -04:00
|
|
|
_confirmation_action = ConfirmationAction.NONE
|
|
|
|
|
_action_in_progress = false
|
|
|
|
|
_transition_flurry.clear_flurries()
|
|
|
|
|
hide()
|
|
|
|
|
if _fishing_spot != null and is_instance_valid(_fishing_spot):
|
|
|
|
|
_fishing_spot.set_local_menu_input_suppressed(INPUT_OWNER, false)
|
|
|
|
|
get_viewport().gui_release_focus()
|
|
|
|
|
if restore_controls:
|
|
|
|
|
_restore_controls()
|
|
|
|
|
else:
|
|
|
|
|
_control_snapshot_stored = false
|
|
|
|
|
_apply_mouse_close_policy(reason)
|
|
|
|
|
menu_visibility_changed.emit(false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _emit_transition_flurry() -> void:
|
|
|
|
|
_transition_flurry.emit_flurry()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _update_responsive_pause_stage() -> void:
|
|
|
|
|
if not is_node_ready():
|
|
|
|
|
return
|
2026-07-29 10:53:46 -04:00
|
|
|
_presentation_scale_root.size = PAUSE_DESKTOP_REFERENCE_SIZE
|
|
|
|
|
_presentation_scale_root.scale = Vector2.ONE
|
|
|
|
|
_presentation_scale_root.position = Vector2.ZERO
|
2026-07-25 18:20:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _restore_controls() -> void:
|
|
|
|
|
if not _control_snapshot_stored:
|
|
|
|
|
return
|
|
|
|
|
if _player != null and is_instance_valid(_player):
|
|
|
|
|
_player.set_movement_enabled(_prior_movement_enabled)
|
|
|
|
|
_player.set_camera_input_enabled(_prior_camera_enabled)
|
|
|
|
|
_control_snapshot_stored = false
|
|
|
|
|
|
|
|
|
|
|
2026-07-25 18:56:47 -04:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
2026-07-25 18:20:49 -04:00
|
|
|
func _on_bite_activated() -> void:
|
|
|
|
|
if visible:
|
|
|
|
|
close_menu(CloseReason.BITE_STARTED)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _exit_tree() -> void:
|
|
|
|
|
if visible:
|
|
|
|
|
close_menu(CloseReason.TEARDOWN)
|