feat(title): TitleScreen composition, menu + selection, boot scene

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-11 10:47:44 -05:00
parent c6d513c966
commit a77bf03ee4
6 changed files with 378 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
extends "res://addons/gut/test.gd"
const SCENE := "res://scenes/title/TitleScreen.tscn"
func _title() -> TitleScreen:
var t = load(SCENE).instantiate()
add_child_autofree(t) # runs _ready()
return t
func _index_of(t: TitleScreen, action: StringName) -> int:
for i in range(t._rows.size()):
if t._rows[i].get_meta("action") == action:
return i
return -1
func test_six_menu_rows_each_with_an_action():
var t := _title()
assert_eq(t._rows.size(), 6)
for row in t._rows:
assert_true(row.has_meta("action"))
func test_down_moves_selection():
var t := _title()
assert_eq(t._sel, 0)
t._move(1)
assert_eq(t._sel, 1)
func test_up_from_first_wraps_to_last():
var t := _title()
t._move(-1)
assert_eq(t._sel, t._rows.size() - 1)
func test_new_game_and_quit_emit_their_action():
var t := _title()
# Isolate the signal seam so the test does not actually change scene / quit.
t.menu_activated.disconnect(t._on_menu_activated)
watch_signals(t)
t._activate(_index_of(t, &"new_game"))
assert_signal_emitted_with_parameters(t, "menu_activated", [&"new_game"])
t._activate(_index_of(t, &"quit"))
assert_signal_emitted_with_parameters(t, "menu_activated", [&"quit"])
func test_footer_shows_version():
var t := _title()
assert_string_contains(t._footer_left.text, Version.new().string())

View File

@@ -0,0 +1 @@
uid://driqdhodq83g2