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 DetailsPopup
extends PanelContainer
## The hover pop-up for table and entry details, result chips and the
## [[references]] / {variables} inside rendered text.
##
## It ignores the mouse, so it never blocks clicks, stays inside the window,
## and hides itself as soon as the control that opened it is no longer hovered.
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
##
## Hover summaries follow RulesView.plain(main): an entry's effects, show_if,
## router condition and pipe labels read in plain words or as written, and a
## step of the last roll (a chip, or a lit row on a card) adds its "Why this?"
## reasons (WhyPopover.why_lines).
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
const WIDTH : = 300.0
const DELAY : = 0.28
const OFFSET : = Vector2 ( 14 , 20 )
var main : Main
var _owner_ctrl : Control
var _title : Label
var _sub : Label
var _body : RichTextLabel
var _wait : = 0.0
var _pending : = false
func setup ( p_main : Main ) - > void :
main = p_main
mouse_filter = MOUSE_FILTER_IGNORE
z_index = 100
top_level = true
var sb : = Style . box ( Style . CARD , 9 , [ 13 , 10 , 13 , 11 ] )
sb . border_width_top = 3
sb . border_color = Style . COPPER
sb . shadow_color = Color ( 0 , 0 , 0 , 0.35 )
sb . shadow_size = 14
sb . shadow_offset = Vector2 ( 0 , 6 )
add_theme_stylebox_override ( " panel " , sb )
var v : = VBoxContainer . new ( )
v . add_theme_constant_override ( " separation " , 3 )
v . mouse_filter = MOUSE_FILTER_IGNORE
add_child ( v )
_title = Style . make_label ( " " , Style . display ( ) , 18 , Style . INK )
_title . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
_title . custom_minimum_size = Vector2 ( WIDTH , 0 )
_title . mouse_filter = MOUSE_FILTER_IGNORE
v . add_child ( _title )
_sub = Style . make_label ( " " , Style . body ( ) , 12 , Style . MUTED )
_sub . mouse_filter = MOUSE_FILTER_IGNORE
v . add_child ( _sub )
_body = RichText . label ( " " , 14 , Style . INK , false )
_body . custom_minimum_size = Vector2 ( WIDTH , 0 )
_body . mouse_filter = MOUSE_FILTER_IGNORE
v . add_child ( _body )
hide ( )
## Shows the pop-up for `owner` after a short delay. Empty parts are hidden.
func show_for ( owner : Control , title : String , body : String , sub : String = " " ) - > void :
if owner == null :
return
if not owner . has_meta ( " _details_hooked " ) :
owner . set_meta ( " _details_hooked " , true )
owner . mouse_exited . connect ( _on_owner_exited . bind ( owner ) )
_owner_ctrl = owner
_title . text = title
_title . visible = title != " "
_sub . text = sub
_sub . visible = sub != " "
_body . text = body
_body . visible = body != " "
_wait = DELAY if not visible else 0.0
_pending = true
if visible :
_place ( )
## Hides the pop-up if `owner` opened it (or always, when owner is null).
func hide_for ( owner : Control = null ) - > void :
if owner == null or owner == _owner_ctrl :
_pending = false
_owner_ctrl = null
hide ( )
func _on_owner_exited ( owner : Control ) - > void :
hide_for ( owner )
## Shows the prepared pop-up at a fixed spot until hide_for() (screenshots).
func pin ( at : Vector2 ) - > void :
_owner_ctrl = null
_pending = false
show ( )
reset_size ( )
global_position = at
func _process ( delta : float ) - > void :
if _owner_ctrl == null :
return
# The owner may be rebuilt away (a card re-rendering) without a mouse_exited.
if not is_instance_valid ( _owner_ctrl ) or not _owner_ctrl . is_visible_in_tree ( ) :
hide_for ( )
return
if _pending :
_wait -= delta
if _wait < = 0.0 :
_pending = false
show ( )
_place ( )
elif visible :
_place ( )
func _place ( ) - > void :
reset_size ( )
var view : = get_viewport_rect ( ) . size
var p : = get_global_mouse_position ( ) + OFFSET
if p . x + size . x > view . x - 8.0 :
p . x = view . x - size . x - 8.0
if p . y + size . y > view . y - 8.0 :
p . y = get_global_mouse_position ( ) . y - size . y - 12.0
global_position = Vector2 ( maxf ( 8.0 , p . x ) , maxf ( 8.0 , p . y ) )
# ---------- Content ----------
func show_table ( owner : Control , tid : String , only_if_details : bool = false ) - > void :
var t : = main . data . get_table ( tid ) if main . data else null
if t == null :
return
if only_if_details and t . details . strip_edges ( ) == " " :
return
show_for ( owner , Formatter . strip_tags ( t . name ) , t . details , table_summary ( t ) )
func show_entry ( owner : Control , tid : String , eid : String ) - > void :
var t : = main . data . get_table ( tid )
var e : = t . find_entry ( eid ) if t else null
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
if e == null :
return
var plain : = RulesView . plain ( main )
var parts : = PackedStringArray ( )
if e . details . strip_edges ( ) != " " :
parts . append ( e . details )
var rules : = rules_bbcode ( t , e , main . data , plain )
if rules != " " :
parts . append ( rules )
if main . is_entry_lit ( tid , eid ) :
var found : = step_for ( tid , eid )
if not found . is_empty ( ) :
var why : = why_bbcode ( found [ " steps " ] , int ( found [ " index " ] ) , main . data , plain )
if why != " " :
parts . append ( why )
if parts . is_empty ( ) :
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
var shown : = main . lit_text ( tid , eid )
if shown == " " :
shown = RichText . preview ( e . text , main . data )
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
show_for ( owner , _short ( Formatter . strip_tags ( shown ) ) , " \n \n " . join ( parts ) , Formatter . strip_tags ( t . name ) )
## An entry's rules as short BBCode lines: "only if …", "Changes: Luck − 1 ·
## Gold + 2D", and "→ Loot: Tier 3 · only if Luck is 2 or more" for each pipe
## with options. Router conditions are on the row itself, so they're left out.
static func rules_bbcode ( t : RollTable , e : TableEntry , board : TowerBoard , plain : bool ) - > String :
var muted : = Style . MUTED . to_html ( false )
var lines : = PackedStringArray ( )
if t . kind == RollTable . KIND_CHOICE and t . choice == " pick " and e . show_if . strip_edges ( ) != " " :
lines . append ( " [color=# %s ]Offered[/color] %s " % [ muted , RichText . plain ( RulesView . show_if_line ( e , board , plain ) ) ] )
if e . effects . strip_edges ( ) != " " :
var fx : Array = Describe . effects ( e . effects , board , t ) if plain else Array ( Effects . split ( e . effects ) )
var ss : = PackedStringArray ( )
for f : Variant in fx :
ss . append ( RichText . plain ( str ( f ) ) )
lines . append ( " [color=# %s ]Changes:[/color] [b] %s [/b] " % [ muted , " · " . join ( ss ) ] )
for to in e . pipes :
var lab : = Describe . pipe ( e , to , board ) if plain else PipeLayer . _pipe_tag ( e , to )
if lab == " " :
continue
var target : = board . get_table ( to ) if board else null
var nm : = Formatter . strip_tags ( target . name ) if target else to
lines . append ( " [color=# %s ]→ %s :[/color] %s " % [ muted , RichText . plain ( nm ) , RichText . plain ( lab ) ] )
return " \n " . join ( lines )
## The "Why this?" reasons for steps[index] as a small BBCode section, or "".
static func why_bbcode ( steps : Array , index : int , board : TowerBoard , plain : bool ) - > String :
var ls : = WhyPopover . why_lines ( steps , index , board , plain )
if ls . is_empty ( ) :
return " "
return " [color=# %s ][b]WHY THIS?[/b][/color] \n %s " % [ Style . MUTED . to_html ( false ) , WhyPopover . bbcode_list ( ls ) ]
## The last step of the current roll for an entry: {"steps", "index"} or {}.
func step_for ( tid : String , eid : String ) - > Dictionary :
var steps : Array = main . current . get ( " steps " , [ ] )
for k in range ( steps . size ( ) - 1 , - 1 , - 1 ) :
var s : Dictionary = steps [ k ]
if str ( s . get ( " table_id " , " " ) ) == tid and str ( s . get ( " entry_id " , " " ) ) == eid :
return { " steps " : steps , " index " : k }
return { }
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
## Plain one-line title, cut down to a readable length.
static func _short ( s : String ) - > String :
s = s . strip_edges ( ) . replace ( " \n " , " " )
while s . contains ( " " ) :
s = s . replace ( " " , " " )
return s if s . length ( ) < = 90 else s . substr ( 0 , 88 ) . strip_edges ( ) + " … "
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
## A result chip: the entry's details, else the table's, then the step's
## "Why this?" reasons when `steps` and `index` are given.
func show_step ( owner : Control , step : Dictionary , steps : Array = [ ] , index : int = - 1 ) - > void :
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 t : = main . data . get_table ( str ( step . get ( " table_id " , " " ) ) )
if t == null :
return
var e : = t . find_entry ( str ( step . get ( " entry_id " , " " ) ) )
var body : = e . details if e and e . details . strip_edges ( ) != " " else t . details
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
if index > = 0 :
var why : = why_bbcode ( steps , index , main . data , RulesView . plain ( main ) )
if why != " " :
body = ( body . strip_edges ( ) + " \n \n " + why ) if body . strip_edges ( ) != " " else why
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 body . strip_edges ( ) == " " :
return
var title : = _short ( Formatter . strip_tags ( str ( step . get ( " text " , " " ) ) ) ) if e and e . details . strip_edges ( ) != " " else Formatter . strip_tags ( t . name )
show_for ( owner , title , body , Formatter . strip_tags ( t . name ) if e and e . details . strip_edges ( ) != " " else table_summary ( t ) )
## True when a result chip has something to show.
func step_has_details ( step : Dictionary ) - > bool :
var t : = main . data . get_table ( str ( step . get ( " table_id " , " " ) ) )
if t == null :
return false
var e : = t . find_entry ( str ( step . get ( " entry_id " , " " ) ) )
return t . details . strip_edges ( ) != " " or ( e != null and e . details . strip_edges ( ) != " " )
## A [url] meta inside rendered text (see TextExpander's marker formats).
func show_meta ( owner : Control , meta : String ) - > void :
var kind : = meta . get_slice ( " : " , 0 )
var arg : = meta . substr ( kind . length ( ) + 1 )
match kind :
" table " :
show_table ( owner , arg )
" var " :
_show_var ( owner , arg )
" missing " :
show_for ( owner , " Missing table " , " There ' s no table called [b] %s [/b]. Check the spelling, or add a table with that name. " % RichText . plain ( arg ) )
" unset " :
show_for ( owner , " { %s } isn ' t set " % arg , " Nothing has saved this variable yet. Save it earlier in the roll with [lb][lb]Table -> %s ]] or a pipe ' s [i]Save as[/i]. " % RichText . plain ( arg ) )
" deep " :
show_for ( owner , " Chain too deep " , " The roll stopped after %d levels so a loop can ' t run forever. " % Roller . MAX_DEPTH )
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
" error " :
show_for ( owner , " Can ' t work this out " , " This expression has a mistake; the message after ⚠ says what. Expressions use @variables, dice such as 2d6, + - * / and functions such as max() and dm(). " )
" expr " :
show_for ( owner , " {= %s } " % RichText . plain ( arg ) , " A computed value, worked out each time the text is 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
func _show_var ( owner : Control , name : String ) - > void :
var persistent : = name . begins_with ( " @ " )
var value : Variant = null
var source : = " "
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 persistent and name . ends_with ( " * " ) :
var parts : = PackedStringArray ( )
for v : Dictionary in RollContext . vars_with_prefix ( main . persistent_vars , name . substr ( 1 ) ) :
parts . append ( " %s %s " % [ v [ " label " ] , Expr . format_value ( v [ " value " ] ) ] )
show_for ( owner , " { %s } " % name , " , " . join ( parts ) if not parts . is_empty ( ) else " [i]None set yet[/i] " ,
" Every variable starting with %s " % name . trim_suffix ( " * " ) )
return
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 persistent :
var v : Variant = main . persistent_vars . get ( name . substr ( 1 ) )
if v is Dictionary :
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
value = Expr . format_value ( v . get ( " value " , " " ) )
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
source = str ( v . get ( " source " , " " ) )
else :
value = ( main . current . get ( " chain_vars " , { } ) as Dictionary ) . get ( name )
var sub : = " Saved for this collection " if persistent else " Saved for this roll "
var st : = main . data . get_table ( source ) if source != " " else null
if st :
sub += " · from %s " % Formatter . strip_tags ( st . name )
var body : = str ( value ) if value != null else " [i]Not set[/i] "
show_for ( owner , " { %s } " % name , body , sub )
## "d100 · 6 ranges · 4 / 6 cards left"
func table_summary ( t : RollTable ) - > String :
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
match t . kind :
RollTable . KIND_CHOICE :
return { " pick " : " Choice · %d options " % t . entries . size ( ) , " number " : " Choice · a number " , " text " : " Choice · open ended " } . get ( t . choice , " Choice " )
RollTable . KIND_LOOP :
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
return " Loop · " + RulesView . loop_rule ( t , main . data , RulesView . plain ( main ) )
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
RollTable . KIND_VARIABLE :
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
if RulesView . plain ( main ) :
return " Collection · kept between rolls " if t . is_collection ( ) else " %s · kept between rolls " % t . var_type . capitalize ( )
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
return " Variable @ %s · %s " % [ t . var_name , t . var_type ]
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
RollTable . KIND_CHECK :
return RulesView . check_line ( t , main . data , RulesView . plain ( main ) )
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
RollTable . KIND_SHEET :
return " Sheet "
2026-11-08 17:55:22 -06:00
RollTable . KIND_ROUTER :
return " Router · %d cases · the first true case is taken " % t . entries . size ( )
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
var dl : = t . dice_label ( )
if t . is_expr_dice ( ) and RulesView . plain ( main ) :
dl = Describe . dice ( t . dice , main . data )
var parts : = PackedStringArray ( [ dl ] )
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
parts . append ( " %d %s " % [ t . entries . size ( ) , " ranges " if t . is_ranged ( ) else " results " ] )
if t . card_mode :
var left : = main . cards_left ( t . id )
parts . append ( " %d / %d cards left " % [ left . x , left . y ] )
return " · " . join ( parts )