Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
class_name Style
|
|
|
|
|
extends RefCounted
|
|
|
|
|
## Palette, fonts and stylebox helpers for the felt-board look.
|
|
|
|
|
|
|
|
|
|
const FELT := Color("#1f4a39")
|
|
|
|
|
const FELT_DEEP := Color("#12301f")
|
|
|
|
|
const FELT_HOVER := Color("#276048")
|
|
|
|
|
const CARD := Color("#efece2")
|
|
|
|
|
const INK := Color("#1c2520")
|
|
|
|
|
const MUTED := Color("#69726b")
|
|
|
|
|
const RULE := Color("#d8d3c3")
|
|
|
|
|
const COPPER := Color("#b8703a")
|
|
|
|
|
const COPPER_DARK := Color("#4f2b12")
|
|
|
|
|
const BRASS := Color("#f3c450")
|
|
|
|
|
const BRASS_DARK := Color("#6e5410")
|
|
|
|
|
const LIT := Color("#f8e4a2")
|
|
|
|
|
const FLICK := Color(0.953, 0.769, 0.314, 0.35)
|
|
|
|
|
const HOVER_ROW := Color("#e9e4d6")
|
|
|
|
|
const ON_FELT := Color("#e9efe9")
|
|
|
|
|
const ON_FELT_MUTED := Color("#a8bdb1")
|
|
|
|
|
const DANGER := Color("#e0574a")
|
|
|
|
|
const DANGER_INK := Color("#a33a2c")
|
|
|
|
|
const WARN_BG := Color("#f4dacb")
|
|
|
|
|
const WARN_INK := Color("#8a2f1d")
|
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 check card's Success and Failure outlets.
|
|
|
|
|
const OK_INK := Color("#2f6b3f")
|
|
|
|
|
const NO_INK := Color("#8a2f1d")
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
const DASH := Color("#bdb6a2")
|
|
|
|
|
const PULSE := Color("#fff6d2")
|
|
|
|
|
|
|
|
|
|
const FONT_DIR := "res://assets/fonts/"
|
|
|
|
|
|
|
|
|
|
static var _fonts: Dictionary = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Fonts ----------
|
|
|
|
|
# Cards live on the zoomable board, so they use MSDF fonts that stay sharp at any scale.
|
|
|
|
|
|
|
|
|
|
static func _file(file: String, msdf: bool) -> FontFile:
|
|
|
|
|
var key := "%s|%s" % [file, msdf]
|
|
|
|
|
if not _fonts.has(key):
|
|
|
|
|
var f: FontFile = load(FONT_DIR + file)
|
|
|
|
|
if msdf:
|
|
|
|
|
f = f.duplicate() as FontFile
|
|
|
|
|
f.multichannel_signed_distance_field = true
|
|
|
|
|
_fonts[key] = f
|
|
|
|
|
return _fonts[key]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func body(msdf: bool = false) -> Font:
|
|
|
|
|
return _file("AtkinsonHyperlegible-Regular.ttf", msdf)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func body_bold(msdf: bool = false) -> Font:
|
|
|
|
|
return _file("AtkinsonHyperlegible-Bold.ttf", msdf)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func body_italic(msdf: bool = false) -> Font:
|
|
|
|
|
return _file("AtkinsonHyperlegible-Italic.ttf", msdf)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Rokkitt, the slab display face. It's a variable font with overlapping
|
|
|
|
|
## outlines, which MSDF renders badly, so on cards it is oversampled instead.
|
|
|
|
|
static func display(zoomable: bool = false, weight: int = 700) -> Font:
|
|
|
|
|
var key := "display|%d|%s" % [weight, zoomable]
|
|
|
|
|
if not _fonts.has(key):
|
|
|
|
|
var v := FontVariation.new()
|
|
|
|
|
var base := _file("Rokkitt-Variable.ttf", false)
|
|
|
|
|
if zoomable:
|
|
|
|
|
base = base.duplicate() as FontFile
|
|
|
|
|
base.oversampling = 2.0
|
|
|
|
|
v.base_font = base
|
|
|
|
|
v.variation_opentype = {TextServerManager.get_primary_interface().name_to_tag("wght"): weight}
|
|
|
|
|
_fonts[key] = v
|
|
|
|
|
return _fonts[key]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Bold body face with a little letter-spacing, for small uppercase labels.
|
|
|
|
|
static func caps() -> Font:
|
|
|
|
|
if not _fonts.has("caps"):
|
|
|
|
|
var v := FontVariation.new()
|
|
|
|
|
v.base_font = body_bold()
|
|
|
|
|
v.spacing_glyph = 1
|
|
|
|
|
_fonts["caps"] = v
|
|
|
|
|
return _fonts["caps"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Styleboxes ----------
|
|
|
|
|
|
|
|
|
|
## margins: [left, top, right, bottom]
|
|
|
|
|
static func box(bg: Color, radius: int = 0, margins: Array = [0, 0, 0, 0]) -> StyleBoxFlat:
|
|
|
|
|
var s := StyleBoxFlat.new()
|
|
|
|
|
s.bg_color = bg
|
|
|
|
|
s.set_corner_radius_all(radius)
|
|
|
|
|
s.content_margin_left = margins[0]
|
|
|
|
|
s.content_margin_top = margins[1]
|
|
|
|
|
s.content_margin_right = margins[2]
|
|
|
|
|
s.content_margin_bottom = margins[3]
|
|
|
|
|
s.anti_aliasing = true
|
|
|
|
|
return s
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func bordered(s: StyleBoxFlat, width: int, color: Color) -> StyleBoxFlat:
|
|
|
|
|
s.set_border_width_all(width)
|
|
|
|
|
s.border_color = color
|
|
|
|
|
return s
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func focus_ring(radius: int = 8) -> StyleBoxFlat:
|
|
|
|
|
var s := box(Color(0, 0, 0, 0), radius)
|
|
|
|
|
s.draw_center = false
|
|
|
|
|
bordered(s, 2, BRASS)
|
|
|
|
|
s.set_expand_margin_all(2)
|
|
|
|
|
return s
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func skin_button(b: Button, normal: StyleBox, hover: StyleBox, pressed: StyleBox,
|
|
|
|
|
fg: Color, fg_hover: Color = Color(0, 0, 0, 0), fg_pressed: Color = Color(0, 0, 0, 0)) -> void:
|
|
|
|
|
if fg_hover.a == 0.0:
|
|
|
|
|
fg_hover = fg
|
|
|
|
|
if fg_pressed.a == 0.0:
|
|
|
|
|
fg_pressed = fg_hover
|
|
|
|
|
b.add_theme_stylebox_override("normal", normal)
|
|
|
|
|
b.add_theme_stylebox_override("hover", hover)
|
|
|
|
|
b.add_theme_stylebox_override("pressed", pressed)
|
|
|
|
|
b.add_theme_stylebox_override("hover_pressed", pressed)
|
|
|
|
|
b.add_theme_stylebox_override("disabled", normal)
|
|
|
|
|
b.add_theme_stylebox_override("focus", focus_ring())
|
|
|
|
|
b.add_theme_color_override("font_color", fg)
|
|
|
|
|
b.add_theme_color_override("font_hover_color", fg_hover)
|
|
|
|
|
b.add_theme_color_override("font_focus_color", fg)
|
|
|
|
|
b.add_theme_color_override("font_pressed_color", fg_pressed)
|
|
|
|
|
b.add_theme_color_override("font_hover_pressed_color", fg_pressed)
|
|
|
|
|
b.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func make_label(text: String, font: Font, font_size: int, color: Color) -> Label:
|
|
|
|
|
var l := Label.new()
|
|
|
|
|
l.text = text
|
|
|
|
|
l.add_theme_font_override("font", font)
|
|
|
|
|
l.add_theme_font_size_override("font_size", font_size)
|
|
|
|
|
l.add_theme_color_override("font_color", color)
|
|
|
|
|
return l
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## A top-bar button: translucent on felt, or brass when primary.
|
|
|
|
|
static func bar_button(text: String, primary: bool = false) -> Button:
|
|
|
|
|
var b := Button.new()
|
|
|
|
|
b.text = text
|
|
|
|
|
var normal := bordered(box(Color(1, 1, 1, 0.04), 8, [12, 6, 12, 6]), 1, Color(1, 1, 1, 0.16))
|
|
|
|
|
var hover := bordered(box(Color(1, 1, 1, 0.1), 8, [12, 6, 12, 6]), 1, Color(1, 1, 1, 0.16))
|
|
|
|
|
var fg := ON_FELT
|
|
|
|
|
if primary:
|
|
|
|
|
normal = bordered(box(BRASS, 8, [12, 6, 12, 6]), 1, BRASS)
|
|
|
|
|
hover = bordered(box(BRASS.lightened(0.15), 8, [12, 6, 12, 6]), 1, BRASS.lightened(0.15))
|
|
|
|
|
fg = INK
|
|
|
|
|
b.add_theme_font_override("font", body_bold())
|
|
|
|
|
skin_button(b, normal, hover, hover, fg)
|
|
|
|
|
b.add_theme_font_size_override("font_size", 15)
|
|
|
|
|
return b
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
## The Plain words / Text switch's look (docs/PLAIN.md §5; the switch itself
|
|
|
|
|
## is Main's): two segment buttons on the felt, the chosen one card-coloured.
|
|
|
|
|
## Adds them to `into` and returns [plain_button, text_button]; `on_change`
|
|
|
|
|
## gets true for Plain words.
|
|
|
|
|
static func rules_switch(into: HBoxContainer, is_plain: bool, on_change: Callable) -> Array[Button]:
|
|
|
|
|
var group := ButtonGroup.new()
|
|
|
|
|
var out: Array[Button] = []
|
|
|
|
|
for k in 2:
|
|
|
|
|
var b := Button.new()
|
|
|
|
|
b.text = "Plain words" if k == 0 else "Text"
|
|
|
|
|
b.toggle_mode = true
|
|
|
|
|
b.button_group = group
|
|
|
|
|
b.button_pressed = (k == 0) == is_plain
|
|
|
|
|
b.tooltip_text = "Show rules in plain words" if k == 0 else "Show rules as their stored text"
|
|
|
|
|
var n := box(Color(0, 0, 0, 0), 7, [11, 4, 11, 5])
|
|
|
|
|
var h := box(Color(1, 1, 1, 0.08), 7, [11, 4, 11, 5])
|
|
|
|
|
var on := box(CARD, 7, [11, 4, 11, 5])
|
|
|
|
|
skin_button(b, n, h, on, ON_FELT_MUTED, ON_FELT, INK)
|
|
|
|
|
b.add_theme_font_override("font", body_bold())
|
|
|
|
|
b.add_theme_font_size_override("font_size", 13)
|
|
|
|
|
var want := k == 0
|
|
|
|
|
b.pressed.connect(func() -> void: on_change.call(want))
|
|
|
|
|
into.add_child(b)
|
|
|
|
|
out.append(b)
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
# ---------- Themes ----------
|
|
|
|
|
|
|
|
|
|
static func app_theme() -> Theme:
|
|
|
|
|
var th := Theme.new()
|
|
|
|
|
th.default_font = body()
|
|
|
|
|
th.default_font_size = 16
|
|
|
|
|
th.set_color("font_color", "Label", ON_FELT)
|
|
|
|
|
th.set_stylebox("panel", "TooltipPanel", box(CARD, 6, [8, 5, 8, 5]))
|
|
|
|
|
th.set_color("font_color", "TooltipLabel", INK)
|
|
|
|
|
return th
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func card_theme() -> Theme:
|
|
|
|
|
var th := Theme.new()
|
|
|
|
|
th.default_font = body(true)
|
|
|
|
|
th.default_font_size = 16
|
|
|
|
|
th.set_color("font_color", "Label", INK)
|
|
|
|
|
var normal := bordered(box(Color(1, 1, 1, 0), 5, [6, 3, 6, 3]), 1, Color(1, 1, 1, 0))
|
|
|
|
|
var focus := bordered(box(Color.WHITE, 5, [6, 3, 6, 3]), 1, COPPER)
|
|
|
|
|
th.set_stylebox("normal", "LineEdit", normal)
|
|
|
|
|
th.set_stylebox("focus", "LineEdit", focus)
|
|
|
|
|
th.set_stylebox("read_only", "LineEdit", normal)
|
|
|
|
|
th.set_color("font_color", "LineEdit", INK)
|
|
|
|
|
th.set_color("caret_color", "LineEdit", INK)
|
|
|
|
|
th.set_color("selection_color", "LineEdit", Color(BRASS, 0.55))
|
|
|
|
|
th.set_color("font_placeholder_color", "LineEdit", MUTED)
|
|
|
|
|
# Card fields are sized by their containers, not by a minimum character count.
|
|
|
|
|
th.set_constant("minimum_character_width", "LineEdit", 0)
|
|
|
|
|
return th
|