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
|
|
|
class_name ThemeStore
|
|
|
|
|
extends RefCounted
|
|
|
|
|
## Theme sets: the built-ins (BuiltinThemes) plus the user's own, saved as JSON
|
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
|
|
|
## in user://themes/ (their pictures and sounds in user://themes/<id>/; see
|
|
|
|
|
## docs/THEMES.md). apply() writes a set into Style's tokens; the app then
|
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
|
|
|
## rebuilds its UI (Main.restyle) so every control picks the new colours up.
|
|
|
|
|
|
|
|
|
|
## Where user sets live (a test points this elsewhere).
|
|
|
|
|
static var DIR := "user://themes/"
|
|
|
|
|
const DEFAULT_ID := "tarot"
|
|
|
|
|
const SETTING := "theme"
|
|
|
|
|
|
|
|
|
|
## Editor rows, in order: [token, label, basic?]. Basic rows show first; the
|
|
|
|
|
## rest sit under "More colours".
|
|
|
|
|
const TOKENS := [
|
|
|
|
|
["ON_BG", "Text on the background", true],
|
|
|
|
|
["CARD", "Card face", true],
|
|
|
|
|
["INK", "Card text", true],
|
|
|
|
|
["MUTED", "Card secondary text", true],
|
|
|
|
|
["THREAD", "Threads", true],
|
|
|
|
|
["ACCENT", "Highlight (lit and selected)", true],
|
|
|
|
|
["TRIM", "Trim and headings", true],
|
|
|
|
|
["GLOW", "Magic sparkles", true],
|
2026-11-15 12:39:37 -06:00
|
|
|
["SELECTED", "Selected card outline", true],
|
|
|
|
|
["CARD_HEAD", "Card header", true],
|
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
|
|
|
["BG", "Background (flat)", false],
|
|
|
|
|
["BG_DEEP", "Background shadow", false],
|
|
|
|
|
["BG_HOVER", "Background buttons, hover", false],
|
|
|
|
|
["PANEL", "Panels (flat)", false],
|
|
|
|
|
["ON_BG_MUTED", "Secondary text on the background", false],
|
|
|
|
|
["CARD_SOFT", "Boxes on cards", false],
|
|
|
|
|
["CARD_HOVER", "Card buttons, hover", false],
|
|
|
|
|
["CARD_SHADE", "Card shading", false],
|
|
|
|
|
["FAINT", "Faint text", false],
|
|
|
|
|
["RULE", "Lines on cards", false],
|
|
|
|
|
["DASH", "Dashed outlines", false],
|
|
|
|
|
["HOVER_ROW", "Result row, hover", false],
|
|
|
|
|
["STRIPE", "Striped rows", false],
|
|
|
|
|
["TRIM_DARK", "Trim, dark", false],
|
|
|
|
|
["THREAD_DARK", "Threads, dark edge", false],
|
|
|
|
|
["ACCENT_DARK", "Highlight, dark", false],
|
|
|
|
|
["LIT", "Lit result", false],
|
|
|
|
|
["FLICK", "Rolling flicker", false],
|
|
|
|
|
["PULSE", "Thread pulse", false],
|
|
|
|
|
["DANGER", "Danger", false],
|
|
|
|
|
["DANGER_INK", "Danger text", false],
|
|
|
|
|
["BAD_INK_ON_BG", "Problem text on the background", false],
|
|
|
|
|
["WARN_BG", "Warning box", false],
|
|
|
|
|
["WARN_INK", "Warning text", false],
|
|
|
|
|
["OK_INK", "Success outlet", false],
|
|
|
|
|
["NO_INK", "Failure outlet", false],
|
|
|
|
|
["REF_INK", "Table link text", false],
|
|
|
|
|
["REF_BG", "Table link box", false],
|
|
|
|
|
["REF_INK_ON_BG", "Table link on the background", false],
|
|
|
|
|
["VALUE_INK", "Value text", false],
|
|
|
|
|
["VALUE_INK_ON_BG", "Value text on the background", false],
|
|
|
|
|
["VALUE_BG", "Value box", false],
|
|
|
|
|
["VALUE_BORDER", "Value box border", false],
|
|
|
|
|
]
|
|
|
|
|
const PATTERNS := [["none", "None"], ["dots", "Dots"], ["stars", "Stars"]]
|
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
|
|
|
const LOGOS := [["fortune_teller", "Morgan (fortune teller)"], ["mascot", "The theme's own mascot"], ["tower", "Tower"], ["none", "None"]]
|
|
|
|
|
const CARD_FRAMES := [["ornate", "Beaded"], ["art", "The theme's own frame"], ["plain", "Plain"]]
|
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
|
|
|
|
|
|
|
|
## The open spread, handed across the scene reload that applies a theme.
|
|
|
|
|
static var carry_board: TowerBoard = null
|
|
|
|
|
## The active set (also kept here so --sample runs, which don't save, keep it).
|
|
|
|
|
static var current: Dictionary = {}
|
|
|
|
|
static var _fallback: Dictionary = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Every set: built-ins first, then the user's, by name.
|
|
|
|
|
static func all() -> Array[Dictionary]:
|
|
|
|
|
var out: Array[Dictionary] = BuiltinThemes.all()
|
|
|
|
|
var mine: Array[Dictionary] = []
|
|
|
|
|
var d := DirAccess.open(DIR)
|
|
|
|
|
if d:
|
|
|
|
|
for f in d.get_files():
|
|
|
|
|
if f.ends_with(".json"):
|
|
|
|
|
var t: Variant = JSON.parse_string(FileAccess.get_file_as_string(DIR + f))
|
|
|
|
|
if t is Dictionary:
|
|
|
|
|
t["builtin"] = false
|
|
|
|
|
mine.append(t)
|
|
|
|
|
mine.sort_custom(func(a: Dictionary, b: Dictionary) -> bool: return str(a.get("name", "")).naturalnocasecmp_to(str(b.get("name", ""))) < 0)
|
|
|
|
|
out.append_array(mine)
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func find(id: String) -> Dictionary:
|
|
|
|
|
for t in all():
|
|
|
|
|
if str(t.get("id", "")) == id:
|
|
|
|
|
return t
|
|
|
|
|
return BuiltinThemes.TAROT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Saves a user set and returns its id. Built-in ids can't be overwritten:
|
|
|
|
|
## saving one makes a copy.
|
|
|
|
|
static func save(t: Dictionary) -> String:
|
|
|
|
|
var out := t.duplicate(true)
|
|
|
|
|
var id := str(out.get("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
|
|
|
# A copy of a built-in theme uses the built-in's files: name them in full.
|
|
|
|
|
if bool(t.get("builtin", false)) or _is_builtin(id):
|
|
|
|
|
out = ThemeAssets.pin_paths(out, ThemeAssets.folder(t))
|
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
|
|
|
if id == "" or bool(out.get("builtin", false)) or _is_builtin(id):
|
|
|
|
|
id = _new_id(str(out.get("name", "My theme")))
|
|
|
|
|
out["id"] = id
|
|
|
|
|
out.erase("builtin")
|
|
|
|
|
DirAccess.make_dir_recursive_absolute(DIR)
|
|
|
|
|
var f := FileAccess.open(DIR + id + ".json", FileAccess.WRITE)
|
|
|
|
|
if f:
|
|
|
|
|
f.store_string(JSON.stringify(out, "\t"))
|
|
|
|
|
return id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func delete(id: String) -> void:
|
|
|
|
|
if not _is_builtin(id):
|
|
|
|
|
DirAccess.remove_absolute(DIR + id + ".json")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Writes a set into Style. Tokens the set doesn't list get the fallback value,
|
|
|
|
|
## so switching sets never leaves colours behind.
|
|
|
|
|
static func apply(t: Dictionary) -> void:
|
|
|
|
|
var sc: Script = Style
|
|
|
|
|
if _fallback.is_empty():
|
|
|
|
|
for row: Array in TOKENS:
|
|
|
|
|
_fallback[row[0]] = sc.get(row[0])
|
|
|
|
|
var colors: Dictionary = t.get("colors", {})
|
|
|
|
|
for row: Array in TOKENS:
|
|
|
|
|
var tok: String = row[0]
|
|
|
|
|
sc.set(tok, Color.from_string(str(colors[tok]), _fallback[tok]) if colors.has(tok) else _fallback[tok])
|
2026-11-15 12:39:37 -06:00
|
|
|
if not colors.has("CARD_HEAD"):
|
|
|
|
|
# Darker than the card face, so card text stays readable in every theme.
|
|
|
|
|
Style.CARD_HEAD = Style.CARD.lerp(Style.CARD_SHADE, 0.85)
|
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
|
|
|
Style.BG_FILL = t.get("background", {})
|
|
|
|
|
Style.PANEL_FILL = t.get("panel", {})
|
|
|
|
|
Style.PATTERN = str(t.get("pattern", "dots"))
|
|
|
|
|
Style.LOGO = str(t.get("logo", "none"))
|
2026-11-10 18:20:46 -06:00
|
|
|
Style.CARD_FRAME = str(t.get("card_frame", "plain"))
|
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
|
|
|
Style.set_fonts(str(t.get("font_body", "")), str(t.get("font_display", "")))
|
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
|
|
|
current = t
|
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
|
|
|
ThemeAssets.clear_cache()
|
|
|
|
|
FrameSet.active = FrameSet.for_theme(t)
|
|
|
|
|
ThreadStrip.active = ThreadStrip.for_theme(t)
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
## Applies a set, remembers it, and rebuilds the app's UI around the open spread.
|
|
|
|
|
static func use(m: Main, t: Dictionary) -> void:
|
|
|
|
|
apply(t)
|
|
|
|
|
if m.state:
|
|
|
|
|
m.state.set_setting(SETTING, str(t.get("id", DEFAULT_ID)))
|
|
|
|
|
m.state.save()
|
|
|
|
|
m._save_now()
|
|
|
|
|
carry_board = m.data
|
Sheets phase B: main menu, Sheets list, sheet editor
- Main menu (Spreads, Sheets, Settings, Quit) on the theme background,
with recent spreads and sheets; logo or ☰ returns to it.
- Sheets: data model, store, templates, snapshot undo; New sheet dialog
(blank or a template); editor with folder tabs, snap-grid canvas on the
spread background, field palette, inspector, Play/Build, status strip.
- Field kinds: Number, Text box (BBCode, live {@name}), Heading.
- PaletteList shared by the card and field palettes; shared top bar brand.
- Keys go to the screen that shows; theme reloads keep the screen.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 15:53:56 -06:00
|
|
|
if m.screens:
|
|
|
|
|
m.screens.keep_for_reload()
|
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
|
|
|
m.get_tree().reload_current_scene.call_deferred()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Every token's colour for a set (its own, else the fallback), as "#hex".
|
|
|
|
|
static func resolved_colors(t: Dictionary) -> Dictionary:
|
|
|
|
|
var colors: Dictionary = t.get("colors", {})
|
|
|
|
|
var out := {}
|
|
|
|
|
for row: Array in TOKENS:
|
|
|
|
|
var fb: Color = _fallback.get(row[0], (Style as Script).get(row[0]))
|
|
|
|
|
out[row[0]] = str(colors[row[0]]) if colors.has(row[0]) else "#" + fb.to_html(true)
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _is_builtin(id: String) -> bool:
|
|
|
|
|
for t in BuiltinThemes.all():
|
|
|
|
|
if t["id"] == id:
|
|
|
|
|
return true
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _new_id(name: String) -> String:
|
|
|
|
|
var base := name.to_lower().replace(" ", "-").validate_filename()
|
|
|
|
|
if base == "":
|
|
|
|
|
base = "theme"
|
|
|
|
|
var id := base
|
|
|
|
|
var n := 2
|
|
|
|
|
while _is_builtin(id) or FileAccess.file_exists(DIR + id + ".json"):
|
|
|
|
|
id = "%s-%d" % [base, n]
|
|
|
|
|
n += 1
|
|
|
|
|
return id
|