Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
class_name TableCardHeader
extends RefCounted
## The top of a TableCard: collapse chevron, name (or its inline editor and
UI pass: striped rows, View/Help menus, zoom control, card ⋯ menu, fuller sample
- Striped result rows (parchment tint, on by default, `striped_rows` setting).
- Top bar: View ▾ (Plain words / Rule text, Collapse/Expand all, Striped rows,
Minimap) and a "− 90% ▾ +" zoom control replace the Plain|Text switch,
Collapse all, −/Fit/+ and Map. Arrange ▾ folds into Board ▾; Search is an icon.
- Help ▾ and F1 open a Help window; the 17 topics live in help/topics.txt.
- Build cards get a ⋯ menu (settings, template, collapse, delete) instead of
the gear and footer Delete, sharing Style.overflow_button with group cards.
Row × buttons show only on hover, focus or selection.
- Sample: Luck value card, Make Camp (pick card) and Search the Ruins
(1d6 + Luck, with results only a modifier reaches).
- New test suite test_top_bar; Canvas/GraphML round-trip tests compare plain
tables only, since logic keys are JSON-only.
- DESIGN.md: open items, including the Card Mode UI redesign.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:36:38 -06:00
## ⋯ menu in Build), the go button, the card-mode deck row and the
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
## kind-specific lines under the title, plus the dashed inputs box. Owns the
## live labels refresh_live() updates (a choice's question, "3 available now").
var card : TableCard
var die_icon : DieIcon
2026-11-10 18:40:53 -06:00
## The die button (disabled while a range runs backwards).
var roll_button : Button
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
var deck_label : Label
## Play mode: "3 available now" on a dynamic pick card.
var options_label : Label
var prompt_label : RichTextLabel
func _init ( p_card : TableCard ) - > void :
card = p_card
## Drops the references to the previous build's labels.
func clear ( ) - > void :
deck_label = null
prompt_label = null
options_label = null
func make ( build : bool , ranged : bool ) - > Control :
var table : = card . table
var main : = card . main
var header : = PanelContainer . new ( )
var hs : = Style . box ( Color ( 0 , 0 , 0 , 0 ) , 0 , [ 12 , 10 , 10 , 9 ] )
hs . border_width_bottom = 1
hs . border_color = Style . RULE
header . add_theme_stylebox_override ( " panel " , hs )
header . mouse_filter = Control . MOUSE_FILTER_PASS
header . mouse_default_cursor_shape = Control . CURSOR_MOVE
header . gui_input . connect ( card . _on_header_input . bind ( header ) )
var row : = TableCard . hbox ( 8 )
var head_box : = TableCard . vbox ( 4 )
header . add_child ( head_box )
head_box . add_child ( row )
if card . can_collapse ( ) :
var chevron : = ChevronButton . new ( )
chevron . open = not table . collapsed
chevron . tooltip_text = ( " Expand " if table . collapsed else " Collapse " ) + table . name
chevron . size_flags_vertical = Control . SIZE_SHRINK_CENTER
chevron . pressed . connect ( func ( ) - > void : main . toggle_collapse ( table . id ) )
row . add_child ( chevron )
header . mouse_entered . connect ( func ( ) - > void :
if not card . _dragging and main . mode == Main . Mode . PLAY :
main . details ( ) . show_table ( header , table . id , true )
)
if build :
var name_edit : = LineEdit . new ( )
name_edit . text = table . name
name_edit . size_flags_horizontal = Control . SIZE_EXPAND_FILL
name_edit . size_flags_vertical = Control . SIZE_SHRINK_CENTER
name_edit . custom_minimum_size = Vector2 ( 40 , 0 )
name_edit . add_theme_font_override ( " font " , Style . display ( true ) )
name_edit . add_theme_font_size_override ( " font_size " , 18 )
name_edit . add_theme_stylebox_override ( " normal " , Style . bordered ( Style . box ( Color . WHITE , 6 , [ 7 , 3 , 7 , 3 ] ) , 1 , Style . RULE ) )
name_edit . text_changed . connect ( func ( s : String ) - > void :
table . name = s
main . mark_dirty ( )
)
row . add_child ( name_edit )
UI pass: striped rows, View/Help menus, zoom control, card ⋯ menu, fuller sample
- Striped result rows (parchment tint, on by default, `striped_rows` setting).
- Top bar: View ▾ (Plain words / Rule text, Collapse/Expand all, Striped rows,
Minimap) and a "− 90% ▾ +" zoom control replace the Plain|Text switch,
Collapse all, −/Fit/+ and Map. Arrange ▾ folds into Board ▾; Search is an icon.
- Help ▾ and F1 open a Help window; the 17 topics live in help/topics.txt.
- Build cards get a ⋯ menu (settings, template, collapse, delete) instead of
the gear and footer Delete, sharing Style.overflow_button with group cards.
Row × buttons show only on hover, focus or selection.
- Sample: Luck value card, Make Camp (pick card) and Search the Ruins
(1d6 + Luck, with results only a modifier reaches).
- New test suite test_top_bar; Canvas/GraphML round-trip tests compare plain
tables only, since logic keys are JSON-only.
- DESIGN.md: open items, including the Card Mode UI redesign.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:36:38 -06:00
row . add_child ( card . edit_ui . make_card_menu ( ) )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
else :
var titles : = TableCard . vbox ( 3 )
titles . size_flags_horizontal = Control . SIZE_EXPAND_FILL
titles . size_flags_vertical = Control . SIZE_SHRINK_CENTER
titles . mouse_filter = Control . MOUSE_FILTER_IGNORE
var title : = Style . make_label ( Formatter . strip_tags ( table . name ) , Style . display ( true ) , 20 , Style . INK )
2026-11-10 18:20:46 -06:00
title . autowrap_mode = TextServer . AUTOWRAP_WORD
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
if table . details . strip_edges ( ) != " " :
# A small ⓘ after the name says hovering shows the table's details.
var name_row : = TableCard . hbox ( 4 )
name_row . mouse_filter = Control . MOUSE_FILTER_IGNORE
title . size_flags_horizontal = Control . SIZE_EXPAND_FILL
name_row . add_child ( title )
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 mark : = Style . make_label ( RichText . INFO_MARK , Style . body ( true ) , 12 , Style . FAINT )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
mark . size_flags_vertical = Control . SIZE_SHRINK_CENTER
name_row . add_child ( mark )
titles . add_child ( name_row )
else :
titles . add_child ( title )
var sub : = _subtitle ( )
if sub != " " :
var cl : = Style . make_label ( sub , Style . body ( true ) , 12 , Style . MUTED )
cl . mouse_filter = Control . MOUSE_FILTER_IGNORE
cl . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
titles . add_child ( cl )
row . add_child ( titles )
var deck_row : Control = null
if table . card_mode :
deck_row = _make_deck_row ( )
var go : = _make_go_button ( )
if go != null :
row . add_child ( go )
if deck_row != null :
head_box . add_child ( deck_row )
var extra : = _make_kind_header ( build )
if extra != null :
head_box . add_child ( extra )
return header
## The small line under the title in Play mode ("2d6 + dm(@end) · 2 ranges").
func _subtitle ( ) - > String :
var table : = card . table
match table . kind :
RollTable . KIND_ROLL :
if table . is_ranged ( ) :
var n : = " %d ranges " % table . entries . size ( )
2026-11-09 10:01:10 -06:00
if table . clamps ( ) :
return " %s · %s " % [ RulesView . roll_line ( table , card . main . data , card . plain ) , n ]
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
return n
if table . collapsed :
return " %d results " % table . entries . size ( )
RollTable . KIND_CHOICE :
if table . collapsed :
return " %d options " % table . entries . size ( )
RollTable . KIND_ROUTER :
return " if / else if / otherwise · %d %s " % [ table . entries . size ( ) , " case " if table . entries . size ( ) == 1 else " cases " ]
RollTable . KIND_CHECK :
return " Check card "
return " "
## The header button that starts a roll: the die on roll tables, a "?" badge on
## choice cards, a loop arrow on loop cards and "Print" on sheets. Variable
## cards have none.
func _make_go_button ( ) - > Button :
var table : = card . table
die_icon = null
2026-11-10 18:40:53 -06:00
roll_button = null
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
if table . kind == RollTable . KIND_VARIABLE :
return null
var b : = Button . new ( )
b . size_flags_vertical = Control . SIZE_SHRINK_CENTER
b . add_theme_font_override ( " font " , Style . display ( true ) )
b . add_theme_font_size_override ( " font_size " , 17 )
var left : = 10
match table . kind :
RollTable . KIND_CHOICE :
b . text = " ? "
b . add_theme_font_size_override ( " font_size " , 20 )
b . custom_minimum_size = Vector2 ( 36 , 0 )
b . tooltip_text = " Ask: %s " % Formatter . strip_tags ( table . prompt if table . prompt != " " else table . name )
RollTable . KIND_LOOP :
b . custom_minimum_size = Vector2 ( 38 , 32 )
b . tooltip_text = " Run %s " % Formatter . strip_tags ( table . name )
var icon : = Control . new ( )
icon . mouse_filter = Control . MOUSE_FILTER_IGNORE
icon . set_anchors_and_offsets_preset ( Control . PRESET_FULL_RECT )
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
icon . draw . connect ( func ( ) - > void : Icons . draw_loop ( icon , icon . size / 2.0 + Vector2 ( 0 , - 1 ) , 7.0 , Style . ACCENT , 2.2 ) )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
b . add_child ( icon )
RollTable . KIND_ROUTER :
b . custom_minimum_size = Vector2 ( 38 , 32 )
b . tooltip_text = " Route %s : the first case that ' s true is chosen " % Formatter . strip_tags ( table . name )
var fork : = Control . new ( )
fork . mouse_filter = Control . MOUSE_FILTER_IGNORE
fork . set_anchors_and_offsets_preset ( Control . PRESET_FULL_RECT )
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
fork . draw . connect ( func ( ) - > void : draw_fork ( fork , fork . size / 2.0 + Vector2 ( 0 , 0 ) , 8.0 , Style . ACCENT , 2.2 ) )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
b . add_child ( fork )
RollTable . KIND_SHEET :
b . text = " Print "
b . add_theme_font_override ( " font " , Style . body_bold ( true ) )
b . add_theme_font_size_override ( " font_size " , 14 )
b . tooltip_text = " Print this sheet in the tray "
RollTable . KIND_CHECK :
b . text = TableCardText . check_badge ( table )
b . custom_minimum_size = Vector2 ( 38 , 0 )
b . tooltip_text = " Roll the check: %s \n Shift-click to skip the animation " % RulesView . check_line ( table , card . main . data , card . plain )
_ :
left = 34
var label : = " d %d " % table . die_size ( )
2026-11-09 10:01:10 -06:00
if table . has_mod ( ) and not table . is_expr_dice ( ) :
# The dice, not the ranges' end (which a modifier stretches).
label = table . dice_label ( )
elif table . is_expr_dice ( ) :
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
label = table . dice_label ( ) if table . dice_label ( ) . length ( ) < = 5 else " Roll "
b . text = label
2026-11-09 10:01:10 -06:00
b . tooltip_text = " Roll %s on %s \n Shift-click to skip the animation " % [ table . roll_text ( ) if table . is_ranged ( ) else table . dice_label ( ) , table . name ]
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 rn : = Style . box ( Style . BG , 8 , [ left , 6 , 10 , 6 ] )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
rn . border_width_bottom = 2
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
rn . border_color = Style . BG_DEEP
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
var rh : = rn . duplicate ( ) as StyleBoxFlat
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
rh . bg_color = Style . BG_HOVER
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
var rp : = rn . duplicate ( ) as StyleBoxFlat
rp . border_width_bottom = 1
rp . content_margin_top = 7
rp . content_margin_bottom = 5
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 . skin_button ( b , rn , rh , rp , Style . ACCENT )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
if table . kind == RollTable . KIND_ROLL :
var die : = DieIcon . new ( )
die . spinning = card . _rolling
die_icon = die
b . add_child ( die )
b . resized . connect ( func ( ) - > void : die . position = Vector2 ( 8 , ( b . size . y - 20.0 ) / 2.0 - 1.0 ) )
b . pressed . connect ( func ( ) - > void : card . main . start_roll ( table . id ) )
2026-11-10 18:40:53 -06:00
roll_button = b
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
return b
## Kind-specific lines under the header: a choice card's question, a loop's
## rule, a variable's name.
func _make_kind_header ( _build : bool ) - > Control :
var table : = card . table
var data : = card . main . data
var plain : = card . plain
match table . kind :
RollTable . KIND_CHOICE :
var v : = TableCard . vbox ( 3 )
prompt_label = RichText . label ( " " , 15 , Style . INK , true )
prompt_label . mouse_filter = Control . MOUSE_FILTER_IGNORE
v . add_child ( prompt_label )
Terminology pass: one set of kind and choice names, 2d6, result/change wording
- Describe.kind_label / choice_label / choice_labels replace six drifting
label tables. Search no longer calls Check and Router cards "Table", and
a Check card's dialog is titled "Check settings".
- Choice types read "Which option / How many / Open ended" everywhere
(menu, settings, inspector, card, preview, details).
- Plain dice read "2d6" / "d6" instead of the 2D-game "2D" / "1D".
- The built-in "2D skill check" template becomes "Skill check (2d6 vs
target)" (builtin:skill-check), a real Check card with Success and Failure.
- User text says "result" and "change" instead of "entry", "row" and "effect"
(Test board, settings dialog, lint, variables panel, pipe options).
- Pipes are deleted (link, toast, undo label), like cards and results; the
reset statement reads "Reset" in the builder and "Reset all X" for
prefixes. "Clear" stays for a value that really was erased.
- The template-saved toast points at "+ Card ▾".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:14:30 -06:00
var info : = Describe . choice_label ( table . choice )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
if table . choice == " number " :
info += " · %s to %s " % [ RulesView . dice ( table . min_expr , data , plain ) , RulesView . dice ( table . max_expr , data , plain ) ]
if table . save_as != " " :
info += " · saves %s " % RulesView . value_name ( table . save_as , data , plain )
var l : = Style . make_label ( info , Style . body ( true ) , 12 , Style . MUTED )
l . mouse_filter = Control . MOUSE_FILTER_IGNORE
l . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
v . add_child ( l )
if table . is_dynamic ( ) :
var bad : = not Roller . lint_options ( table ) . is_empty ( )
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 ol : = Style . make_label ( RulesView . options_line ( table , data , plain ) , Style . body_bold ( true ) , 12 , Style . DANGER_INK if bad else Style . TRIM_DARK )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
ol . mouse_filter = Control . MOUSE_FILTER_PASS
ol . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
Terminology pass: one set of kind and choice names, 2d6, result/change wording
- Describe.kind_label / choice_label / choice_labels replace six drifting
label tables. Search no longer calls Check and Router cards "Table", and
a Check card's dialog is titled "Check settings".
- Choice types read "Which option / How many / Open ended" everywhere
(menu, settings, inspector, card, preview, details).
- Plain dice read "2d6" / "d6" instead of the 2D-game "2D" / "1D".
- The built-in "2D skill check" template becomes "Skill check (2d6 vs
target)" (builtin:skill-check), a real Check card with Success and Failure.
- User text says "result" and "change" instead of "entry", "row" and "effect"
(Test board, settings dialog, lint, variables panel, pipe options).
- Pipes are deleted (link, toast, undo label), like cards and results; the
reset statement reads "Reset" in the builder and "Reset all X" for
prefixes. "Clear" stays for a value that really was erased.
- The template-saved toast points at "+ Card ▾".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:14:30 -06:00
ol . tooltip_text = " One option per %s ; the Chosen result runs for whichever is picked (option, option_label and option_value hold it) " % table . options_description ( )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
v . add_child ( ol )
if not _build :
options_label = Style . make_label ( " " , Style . body ( true ) , 12 , Style . MUTED )
options_label . mouse_filter = Control . MOUSE_FILTER_IGNORE
v . add_child ( options_label )
return v
RollTable . KIND_LOOP :
var chip : = PanelContainer . new ( )
chip . mouse_filter = Control . MOUSE_FILTER_PASS
chip . size_flags_horizontal = Control . SIZE_SHRINK_BEGIN
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
chip . add_theme_stylebox_override ( " panel " , Style . bordered ( Style . box ( Color ( Style . ACCENT , 0.16 ) , 6 , [ 8 , 1 , 8 , 2 ] ) , 1 , Color ( Style . ACCENT_DARK , 0.35 ) ) )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
var err : = Expr . check ( table . loop_expr ) if table . loop_expr . strip_edges ( ) != " " else " No rule yet "
var rule : = RulesView . loop_rule ( table , data , 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
var l : = Style . make_label ( rule , Style . display ( true ) , 16 , Style . DANGER_INK if err != " " else Style . TRIM_DARK )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
l . mouse_filter = Control . MOUSE_FILTER_IGNORE
if rule . length ( ) > 26 :
# A long plain rule wraps across the card instead of widening it.
l . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
chip . size_flags_horizontal = Control . SIZE_FILL
chip . add_child ( l )
chip . tooltip_text = err if err != " " else ( TableCardText . loop_rule ( table ) if plain else " " )
return chip
RollTable . KIND_ROUTER :
if not _build :
return null
2026-11-10 18:24:23 -06:00
var rl : = Style . make_label ( " Branch · the first true case is chosen " , Style . body ( true ) , 12 , Style . MUTED )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
rl . mouse_filter = Control . MOUSE_FILTER_IGNORE
rl . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
return rl
RollTable . KIND_VARIABLE :
var txt : = " @ %s · %s " % [ table . var_name , table . var_type ]
if table . is_collection ( ) :
2026-11-10 18:24:23 -06:00
txt = " Collection · kept between rolls " if plain else " @ %s _* (spread values) " % table . var_name
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
elif plain :
txt = " %s · kept between rolls " % table . var_type . capitalize ( )
var l : = Style . make_label ( txt , Style . body ( true ) , 12 , Style . MUTED )
l . mouse_filter = Control . MOUSE_FILTER_IGNORE
l . tooltip_text = " @ " + table . var_name if plain and not table . is_collection ( ) else " "
if l . tooltip_text != " " :
l . mouse_filter = Control . MOUSE_FILTER_PASS
return l
RollTable . KIND_CHECK :
var cl : = RichText . label ( TableCardText . check_sentence ( table , data , plain ) , 14 , Style . INK , true )
cl . mouse_filter = Control . MOUSE_FILTER_IGNORE
return cl
return null
## Re-renders the header's live labels: a dynamic pick's available count and a
## choice's question.
func refresh_live ( ) - > void :
var table : = card . table
var main : = card . main
if is_instance_valid ( options_label ) :
var n : = Roller . available_count ( table , Roller . live_context ( main . data , main . persistent_vars ) )
var txt : = " No options available now " if n == 0 else ( " 1 option available now " if n == 1 else " %d options available now " % n )
if options_label . text != txt :
options_label . text = txt
if is_instance_valid ( prompt_label ) :
var p : String
if main . mode == Main . Mode . BUILD :
p = RichText . preview ( table . prompt , main . data )
else :
p = RichText . decorate ( TextExpander . render ( table . prompt , Roller . live_context ( main . data , main . persistent_vars ) ) )
if prompt_label . text != p :
prompt_label . text = p
prompt_label . visible = table . prompt . strip_edges ( ) != " "
## A dashed box under the header naming the card's inputs: "Input Tier ·
## starts at 1" (plain) or "input tier · default 1" (text), one line each.
func make_inputs_box ( ) - > Control :
var wrap : = MarginContainer . new ( )
wrap . mouse_filter = Control . MOUSE_FILTER_PASS
wrap . add_theme_constant_override ( " margin_left " , 10 )
wrap . add_theme_constant_override ( " margin_right " , 10 )
wrap . add_theme_constant_override ( " margin_top " , 8 )
var p : = PanelContainer . new ( )
p . mouse_filter = Control . MOUSE_FILTER_PASS
p . add_theme_stylebox_override ( " panel " , DashedBox . new ( ) )
2026-11-10 18:24:23 -06:00
p . tooltip_text = " Values a thread into this card can pass ( \" with \" ); a roll that starts here uses the starting values "
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
wrap . add_child ( p )
var v : = TableCard . vbox ( 2 )
p . add_child ( v )
for inp : Dictionary in card . table . inputs :
var line : = RichText . label ( TableCardText . input_line ( inp , card . main . data , card . plain ) , 13 , Style . MUTED , true )
line . mouse_filter = Control . MOUSE_FILTER_IGNORE
line . set_meta ( " input_line " , true )
v . add_child ( line )
wrap . set_meta ( " inputs_box " , true )
return wrap
## A dashed rounded outline (the inputs box), since StyleBoxFlat has no
## dashes.
class DashedBox extends StyleBox :
func _init ( ) - > void :
content_margin_left = 9
content_margin_right = 9
content_margin_top = 6
content_margin_bottom = 6
func _draw ( to_canvas_item : RID , rect : Rect2 ) - > void :
var r : = rect . grow ( - 0.5 )
var pts : = PackedVector2Array ( [ r . position , Vector2 ( r . end . x , r . position . y ) , r . end , Vector2 ( r . position . x , r . end . y ) , r . position ] )
var col : = Style . DASH
for i in 4 :
var a : = pts [ i ]
var b : = pts [ i + 1 ]
var seg_len : = a . distance_to ( b )
var d : = 0.0
while d < seg_len :
var e : = minf ( d + 5.0 , seg_len )
RenderingServer . canvas_item_add_line ( to_canvas_item , a . lerp ( b , d / seg_len ) , a . lerp ( b , e / seg_len ) , col , 1.2 , true )
d += 9.0
## A fork: one stem splitting into two branches, each ending in a dot (the
## router card's go button). `r` is about half the icon's height.
static func draw_fork ( ci : CanvasItem , c : Vector2 , r : float , color : Color , width : float = 2.0 ) - > void :
var base : = c + Vector2 ( - r , 0 )
var split : = c + Vector2 ( - r * 0.15 , 0 )
ci . draw_line ( base , split , color , width , true )
var up : = c + Vector2 ( r * 0.85 , - r * 0.75 )
var down : = c + Vector2 ( r * 0.85 , r * 0.75 )
for tip : Vector2 in [ up , down ] :
var pts : = PackedVector2Array ( )
for k in 9 :
var u : = float ( k ) / 8.0
pts . append ( split . bezier_interpolate ( split + Vector2 ( r * 0.5 , 0 ) , tip - Vector2 ( r * 0.45 , 0 ) , tip , u ) )
ci . draw_polyline ( pts , color , width , true )
ci . draw_circle ( tip , width * 1.25 , color )
ci . draw_circle ( base , width * 0.9 , color )
## Card mode: "4 / 6 left" and a small Reshuffle link under the title.
func _make_deck_row ( ) - > Control :
var h : = TableCard . hbox ( 6 )
var pad : = Control . new ( )
pad . custom_minimum_size = Vector2 ( 26 , 0 )
pad . mouse_filter = Control . MOUSE_FILTER_IGNORE
h . add_child ( pad )
deck_label = Style . make_label ( " " , Style . body ( true ) , 12 , Style . MUTED )
deck_label . size_flags_vertical = Control . SIZE_SHRINK_CENTER
deck_label . mouse_filter = Control . MOUSE_FILTER_IGNORE
h . add_child ( deck_label )
var b : = Button . new ( )
b . text = " ↻ Reshuffle "
b . tooltip_text = " Put every card back in the deck "
b . add_theme_font_override ( " font " , Style . body ( true ) )
b . add_theme_font_size_override ( " font_size " , 12 )
b . size_flags_vertical = Control . SIZE_SHRINK_CENTER
var n : = Style . box ( Color ( 0 , 0 , 0 , 0 ) , 5 , [ 5 , 0 , 5 , 1 ] )
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 hv : = Style . box ( Style . CARD_HOVER , 5 , [ 5 , 0 , 5 , 1 ] )
Style . skin_button ( b , n , hv , hv , Style . TRIM , Style . INK )
Split TableCard into header, rows, editing, value-body and text helpers
ui/table_card.gd keeps the card node (setup, rebuild, styling, selection,
highlights API, geometry, drag input) and delegates to RefCounted helpers
that own their own state: TableCardHeader, TableCardRows, TableCardEditing,
TableCardValue, plus static TableCardText. No behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:10:57 -06:00
b . pressed . connect ( func ( ) - > void : card . main . reshuffle_table ( card . table . id ) )
h . add_child ( b )
update_deck ( )
return h
## Refreshes the cards-left count of a card-mode table.
func update_deck ( ) - > void :
if deck_label == null or not is_instance_valid ( deck_label ) :
return
var left : = card . main . cards_left ( card . table . id )
deck_label . text = " %d / %d left " % [ left . x , left . y ]
deck_label . add_theme_color_override ( " font_color " , Style . DANGER_INK if left . x == 0 else Style . MUTED )