Add saves, settings, and multiplayer-safe menus
This commit is contained in:
parent
e2067e3bf4
commit
0d050b08cc
32 changed files with 2468 additions and 49 deletions
|
|
@ -10,6 +10,8 @@ const FishingSpotType = preload("res://fishing/fishing_spot.gd")
|
|||
const PlayerMenuType = preload("res://ui/player_menu.gd")
|
||||
const PlayerType = preload("res://player/player.gd")
|
||||
const PlayerWalletType = preload("res://economy/player_wallet.gd")
|
||||
const TitleScreenType = preload("res://ui/title_screen.gd")
|
||||
const PauseMenuType = preload("res://ui/pause_menu.gd")
|
||||
|
||||
@onready var _status_label: Label = %StatusLabel
|
||||
@onready var _catch_track: Control = %CatchTrack
|
||||
|
|
@ -22,9 +24,12 @@ const PlayerWalletType = preload("res://economy/player_wallet.gd")
|
|||
@onready var _fishing_panel: PanelContainer = %FishingPanel
|
||||
@onready var _player_menu: PlayerMenuType = %PlayerMenu
|
||||
@onready var _screen_fade: ScreenFade = %ScreenFade
|
||||
@onready var _title_screen: TitleScreenType = %TitleScreen
|
||||
@onready var _pause_menu: PauseMenuType = %PauseMenu
|
||||
|
||||
var _showcase_active: bool = false
|
||||
var _player_menu_open: bool = false
|
||||
var _gameplay_ui_enabled: bool = false
|
||||
|
||||
|
||||
func setup(
|
||||
|
|
@ -59,10 +64,43 @@ func close_player_menu() -> void:
|
|||
_player_menu.close_menu()
|
||||
|
||||
|
||||
func close_player_menu_for_water_recovery() -> void:
|
||||
_player_menu.close_for_water_recovery()
|
||||
|
||||
|
||||
func close_player_menu_for_game_menu() -> void:
|
||||
_player_menu.close_for_game_menu()
|
||||
|
||||
|
||||
func close_player_menu_for_session_end() -> void:
|
||||
_player_menu.close_for_session_end()
|
||||
|
||||
|
||||
func consume_player_menu_escape() -> bool:
|
||||
return _player_menu.consume_escape()
|
||||
|
||||
|
||||
func get_pause_menu() -> PauseMenuType:
|
||||
return _pause_menu
|
||||
|
||||
|
||||
func set_gameplay_ui_enabled(enabled: bool) -> void:
|
||||
_gameplay_ui_enabled = enabled
|
||||
if not enabled:
|
||||
close_player_menu_for_session_end()
|
||||
_fishing_panel.visible = false
|
||||
else:
|
||||
_refresh_fishing_panel_visibility()
|
||||
|
||||
|
||||
func get_screen_fade() -> ScreenFade:
|
||||
return _screen_fade
|
||||
|
||||
|
||||
func get_title_screen() -> TitleScreenType:
|
||||
return _title_screen
|
||||
|
||||
|
||||
func _on_fishing_status_changed(status: String) -> void:
|
||||
if _showcase_active:
|
||||
return
|
||||
|
|
@ -84,7 +122,11 @@ func _refresh_fishing_panel_visibility() -> void:
|
|||
or _barrier_summary.visible
|
||||
or _barrier_health.visible
|
||||
)
|
||||
_fishing_panel.visible = has_content and not _player_menu_open
|
||||
_fishing_panel.visible = (
|
||||
_gameplay_ui_enabled
|
||||
and has_content
|
||||
and not _player_menu_open
|
||||
)
|
||||
|
||||
|
||||
func _on_catch_display_changed(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
[gd_scene load_steps=9 format=3]
|
||||
[gd_scene load_steps=11 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/game_ui.gd" id="1_ui"]
|
||||
[ext_resource type="PackedScene" path="res://ui/player_menu.tscn" id="2_menu"]
|
||||
[ext_resource type="Theme" path="res://ui/game_theme.tres" id="3_theme"]
|
||||
[ext_resource type="Script" path="res://ui/screen_fade.gd" id="4_fade"]
|
||||
[ext_resource type="PackedScene" path="res://ui/title_screen.tscn" id="5_title"]
|
||||
[ext_resource type="PackedScene" path="res://ui/pause_menu.tscn" id="6_pause"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBox_chase_background"]
|
||||
bg_color = Color(0.055, 0.105, 0.125, 1)
|
||||
|
|
@ -138,3 +140,9 @@ grow_vertical = 2
|
|||
mouse_filter = 0
|
||||
color = Color(0, 0, 0, 1)
|
||||
script = ExtResource("4_fade")
|
||||
|
||||
[node name="TitleScreen" parent="." instance=ExtResource("5_title")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="PauseMenu" parent="." instance=ExtResource("6_pause")]
|
||||
unique_name_in_owner = true
|
||||
|
|
|
|||
305
ui/pause_menu.gd
Normal file
305
ui/pause_menu.gd
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
class_name PauseMenu
|
||||
extends Control
|
||||
|
||||
const INPUT_OWNER: StringName = &"game_menu"
|
||||
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")
|
||||
const FishingSpotType = preload("res://fishing/fishing_spot.gd")
|
||||
|
||||
signal return_to_title_requested
|
||||
signal reset_progress_requested
|
||||
signal quit_requested
|
||||
|
||||
enum ConfirmationAction {
|
||||
NONE,
|
||||
RETURN_TO_TITLE,
|
||||
RESET_PROGRESS,
|
||||
QUIT_ANYWAY,
|
||||
}
|
||||
|
||||
enum CloseReason {
|
||||
USER_RETURN,
|
||||
BITE_STARTED,
|
||||
WATER_RECOVERY,
|
||||
RETURN_TO_TITLE,
|
||||
RESET_PROGRESS,
|
||||
QUIT,
|
||||
TEARDOWN,
|
||||
}
|
||||
|
||||
@onready var _root_panel: PanelContainer = %RootPanel
|
||||
@onready var _settings_panel: SettingsPanelType = %SettingsPanel
|
||||
@onready var _confirmation_panel: PanelContainer = %ConfirmationPanel
|
||||
@onready var _confirmation_title: Label = %ConfirmationTitle
|
||||
@onready var _confirmation_text: Label = %ConfirmationText
|
||||
@onready var _confirm_button: Button = %ConfirmButton
|
||||
@onready var _cancel_button: Button = %CancelConfirmButton
|
||||
@onready var _feedback: Label = %FeedbackLabel
|
||||
@onready var _save_button: Button = %SaveButton
|
||||
|
||||
var _player: PlayerType
|
||||
var _save_manager: SaveManagerType
|
||||
var _settings_manager: SettingsManagerType
|
||||
var _fishing_spot: FishingSpotType
|
||||
var _prior_movement_enabled: bool = true
|
||||
var _prior_camera_enabled: bool = true
|
||||
var _control_snapshot_stored: bool = false
|
||||
var _confirmation_action: ConfirmationAction = ConfirmationAction.NONE
|
||||
var _action_in_progress: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
%ResumeButton.pressed.connect(resume)
|
||||
_save_button.pressed.connect(_save_now)
|
||||
%SettingsButton.pressed.connect(_open_settings)
|
||||
%ReturnToTitleButton.pressed.connect(_confirm_return_to_title)
|
||||
%ResetProgressButton.pressed.connect(_confirm_reset_progress)
|
||||
%QuitButton.pressed.connect(_request_quit)
|
||||
_confirm_button.pressed.connect(_accept_confirmation)
|
||||
_cancel_button.pressed.connect(_close_confirmation)
|
||||
_settings_panel.applied.connect(_on_settings_applied)
|
||||
_settings_panel.closed.connect(_on_settings_closed)
|
||||
|
||||
|
||||
func setup(
|
||||
player: PlayerType,
|
||||
save_manager: SaveManagerType,
|
||||
settings_manager: SettingsManagerType,
|
||||
fishing_spot: FishingSpotType,
|
||||
) -> void:
|
||||
_player = player
|
||||
_save_manager = save_manager
|
||||
_settings_manager = settings_manager
|
||||
_fishing_spot = fishing_spot
|
||||
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()
|
||||
_control_snapshot_stored = true
|
||||
_player.set_movement_enabled(false)
|
||||
_player.set_camera_input_enabled(false)
|
||||
_fishing_spot.set_local_menu_input_suppressed(INPUT_OWNER, true)
|
||||
_feedback.text = ""
|
||||
_root_panel.show()
|
||||
_settings_panel.hide()
|
||||
_confirmation_panel.hide()
|
||||
_confirmation_action = ConfirmationAction.NONE
|
||||
show()
|
||||
%ResumeButton.grab_focus()
|
||||
|
||||
|
||||
func resume() -> void:
|
||||
if not visible or _action_in_progress:
|
||||
return
|
||||
close_menu(CloseReason.USER_RETURN)
|
||||
|
||||
|
||||
func close_for_title_transition() -> void:
|
||||
close_menu(CloseReason.RETURN_TO_TITLE, false)
|
||||
|
||||
|
||||
func close_for_water_recovery() -> void:
|
||||
close_menu(CloseReason.WATER_RECOVERY)
|
||||
|
||||
|
||||
func close_menu(
|
||||
_reason: CloseReason,
|
||||
restore_controls: bool = true,
|
||||
) -> void:
|
||||
if not visible:
|
||||
return
|
||||
if _settings_panel.visible:
|
||||
_settings_panel.close_panel()
|
||||
hide()
|
||||
_root_panel.show()
|
||||
_settings_panel.hide()
|
||||
_confirmation_panel.hide()
|
||||
_confirmation_action = ConfirmationAction.NONE
|
||||
_action_in_progress = false
|
||||
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
|
||||
|
||||
|
||||
func handle_escape() -> bool:
|
||||
if not visible:
|
||||
return false
|
||||
if _confirmation_panel.visible:
|
||||
_close_confirmation()
|
||||
elif _settings_panel.visible:
|
||||
_settings_panel.close_panel()
|
||||
else:
|
||||
resume()
|
||||
return true
|
||||
|
||||
|
||||
func _save_now() -> void:
|
||||
if _action_in_progress:
|
||||
return
|
||||
_action_in_progress = true
|
||||
_save_button.disabled = true
|
||||
if _save_manager.save_now():
|
||||
_feedback.text = "Game saved."
|
||||
else:
|
||||
_feedback.text = "Save failed. Previous save was preserved."
|
||||
_action_in_progress = false
|
||||
call_deferred("_reenable_save_button")
|
||||
|
||||
|
||||
func _reenable_save_button() -> void:
|
||||
_save_button.disabled = false
|
||||
|
||||
|
||||
func _open_settings() -> void:
|
||||
if _action_in_progress or _confirmation_panel.visible:
|
||||
return
|
||||
_root_panel.hide()
|
||||
_settings_panel.open_panel(_settings_manager)
|
||||
|
||||
|
||||
func _on_settings_applied() -> void:
|
||||
_root_panel.show()
|
||||
_feedback.text = "Settings saved."
|
||||
%SettingsButton.grab_focus()
|
||||
|
||||
|
||||
func _on_settings_closed() -> void:
|
||||
_root_panel.show()
|
||||
%SettingsButton.grab_focus()
|
||||
|
||||
|
||||
func _confirm_return_to_title() -> void:
|
||||
_open_confirmation(
|
||||
ConfirmationAction.RETURN_TO_TITLE,
|
||||
"Return to Title",
|
||||
"Unsaved progress will be saved first.",
|
||||
"Save and Return",
|
||||
false
|
||||
)
|
||||
|
||||
|
||||
func _confirm_reset_progress() -> void:
|
||||
_open_confirmation(
|
||||
ConfirmationAction.RESET_PROGRESS,
|
||||
"Reset all progression?",
|
||||
(
|
||||
"This permanently deletes your fish, discoveries, "
|
||||
+ "favorites, and wallet balance.\n\n"
|
||||
+ "Your settings will be preserved."
|
||||
),
|
||||
"DELETE ALL PROGRESS",
|
||||
true
|
||||
)
|
||||
|
||||
|
||||
func _request_quit() -> void:
|
||||
if _action_in_progress:
|
||||
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,
|
||||
"Save failed",
|
||||
"Some progress or settings could not be saved. Quit anyway?",
|
||||
"Quit Anyway",
|
||||
true
|
||||
)
|
||||
|
||||
|
||||
func _open_confirmation(
|
||||
action: ConfirmationAction,
|
||||
title: String,
|
||||
message: String,
|
||||
confirm_text: String,
|
||||
dangerous: bool,
|
||||
) -> void:
|
||||
if _action_in_progress:
|
||||
return
|
||||
_confirmation_action = action
|
||||
_confirmation_title.text = title
|
||||
_confirmation_text.text = message
|
||||
_confirm_button.text = confirm_text
|
||||
_confirm_button.theme_type_variation = (
|
||||
&"DangerButton" if dangerous else StringName()
|
||||
)
|
||||
_root_panel.hide()
|
||||
_confirmation_panel.show()
|
||||
if dangerous:
|
||||
_cancel_button.grab_focus()
|
||||
else:
|
||||
_confirm_button.grab_focus()
|
||||
|
||||
|
||||
func _close_confirmation() -> void:
|
||||
_confirmation_action = ConfirmationAction.NONE
|
||||
_confirmation_panel.hide()
|
||||
_root_panel.show()
|
||||
%ResumeButton.grab_focus()
|
||||
|
||||
|
||||
func _accept_confirmation() -> void:
|
||||
if _action_in_progress:
|
||||
return
|
||||
var action: ConfirmationAction = _confirmation_action
|
||||
_confirmation_action = ConfirmationAction.NONE
|
||||
_confirmation_panel.hide()
|
||||
_action_in_progress = true
|
||||
match action:
|
||||
ConfirmationAction.RETURN_TO_TITLE:
|
||||
if _save_manager.save_now():
|
||||
return_to_title_requested.emit()
|
||||
else:
|
||||
_feedback.text = "Save failed. Previous save was preserved."
|
||||
_root_panel.show()
|
||||
ConfirmationAction.RESET_PROGRESS:
|
||||
reset_progress_requested.emit()
|
||||
ConfirmationAction.QUIT_ANYWAY:
|
||||
quit_requested.emit()
|
||||
_:
|
||||
_root_panel.show()
|
||||
_action_in_progress = false
|
||||
|
||||
|
||||
func report_reset_failure() -> void:
|
||||
_action_in_progress = false
|
||||
_root_panel.show()
|
||||
_confirmation_panel.hide()
|
||||
_feedback.text = "Reset failed. Your progression was preserved."
|
||||
%ResumeButton.grab_focus()
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
func _on_bite_activated() -> void:
|
||||
if visible:
|
||||
close_menu(CloseReason.BITE_STARTED)
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
if visible:
|
||||
close_menu(CloseReason.TEARDOWN)
|
||||
1
ui/pause_menu.gd.uid
Normal file
1
ui/pause_menu.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://djp0uuwevg2ht
|
||||
173
ui/pause_menu.tscn
Normal file
173
ui/pause_menu.tscn
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
[gd_scene load_steps=4 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/pause_menu.gd" id="1_script"]
|
||||
[ext_resource type="PackedScene" path="res://ui/settings_panel.tscn" id="2_settings"]
|
||||
[ext_resource type="Theme" path="res://ui/game_theme.tres" id="3_theme"]
|
||||
|
||||
[node name="PauseMenu" type="Control"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
z_index = 190
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 0
|
||||
theme = ExtResource("3_theme")
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="DimBackground" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 0
|
||||
color = Color(0.02, 0.05, 0.07, 0.78)
|
||||
|
||||
[node name="RootCenter" type="CenterContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="RootPanel" type="PanelContainer" parent="RootCenter"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(420, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="RootCenter/RootPanel"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 32
|
||||
theme_override_constants/margin_top = 26
|
||||
theme_override_constants/margin_right = 32
|
||||
theme_override_constants/margin_bottom = 26
|
||||
|
||||
[node name="Content" type="VBoxContainer" parent="RootCenter/RootPanel/Margin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 11
|
||||
|
||||
[node name="Title" type="Label" parent="RootCenter/RootPanel/Margin/Content"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 30
|
||||
text = "Game Menu"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ResumeButton" type="Button" parent="RootCenter/RootPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 43)
|
||||
layout_mode = 2
|
||||
text = "Return to Game"
|
||||
|
||||
[node name="SaveButton" type="Button" parent="RootCenter/RootPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 43)
|
||||
layout_mode = 2
|
||||
text = "Save Now"
|
||||
|
||||
[node name="SettingsButton" type="Button" parent="RootCenter/RootPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 43)
|
||||
layout_mode = 2
|
||||
text = "Settings"
|
||||
|
||||
[node name="ReturnToTitleButton" type="Button" parent="RootCenter/RootPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 43)
|
||||
layout_mode = 2
|
||||
text = "Return to Title"
|
||||
|
||||
[node name="ResetProgressButton" type="Button" parent="RootCenter/RootPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 43)
|
||||
layout_mode = 2
|
||||
theme_type_variation = &"DangerButton"
|
||||
text = "Reset Progress"
|
||||
|
||||
[node name="QuitButton" type="Button" parent="RootCenter/RootPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 43)
|
||||
layout_mode = 2
|
||||
text = "Quit"
|
||||
|
||||
[node name="FeedbackLabel" type="Label" parent="RootCenter/RootPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
layout_mode = 2
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="SettingsCenter" type="CenterContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="SettingsPanel" parent="SettingsCenter" instance=ExtResource("2_settings")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ConfirmationCenter" type="CenterContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="ConfirmationPanel" type="PanelContainer" parent="ConfirmationCenter"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(520, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="ConfirmationCenter/ConfirmationPanel"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 28
|
||||
theme_override_constants/margin_top = 24
|
||||
theme_override_constants/margin_right = 28
|
||||
theme_override_constants/margin_bottom = 24
|
||||
|
||||
[node name="Content" type="VBoxContainer" parent="ConfirmationCenter/ConfirmationPanel/Margin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 15
|
||||
|
||||
[node name="ConfirmationTitle" type="Label" parent="ConfirmationCenter/ConfirmationPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.937, 0.357, 0.384, 1)
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "Confirm"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ConfirmationText" type="Label" parent="ConfirmationCenter/ConfirmationPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Are you sure?"
|
||||
horizontal_alignment = 1
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="Buttons" type="HBoxContainer" parent="ConfirmationCenter/ConfirmationPanel/Margin/Content"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
alignment = 1
|
||||
|
||||
[node name="ConfirmButton" type="Button" parent="ConfirmationCenter/ConfirmationPanel/Margin/Content/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(190, 43)
|
||||
layout_mode = 2
|
||||
text = "Confirm"
|
||||
|
||||
[node name="CancelConfirmButton" type="Button" parent="ConfirmationCenter/ConfirmationPanel/Margin/Content/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(130, 43)
|
||||
layout_mode = 2
|
||||
text = "Cancel"
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
class_name PlayerMenu
|
||||
extends Control
|
||||
|
||||
const INPUT_OWNER: StringName = &"player_menu"
|
||||
const CollectionLogType = preload("res://collection/collection_log.gd")
|
||||
const FishCatchType = preload("res://fish/fish_catch.gd")
|
||||
const FishDataType = preload("res://fish/fish_data.gd")
|
||||
|
|
@ -26,6 +27,15 @@ enum SortMode {
|
|||
RARITY,
|
||||
}
|
||||
|
||||
enum CloseReason {
|
||||
USER,
|
||||
BITE_STARTED,
|
||||
WATER_RECOVERY,
|
||||
GAME_MENU,
|
||||
SESSION_END,
|
||||
TEARDOWN,
|
||||
}
|
||||
|
||||
@onready var _inventory_tab: Button = %InventoryTab
|
||||
@onready var _logbook_tab: Button = %LogbookTab
|
||||
@onready var _close_button: Button = %CloseButton
|
||||
|
|
@ -128,20 +138,10 @@ func _input(event: InputEvent) -> void:
|
|||
if event is InputEventKey and event.echo:
|
||||
return
|
||||
if visible:
|
||||
if (
|
||||
event.is_action_pressed("ui_cancel")
|
||||
and _sale_confirmation.visible
|
||||
):
|
||||
_close_sale_confirmation()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if (
|
||||
event.is_action_pressed("open_backpack")
|
||||
or event.is_action_pressed("ui_cancel")
|
||||
):
|
||||
if event.is_action_pressed("open_backpack"):
|
||||
close_menu()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
return
|
||||
if (
|
||||
event.is_action_pressed("open_backpack")
|
||||
and _fishing_spot != null
|
||||
|
|
@ -151,6 +151,16 @@ func _input(event: InputEvent) -> void:
|
|||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func consume_escape() -> bool:
|
||||
if not visible:
|
||||
return false
|
||||
if _sale_confirmation.visible:
|
||||
_close_sale_confirmation()
|
||||
else:
|
||||
close_menu()
|
||||
return true
|
||||
|
||||
|
||||
func open_menu() -> void:
|
||||
if (
|
||||
visible
|
||||
|
|
@ -165,6 +175,7 @@ func open_menu() -> void:
|
|||
_control_snapshot_stored = true
|
||||
_player.set_movement_enabled(false)
|
||||
_player.set_camera_input_enabled(false)
|
||||
_fishing_spot.set_local_menu_input_suppressed(INPUT_OWNER, true)
|
||||
visible = true
|
||||
_refresh_all()
|
||||
_show_section(_current_section)
|
||||
|
|
@ -172,22 +183,41 @@ func open_menu() -> void:
|
|||
menu_visibility_changed.emit(true)
|
||||
|
||||
|
||||
func close_menu() -> void:
|
||||
func close_menu(
|
||||
_reason: CloseReason = CloseReason.USER,
|
||||
restore_controls: bool = true,
|
||||
) -> void:
|
||||
if not visible:
|
||||
return
|
||||
_close_sale_confirmation()
|
||||
var closing_generation: int = _menu_generation
|
||||
visible = false
|
||||
get_viewport().gui_release_focus()
|
||||
_restore_player_controls(closing_generation)
|
||||
if _fishing_spot != null and is_instance_valid(_fishing_spot):
|
||||
_fishing_spot.set_local_menu_input_suppressed(INPUT_OWNER, false)
|
||||
if restore_controls:
|
||||
_restore_player_controls(closing_generation)
|
||||
else:
|
||||
_control_snapshot_stored = false
|
||||
_menu_generation += 1
|
||||
menu_visibility_changed.emit(false)
|
||||
|
||||
|
||||
func close_for_water_recovery() -> void:
|
||||
close_menu(CloseReason.WATER_RECOVERY)
|
||||
|
||||
|
||||
func close_for_game_menu() -> void:
|
||||
close_menu(CloseReason.GAME_MENU)
|
||||
|
||||
|
||||
func close_for_session_end() -> void:
|
||||
close_menu(CloseReason.SESSION_END, false)
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
if visible:
|
||||
visible = false
|
||||
_restore_player_controls(_menu_generation)
|
||||
close_menu(CloseReason.TEARDOWN, false)
|
||||
_selected_catch_id = StringName()
|
||||
_menu_generation += 1
|
||||
|
||||
|
|
@ -206,7 +236,7 @@ func _restore_player_controls(generation: int) -> void:
|
|||
|
||||
func _on_bite_activated() -> void:
|
||||
if visible:
|
||||
close_menu()
|
||||
close_menu(CloseReason.BITE_STARTED)
|
||||
|
||||
|
||||
func _show_section(section: Section) -> void:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
[ext_resource type="Theme" path="res://ui/game_theme.tres" id="2_theme"]
|
||||
|
||||
[node name="PlayerMenu" type="Control"]
|
||||
process_mode = 3
|
||||
visible = false
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
|
|
|
|||
80
ui/settings_panel.gd
Normal file
80
ui/settings_panel.gd
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
class_name SettingsPanel
|
||||
extends PanelContainer
|
||||
|
||||
const SettingsManagerType = preload(
|
||||
"res://settings/player_settings_manager.gd"
|
||||
)
|
||||
|
||||
signal applied
|
||||
signal closed
|
||||
|
||||
@onready var _auto_click_toggle: CheckButton = %AutoClickToggle
|
||||
@onready var _auto_click_interval: HSlider = %AutoClickInterval
|
||||
@onready var _auto_click_interval_value: Label = %AutoClickIntervalValue
|
||||
@onready var _mouse_sensitivity: HSlider = %MouseSensitivity
|
||||
@onready var _mouse_sensitivity_value: Label = %MouseSensitivityValue
|
||||
@onready var _controller_sensitivity: HSlider = %ControllerSensitivity
|
||||
@onready var _controller_sensitivity_value: Label = %ControllerSensitivityValue
|
||||
@onready var _invert_y_toggle: CheckButton = %InvertYToggle
|
||||
@onready var _feedback: Label = %SettingsFeedback
|
||||
|
||||
var _settings_manager: SettingsManagerType
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
%ApplySettingsButton.pressed.connect(_apply_settings)
|
||||
%CancelSettingsButton.pressed.connect(close_panel)
|
||||
_auto_click_interval.value_changed.connect(_refresh_value_labels)
|
||||
_mouse_sensitivity.value_changed.connect(_refresh_value_labels)
|
||||
_controller_sensitivity.value_changed.connect(_refresh_value_labels)
|
||||
|
||||
|
||||
func open_panel(settings_manager: SettingsManagerType) -> void:
|
||||
_settings_manager = settings_manager
|
||||
_load_controls()
|
||||
_feedback.text = ""
|
||||
show()
|
||||
_auto_click_toggle.grab_focus()
|
||||
|
||||
|
||||
func close_panel() -> void:
|
||||
if not visible:
|
||||
return
|
||||
hide()
|
||||
_load_controls()
|
||||
closed.emit()
|
||||
|
||||
|
||||
func _apply_settings() -> void:
|
||||
if _settings_manager == null:
|
||||
_feedback.text = "Settings are unavailable."
|
||||
return
|
||||
var edited := PlayerSettings.new()
|
||||
edited.auto_click_enabled = _auto_click_toggle.button_pressed
|
||||
edited.auto_click_interval = float(_auto_click_interval.value)
|
||||
edited.mouse_camera_sensitivity = float(_mouse_sensitivity.value)
|
||||
edited.controller_camera_sensitivity = float(_controller_sensitivity.value)
|
||||
edited.invert_camera_y = _invert_y_toggle.button_pressed
|
||||
if _settings_manager.apply_settings(edited):
|
||||
hide()
|
||||
applied.emit()
|
||||
else:
|
||||
_feedback.text = "Failed to save settings."
|
||||
|
||||
|
||||
func _load_controls() -> void:
|
||||
if _settings_manager == null or not is_node_ready():
|
||||
return
|
||||
var settings: PlayerSettings = _settings_manager.current_settings
|
||||
_auto_click_toggle.button_pressed = settings.auto_click_enabled
|
||||
_auto_click_interval.value = settings.auto_click_interval
|
||||
_mouse_sensitivity.value = settings.mouse_camera_sensitivity
|
||||
_controller_sensitivity.value = settings.controller_camera_sensitivity
|
||||
_invert_y_toggle.button_pressed = settings.invert_camera_y
|
||||
_refresh_value_labels(0.0)
|
||||
|
||||
|
||||
func _refresh_value_labels(_unused: float) -> void:
|
||||
_auto_click_interval_value.text = "%.2f s" % _auto_click_interval.value
|
||||
_mouse_sensitivity_value.text = "%.4f" % _mouse_sensitivity.value
|
||||
_controller_sensitivity_value.text = "%.1f" % _controller_sensitivity.value
|
||||
1
ui/settings_panel.gd.uid
Normal file
1
ui/settings_panel.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cuoxpo2o3usey
|
||||
136
ui/settings_panel.tscn
Normal file
136
ui/settings_panel.tscn
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
[gd_scene load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/settings_panel.gd" id="1_script"]
|
||||
[ext_resource type="Theme" path="res://ui/game_theme.tres" id="2_theme"]
|
||||
|
||||
[node name="SettingsPanel" type="PanelContainer"]
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(600, 490)
|
||||
theme = ExtResource("2_theme")
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 28
|
||||
theme_override_constants/margin_top = 24
|
||||
theme_override_constants/margin_right = 28
|
||||
theme_override_constants/margin_bottom = 24
|
||||
|
||||
[node name="Content" type="VBoxContainer" parent="Margin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
|
||||
[node name="Heading" type="Label" parent="Margin/Content"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 26
|
||||
text = "Settings"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="AutoClickToggle" type="CheckButton" parent="Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Accessibility auto-click"
|
||||
|
||||
[node name="AutoClickHelp" type="Label" parent="Margin/Content"]
|
||||
layout_mode = 2
|
||||
text = "Lower intervals click barriers faster while held."
|
||||
|
||||
[node name="AutoClickRow" type="HBoxContainer" parent="Margin/Content"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
|
||||
[node name="Label" type="Label" parent="Margin/Content/AutoClickRow"]
|
||||
custom_minimum_size = Vector2(190, 0)
|
||||
layout_mode = 2
|
||||
text = "Auto-click interval"
|
||||
|
||||
[node name="AutoClickInterval" type="HSlider" parent="Margin/Content/AutoClickRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
min_value = 0.1
|
||||
max_value = 0.5
|
||||
step = 0.01
|
||||
value = 0.2
|
||||
|
||||
[node name="AutoClickIntervalValue" type="Label" parent="Margin/Content/AutoClickRow"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(62, 0)
|
||||
layout_mode = 2
|
||||
text = "0.20 s"
|
||||
|
||||
[node name="MouseRow" type="HBoxContainer" parent="Margin/Content"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
|
||||
[node name="Label" type="Label" parent="Margin/Content/MouseRow"]
|
||||
custom_minimum_size = Vector2(190, 0)
|
||||
layout_mode = 2
|
||||
text = "Mouse camera sensitivity"
|
||||
|
||||
[node name="MouseSensitivity" type="HSlider" parent="Margin/Content/MouseRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
min_value = 0.001
|
||||
max_value = 0.012
|
||||
step = 0.0005
|
||||
value = 0.005
|
||||
|
||||
[node name="MouseSensitivityValue" type="Label" parent="Margin/Content/MouseRow"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(62, 0)
|
||||
layout_mode = 2
|
||||
text = "0.0050"
|
||||
|
||||
[node name="ControllerRow" type="HBoxContainer" parent="Margin/Content"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
|
||||
[node name="Label" type="Label" parent="Margin/Content/ControllerRow"]
|
||||
custom_minimum_size = Vector2(190, 0)
|
||||
layout_mode = 2
|
||||
text = "Controller camera sensitivity"
|
||||
|
||||
[node name="ControllerSensitivity" type="HSlider" parent="Margin/Content/ControllerRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
min_value = 0.5
|
||||
max_value = 5.0
|
||||
step = 0.1
|
||||
value = 2.5
|
||||
|
||||
[node name="ControllerSensitivityValue" type="Label" parent="Margin/Content/ControllerRow"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(62, 0)
|
||||
layout_mode = 2
|
||||
text = "2.5"
|
||||
|
||||
[node name="InvertYToggle" type="CheckButton" parent="Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Invert vertical camera"
|
||||
|
||||
[node name="SettingsFeedback" type="Label" parent="Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 28)
|
||||
layout_mode = 2
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Buttons" type="HBoxContainer" parent="Margin/Content"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
alignment = 2
|
||||
|
||||
[node name="ApplySettingsButton" type="Button" parent="Margin/Content/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(120, 42)
|
||||
layout_mode = 2
|
||||
text = "Apply"
|
||||
|
||||
[node name="CancelSettingsButton" type="Button" parent="Margin/Content/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(120, 42)
|
||||
layout_mode = 2
|
||||
text = "Back"
|
||||
232
ui/title_screen.gd
Normal file
232
ui/title_screen.gd
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
class_name TitleScreen
|
||||
extends Control
|
||||
|
||||
const SaveInspectionType = preload("res://save/player_save_inspection.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")
|
||||
|
||||
signal gameplay_requested
|
||||
signal quit_requested
|
||||
|
||||
enum ConfirmationAction {
|
||||
NONE,
|
||||
NEW_GAME,
|
||||
DELETE_SAVE,
|
||||
}
|
||||
|
||||
@onready var _continue_button: Button = %ContinueButton
|
||||
@onready var _new_game_button: Button = %NewGameButton
|
||||
@onready var _settings_button: Button = %SettingsButton
|
||||
@onready var _delete_button: Button = %DeleteSaveButton
|
||||
@onready var _feedback_label: Label = %FeedbackLabel
|
||||
@onready var _confirmation_panel: PanelContainer = %ConfirmationPanel
|
||||
@onready var _confirmation_text: Label = %ConfirmationText
|
||||
@onready var _confirm_button: Button = %ConfirmButton
|
||||
@onready var _settings_panel: SettingsPanelType = %SettingsPanel
|
||||
|
||||
var _save_manager: SaveManagerType
|
||||
var _settings_manager: SettingsManagerType
|
||||
var _inspection: SaveInspectionType
|
||||
var _confirmation_action: ConfirmationAction = ConfirmationAction.NONE
|
||||
var _action_in_progress: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_continue_button.pressed.connect(_on_continue_pressed)
|
||||
_new_game_button.pressed.connect(_on_new_game_pressed)
|
||||
_settings_button.pressed.connect(_open_settings)
|
||||
_delete_button.pressed.connect(_on_delete_pressed)
|
||||
%QuitButton.pressed.connect(_on_quit_pressed)
|
||||
_confirm_button.pressed.connect(_on_confirmation_accepted)
|
||||
%CancelConfirmButton.pressed.connect(_close_confirmation)
|
||||
_settings_panel.applied.connect(_on_settings_applied)
|
||||
_settings_panel.closed.connect(_on_settings_closed)
|
||||
|
||||
|
||||
func setup(
|
||||
save_manager: SaveManagerType,
|
||||
settings_manager: SettingsManagerType,
|
||||
) -> void:
|
||||
_save_manager = save_manager
|
||||
_settings_manager = settings_manager
|
||||
_refresh_save_inspection()
|
||||
show()
|
||||
call_deferred("_focus_initial_button")
|
||||
|
||||
|
||||
func reopen() -> void:
|
||||
_close_confirmation()
|
||||
_settings_panel.hide()
|
||||
_refresh_save_inspection()
|
||||
show()
|
||||
call_deferred("_focus_initial_button")
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not visible or not event.is_action_pressed("ui_cancel"):
|
||||
return
|
||||
if _confirmation_panel.visible:
|
||||
_close_confirmation()
|
||||
elif _settings_panel.visible:
|
||||
_close_settings()
|
||||
else:
|
||||
return
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _on_continue_pressed() -> void:
|
||||
if (
|
||||
_action_in_progress
|
||||
or _confirmation_panel.visible
|
||||
or _settings_panel.visible
|
||||
or _inspection == null
|
||||
or not _inspection.can_continue()
|
||||
):
|
||||
return
|
||||
_action_in_progress = true
|
||||
if _save_manager.load_player_data():
|
||||
_feedback_label.text = "Save loaded."
|
||||
gameplay_requested.emit()
|
||||
else:
|
||||
_refresh_save_inspection()
|
||||
_feedback_label.text = "Failed to load save. The original was preserved."
|
||||
_action_in_progress = false
|
||||
|
||||
|
||||
func _on_new_game_pressed() -> void:
|
||||
if (
|
||||
_action_in_progress
|
||||
or _confirmation_panel.visible
|
||||
or _settings_panel.visible
|
||||
or _inspection == null
|
||||
):
|
||||
return
|
||||
if _inspection.status == SaveInspectionType.Status.MISSING:
|
||||
if _save_manager.initialize_new_game():
|
||||
gameplay_requested.emit()
|
||||
return
|
||||
if _inspection.status == SaveInspectionType.Status.UNSUPPORTED_VERSION:
|
||||
_feedback_label.text = (
|
||||
"This save is from a newer game version. "
|
||||
+ "Use Delete Save before starting over."
|
||||
)
|
||||
return
|
||||
if _inspection.status == SaveInspectionType.Status.IO_ERROR:
|
||||
_feedback_label.text = "The existing save cannot be accessed safely."
|
||||
return
|
||||
_open_confirmation(
|
||||
ConfirmationAction.NEW_GAME,
|
||||
"Start a new game? Existing progression will be deleted.",
|
||||
"Start New Game"
|
||||
)
|
||||
|
||||
|
||||
func _on_delete_pressed() -> void:
|
||||
if (
|
||||
_action_in_progress
|
||||
or _confirmation_panel.visible
|
||||
or _settings_panel.visible
|
||||
or _inspection == null
|
||||
or not _inspection.can_delete()
|
||||
):
|
||||
return
|
||||
_open_confirmation(
|
||||
ConfirmationAction.DELETE_SAVE,
|
||||
"Delete your saved progression? This cannot be undone.",
|
||||
"Delete"
|
||||
)
|
||||
|
||||
|
||||
func _on_confirmation_accepted() -> void:
|
||||
if _action_in_progress:
|
||||
return
|
||||
var action: ConfirmationAction = _confirmation_action
|
||||
_close_confirmation()
|
||||
_action_in_progress = true
|
||||
if not _save_manager.delete_progression_save():
|
||||
_feedback_label.text = "Failed to delete saved progression."
|
||||
_action_in_progress = false
|
||||
_refresh_save_inspection()
|
||||
return
|
||||
_save_manager.initialize_new_game()
|
||||
_refresh_save_inspection()
|
||||
if action == ConfirmationAction.NEW_GAME:
|
||||
gameplay_requested.emit()
|
||||
else:
|
||||
_feedback_label.text = "Saved progression deleted."
|
||||
_action_in_progress = false
|
||||
|
||||
|
||||
func _open_confirmation(
|
||||
action: ConfirmationAction,
|
||||
message: String,
|
||||
confirm_text: String,
|
||||
) -> void:
|
||||
_confirmation_action = action
|
||||
_confirmation_text.text = message
|
||||
_confirm_button.text = confirm_text
|
||||
_confirmation_panel.visible = true
|
||||
_confirm_button.grab_focus()
|
||||
|
||||
|
||||
func _close_confirmation() -> void:
|
||||
_confirmation_action = ConfirmationAction.NONE
|
||||
_confirmation_panel.visible = false
|
||||
_focus_initial_button()
|
||||
|
||||
|
||||
func _open_settings() -> void:
|
||||
if _confirmation_panel.visible or _action_in_progress:
|
||||
return
|
||||
_feedback_label.text = ""
|
||||
_settings_panel.open_panel(_settings_manager)
|
||||
|
||||
|
||||
func _close_settings() -> void:
|
||||
_settings_panel.close_panel()
|
||||
|
||||
|
||||
func _on_settings_applied() -> void:
|
||||
_feedback_label.text = "Settings saved."
|
||||
_settings_button.grab_focus()
|
||||
|
||||
|
||||
func _on_settings_closed() -> void:
|
||||
_settings_button.grab_focus()
|
||||
|
||||
|
||||
func _refresh_save_inspection() -> void:
|
||||
_inspection = _save_manager.inspect_save()
|
||||
_continue_button.disabled = not _inspection.can_continue()
|
||||
_delete_button.disabled = not _inspection.can_delete()
|
||||
_feedback_label.text = _inspection.message
|
||||
if _inspection.status == SaveInspectionType.Status.VALID_SUPPORTED:
|
||||
_feedback_label.text = (
|
||||
"%d fish • $%d • %d discovered"
|
||||
% [
|
||||
_inspection.catch_count,
|
||||
_inspection.wallet_balance,
|
||||
_inspection.discovered_species_count,
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
func _focus_initial_button() -> void:
|
||||
if not is_node_ready() or not visible:
|
||||
return
|
||||
if not _continue_button.disabled:
|
||||
_continue_button.grab_focus()
|
||||
else:
|
||||
_new_game_button.grab_focus()
|
||||
|
||||
|
||||
func _on_quit_pressed() -> void:
|
||||
if (
|
||||
not _action_in_progress
|
||||
and not _confirmation_panel.visible
|
||||
and not _settings_panel.visible
|
||||
):
|
||||
quit_requested.emit()
|
||||
1
ui/title_screen.gd.uid
Normal file
1
ui/title_screen.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://6xhmtogx3c66
|
||||
172
ui/title_screen.tscn
Normal file
172
ui/title_screen.tscn
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
[gd_scene load_steps=4 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/title_screen.gd" id="1_script"]
|
||||
[ext_resource type="Theme" path="res://ui/game_theme.tres" id="2_theme"]
|
||||
[ext_resource type="PackedScene" path="res://ui/settings_panel.tscn" id="3_settings"]
|
||||
|
||||
[node name="TitleScreen" type="Control"]
|
||||
unique_name_in_owner = true
|
||||
z_index = 200
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 0
|
||||
theme = ExtResource("2_theme")
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.047, 0.102, 0.145, 1)
|
||||
|
||||
[node name="Center" type="CenterContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MainPanel" type="PanelContainer" parent="Center"]
|
||||
custom_minimum_size = Vector2(440, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="Center/MainPanel"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 36
|
||||
theme_override_constants/margin_top = 30
|
||||
theme_override_constants/margin_right = 36
|
||||
theme_override_constants/margin_bottom = 30
|
||||
|
||||
[node name="Content" type="VBoxContainer" parent="Center/MainPanel/Margin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
|
||||
[node name="Title" type="Label" parent="Center/MainPanel/Margin/Content"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 36
|
||||
text = "NETFISHING"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Subtitle" type="Label" parent="Center/MainPanel/Margin/Content"]
|
||||
layout_mode = 2
|
||||
text = "A cozy social fishing game"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Spacer" type="Control" parent="Center/MainPanel/Margin/Content"]
|
||||
custom_minimum_size = Vector2(0, 12)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ContinueButton" type="Button" parent="Center/MainPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
layout_mode = 2
|
||||
text = "Continue"
|
||||
|
||||
[node name="NewGameButton" type="Button" parent="Center/MainPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
layout_mode = 2
|
||||
text = "New Game"
|
||||
|
||||
[node name="SettingsButton" type="Button" parent="Center/MainPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
layout_mode = 2
|
||||
text = "Settings"
|
||||
|
||||
[node name="DeleteSaveButton" type="Button" parent="Center/MainPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
layout_mode = 2
|
||||
text = "Delete Save"
|
||||
|
||||
[node name="QuitButton" type="Button" parent="Center/MainPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
layout_mode = 2
|
||||
text = "Quit"
|
||||
|
||||
[node name="FeedbackLabel" type="Label" parent="Center/MainPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 42)
|
||||
layout_mode = 2
|
||||
text = ""
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="ConfirmationPanel" type="PanelContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
z_index = 210
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -230.0
|
||||
offset_top = -95.0
|
||||
offset_right = 230.0
|
||||
offset_bottom = 95.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="ConfirmationPanel"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 24
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 24
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="Content" type="VBoxContainer" parent="ConfirmationPanel/Margin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 14
|
||||
|
||||
[node name="ConfirmationText" type="Label" parent="ConfirmationPanel/Margin/Content"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Confirm?"
|
||||
horizontal_alignment = 1
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="Buttons" type="HBoxContainer" parent="ConfirmationPanel/Margin/Content"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
alignment = 1
|
||||
|
||||
[node name="ConfirmButton" type="Button" parent="ConfirmationPanel/Margin/Content/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(150, 42)
|
||||
layout_mode = 2
|
||||
text = "Confirm"
|
||||
|
||||
[node name="CancelConfirmButton" type="Button" parent="ConfirmationPanel/Margin/Content/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(120, 42)
|
||||
layout_mode = 2
|
||||
text = "Cancel"
|
||||
|
||||
[node name="SettingsPanel" parent="." instance=ExtResource("3_settings")]
|
||||
unique_name_in_owner = true
|
||||
z_index = 210
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -300.0
|
||||
offset_top = -245.0
|
||||
offset_right = 300.0
|
||||
offset_bottom = 245.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
Loading…
Add table
Add a link
Reference in a new issue