Theme tiers 1-2: theme folders, mascot recolour, background scene and tile, frame sets, picture threads, sounds; nine new built-in themes
- ThemeAssets loads a theme's files; FrameSet + GradientMap (3-stop) generalise the card frame;
ThreadStrip draws threads from a picture; BoardBackdrop draws scene and tile; MascotArt
recolours Morgan by role (logo SVG now uses the Keep File importer); SoundBoard plays
roll / card turn / thread / click / ambient with View > Sound levels.
- Vaporwave, Synthwave, Cozy Autumn, Rustic, Woodsy, Sky Blue, Frutiger Aero, Gothic, Terminal:
generated art (tools/theme_art), sounds (tools/theme_sounds), settings (tools/theme_defs).
- Ten OFL fonts; --theme=<id> flag; docs/THEMES.md format spec; test_theme_assets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:05:40 -06:00
|
|
|
extends TestBase
|
|
|
|
|
## Theme files: every built-in theme's pictures, sounds and fonts load; frame
|
|
|
|
|
## sets, thread strips, the backdrop and the recoloured mascot build; a copy of
|
|
|
|
|
## a built-in keeps its file paths; the sound board follows the volume.
|
|
|
|
|
## Run: godot --headless --path . -s res://tests/test_theme_assets.gd -- --sample
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
|
|
|
|
if not require_sample():
|
|
|
|
|
return
|
|
|
|
|
ThemeStore.DIR = OS.get_temp_dir().path_join("tt_theme_assets_%d/" % OS.get_process_id())
|
|
|
|
|
if not await start_main():
|
|
|
|
|
return
|
|
|
|
|
_test_builtin_files()
|
|
|
|
|
_test_mascot()
|
|
|
|
|
_test_pin_paths()
|
|
|
|
|
_test_frames_and_threads()
|
|
|
|
|
_test_sounds()
|
|
|
|
|
ThemeStore.apply(BuiltinThemes.TAROT)
|
|
|
|
|
finish()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_builtin_files() -> void:
|
|
|
|
|
for theme_set in BuiltinThemes.all():
|
|
|
|
|
var id := str(theme_set["id"])
|
|
|
|
|
for role: String in ["body", "display"]:
|
|
|
|
|
var font_id := str(theme_set.get("font_" + role, FontCatalog.DEFAULT_BODY))
|
|
|
|
|
_check(FontCatalog.FAMILIES.has(font_id), "%s: %s font %s is bundled" % [id, role, font_id])
|
|
|
|
|
var pinned := ThemeAssets.pin_paths(theme_set, ThemeAssets.folder(theme_set))
|
|
|
|
|
for key: Array in ThemeAssets.FILE_KEYS:
|
|
|
|
|
var value: Variant = pinned.get(key[0]) if key.size() == 1 else (pinned.get(key[0], {}) as Dictionary).get(key[1])
|
|
|
|
|
if value != null and str(value) != "" and key[0] != "mascot":
|
|
|
|
|
_check(ThemeAssets.texture(theme_set, str(value)) != null, "%s: %s loads" % [id, str(value)])
|
|
|
|
|
var sounds: Dictionary = theme_set.get("sounds", {})
|
|
|
|
|
for event: String in sounds:
|
|
|
|
|
_check(ThemeAssets.sound(theme_set, str(sounds[event])) != null, "%s: %s sound loads" % [id, event])
|
|
|
|
|
if str(theme_set.get("card_frame", "")) == "art":
|
|
|
|
|
_check(FrameSet.for_theme(theme_set) != null, "%s: its frame set builds" % id)
|
|
|
|
|
if theme_set.has("thread"):
|
|
|
|
|
_check(ThreadStrip.for_theme(theme_set) != null, "%s: its thread strip builds" % id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_mascot() -> void:
|
|
|
|
|
var drawn := MascotArt.file_colors(MascotArt.MORGAN)
|
|
|
|
|
_check(drawn.size() == MascotArt.ROLES.size(), "Morgan's file has every colour role")
|
|
|
|
|
_eq(drawn.get("inner_line"), "#390853", "the inner lines keep the old background purple")
|
|
|
|
|
var svg := "<svg width=\"10\"><path id=\"cloth\" fill=\"#111111\" d=\"M0 0\"/><path id=\"eye\" d=\"M1 1\"/><path id=\"other\" fill=\"#222222\"/></svg>"
|
|
|
|
|
var out := MascotArt.recolour(svg, {"cloth": "#abcdef", "eye": "#00ff00"})
|
|
|
|
|
_check(out.contains("id=\"cloth\" fill=\"#abcdef\""), "a role's fill is replaced")
|
|
|
|
|
_check(out.contains("fill=\"#00ff00\""), "a role with no fill gets one")
|
|
|
|
|
_check(out.contains("fill=\"#222222\""), "parts without a role keep their colour")
|
|
|
|
|
var theme_set := {"logo": "fortune_teller", "mascot_colors": {"cloth": "#ff0000"}}
|
|
|
|
|
var tex := MascotArt.texture(theme_set, 64)
|
|
|
|
|
_check(tex != null and tex.get_width() == 64, "the recoloured mascot renders at the asked size")
|
|
|
|
|
_check(MascotArt.texture({"logo": "tower"}, 64) == null, "the tower logo has no mascot picture")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_pin_paths() -> void:
|
|
|
|
|
var builtin := {"id": "demo", "builtin": true, "mascot": "m.svg",
|
|
|
|
|
"frame": {"corner": "c.svg", "edge": "user://elsewhere/e.svg"}, "sounds": {"roll": "sounds/roll.ogg"}}
|
|
|
|
|
var pinned := ThemeAssets.pin_paths(builtin, ThemeAssets.folder(builtin))
|
|
|
|
|
_eq(pinned["mascot"], "res://themes/demo/m.svg", "a relative file gets the built-in folder")
|
|
|
|
|
_eq(pinned["frame"]["edge"], "user://elsewhere/e.svg", "a full path is kept")
|
|
|
|
|
_eq(pinned["sounds"]["roll"], "res://themes/demo/sounds/roll.ogg", "sound paths are pinned too")
|
|
|
|
|
var saved_id := ThemeStore.save(builtin)
|
|
|
|
|
var saved := ThemeStore.find(saved_id)
|
|
|
|
|
_eq(str(saved.get("frame", {}).get("corner", "")), "res://themes/demo/c.svg", "a saved copy of a built-in keeps its files")
|
|
|
|
|
ThemeStore.delete(saved_id)
|
|
|
|
|
var mine := {"id": "mine", "frame": {"corner": "c.svg"}}
|
|
|
|
|
_eq(ThemeAssets.resolve(mine, "c.svg"), ThemeStore.DIR + "mine/c.svg", "a user theme's files sit in its own folder")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_frames_and_threads() -> void:
|
|
|
|
|
for theme_set in BuiltinThemes.all():
|
|
|
|
|
ThemeStore.apply(theme_set)
|
|
|
|
|
var backdrop := BoardBackdrop.new(theme_set)
|
|
|
|
|
_check(backdrop != null, "%s: the backdrop builds" % theme_set["id"])
|
|
|
|
|
if FrameSet.active and FrameSet.active.corner_fixed:
|
|
|
|
|
var frame := CardFrame.new()
|
|
|
|
|
_check(frame._fixed != null, "%s: fixed corner pieces get their own layer" % theme_set["id"])
|
2026-11-14 13:52:53 -06:00
|
|
|
main.add_child(frame)
|
|
|
|
|
frame.size = Vector2(300, 200)
|
|
|
|
|
frame.size = Vector2(420, 260)
|
|
|
|
|
_check(frame._fixed.size == frame.size, "%s: the corner layer follows the frame's size (so it redraws on resize)" % theme_set["id"])
|
Theme tiers 1-2: theme folders, mascot recolour, background scene and tile, frame sets, picture threads, sounds; nine new built-in themes
- ThemeAssets loads a theme's files; FrameSet + GradientMap (3-stop) generalise the card frame;
ThreadStrip draws threads from a picture; BoardBackdrop draws scene and tile; MascotArt
recolours Morgan by role (logo SVG now uses the Keep File importer); SoundBoard plays
roll / card turn / thread / click / ambient with View > Sound levels.
- Vaporwave, Synthwave, Cozy Autumn, Rustic, Woodsy, Sky Blue, Frutiger Aero, Gothic, Terminal:
generated art (tools/theme_art), sounds (tools/theme_sounds), settings (tools/theme_defs).
- Ten OFL fonts; --theme=<id> flag; docs/THEMES.md format spec; test_theme_assets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:05:40 -06:00
|
|
|
frame.free()
|
|
|
|
|
if ThreadStrip.active:
|
|
|
|
|
var rid := RenderingServer.canvas_item_create()
|
|
|
|
|
ThreadStrip.active.add_to(rid, PipeLayer.curve(Vector2.ZERO, Vector2(300, 80)), Style.THREAD, Style.THREAD_DARK)
|
|
|
|
|
RenderingServer.free_rid(rid)
|
|
|
|
|
ThemeStore.apply(BuiltinThemes.FELT)
|
|
|
|
|
_check(FrameSet.active == null and ThreadStrip.active == null, "Felt has plain cards and drawn threads")
|
|
|
|
|
ThemeStore.apply(BuiltinThemes.TAROT)
|
|
|
|
|
_check(FrameSet.active != null and FrameSet.active.mid == 0.30, "Tarot keeps the beaded frame and its old shading")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_sounds() -> void:
|
|
|
|
|
_check(main.sound != null, "the app has a sound board")
|
|
|
|
|
if main.sound == null:
|
|
|
|
|
return
|
|
|
|
|
_check(main.sound.has("roll"), "Tarot has a roll sound")
|
|
|
|
|
main.sound.set_volume(0.0)
|
|
|
|
|
_eq(main.sound.level_name(), "Off", "volume 0 reads as Off")
|
|
|
|
|
main.sound.play("roll")
|
|
|
|
|
var playing := main.sound._voices.any(func(voice: AudioStreamPlayer) -> bool: return voice.playing)
|
|
|
|
|
_check(not playing, "nothing plays when the sound is off")
|
|
|
|
|
main.sound.set_volume(SoundBoard.DEFAULT_VOLUME)
|
|
|
|
|
_eq(main.sound.level_name(), "Quiet", "the default level is Quiet")
|