wayfarers_wanderer/boot/main_menu.gd
Jonas Reith 67862a46f3 Add boot flow, save-system skeleton, and Equipment skeleton
boot/: opening_screen (attribution -> title/flavor text placeholder,
explicitly marked TODO for a later real cinematic, skippable by
keypress/click) -> main_menu (Neues Spiel/Fortsetzen/Optionen/Credits/
Beenden, ConfirmationDialog for overwrite-existing-save) -> options_menu
(TabContainer with 4 empty placeholder categories: Grafik/Sound/
Steuerung/Spieloptionen) and credits_screen, both just navigable stubs.
project.godot's run/main_scene now points at boot/opening_screen.tscn
instead of directly at the gameplay scene.

autoload/save_manager.gd: new SaveManager singleton. Deliberately
minimal — persists only a timestamp to user://savegame.json — but a
real, working has_save()/save_game()/load_game()/start_new_game()
round trip, enough to back the menu's Start/Continue/overwrite-confirm
logic without inventing game state that doesn't exist yet.

player/equipment/: Equipment (Node) + EquipmentItem (Resource) stub
classes per the user's explicit ask for a "class diagram skeleton" to
build on later — exported fields and empty TODO methods, no logic.
Wired as a child of world/island.tscn's real Player (not player.tscn,
which is only a debug prototype scene, not the actual game's player).
player.gd's new `equipment` onready var uses get_node_or_null() since
that child only exists on the real player, not every scene reusing
this script.

Verified headless: all new boot scenes load cleanly, a full boot smoke
test via run/main_scene succeeds, and — since button-click navigation
can't be simulated headlessly — SaveManager's actual save/load/
overwrite/cleanup cycle was exercised directly and behaves correctly
(has_save flips true/false correctly, loaded data matches what was
saved). Manual in-editor check of the menu navigation itself is still
needed and not yet done.
2026-08-27 09:21:15 +02:00

46 lines
1.5 KiB
GDScript

extends Control
const GAMEPLAY_SCENE := "res://world/island.tscn"
@onready var start_button: Button = $Panel/ButtonList/StartButton
@onready var continue_button: Button = $Panel/ButtonList/ContinueButton
@onready var options_button: Button = $Panel/ButtonList/OptionsButton
@onready var credits_button: Button = $Panel/ButtonList/CreditsButton
@onready var exit_button: Button = $Panel/ButtonList/ExitButton
@onready var overwrite_dialog: ConfirmationDialog = $OverwriteConfirmDialog
func _ready() -> void:
continue_button.disabled = not SaveManager.has_save()
start_button.pressed.connect(_on_start_pressed)
continue_button.pressed.connect(_on_continue_pressed)
options_button.pressed.connect(_on_options_pressed)
credits_button.pressed.connect(_on_credits_pressed)
exit_button.pressed.connect(_on_exit_pressed)
overwrite_dialog.confirmed.connect(_on_overwrite_confirmed)
func _on_start_pressed() -> void:
if SaveManager.has_save():
overwrite_dialog.popup_centered()
else:
_start_new_game()
func _on_overwrite_confirmed() -> void:
_start_new_game()
func _start_new_game() -> void:
SaveManager.start_new_game()
get_tree().change_scene_to_file(GAMEPLAY_SCENE)
func _on_continue_pressed() -> void:
SaveManager.load_game()
get_tree().change_scene_to_file(GAMEPLAY_SCENE)
func _on_options_pressed() -> void:
get_tree().change_scene_to_file("res://boot/options_menu.tscn")
func _on_credits_pressed() -> void:
get_tree().change_scene_to_file("res://boot/credits_screen.tscn")
func _on_exit_pressed() -> void:
get_tree().quit()