Play-side UI: BBCode rendering, hover details, card decks, variables, copy, ref pipes
- Cards, result chips and the Earlier list render BBCode with RichTextLabel;
Play rows show [[refs]] as teal chips and {vars} in brass, lit rows show the
rolled text; missing/unset/too-deep markers are red.
- Hover pop-up (DetailsPopup) for table headers, entries with details, result
chips and [url] metas in rendered text; items with details get a small ⓘ.
- Card-mode tables show cards left and Reshuffle; chips note reshuffles.
- Local state: decks, persistent variables and history per collection via
StateStore (memory only when saving is off); delete_table forgets its state.
- Result tray: Copy menu (text / BBCode / with details) and a Variables tab
(edit, re-roll, clear; last roll's chain variables read-only).
- Reference pipes drawn dashed from TextExpander.references; lit when used.
- Build mode: weight field, per-entry and table details editors, a gear
button for table settings, pipe popover (count, save as, remove), range
clamps use min_value(); Build cards are 300px wide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:43:01 -06:00
|
|
|
|
class_name RichText
|
|
|
|
|
|
extends RefCounted
|
|
|
|
|
|
## BBCode display helpers: RichTextLabels in the app's fonts, a readable preview
|
|
|
|
|
|
## of entry text with [[references]] and {variables}, and colouring for
|
|
|
|
|
|
## TextExpander's internal markers in rolled results.
|
|
|
|
|
|
|
|
|
|
|
|
## Marker shown after items that have hover details.
|
|
|
|
|
|
const INFO_MARK := "ⓘ"
|
|
|
|
|
|
|
|
|
|
|
|
const _VAR_PATTERN := "\\{(@?[A-Za-z_][A-Za-z0-9_]*)(?:\\|([^{}\\[\\]\\n]+))?\\}"
|
|
|
|
|
|
const _COUNT_PATTERN := "^(?:(\\d+)\\s*[x×]|(\\d*[dD]\\d+(?:\\s*[+-]\\s*\\d+)?))\\s+(\\S.*)$"
|
|
|
|
|
|
|
|
|
|
|
|
static var _var_re: RegEx
|
|
|
|
|
|
static var _count_re: RegEx
|
Logic cards UI: choice pop-up, card kinds, Build creation and settings, tray
- ChoiceDialog: card-styled pop-up for pick (option rows with details, Random,
1-9 / R keys), number (spin box with min/max/default, Enter) and text.
Cancel, Esc, freeing the dialog, a new roll or a collection switch all
answer null through a separate Reply object, so a roll never hangs.
- Main: real prompt hook; the steps so far light on the board and in the
tray before each question; a roll with questions shows the rest at once;
a new roll cancels an open question cleanly; refresh_live() re-renders
variable, sheet and question text only after rolls and edits.
- TableCard: "?" badge and question for choice cards, loop icon, rule chip
and Each time / Afterwards rows, compact live variable cards (reset in
Build), live sheet cards with one outlet, expression-dice subtitles,
effect chips in Play and a validated effects editor in Build.
- Build: "+ Table" menu for every kind; kind-specific settings (choice type,
question, save as, min/max; loop mode and rule; variable name, type,
starting value; sheet template) checked with Expr.check; expression pipe
counts in the pipe popover and on pipe labels.
- Tray: effect lines under chips, last 12 steps behind "+N earlier steps",
sheet headline, Cancelled / action-limit pill, capped indents and Earlier
rows; Variables tab lists every board variable with Reset all.
- RichText: error markers in red; previews show {@x_*} and {= expr}.
- examples/logic_demo.json and tests/test_logic_ui.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:07:57 -06:00
|
|
|
|
static var _list_re: RegEx
|
Play-side UI: BBCode rendering, hover details, card decks, variables, copy, ref pipes
- Cards, result chips and the Earlier list render BBCode with RichTextLabel;
Play rows show [[refs]] as teal chips and {vars} in brass, lit rows show the
rolled text; missing/unset/too-deep markers are red.
- Hover pop-up (DetailsPopup) for table headers, entries with details, result
chips and [url] metas in rendered text; items with details get a small ⓘ.
- Card-mode tables show cards left and Reshuffle; chips note reshuffles.
- Local state: decks, persistent variables and history per collection via
StateStore (memory only when saving is off); delete_table forgets its state.
- Result tray: Copy menu (text / BBCode / with details) and a Variables tab
(edit, re-roll, clear; last roll's chain variables read-only).
- Reference pipes drawn dashed from TextExpander.references; lit when used.
- Build mode: weight field, per-entry and table details editors, a gear
button for table settings, pipe popover (count, save as, remove), range
clamps use min_value(); Build cards are 300px wide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:43:01 -06:00
|
|
|
|
|
|
|
|
|
|
|
Formatting: right-click Format menu in text fields, more toolbar buttons, sparkle/shimmer/flash
Every text field's right-click menu gains Format: Bold, Italic, Underline,
Strike-through, Colour, Size and Effect (Godot's wave, tornado, shake,
rainbow, pulse, fade plus the app's own sparkle, shimmer and flash, drawn
by RichTextEffects in ui/text_effects). The details toolbar adds U, S and
Effect.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 14:32:46 -06:00
|
|
|
|
## The app's own text effects ([sparkle], [shimmer], [flash]), made once.
|
|
|
|
|
|
static var _effects: Array[RichTextEffect] = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Lets `l` draw the app's own text effects (Godot's wave, tornado, shake,
|
|
|
|
|
|
## rainbow, pulse and fade work everywhere already).
|
|
|
|
|
|
static func install_effects(l: RichTextLabel) -> void:
|
|
|
|
|
|
if _effects.is_empty():
|
|
|
|
|
|
_effects = [SparkleEffect.new(), ShimmerEffect.new(), FlashEffect.new()]
|
|
|
|
|
|
for effect in _effects:
|
|
|
|
|
|
l.install_effect(effect)
|
|
|
|
|
|
|
|
|
|
|
|
|
Play-side UI: BBCode rendering, hover details, card decks, variables, copy, ref pipes
- Cards, result chips and the Earlier list render BBCode with RichTextLabel;
Play rows show [[refs]] as teal chips and {vars} in brass, lit rows show the
rolled text; missing/unset/too-deep markers are red.
- Hover pop-up (DetailsPopup) for table headers, entries with details, result
chips and [url] metas in rendered text; items with details get a small ⓘ.
- Card-mode tables show cards left and Reshuffle; chips note reshuffles.
- Local state: decks, persistent variables and history per collection via
StateStore (memory only when saving is off); delete_table forgets its state.
- Result tray: Copy menu (text / BBCode / with details) and a Variables tab
(edit, re-roll, clear; last roll's chain variables read-only).
- Reference pipes drawn dashed from TextExpander.references; lit when used.
- Build mode: weight field, per-entry and table details editors, a gear
button for table settings, pipe popover (count, save as, remove), range
clamps use min_value(); Build cards are 300px wide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:43:01 -06:00
|
|
|
|
## A RichTextLabel that sizes itself to its text like a Label.
|
|
|
|
|
|
## `zoomable` picks the card (MSDF) fonts that stay sharp on the zoomed board.
|
|
|
|
|
|
static func label(text: String, font_size: int, color: Color, zoomable: bool, wrap: bool = true, bold: bool = false) -> RichTextLabel:
|
|
|
|
|
|
var l := RichTextLabel.new()
|
|
|
|
|
|
l.bbcode_enabled = true
|
Formatting: right-click Format menu in text fields, more toolbar buttons, sparkle/shimmer/flash
Every text field's right-click menu gains Format: Bold, Italic, Underline,
Strike-through, Colour, Size and Effect (Godot's wave, tornado, shake,
rainbow, pulse, fade plus the app's own sparkle, shimmer and flash, drawn
by RichTextEffects in ui/text_effects). The details toolbar adds U, S and
Effect.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 14:32:46 -06:00
|
|
|
|
install_effects(l)
|
Play-side UI: BBCode rendering, hover details, card decks, variables, copy, ref pipes
- Cards, result chips and the Earlier list render BBCode with RichTextLabel;
Play rows show [[refs]] as teal chips and {vars} in brass, lit rows show the
rolled text; missing/unset/too-deep markers are red.
- Hover pop-up (DetailsPopup) for table headers, entries with details, result
chips and [url] metas in rendered text; items with details get a small ⓘ.
- Card-mode tables show cards left and Reshuffle; chips note reshuffles.
- Local state: decks, persistent variables and history per collection via
StateStore (memory only when saving is off); delete_table forgets its state.
- Result tray: Copy menu (text / BBCode / with details) and a Variables tab
(edit, re-roll, clear; last roll's chain variables read-only).
- Reference pipes drawn dashed from TextExpander.references; lit when used.
- Build mode: weight field, per-entry and table details editors, a gear
button for table settings, pipe popover (count, save as, remove), range
clamps use min_value(); Build cards are 300px wide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:43:01 -06:00
|
|
|
|
l.fit_content = true
|
|
|
|
|
|
l.scroll_active = false
|
|
|
|
|
|
l.meta_underlined = false
|
|
|
|
|
|
l.hint_underlined = false
|
|
|
|
|
|
l.shortcut_keys_enabled = false
|
|
|
|
|
|
l.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART if wrap else TextServer.AUTOWRAP_OFF
|
|
|
|
|
|
l.mouse_filter = Control.MOUSE_FILTER_PASS
|
|
|
|
|
|
set_fonts(l, font_size, zoomable, bold)
|
|
|
|
|
|
l.add_theme_color_override("default_color", color)
|
|
|
|
|
|
l.text = text
|
|
|
|
|
|
return l
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Sets every font slot of a RichTextLabel. `bold` makes the normal text bold
|
|
|
|
|
|
## (used for a lit row).
|
|
|
|
|
|
static func set_fonts(l: RichTextLabel, font_size: int, zoomable: bool, bold: bool = false) -> void:
|
|
|
|
|
|
l.add_theme_font_override("normal_font", Style.body_bold(zoomable) if bold else Style.body(zoomable))
|
|
|
|
|
|
l.add_theme_font_override("bold_font", Style.body_bold(zoomable))
|
|
|
|
|
|
l.add_theme_font_override("italics_font", Style.body_italic(zoomable))
|
|
|
|
|
|
l.add_theme_font_override("bold_italics_font", Style.body_bold(zoomable))
|
|
|
|
|
|
for slot in ["normal_font_size", "bold_font_size", "italics_font_size", "bold_italics_font_size", "mono_font_size"]:
|
|
|
|
|
|
l.add_theme_font_size_override(slot, font_size)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Same as label() but in the Rokkitt display face (result chips).
|
|
|
|
|
|
static func display_label(text: String, font_size: int, color: Color, zoomable: bool = false) -> RichTextLabel:
|
|
|
|
|
|
var l := label(text, font_size, color, zoomable, false)
|
|
|
|
|
|
var f := Style.display(zoomable)
|
|
|
|
|
|
l.add_theme_font_override("normal_font", f)
|
|
|
|
|
|
l.add_theme_font_override("bold_font", Style.display(zoomable, 900))
|
|
|
|
|
|
return l
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Connects a label's [url] metas to the details pop-up.
|
|
|
|
|
|
static func hook_hover(l: RichTextLabel, main: Main) -> void:
|
|
|
|
|
|
l.meta_hover_started.connect(func(meta: Variant) -> void:
|
|
|
|
|
|
main.details().show_meta(l, str(meta)))
|
|
|
|
|
|
l.meta_hover_ended.connect(func(_meta: Variant) -> void:
|
|
|
|
|
|
main.details().hide_for(l))
|
|
|
|
|
|
# A click (or a tap, where there's no hover) opens the same pop-up.
|
|
|
|
|
|
l.meta_clicked.connect(func(meta: Variant) -> void:
|
|
|
|
|
|
main.details().show_meta(l, str(meta)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Small muted ⓘ appended to text that has hover details.
|
|
|
|
|
|
static func info_mark(on_felt: bool = false) -> String:
|
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 c := Style.ON_BG_MUTED if on_felt else Style.FAINT
|
Play-side UI: BBCode rendering, hover details, card decks, variables, copy, ref pipes
- Cards, result chips and the Earlier list render BBCode with RichTextLabel;
Play rows show [[refs]] as teal chips and {vars} in brass, lit rows show the
rolled text; missing/unset/too-deep markers are red.
- Hover pop-up (DetailsPopup) for table headers, entries with details, result
chips and [url] metas in rendered text; items with details get a small ⓘ.
- Card-mode tables show cards left and Reshuffle; chips note reshuffles.
- Local state: decks, persistent variables and history per collection via
StateStore (memory only when saving is off); delete_table forgets its state.
- Result tray: Copy menu (text / BBCode / with details) and a Variables tab
(edit, re-roll, clear; last roll's chain variables read-only).
- Reference pipes drawn dashed from TextExpander.references; lit when used.
- Build mode: weight field, per-entry and table details editors, a gear
button for table settings, pipe popover (count, save as, remove), range
clamps use min_value(); Build cards are 300px wide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:43:01 -06:00
|
|
|
|
return " [font_size=12][color=#%s]%s[/color][/font_size]" % [c.to_html(false), INFO_MARK]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Escapes text so it shows exactly as typed.
|
|
|
|
|
|
static func plain(text: String) -> String:
|
|
|
|
|
|
return text.replace("[", "[lb]")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Readable BBCode for an entry's text as written (not rolled): each [[reference]]
|
|
|
|
|
|
## becomes a small teal chip with the table's name, {variables} show in brass,
|
|
|
|
|
|
## and a missing table shows the warning marker. References are wrapped in
|
|
|
|
|
|
## [url=table:id] so hovering them shows the table's details.
|
|
|
|
|
|
static func preview(text: String, board: TowerBoard) -> String:
|
|
|
|
|
|
if not text.contains("[[") and not text.contains("{"):
|
|
|
|
|
|
return text
|
|
|
|
|
|
var out := ""
|
|
|
|
|
|
var i := 0
|
|
|
|
|
|
var n := text.length()
|
|
|
|
|
|
while i < n:
|
|
|
|
|
|
var c := text[i]
|
|
|
|
|
|
if c == "[" and i + 1 < n and text[i + 1] == "[":
|
|
|
|
|
|
var close := text.find("]]", i + 2)
|
|
|
|
|
|
var body := text.substr(i + 2, close - i - 2) if close >= 0 else ""
|
|
|
|
|
|
if close >= 0 and body.strip_edges() != "" and not body.contains("[") and not body.contains("]") and not body.contains("\n"):
|
|
|
|
|
|
out += _ref_chip(body, board)
|
|
|
|
|
|
i = close + 2
|
|
|
|
|
|
continue
|
|
|
|
|
|
out += c
|
|
|
|
|
|
i += 1
|
|
|
|
|
|
continue
|
|
|
|
|
|
if c == "[":
|
|
|
|
|
|
var tag := Formatter.tag_at(text, i)
|
|
|
|
|
|
if not tag.is_empty():
|
|
|
|
|
|
out += tag["raw"]
|
|
|
|
|
|
i += (tag["raw"] as String).length()
|
|
|
|
|
|
continue
|
|
|
|
|
|
elif c == "{":
|
Logic cards UI: choice pop-up, card kinds, Build creation and settings, tray
- ChoiceDialog: card-styled pop-up for pick (option rows with details, Random,
1-9 / R keys), number (spin box with min/max/default, Enter) and text.
Cancel, Esc, freeing the dialog, a new roll or a collection switch all
answer null through a separate Reply object, so a roll never hangs.
- Main: real prompt hook; the steps so far light on the board and in the
tray before each question; a roll with questions shows the rest at once;
a new roll cancels an open question cleanly; refresh_live() re-renders
variable, sheet and question text only after rolls and edits.
- TableCard: "?" badge and question for choice cards, loop icon, rule chip
and Each time / Afterwards rows, compact live variable cards (reset in
Build), live sheet cards with one outlet, expression-dice subtitles,
effect chips in Play and a validated effects editor in Build.
- Build: "+ Table" menu for every kind; kind-specific settings (choice type,
question, save as, min/max; loop mode and rule; variable name, type,
starting value; sheet template) checked with Expr.check; expression pipe
counts in the pipe popover and on pipe labels.
- Tray: effect lines under chips, last 12 steps behind "+N earlier steps",
sheet headline, Cancelled / action-limit pill, capped indents and Earlier
rows; Variables tab lists every board variable with Reset all.
- RichText: error markers in red; previews show {@x_*} and {= expr}.
- examples/logic_demo.json and tests/test_logic_ui.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:07:57 -06:00
|
|
|
|
# {= expr}: a computed value, shown as written (red if it can't parse).
|
|
|
|
|
|
if i + 1 < n and text[i + 1] == "=":
|
|
|
|
|
|
var close := text.find("}", i + 2)
|
|
|
|
|
|
var nl := text.find("\n", i + 2)
|
|
|
|
|
|
if close >= 0 and (nl < 0 or close < nl):
|
|
|
|
|
|
var src := text.substr(i + 2, close - i - 2).strip_edges()
|
|
|
|
|
|
var err := Expr.check(src)
|
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 ink := Style.DANGER_INK if err != "" else Style.VALUE_INK
|
Logic cards UI: choice pop-up, card kinds, Build creation and settings, tray
- ChoiceDialog: card-styled pop-up for pick (option rows with details, Random,
1-9 / R keys), number (spin box with min/max/default, Enter) and text.
Cancel, Esc, freeing the dialog, a new roll or a collection switch all
answer null through a separate Reply object, so a roll never hangs.
- Main: real prompt hook; the steps so far light on the board and in the
tray before each question; a roll with questions shows the rest at once;
a new roll cancels an open question cleanly; refresh_live() re-renders
variable, sheet and question text only after rolls and edits.
- TableCard: "?" badge and question for choice cards, loop icon, rule chip
and Each time / Afterwards rows, compact live variable cards (reset in
Build), live sheet cards with one outlet, expression-dice subtitles,
effect chips in Play and a validated effects editor in Build.
- Build: "+ Table" menu for every kind; kind-specific settings (choice type,
question, save as, min/max; loop mode and rule; variable name, type,
starting value; sheet template) checked with Expr.check; expression pipe
counts in the pipe popover and on pipe labels.
- Tray: effect lines under chips, last 12 steps behind "+N earlier steps",
sheet headline, Cancelled / action-limit pill, capped indents and Earlier
rows; Variables tab lists every board variable with Reset all.
- RichText: error markers in red; previews show {@x_*} and {= expr}.
- examples/logic_demo.json and tests/test_logic_ui.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:07:57 -06:00
|
|
|
|
out += "[url=%s][color=#%s]{= %s}[/color][/url]" % ["error:expr" if err != "" else "expr:" + plain(src).replace("]", ""),
|
|
|
|
|
|
ink.to_html(false), plain(src)]
|
|
|
|
|
|
i = close + 1
|
|
|
|
|
|
continue
|
|
|
|
|
|
# {@prefix_*}: a list of every variable with the prefix.
|
|
|
|
|
|
var lm := _lre().search(text, i)
|
|
|
|
|
|
if lm != null and lm.get_start() == i:
|
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
|
|
|
|
out += "[url=var:@%s*][color=#%s]{@%s*}[/color][/url]" % [lm.get_string(1), Style.VALUE_INK.to_html(false), lm.get_string(1)]
|
Logic cards UI: choice pop-up, card kinds, Build creation and settings, tray
- ChoiceDialog: card-styled pop-up for pick (option rows with details, Random,
1-9 / R keys), number (spin box with min/max/default, Enter) and text.
Cancel, Esc, freeing the dialog, a new roll or a collection switch all
answer null through a separate Reply object, so a roll never hangs.
- Main: real prompt hook; the steps so far light on the board and in the
tray before each question; a roll with questions shows the rest at once;
a new roll cancels an open question cleanly; refresh_live() re-renders
variable, sheet and question text only after rolls and edits.
- TableCard: "?" badge and question for choice cards, loop icon, rule chip
and Each time / Afterwards rows, compact live variable cards (reset in
Build), live sheet cards with one outlet, expression-dice subtitles,
effect chips in Play and a validated effects editor in Build.
- Build: "+ Table" menu for every kind; kind-specific settings (choice type,
question, save as, min/max; loop mode and rule; variable name, type,
starting value; sheet template) checked with Expr.check; expression pipe
counts in the pipe popover and on pipe labels.
- Tray: effect lines under chips, last 12 steps behind "+N earlier steps",
sheet headline, Cancelled / action-limit pill, capped indents and Earlier
rows; Variables tab lists every board variable with Reset all.
- RichText: error markers in red; previews show {@x_*} and {= expr}.
- examples/logic_demo.json and tests/test_logic_ui.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:07:57 -06:00
|
|
|
|
i = lm.get_end()
|
|
|
|
|
|
continue
|
Play-side UI: BBCode rendering, hover details, card decks, variables, copy, ref pipes
- Cards, result chips and the Earlier list render BBCode with RichTextLabel;
Play rows show [[refs]] as teal chips and {vars} in brass, lit rows show the
rolled text; missing/unset/too-deep markers are red.
- Hover pop-up (DetailsPopup) for table headers, entries with details, result
chips and [url] metas in rendered text; items with details get a small ⓘ.
- Card-mode tables show cards left and Reshuffle; chips note reshuffles.
- Local state: decks, persistent variables and history per collection via
StateStore (memory only when saving is off); delete_table forgets its state.
- Result tray: Copy menu (text / BBCode / with details) and a Variables tab
(edit, re-roll, clear; last roll's chain variables read-only).
- Reference pipes drawn dashed from TextExpander.references; lit when used.
- Build mode: weight field, per-entry and table details editors, a gear
button for table settings, pipe popover (count, save as, remove), range
clamps use min_value(); Build cards are 300px wide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:43:01 -06:00
|
|
|
|
var m := _vre().search(text, i)
|
|
|
|
|
|
if m != null and m.get_start() == i:
|
|
|
|
|
|
var vname := m.get_string(1)
|
|
|
|
|
|
var shown := "{%s}" % vname
|
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
|
|
|
|
out += "[url=var:%s][color=#%s]%s[/color][/url]" % [vname, Style.VALUE_INK.to_html(false), shown]
|
Play-side UI: BBCode rendering, hover details, card decks, variables, copy, ref pipes
- Cards, result chips and the Earlier list render BBCode with RichTextLabel;
Play rows show [[refs]] as teal chips and {vars} in brass, lit rows show the
rolled text; missing/unset/too-deep markers are red.
- Hover pop-up (DetailsPopup) for table headers, entries with details, result
chips and [url] metas in rendered text; items with details get a small ⓘ.
- Card-mode tables show cards left and Reshuffle; chips note reshuffles.
- Local state: decks, persistent variables and history per collection via
StateStore (memory only when saving is off); delete_table forgets its state.
- Result tray: Copy menu (text / BBCode / with details) and a Variables tab
(edit, re-roll, clear; last roll's chain variables read-only).
- Reference pipes drawn dashed from TextExpander.references; lit when used.
- Build mode: weight field, per-entry and table details editors, a gear
button for table settings, pipe popover (count, save as, remove), range
clamps use min_value(); Build cards are 300px wide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:43:01 -06:00
|
|
|
|
var from := m.get_string(2).strip_edges()
|
|
|
|
|
|
if from != "":
|
|
|
|
|
|
var id := Roller.resolve(board, from)
|
|
|
|
|
|
if id == "":
|
|
|
|
|
|
out += " " + _bad(TextExpander.missing_marker(from), false)
|
|
|
|
|
|
i = m.get_end()
|
|
|
|
|
|
continue
|
|
|
|
|
|
out += c
|
|
|
|
|
|
i += 1
|
|
|
|
|
|
return Formatter.close_open_tags(out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _ref_chip(body: String, board: TowerBoard) -> String:
|
|
|
|
|
|
var name := body
|
|
|
|
|
|
var save := ""
|
|
|
|
|
|
var arrow := body.rfind("->")
|
|
|
|
|
|
if arrow >= 0:
|
|
|
|
|
|
save = body.substr(arrow + 2).strip_edges()
|
|
|
|
|
|
name = body.substr(0, arrow)
|
|
|
|
|
|
name = name.strip_edges()
|
|
|
|
|
|
var count := ""
|
|
|
|
|
|
var id := Roller.resolve(board, name)
|
|
|
|
|
|
if id == "":
|
|
|
|
|
|
var m := _cre().search(name)
|
|
|
|
|
|
if m != null:
|
|
|
|
|
|
count = (m.get_string(1) + "×") if m.get_string(1) != "" else (m.get_string(2) + "×")
|
|
|
|
|
|
name = m.get_string(3).strip_edges()
|
|
|
|
|
|
id = Roller.resolve(board, name)
|
|
|
|
|
|
if id == "":
|
|
|
|
|
|
return _bad(TextExpander.missing_marker(name), false)
|
|
|
|
|
|
var t := board.get_table(id)
|
|
|
|
|
|
var label_text := count + plain(Formatter.strip_tags(t.name))
|
|
|
|
|
|
if save != "":
|
|
|
|
|
|
label_text += " → " + plain(save)
|
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 "[url=table:%s][bgcolor=#%s][color=#%s] %s [/color][/bgcolor][/url]" % [id, Style.REF_BG.to_html(false), Style.REF_INK.to_html(false), label_text]
|
Play-side UI: BBCode rendering, hover details, card decks, variables, copy, ref pipes
- Cards, result chips and the Earlier list render BBCode with RichTextLabel;
Play rows show [[refs]] as teal chips and {vars} in brass, lit rows show the
rolled text; missing/unset/too-deep markers are red.
- Hover pop-up (DetailsPopup) for table headers, entries with details, result
chips and [url] metas in rendered text; items with details get a small ⓘ.
- Card-mode tables show cards left and Reshuffle; chips note reshuffles.
- Local state: decks, persistent variables and history per collection via
StateStore (memory only when saving is off); delete_table forgets its state.
- Result tray: Copy menu (text / BBCode / with details) and a Variables tab
(edit, re-roll, clear; last roll's chain variables read-only).
- Reference pipes drawn dashed from TextExpander.references; lit when used.
- Build mode: weight field, per-entry and table details editors, a gear
button for table settings, pipe popover (count, save as, remove), range
clamps use min_value(); Build cards are 300px wide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:43:01 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Colours the internal markers of rolled text: table rolls in teal, variables in
|
|
|
|
|
|
## brass, and missing / unset / too-deep markers in red, so they're visible.
|
|
|
|
|
|
static func decorate(bbcode: String, on_felt: bool = false) -> String:
|
|
|
|
|
|
if not bbcode.contains("[url="):
|
|
|
|
|
|
return bbcode
|
|
|
|
|
|
var out := ""
|
|
|
|
|
|
var open: Array[String] = []
|
|
|
|
|
|
for t: Dictionary in Formatter.tokenize(bbcode):
|
|
|
|
|
|
if t["name"] == "url":
|
|
|
|
|
|
if t["kind"] == "open":
|
|
|
|
|
|
var meta := (t["param"] as String).trim_prefix("=").strip_edges().trim_prefix("\"").trim_suffix("\"")
|
|
|
|
|
|
var color := _marker_color(meta, on_felt)
|
|
|
|
|
|
out += t["raw"]
|
|
|
|
|
|
if color != "":
|
|
|
|
|
|
out += "[color=#%s]" % color
|
|
|
|
|
|
open.append(color)
|
|
|
|
|
|
continue
|
|
|
|
|
|
elif not open.is_empty():
|
|
|
|
|
|
if open.pop_back() != "":
|
|
|
|
|
|
out += "[/color]"
|
|
|
|
|
|
out += t["raw"]
|
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _marker_color(meta: String, on_felt: bool) -> String:
|
|
|
|
|
|
if meta.begins_with("table:"):
|
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 (Style.REF_INK_ON_BG if on_felt else Style.REF_INK).to_html(false)
|
Play-side UI: BBCode rendering, hover details, card decks, variables, copy, ref pipes
- Cards, result chips and the Earlier list render BBCode with RichTextLabel;
Play rows show [[refs]] as teal chips and {vars} in brass, lit rows show the
rolled text; missing/unset/too-deep markers are red.
- Hover pop-up (DetailsPopup) for table headers, entries with details, result
chips and [url] metas in rendered text; items with details get a small ⓘ.
- Card-mode tables show cards left and Reshuffle; chips note reshuffles.
- Local state: decks, persistent variables and history per collection via
StateStore (memory only when saving is off); delete_table forgets its state.
- Result tray: Copy menu (text / BBCode / with details) and a Variables tab
(edit, re-roll, clear; last roll's chain variables read-only).
- Reference pipes drawn dashed from TextExpander.references; lit when used.
- Build mode: weight field, per-entry and table details editors, a gear
button for table settings, pipe popover (count, save as, remove), range
clamps use min_value(); Build cards are 300px wide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:43:01 -06:00
|
|
|
|
if meta.begins_with("var:"):
|
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 (Style.VALUE_INK_ON_BG if on_felt else Style.VALUE_INK).to_html(false)
|
Logic cards UI: choice pop-up, card kinds, Build creation and settings, tray
- ChoiceDialog: card-styled pop-up for pick (option rows with details, Random,
1-9 / R keys), number (spin box with min/max/default, Enter) and text.
Cancel, Esc, freeing the dialog, a new roll or a collection switch all
answer null through a separate Reply object, so a roll never hangs.
- Main: real prompt hook; the steps so far light on the board and in the
tray before each question; a roll with questions shows the rest at once;
a new roll cancels an open question cleanly; refresh_live() re-renders
variable, sheet and question text only after rolls and edits.
- TableCard: "?" badge and question for choice cards, loop icon, rule chip
and Each time / Afterwards rows, compact live variable cards (reset in
Build), live sheet cards with one outlet, expression-dice subtitles,
effect chips in Play and a validated effects editor in Build.
- Build: "+ Table" menu for every kind; kind-specific settings (choice type,
question, save as, min/max; loop mode and rule; variable name, type,
starting value; sheet template) checked with Expr.check; expression pipe
counts in the pipe popover and on pipe labels.
- Tray: effect lines under chips, last 12 steps behind "+N earlier steps",
sheet headline, Cancelled / action-limit pill, capped indents and Earlier
rows; Variables tab lists every board variable with Reset all.
- RichText: error markers in red; previews show {@x_*} and {= expr}.
- examples/logic_demo.json and tests/test_logic_ui.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:07:57 -06:00
|
|
|
|
if meta.begins_with("missing:") or meta.begins_with("unset:") or meta.begins_with("deep:") or meta.begins_with("error:"):
|
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 (Style.BAD_INK_ON_BG if on_felt else Style.DANGER_INK).to_html(false)
|
Play-side UI: BBCode rendering, hover details, card decks, variables, copy, ref pipes
- Cards, result chips and the Earlier list render BBCode with RichTextLabel;
Play rows show [[refs]] as teal chips and {vars} in brass, lit rows show the
rolled text; missing/unset/too-deep markers are red.
- Hover pop-up (DetailsPopup) for table headers, entries with details, result
chips and [url] metas in rendered text; items with details get a small ⓘ.
- Card-mode tables show cards left and Reshuffle; chips note reshuffles.
- Local state: decks, persistent variables and history per collection via
StateStore (memory only when saving is off); delete_table forgets its state.
- Result tray: Copy menu (text / BBCode / with details) and a Variables tab
(edit, re-roll, clear; last roll's chain variables read-only).
- Reference pipes drawn dashed from TextExpander.references; lit when used.
- Build mode: weight field, per-entry and table details editors, a gear
button for table settings, pipe popover (count, save as, remove), range
clamps use min_value(); Build cards are 300px wide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:43:01 -06:00
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _bad(marker: String, on_felt: bool) -> String:
|
|
|
|
|
|
return decorate(marker, on_felt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _vre() -> RegEx:
|
|
|
|
|
|
if _var_re == null:
|
|
|
|
|
|
_var_re = RegEx.new()
|
|
|
|
|
|
_var_re.compile(_VAR_PATTERN)
|
|
|
|
|
|
return _var_re
|
|
|
|
|
|
|
|
|
|
|
|
|
Logic cards UI: choice pop-up, card kinds, Build creation and settings, tray
- ChoiceDialog: card-styled pop-up for pick (option rows with details, Random,
1-9 / R keys), number (spin box with min/max/default, Enter) and text.
Cancel, Esc, freeing the dialog, a new roll or a collection switch all
answer null through a separate Reply object, so a roll never hangs.
- Main: real prompt hook; the steps so far light on the board and in the
tray before each question; a roll with questions shows the rest at once;
a new roll cancels an open question cleanly; refresh_live() re-renders
variable, sheet and question text only after rolls and edits.
- TableCard: "?" badge and question for choice cards, loop icon, rule chip
and Each time / Afterwards rows, compact live variable cards (reset in
Build), live sheet cards with one outlet, expression-dice subtitles,
effect chips in Play and a validated effects editor in Build.
- Build: "+ Table" menu for every kind; kind-specific settings (choice type,
question, save as, min/max; loop mode and rule; variable name, type,
starting value; sheet template) checked with Expr.check; expression pipe
counts in the pipe popover and on pipe labels.
- Tray: effect lines under chips, last 12 steps behind "+N earlier steps",
sheet headline, Cancelled / action-limit pill, capped indents and Earlier
rows; Variables tab lists every board variable with Reset all.
- RichText: error markers in red; previews show {@x_*} and {= expr}.
- examples/logic_demo.json and tests/test_logic_ui.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:07:57 -06:00
|
|
|
|
static func _lre() -> RegEx:
|
|
|
|
|
|
if _list_re == null:
|
|
|
|
|
|
_list_re = RegEx.new()
|
|
|
|
|
|
_list_re.compile("\\{@([A-Za-z0-9_]*)\\*\\}")
|
|
|
|
|
|
return _list_re
|
|
|
|
|
|
|
|
|
|
|
|
|
Play-side UI: BBCode rendering, hover details, card decks, variables, copy, ref pipes
- Cards, result chips and the Earlier list render BBCode with RichTextLabel;
Play rows show [[refs]] as teal chips and {vars} in brass, lit rows show the
rolled text; missing/unset/too-deep markers are red.
- Hover pop-up (DetailsPopup) for table headers, entries with details, result
chips and [url] metas in rendered text; items with details get a small ⓘ.
- Card-mode tables show cards left and Reshuffle; chips note reshuffles.
- Local state: decks, persistent variables and history per collection via
StateStore (memory only when saving is off); delete_table forgets its state.
- Result tray: Copy menu (text / BBCode / with details) and a Variables tab
(edit, re-roll, clear; last roll's chain variables read-only).
- Reference pipes drawn dashed from TextExpander.references; lit when used.
- Build mode: weight field, per-entry and table details editors, a gear
button for table settings, pipe popover (count, save as, remove), range
clamps use min_value(); Build cards are 300px wide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:43:01 -06:00
|
|
|
|
static func _cre() -> RegEx:
|
|
|
|
|
|
if _count_re == null:
|
|
|
|
|
|
_count_re = RegEx.new()
|
|
|
|
|
|
_count_re.compile(_COUNT_PATTERN)
|
|
|
|
|
|
return _count_re
|