fix(theme): drift-guard test, interactive stylebox states, ThemeKeys font consts, richer showcase (whole-branch review)
- build_game_theme.gd: extract build_theme() as a static func returning the fully-built Theme; _init() is now a thin save+quit wrapper. Enables a test to build a fresh Theme in memory without running the SceneTree main loop. - test_theme_resource.gd: add test_committed_tres_matches_builder() — builds a fresh Theme via the preloaded builder and compares bg_color against the committed game_theme.tres for PrimaryCTA/normal, ParchmentCard/panel, and DarkPanel/panel. Catches "palette/builder changed, .tres not regenerated." - build_game_theme.gd: give Tab, TabActive, and Chip explicit hover/pressed/ focus styleboxes (focus is StyleBoxEmpty to suppress the default ring) so they no longer fall back to Godot's default gray button on interaction. Add a disabled stylebox + font_disabled_color to PrimaryCTA for the unaffordable-CTA state the 2a shell will need. - theme_keys.gd: add HEADING/ACCENT/MONO font-role consts (kept out of ALL, which is stylebox-variation-only); build_game_theme.gd and theme_showcase.gd now reference them instead of raw StringName literals. - theme_showcase.gd: add an italic DM-voice RichTextLabel (EB Garamond italic face, spec §6) and two semantic-coloured chips (BLOOD for aggressive actions, GOLD for pay/faith) alongside the existing neutral chip, demonstrating the script-applied colouring from spec §5.3. - dark_bay.gdshader: comment noting the stripe uses FRAGCOORD (screen-space) while the vignette uses UV (node-local) — intended for full-bleed use. - surfaces/*.gd: ## comments documenting the accepted deviation from spec §5.4 (uniforms set at runtime from Palette rather than baked into the .tscn) — no behavior change. - Regenerated game_theme.tres via build_game_theme.gd. Full suite: 125/125 (was 124, +1 drift-guard test). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GFDm1ku9WDUacK2S78m2be
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
extends "res://addons/gut/test.gd"
|
||||
|
||||
const ThemeKeys = preload("res://scripts/theme/theme_keys.gd")
|
||||
const Builder = preload("res://scripts/theme/build_game_theme.gd")
|
||||
const THEME_PATH := "res://assets/theme/game_theme.tres"
|
||||
|
||||
|
||||
@@ -27,3 +28,24 @@ func test_cta_has_normal_stylebox():
|
||||
func test_default_font_is_set():
|
||||
var t: Theme = load(THEME_PATH)
|
||||
assert_true(t.default_font is FontFile)
|
||||
|
||||
|
||||
func test_committed_tres_matches_builder():
|
||||
# Catches "palette/builder changed but nobody regenerated game_theme.tres."
|
||||
# Preloading the builder script and calling its static build_theme() does
|
||||
# NOT run _init() (that only fires on .new()), so this is side-effect-free.
|
||||
var fresh: Theme = Builder.build_theme()
|
||||
var committed: Theme = load(THEME_PATH)
|
||||
|
||||
var checks := [
|
||||
[ThemeKeys.PRIMARY_CTA, &"normal"],
|
||||
[ThemeKeys.PARCHMENT_CARD, &"panel"],
|
||||
[ThemeKeys.DARK_PANEL, &"panel"],
|
||||
]
|
||||
for pair in checks:
|
||||
var variation: StringName = pair[0]
|
||||
var state: StringName = pair[1]
|
||||
var fresh_box: StyleBoxFlat = fresh.get_stylebox(state, variation)
|
||||
var committed_box: StyleBoxFlat = committed.get_stylebox(state, variation)
|
||||
assert_eq(fresh_box.bg_color, committed_box.bg_color,
|
||||
"stale game_theme.tres — %s/%s bg_color drifted from the builder; re-run build_game_theme.gd" % [variation, state])
|
||||
|
||||
Reference in New Issue
Block a user