Add a main menu scene (#47)

MainMenu.tscn is now project.godot's entry point: Play / Map Editor
(disabled, explains itself - #48 wires it up) / Quit (hidden in web
builds), styled like the rest of the game's menus and reusing the
starfield shader for its background.

Play calls GameState.reset_new_game(), so a second playthrough in the
same process starts fresh instead of inheriting whatever the previous
run left in the autoload - existing tests still load Main.tscn
directly and are unaffected.

Part of the #40 conquest-mechanic breakdown.
This commit is contained in:
Loïc Wisniewski 2026-08-15 14:43:46 +02:00
commit a1fb239a50
7 changed files with 297 additions and 1 deletions

33
MainMenu.gd Normal file
View file

@ -0,0 +1,33 @@
extends Node2D
@onready var play_button: IconButton = $UI/PlayButton
@onready var editor_button: IconButton = $UI/EditorButton
@onready var quit_button: IconButton = $UI/QuitButton
@onready var status_label: Label = $UI/StatusLabel
func _ready() -> void:
play_button.pressed.connect(_on_play_pressed)
editor_button.pressed.connect(_on_editor_pressed)
# #48 wires the real map editor scene up to this button; until then it
# stays visible but explains itself instead of silently doing nothing
# or pointing at a scene that doesn't exist yet.
editor_button.enabled = false
quit_button.pressed.connect(_on_quit_pressed)
quit_button.visible = not OS.has_feature("web")
func _on_play_pressed() -> void:
GameState.reset_new_game()
get_tree().change_scene_to_file("res://Main.tscn")
func _on_editor_pressed() -> void:
if editor_button.enabled:
get_tree().change_scene_to_file("res://PlanetSetupEditor.tscn")
return
status_label.text = "Map editor coming soon"
func _on_quit_pressed() -> void:
get_tree().quit()