2024-10-18 16:04:50 +00:00
|
|
|
class_name MainMenu extends Panel
|
2024-10-01 23:32:59 +00:00
|
|
|
|
2024-10-07 09:21:36 +00:00
|
|
|
var has_stage: bool = false:
|
2024-10-06 09:40:42 +00:00
|
|
|
set(value):
|
2024-10-07 09:21:36 +00:00
|
|
|
has_stage = value
|
2025-12-12 15:33:06 +00:00
|
|
|
assert(is_node_ready(), "MainMenu node not ready yet!")
|
|
|
|
|
if save_game_handle.get_most_recent_save().current_room == 0:
|
|
|
|
|
continue_button.visible = false
|
|
|
|
|
continue_button.disabled = true
|
|
|
|
|
new_game_button.theme_type_variation = "H1Button"
|
|
|
|
|
else:
|
|
|
|
|
continue_button.visible = true
|
|
|
|
|
continue_button.disabled = not has_stage
|
|
|
|
|
new_game_button.theme_type_variation = ""
|
|
|
|
|
load_game_button.disabled = not save_game_handle.has_existing_saves()
|
|
|
|
|
for child: Control in $PanelContainer.get_children():
|
|
|
|
|
child.focus_mode = FOCUS_ALL if has_stage else FOCUS_NONE
|
|
|
|
|
child.modulate = Color.WHITE if has_stage else Color.WEB_GRAY
|
|
|
|
|
child.mouse_filter = Control.MOUSE_FILTER_STOP if has_stage else Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
if has_stage:
|
|
|
|
|
if continue_button.visible:
|
|
|
|
|
continue_button.grab_focus()
|
2025-10-07 22:33:15 +00:00
|
|
|
else:
|
2025-12-12 15:33:06 +00:00
|
|
|
new_game_button.grab_focus()
|
2024-10-06 09:40:42 +00:00
|
|
|
|
2024-10-01 23:32:59 +00:00
|
|
|
signal start_game(savegame: SaveGame)
|
|
|
|
|
signal open_settings(new_game: bool)
|
2024-10-07 09:21:36 +00:00
|
|
|
signal roll_credits
|
2024-10-01 23:32:59 +00:00
|
|
|
|
|
|
|
|
@onready var new_game_button: Button = $PanelContainer/NewGameButton
|
|
|
|
|
@onready var continue_button: Button = $PanelContainer/ContinueGameButton
|
|
|
|
|
@onready var load_game_button: Button = $PanelContainer/LoadGameButton
|
2025-10-07 22:33:15 +00:00
|
|
|
@onready var settings_button: Button = $PanelContainer/SettingsButton
|
2024-10-07 09:21:36 +00:00
|
|
|
@onready var settings_popup: SettingsPopup = %SettingsPopup
|
|
|
|
|
@onready var credits_button: Button = $PanelContainer/CreditsButton
|
2024-10-01 23:32:59 +00:00
|
|
|
@onready var quit_button: Button = $PanelContainer/QuitButton
|
2025-12-12 15:35:07 +00:00
|
|
|
@onready var save_game_handle: SaveGameList = %SaveGameList
|
2024-10-01 23:32:59 +00:00
|
|
|
@export var save_game_exists: bool = false:
|
|
|
|
|
set(value):
|
|
|
|
|
save_game_exists = value
|
2024-10-06 09:40:42 +00:00
|
|
|
|
|
|
|
|
var await_new_game: bool = false
|
|
|
|
|
|
2024-10-01 23:32:59 +00:00
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
|
func _ready() -> void:
|
2025-12-12 15:33:06 +00:00
|
|
|
print("main_menu.gd: ready()")
|
2024-10-06 09:40:42 +00:00
|
|
|
save_game_handle.picked.connect(_on_save_picked)
|
2025-10-07 22:33:15 +00:00
|
|
|
if save_game_handle.get_most_recent_save().current_room == 0:
|
|
|
|
|
continue_button.disabled = true
|
|
|
|
|
continue_button.visible = false
|
|
|
|
|
new_game_button.theme_type_variation = "H1Button"
|
2024-10-07 09:21:36 +00:00
|
|
|
continue_button.pressed.connect(func(): start_game.emit(save_game_handle.get_most_recent_save()))
|
2025-03-23 14:43:04 +00:00
|
|
|
new_game_button.pressed.connect(func(): save_game_handle.pick_save_slot(true))
|
|
|
|
|
load_game_button.pressed.connect(func(): save_game_handle.pick_save_slot(false))
|
2025-03-25 21:34:13 +00:00
|
|
|
load_game_button.disabled = not save_game_handle.has_existing_saves()
|
2025-10-07 22:33:15 +00:00
|
|
|
settings_button.pressed.connect(settings_popup.show_settings)
|
2024-10-07 09:21:36 +00:00
|
|
|
quit_button.pressed.connect(get_tree().quit)
|
2025-10-29 21:37:17 +00:00
|
|
|
credits_button.pressed.connect(roll_credits.emit)
|
2025-12-08 09:43:02 +00:00
|
|
|
|
2025-12-12 15:33:06 +00:00
|
|
|
#State.take_stage(self)
|
2024-10-01 23:32:59 +00:00
|
|
|
|
2024-10-06 09:40:42 +00:00
|
|
|
func _on_save_picked(save: SaveGame):
|
|
|
|
|
start_game.emit(save)
|