2026-11-25 15:36:55 -06:00
|
|
|
extends AppTestBase
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
## Theme sets: applying built-ins sets Style tokens and fills, saving and
|
|
|
|
|
## deleting a user set, and the Theme dialog building its editors.
|
2026-11-25 15:36:55 -06:00
|
|
|
## Run: tools/run_tests.sh theme
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
|
|
|
|
|
|
2026-11-25 15:36:55 -06:00
|
|
|
func run() -> void:
|
2026-11-10 19:53:07 -06:00
|
|
|
if not require_sample():
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
return
|
|
|
|
|
ThemeStore.DIR = OS.get_temp_dir().path_join("tt_theme_test_%d/" % OS.get_process_id())
|
2026-11-10 19:53:07 -06:00
|
|
|
if not await start_main():
|
|
|
|
|
return
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
_test_apply()
|
|
|
|
|
_test_save_delete()
|
|
|
|
|
await _test_dialog()
|
Theme fonts: 13 bundled families and text/title pickers in the theme editor
Standard (Inter, Source Sans 3, Lora, Rokkitt), easy to read (Atkinson
Hyperlegible, Lexend, Andika, OpenDyslexic) and themed title faces (Cinzel,
IM Fell English, Uncial Antiqua, Orbitron, Special Elite). All OFL except
Special Elite (Apache 2.0); licence files sit beside the fonts. FontCatalog
builds faces, synthesising missing bold/italic.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:16:39 -06:00
|
|
|
_test_fonts()
|
2026-11-10 18:20:46 -06:00
|
|
|
_test_own_colours()
|
2026-11-10 18:26:02 -06:00
|
|
|
await _test_sparkles()
|
2026-11-10 19:53:07 -06:00
|
|
|
finish()
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_apply() -> void:
|
|
|
|
|
_check(ThemeStore.current.get("id") == "tarot", "Tarot is the default set")
|
|
|
|
|
_check(Style.BG == Color("#2c0744"), "Tarot sets the background colour")
|
|
|
|
|
_check(Style.fill_texture(Style.BG_FILL) != null, "Tarot's background is a gradient")
|
|
|
|
|
_check(BoardView.pattern_texture("stars") != null and BoardView.pattern_texture("none") == null, "patterns build")
|
|
|
|
|
ThemeStore.apply(BuiltinThemes.FELT)
|
|
|
|
|
_check(Style.BG == Color("#1f4a39"), "Felt falls back to the original colours")
|
|
|
|
|
_check(Style.PATTERN == "dots", "Felt uses dots")
|
|
|
|
|
_check(Style.panel_box() is StyleBoxFlat, "a solid panel fill is a flat box")
|
|
|
|
|
ThemeStore.apply(BuiltinThemes.TAROT)
|
|
|
|
|
_check(Style.panel_box() is StyleBoxTexture, "a gradient panel fill is a texture box")
|
|
|
|
|
var cols := ThemeStore.resolved_colors(BuiltinThemes.FELT)
|
|
|
|
|
_check(cols.size() == ThemeStore.TOKENS.size(), "resolved colours cover every token")
|
|
|
|
|
|
|
|
|
|
|
Theme fonts: 13 bundled families and text/title pickers in the theme editor
Standard (Inter, Source Sans 3, Lora, Rokkitt), easy to read (Atkinson
Hyperlegible, Lexend, Andika, OpenDyslexic) and themed title faces (Cinzel,
IM Fell English, Uncial Antiqua, Orbitron, Special Elite). All OFL except
Special Elite (Apache 2.0); licence files sit beside the fonts. FontCatalog
builds faces, synthesising missing bold/italic.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:16:39 -06:00
|
|
|
func _test_fonts() -> void:
|
|
|
|
|
for id: String in FontCatalog.FAMILIES:
|
|
|
|
|
var fam: Dictionary = FontCatalog.FAMILIES[id]
|
|
|
|
|
for k: String in ["regular", "bold", "italic"]:
|
|
|
|
|
if fam.has(k):
|
|
|
|
|
_check(ResourceLoader.exists(FontCatalog.DIR + fam[k]), "%s %s file exists" % [id, k])
|
|
|
|
|
for zoom: bool in [false, true]:
|
|
|
|
|
var f := FontCatalog.face(id, 700, true, zoom)
|
|
|
|
|
_check(f is FontVariation and (f as FontVariation).base_font != null, "%s builds a bold italic face" % id)
|
|
|
|
|
_check(FontCatalog.options("body").size() < FontCatalog.FAMILIES.size(), "title-only fonts aren't offered for text")
|
|
|
|
|
var t := BuiltinThemes.TAROT.duplicate(true)
|
|
|
|
|
t["font_body"] = "lexend"
|
|
|
|
|
t["font_display"] = "cinzel"
|
|
|
|
|
ThemeStore.apply(t)
|
|
|
|
|
_check(Style.BODY_FONT == "lexend" and Style.DISPLAY_FONT == "cinzel", "a theme sets both fonts")
|
|
|
|
|
t["font_body"] = "uncial"
|
|
|
|
|
ThemeStore.apply(t)
|
|
|
|
|
_check(Style.BODY_FONT == FontCatalog.DEFAULT_BODY, "a title-only font falls back for text")
|
|
|
|
|
ThemeStore.apply(BuiltinThemes.TAROT)
|
|
|
|
|
_check(Style.BODY_FONT == "atkinson", "Tarot uses Atkinson for text")
|
|
|
|
|
|
|
|
|
|
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
func _test_save_delete() -> void:
|
|
|
|
|
var t := BuiltinThemes.TAROT.duplicate(true)
|
|
|
|
|
t["name"] = "Night Sky"
|
|
|
|
|
var id := ThemeStore.save(t)
|
|
|
|
|
_check(id != "tarot", "saving a built-in makes a new id: " + id)
|
|
|
|
|
_check(ThemeStore.find(id).get("name") == "Night Sky", "the saved set is found")
|
|
|
|
|
_check(ThemeStore.all().size() == BuiltinThemes.all().size() + 1, "the saved set is listed")
|
|
|
|
|
ThemeStore.delete("tarot")
|
|
|
|
|
_check(ThemeStore.find("tarot").get("builtin", false), "built-ins can't be deleted")
|
|
|
|
|
ThemeStore.delete(id)
|
|
|
|
|
_check(ThemeStore.all().size() == BuiltinThemes.all().size(), "the user set is deleted")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_dialog() -> void:
|
|
|
|
|
var d := ThemeDialog.new(main)
|
|
|
|
|
main.add_child(d)
|
|
|
|
|
await _frames()
|
|
|
|
|
_check(d._content.find_children("*", "FillEditor", true, false).size() == 2, "background and panel fill editors")
|
2026-11-14 14:26:39 -06:00
|
|
|
_check(bool(d._work.get("builtin", false)) and not d._delete_button.visible, "a built-in theme doesn't offer Delete")
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
var basic := d._content.find_children("*", "ColorPickerButton", true, false).size()
|
|
|
|
|
d._more = true
|
|
|
|
|
d._rebuild()
|
|
|
|
|
await _frames()
|
|
|
|
|
var all := d._content.find_children("*", "ColorPickerButton", true, false).size()
|
|
|
|
|
_check(all > basic, "More colours shows more swatches (%d > %d)" % [all, basic])
|
|
|
|
|
var fe := d._content.find_children("*", "FillEditor", true, false)[0] as FillEditor
|
|
|
|
|
fe._set_kind(1)
|
|
|
|
|
_check((fe.fill["colors"] as Array).size() >= 2 and d._dirty, "a gradient gets two colours and marks the set changed")
|
|
|
|
|
d.close()
|
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
2026-11-10 18:20:46 -06:00
|
|
|
func _test_own_colours() -> void:
|
|
|
|
|
var t := RollTable.new()
|
|
|
|
|
t.id = "a"
|
|
|
|
|
t.color = "#2f8a4f"
|
|
|
|
|
var e := TableEntry.new("e1", "x")
|
|
|
|
|
e.add_pipe("b")
|
|
|
|
|
e.pipe_color["b"] = "#c04a86"
|
|
|
|
|
t.entries.append(e)
|
|
|
|
|
var back := RollTable.from_dict(t.to_dict())
|
|
|
|
|
_check(back.color == "#2f8a4f", "a card's colour survives saving")
|
|
|
|
|
_check(back.entries[0].pipe_color.get("b") == "#c04a86", "a thread's colour survives saving")
|
|
|
|
|
back.entries[0].remove_pipe("b")
|
|
|
|
|
_check(back.entries[0].pipe_color.is_empty(), "deleting a thread drops its colour")
|
|
|
|
|
var card := main.card_for(main.data.tables[0].id)
|
|
|
|
|
if card and card.frame:
|
|
|
|
|
main.data.get_table(card.table.id).color = "#b8382c"
|
|
|
|
|
card.rebuild()
|
|
|
|
|
_check(card.frame.material == CardFrame.material_for(Color("#b8382c")), "the frame takes the card's colour")
|
|
|
|
|
|
|
|
|
|
|
2026-11-10 18:26:02 -06:00
|
|
|
func _test_sparkles() -> void:
|
|
|
|
|
var card := main.card_for(main.data.tables[0].id)
|
|
|
|
|
var layer := card.get_parent()
|
|
|
|
|
var before := layer.find_children("*", "CPUParticles2D", false, false).size()
|
|
|
|
|
card.sparkle(card.table.entries[0].id)
|
|
|
|
|
_check(layer.find_children("*", "CPUParticles2D", false, false).size() == before + 1, "a landing result bursts sparkles")
|
|
|
|
|
var pipes := main.board.pipes
|
|
|
|
|
pipes.pulse_key = pipes._paths.keys()[0] if not pipes._paths.is_empty() else ""
|
|
|
|
|
await _frames()
|
|
|
|
|
_check(pipes._trail != null and pipes._trail.emitting, "the pulse trails sparkles")
|
|
|
|
|
pipes.pulse_key = ""
|
|
|
|
|
await _frames()
|
|
|
|
|
_check(not pipes._trail.emitting, "the trail stops with the pulse")
|
|
|
|
|
|