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 CardLayer
|
|
|
|
|
extends Control
|
|
|
|
|
## Holds the table cards and paints their hard drop shadow underneath them.
|
Big-board navigation: search, focus_table, minimap, pack, lazy cards
- Search (top bar button and Ctrl+F): a card-styled pop-over with live
results from names, result text, details, prompts, variables and group
names (BBCode stripped, case and accents ignored, exact names first).
Up/Down, Enter or click jump to a result, Esc closes.
- Main.focus_table(table_id, entry_id): opens a collapsed group (toast),
expands the card for an entry, glides to it at a readable zoom, scrolls
the long list and flashes rings around the card and the row.
- Minimap (Map toggle beside Fit, M key): tinted blocks, lit cards in
brass, the view rect; click or drag to pan. Off by default in Play, on in
Build, remembered per mode. Redraws only on change.
- Zoom goes down to 0.08 and Fit uses it; far out, cards draw as plain
cards and group names show large.
- Build > Arrange > Pack collapsed groups closes the gaps collapsed blocks
leave, in reading order, with undo. Expanding a group whose frame would
cover its neighbours pushes them right/down to clear it, with undo.
- Performance: cards in collapsed groups aren't built until expanded; the
pipe, port and card layers redraw only when the board's geometry
changes; unlit pipes go in per-pipe canvas items so off-screen ones are
culled; off-screen cards aren't rendered. 792-card board: open 5.0 s ->
0.38 s, idle frame 36 ms -> 0.7 ms (all groups expanded: 313 ms -> 9 ms).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:16:32 -06:00
|
|
|
## Redraws only when the board's geometry changes (BoardView calls
|
|
|
|
|
## queue_redraw), not every frame.
|
|
|
|
|
##
|
|
|
|
|
## Far out (BoardView.FAR_ZOOM) the cards' contents aren't rendered; the
|
|
|
|
|
## overlay sketches each card's title line (brass when it holds a lit result)
|
|
|
|
|
## and writes group names large enough to read.
|
|
|
|
|
##
|
|
|
|
|
## It also owns the focus flash (Main.focus_table): a brass ring around a card
|
|
|
|
|
## and, optionally, around one of its rows, fading out over FLASH_TIME. The
|
|
|
|
|
## flash is drawn in `overlay`, a layer BoardView puts above the cards.
|
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
|
|
|
|
Big-board navigation: search, focus_table, minimap, pack, lazy cards
- Search (top bar button and Ctrl+F): a card-styled pop-over with live
results from names, result text, details, prompts, variables and group
names (BBCode stripped, case and accents ignored, exact names first).
Up/Down, Enter or click jump to a result, Esc closes.
- Main.focus_table(table_id, entry_id): opens a collapsed group (toast),
expands the card for an entry, glides to it at a readable zoom, scrolls
the long list and flashes rings around the card and the row.
- Minimap (Map toggle beside Fit, M key): tinted blocks, lit cards in
brass, the view rect; click or drag to pan. Off by default in Play, on in
Build, remembered per mode. Redraws only on change.
- Zoom goes down to 0.08 and Fit uses it; far out, cards draw as plain
cards and group names show large.
- Build > Arrange > Pack collapsed groups closes the gaps collapsed blocks
leave, in reading order, with undo. Expanding a group whose frame would
cover its neighbours pushes them right/down to clear it, with undo.
- Performance: cards in collapsed groups aren't built until expanded; the
pipe, port and card layers redraw only when the board's geometry
changes; unlit pipes go in per-pipe canvas items so off-screen ones are
culled; off-screen cards aren't rendered. 792-card board: open 5.0 s ->
0.38 s, idle frame 36 ms -> 0.7 ms (all groups expanded: 313 ms -> 9 ms).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:16:32 -06:00
|
|
|
const FLASH_TIME := 1.5
|
|
|
|
|
|
|
|
|
|
## Drawn above the cards (BoardView adds it to the world after this layer).
|
|
|
|
|
var overlay: Control
|
|
|
|
|
var main: Main
|
|
|
|
|
## True while the board is zoomed out past BoardView.FAR_ZOOM.
|
|
|
|
|
var far := false
|
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
|
|
|
var _shadow: StyleBoxFlat
|
Big-board navigation: search, focus_table, minimap, pack, lazy cards
- Search (top bar button and Ctrl+F): a card-styled pop-over with live
results from names, result text, details, prompts, variables and group
names (BBCode stripped, case and accents ignored, exact names first).
Up/Down, Enter or click jump to a result, Esc closes.
- Main.focus_table(table_id, entry_id): opens a collapsed group (toast),
expands the card for an entry, glides to it at a readable zoom, scrolls
the long list and flashes rings around the card and the row.
- Minimap (Map toggle beside Fit, M key): tinted blocks, lit cards in
brass, the view rect; click or drag to pan. Off by default in Play, on in
Build, remembered per mode. Redraws only on change.
- Zoom goes down to 0.08 and Fit uses it; far out, cards draw as plain
cards and group names show large.
- Build > Arrange > Pack collapsed groups closes the gaps collapsed blocks
leave, in reading order, with undo. Expanding a group whose frame would
cover its neighbours pushes them right/down to clear it, with undo.
- Performance: cards in collapsed groups aren't built until expanded; the
pipe, port and card layers redraw only when the board's geometry
changes; unlit pipes go in per-pipe canvas items so off-screen ones are
culled; off-screen cards aren't rendered. 792-card board: open 5.0 s ->
0.38 s, idle frame 36 ms -> 0.7 ms (all groups expanded: 313 ms -> 9 ms).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:16:32 -06:00
|
|
|
var _ring: StyleBoxFlat
|
|
|
|
|
var _flash_node: Control = null
|
Undo and redo for every Build edit
EditHistory (ui/edit_history.gd) keeps an undo and a redo stack of
whole-board snapshots per collection. Each table and group is its own
JSON string, shared with the previous snapshot when unchanged, so a step
costs about the size of the cards it changed. Collapsed flags are kept
apart: collapsing isn't a step and undo leaves it as it is. Labels come
from diffing the snapshots ("Delete table Loot", "Add pipe Loot → Gems",
"Move 3 cards", "Group Careers"), or from the caller.
Main.mark_dirty records steps: typing commits when it pauses (0.8 s) and
merges until focus moves, other edits commit at the end of the frame (a
drag is one step), and quick edits to the same card or pipe merge.
Actions in main.gd bracket their changes with _begin_edit/_end_edit.
Undo patches only the changed tables and groups in place and rebuilds
their cards, keeping view, mode, search and lit results, then flashes
what changed. Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y outside text fields (Play
too), Undo/Redo buttons with step tooltips in the Build bar, and the
toast's Undo now goes through the history.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 19:00:47 -06:00
|
|
|
## More nodes ringed along with _flash_node (flash_all: an undo's changes).
|
|
|
|
|
var _flash_extra: Array[Control] = []
|
Big-board navigation: search, focus_table, minimap, pack, lazy cards
- Search (top bar button and Ctrl+F): a card-styled pop-over with live
results from names, result text, details, prompts, variables and group
names (BBCode stripped, case and accents ignored, exact names first).
Up/Down, Enter or click jump to a result, Esc closes.
- Main.focus_table(table_id, entry_id): opens a collapsed group (toast),
expands the card for an entry, glides to it at a readable zoom, scrolls
the long list and flashes rings around the card and the row.
- Minimap (Map toggle beside Fit, M key): tinted blocks, lit cards in
brass, the view rect; click or drag to pan. Off by default in Play, on in
Build, remembered per mode. Redraws only on change.
- Zoom goes down to 0.08 and Fit uses it; far out, cards draw as plain
cards and group names show large.
- Build > Arrange > Pack collapsed groups closes the gaps collapsed blocks
leave, in reading order, with undo. Expanding a group whose frame would
cover its neighbours pushes them right/down to clear it, with undo.
- Performance: cards in collapsed groups aren't built until expanded; the
pipe, port and card layers redraw only when the board's geometry
changes; unlit pipes go in per-pipe canvas items so off-screen ones are
culled; off-screen cards aren't rendered. 792-card board: open 5.0 s ->
0.38 s, idle frame 36 ms -> 0.7 ms (all groups expanded: 313 ms -> 9 ms).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:16:32 -06:00
|
|
|
var _flash_row: Rect2 = Rect2()
|
|
|
|
|
var _flash_left := 0.0
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
|
|
|
|
mouse_filter = MOUSE_FILTER_IGNORE
|
|
|
|
|
# Controls only draw inside their own rect, so cover the whole world.
|
|
|
|
|
size = Vector2(BoardView.WORLD_SIZE, BoardView.WORLD_SIZE)
|
|
|
|
|
_shadow = Style.box(Color(0, 0, 0, 0.22), 10)
|
Big-board navigation: search, focus_table, minimap, pack, lazy cards
- Search (top bar button and Ctrl+F): a card-styled pop-over with live
results from names, result text, details, prompts, variables and group
names (BBCode stripped, case and accents ignored, exact names first).
Up/Down, Enter or click jump to a result, Esc closes.
- Main.focus_table(table_id, entry_id): opens a collapsed group (toast),
expands the card for an entry, glides to it at a readable zoom, scrolls
the long list and flashes rings around the card and the row.
- Minimap (Map toggle beside Fit, M key): tinted blocks, lit cards in
brass, the view rect; click or drag to pan. Off by default in Play, on in
Build, remembered per mode. Redraws only on change.
- Zoom goes down to 0.08 and Fit uses it; far out, cards draw as plain
cards and group names show large.
- Build > Arrange > Pack collapsed groups closes the gaps collapsed blocks
leave, in reading order, with undo. Expanding a group whose frame would
cover its neighbours pushes them right/down to clear it, with undo.
- Performance: cards in collapsed groups aren't built until expanded; the
pipe, port and card layers redraw only when the board's geometry
changes; unlit pipes go in per-pipe canvas items so off-screen ones are
culled; off-screen cards aren't rendered. 792-card board: open 5.0 s ->
0.38 s, idle frame 36 ms -> 0.7 ms (all groups expanded: 313 ms -> 9 ms).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:16:32 -06:00
|
|
|
_ring = Style.box(Color(0, 0, 0, 0), 14)
|
|
|
|
|
_ring.draw_center = false
|
|
|
|
|
Style.bordered(_ring, 4, Style.BRASS)
|
|
|
|
|
overlay = Control.new()
|
|
|
|
|
overlay.mouse_filter = MOUSE_FILTER_IGNORE
|
|
|
|
|
overlay.size = size
|
|
|
|
|
overlay.draw.connect(_draw_flash)
|
|
|
|
|
set_process(false)
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
func _draw() -> void:
|
|
|
|
|
for c in get_children():
|
|
|
|
|
var card := c as Control
|
|
|
|
|
if card and card.visible:
|
|
|
|
|
draw_style_box(_shadow, Rect2(card.position + Vector2(0, 5), card.size))
|
Big-board navigation: search, focus_table, minimap, pack, lazy cards
- Search (top bar button and Ctrl+F): a card-styled pop-over with live
results from names, result text, details, prompts, variables and group
names (BBCode stripped, case and accents ignored, exact names first).
Up/Down, Enter or click jump to a result, Esc closes.
- Main.focus_table(table_id, entry_id): opens a collapsed group (toast),
expands the card for an entry, glides to it at a readable zoom, scrolls
the long list and flashes rings around the card and the row.
- Minimap (Map toggle beside Fit, M key): tinted blocks, lit cards in
brass, the view rect; click or drag to pan. Off by default in Play, on in
Build, remembered per mode. Redraws only on change.
- Zoom goes down to 0.08 and Fit uses it; far out, cards draw as plain
cards and group names show large.
- Build > Arrange > Pack collapsed groups closes the gaps collapsed blocks
leave, in reading order, with undo. Expanding a group whose frame would
cover its neighbours pushes them right/down to clear it, with undo.
- Performance: cards in collapsed groups aren't built until expanded; the
pipe, port and card layers redraw only when the board's geometry
changes; unlit pipes go in per-pipe canvas items so off-screen ones are
culled; off-screen cards aren't rendered. 792-card board: open 5.0 s ->
0.38 s, idle frame 36 ms -> 0.7 ms (all groups expanded: 313 ms -> 9 ms).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:16:32 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
## Flashes a ring around `node` (a TableCard or GroupCard) for FLASH_TIME.
|
|
|
|
|
## `row` is a world rect inside it to ring as well (Rect2() for none).
|
|
|
|
|
func flash(node: Control, row: Rect2 = Rect2()) -> void:
|
Undo and redo for every Build edit
EditHistory (ui/edit_history.gd) keeps an undo and a redo stack of
whole-board snapshots per collection. Each table and group is its own
JSON string, shared with the previous snapshot when unchanged, so a step
costs about the size of the cards it changed. Collapsed flags are kept
apart: collapsing isn't a step and undo leaves it as it is. Labels come
from diffing the snapshots ("Delete table Loot", "Add pipe Loot → Gems",
"Move 3 cards", "Group Careers"), or from the caller.
Main.mark_dirty records steps: typing commits when it pauses (0.8 s) and
merges until focus moves, other edits commit at the end of the frame (a
drag is one step), and quick edits to the same card or pipe merge.
Actions in main.gd bracket their changes with _begin_edit/_end_edit.
Undo patches only the changed tables and groups in place and rebuilds
their cards, keeping view, mode, search and lit results, then flashes
what changed. Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y outside text fields (Play
too), Undo/Redo buttons with step tooltips in the Build bar, and the
toast's Undo now goes through the history.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 19:00:47 -06:00
|
|
|
_flash_extra.clear()
|
Big-board navigation: search, focus_table, minimap, pack, lazy cards
- Search (top bar button and Ctrl+F): a card-styled pop-over with live
results from names, result text, details, prompts, variables and group
names (BBCode stripped, case and accents ignored, exact names first).
Up/Down, Enter or click jump to a result, Esc closes.
- Main.focus_table(table_id, entry_id): opens a collapsed group (toast),
expands the card for an entry, glides to it at a readable zoom, scrolls
the long list and flashes rings around the card and the row.
- Minimap (Map toggle beside Fit, M key): tinted blocks, lit cards in
brass, the view rect; click or drag to pan. Off by default in Play, on in
Build, remembered per mode. Redraws only on change.
- Zoom goes down to 0.08 and Fit uses it; far out, cards draw as plain
cards and group names show large.
- Build > Arrange > Pack collapsed groups closes the gaps collapsed blocks
leave, in reading order, with undo. Expanding a group whose frame would
cover its neighbours pushes them right/down to clear it, with undo.
- Performance: cards in collapsed groups aren't built until expanded; the
pipe, port and card layers redraw only when the board's geometry
changes; unlit pipes go in per-pipe canvas items so off-screen ones are
culled; off-screen cards aren't rendered. 792-card board: open 5.0 s ->
0.38 s, idle frame 36 ms -> 0.7 ms (all groups expanded: 313 ms -> 9 ms).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:16:32 -06:00
|
|
|
_flash_node = node
|
|
|
|
|
_flash_row = row
|
|
|
|
|
_flash_left = FLASH_TIME
|
|
|
|
|
set_process(true)
|
|
|
|
|
overlay.queue_redraw()
|
|
|
|
|
|
|
|
|
|
|
Undo and redo for every Build edit
EditHistory (ui/edit_history.gd) keeps an undo and a redo stack of
whole-board snapshots per collection. Each table and group is its own
JSON string, shared with the previous snapshot when unchanged, so a step
costs about the size of the cards it changed. Collapsed flags are kept
apart: collapsing isn't a step and undo leaves it as it is. Labels come
from diffing the snapshots ("Delete table Loot", "Add pipe Loot → Gems",
"Move 3 cards", "Group Careers"), or from the caller.
Main.mark_dirty records steps: typing commits when it pauses (0.8 s) and
merges until focus moves, other edits commit at the end of the frame (a
drag is one step), and quick edits to the same card or pipe merge.
Actions in main.gd bracket their changes with _begin_edit/_end_edit.
Undo patches only the changed tables and groups in place and rebuilds
their cards, keeping view, mode, search and lit results, then flashes
what changed. Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y outside text fields (Play
too), Undo/Redo buttons with step tooltips in the Build bar, and the
toast's Undo now goes through the history.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 19:00:47 -06:00
|
|
|
## Flashes rings around several nodes at once (none: nothing happens).
|
|
|
|
|
func flash_all(nodes: Array[Control]) -> void:
|
|
|
|
|
if nodes.is_empty():
|
|
|
|
|
return
|
|
|
|
|
flash(nodes[0])
|
|
|
|
|
_flash_extra = nodes.slice(1)
|
|
|
|
|
|
|
|
|
|
|
Big-board navigation: search, focus_table, minimap, pack, lazy cards
- Search (top bar button and Ctrl+F): a card-styled pop-over with live
results from names, result text, details, prompts, variables and group
names (BBCode stripped, case and accents ignored, exact names first).
Up/Down, Enter or click jump to a result, Esc closes.
- Main.focus_table(table_id, entry_id): opens a collapsed group (toast),
expands the card for an entry, glides to it at a readable zoom, scrolls
the long list and flashes rings around the card and the row.
- Minimap (Map toggle beside Fit, M key): tinted blocks, lit cards in
brass, the view rect; click or drag to pan. Off by default in Play, on in
Build, remembered per mode. Redraws only on change.
- Zoom goes down to 0.08 and Fit uses it; far out, cards draw as plain
cards and group names show large.
- Build > Arrange > Pack collapsed groups closes the gaps collapsed blocks
leave, in reading order, with undo. Expanding a group whose frame would
cover its neighbours pushes them right/down to clear it, with undo.
- Performance: cards in collapsed groups aren't built until expanded; the
pipe, port and card layers redraw only when the board's geometry
changes; unlit pipes go in per-pipe canvas items so off-screen ones are
culled; off-screen cards aren't rendered. 792-card board: open 5.0 s ->
0.38 s, idle frame 36 ms -> 0.7 ms (all groups expanded: 313 ms -> 9 ms).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:16:32 -06:00
|
|
|
func is_flashing() -> bool:
|
|
|
|
|
return _flash_left > 0.0 and is_instance_valid(_flash_node)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The world rect of the flashed card, or Rect2() when nothing flashes.
|
|
|
|
|
func flash_rect() -> Rect2:
|
|
|
|
|
if not is_flashing():
|
|
|
|
|
return Rect2()
|
|
|
|
|
return Rect2(_flash_node.position, _flash_node.size)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func flash_row_rect() -> Rect2:
|
|
|
|
|
return _flash_row if is_flashing() else Rect2()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> void:
|
|
|
|
|
_flash_left -= delta
|
|
|
|
|
overlay.queue_redraw()
|
|
|
|
|
if _flash_left <= 0.0:
|
|
|
|
|
_flash_node = null
|
Undo and redo for every Build edit
EditHistory (ui/edit_history.gd) keeps an undo and a redo stack of
whole-board snapshots per collection. Each table and group is its own
JSON string, shared with the previous snapshot when unchanged, so a step
costs about the size of the cards it changed. Collapsed flags are kept
apart: collapsing isn't a step and undo leaves it as it is. Labels come
from diffing the snapshots ("Delete table Loot", "Add pipe Loot → Gems",
"Move 3 cards", "Group Careers"), or from the caller.
Main.mark_dirty records steps: typing commits when it pauses (0.8 s) and
merges until focus moves, other edits commit at the end of the frame (a
drag is one step), and quick edits to the same card or pipe merge.
Actions in main.gd bracket their changes with _begin_edit/_end_edit.
Undo patches only the changed tables and groups in place and rebuilds
their cards, keeping view, mode, search and lit results, then flashes
what changed. Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y outside text fields (Play
too), Undo/Redo buttons with step tooltips in the Build bar, and the
toast's Undo now goes through the history.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 19:00:47 -06:00
|
|
|
_flash_extra.clear()
|
Big-board navigation: search, focus_table, minimap, pack, lazy cards
- Search (top bar button and Ctrl+F): a card-styled pop-over with live
results from names, result text, details, prompts, variables and group
names (BBCode stripped, case and accents ignored, exact names first).
Up/Down, Enter or click jump to a result, Esc closes.
- Main.focus_table(table_id, entry_id): opens a collapsed group (toast),
expands the card for an entry, glides to it at a readable zoom, scrolls
the long list and flashes rings around the card and the row.
- Minimap (Map toggle beside Fit, M key): tinted blocks, lit cards in
brass, the view rect; click or drag to pan. Off by default in Play, on in
Build, remembered per mode. Redraws only on change.
- Zoom goes down to 0.08 and Fit uses it; far out, cards draw as plain
cards and group names show large.
- Build > Arrange > Pack collapsed groups closes the gaps collapsed blocks
leave, in reading order, with undo. Expanding a group whose frame would
cover its neighbours pushes them right/down to clear it, with undo.
- Performance: cards in collapsed groups aren't built until expanded; the
pipe, port and card layers redraw only when the board's geometry
changes; unlit pipes go in per-pipe canvas items so off-screen ones are
culled; off-screen cards aren't rendered. 792-card board: open 5.0 s ->
0.38 s, idle frame 36 ms -> 0.7 ms (all groups expanded: 313 ms -> 9 ms).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:16:32 -06:00
|
|
|
set_process(false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _draw_flash() -> void:
|
|
|
|
|
if far:
|
|
|
|
|
_draw_far()
|
|
|
|
|
if not is_flashing():
|
|
|
|
|
return
|
|
|
|
|
var t := clampf(_flash_left / FLASH_TIME, 0.0, 1.0)
|
|
|
|
|
# Two quick pulses, then a fade.
|
|
|
|
|
var pulse := 0.65 + 0.35 * cos((1.0 - t) * TAU * 2.0)
|
|
|
|
|
var a := minf(1.0, t * 2.5) * pulse
|
|
|
|
|
_ring.border_color = Color(Style.BRASS, a)
|
Undo and redo for every Build edit
EditHistory (ui/edit_history.gd) keeps an undo and a redo stack of
whole-board snapshots per collection. Each table and group is its own
JSON string, shared with the previous snapshot when unchanged, so a step
costs about the size of the cards it changed. Collapsed flags are kept
apart: collapsing isn't a step and undo leaves it as it is. Labels come
from diffing the snapshots ("Delete table Loot", "Add pipe Loot → Gems",
"Move 3 cards", "Group Careers"), or from the caller.
Main.mark_dirty records steps: typing commits when it pauses (0.8 s) and
merges until focus moves, other edits commit at the end of the frame (a
drag is one step), and quick edits to the same card or pipe merge.
Actions in main.gd bracket their changes with _begin_edit/_end_edit.
Undo patches only the changed tables and groups in place and rebuilds
their cards, keeping view, mode, search and lit results, then flashes
what changed. Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y outside text fields (Play
too), Undo/Redo buttons with step tooltips in the Build bar, and the
toast's Undo now goes through the history.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 19:00:47 -06:00
|
|
|
var glow := _glow_box(a)
|
|
|
|
|
for v: Variant in [_flash_node] + _flash_extra:
|
|
|
|
|
if not is_instance_valid(v):
|
|
|
|
|
continue
|
|
|
|
|
var n := v as Control
|
|
|
|
|
if n.visible:
|
|
|
|
|
var r := Rect2(n.position, n.size).grow(8.0)
|
|
|
|
|
overlay.draw_style_box(glow, r.grow(6.0))
|
|
|
|
|
overlay.draw_style_box(_ring, r)
|
Big-board navigation: search, focus_table, minimap, pack, lazy cards
- Search (top bar button and Ctrl+F): a card-styled pop-over with live
results from names, result text, details, prompts, variables and group
names (BBCode stripped, case and accents ignored, exact names first).
Up/Down, Enter or click jump to a result, Esc closes.
- Main.focus_table(table_id, entry_id): opens a collapsed group (toast),
expands the card for an entry, glides to it at a readable zoom, scrolls
the long list and flashes rings around the card and the row.
- Minimap (Map toggle beside Fit, M key): tinted blocks, lit cards in
brass, the view rect; click or drag to pan. Off by default in Play, on in
Build, remembered per mode. Redraws only on change.
- Zoom goes down to 0.08 and Fit uses it; far out, cards draw as plain
cards and group names show large.
- Build > Arrange > Pack collapsed groups closes the gaps collapsed blocks
leave, in reading order, with undo. Expanding a group whose frame would
cover its neighbours pushes them right/down to clear it, with undo.
- Performance: cards in collapsed groups aren't built until expanded; the
pipe, port and card layers redraw only when the board's geometry
changes; unlit pipes go in per-pipe canvas items so off-screen ones are
culled; off-screen cards aren't rendered. 792-card board: open 5.0 s ->
0.38 s, idle frame 36 ms -> 0.7 ms (all groups expanded: 313 ms -> 9 ms).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:16:32 -06:00
|
|
|
if _flash_row.size != Vector2.ZERO:
|
|
|
|
|
overlay.draw_rect(_flash_row, Color(Style.BRASS, 0.28 * a))
|
|
|
|
|
overlay.draw_rect(_flash_row, Color(Style.BRASS_DARK, a), false, 2.5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _glow_box(a: float) -> StyleBoxFlat:
|
|
|
|
|
var g := Style.box(Color(0, 0, 0, 0), 20)
|
|
|
|
|
g.draw_center = false
|
|
|
|
|
Style.bordered(g, 8, Color(Style.BRASS, 0.25 * a))
|
|
|
|
|
return g
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The far-out sketch: a title line per card, group names in large type.
|
|
|
|
|
func _draw_far() -> void:
|
|
|
|
|
if main == null or main.data == null:
|
|
|
|
|
return
|
|
|
|
|
var lit := {}
|
|
|
|
|
for k: String in main.lit_entries:
|
|
|
|
|
lit[k.substr(0, k.rfind(":"))] = true
|
|
|
|
|
var ink := Color(Style.INK, 0.45)
|
|
|
|
|
for c in get_children():
|
|
|
|
|
var card := c as TableCard
|
|
|
|
|
if card == null or not card.visible or card.table == null:
|
|
|
|
|
continue
|
|
|
|
|
var p := card.position
|
|
|
|
|
var w := card.size.x
|
|
|
|
|
overlay.draw_rect(Rect2(p + Vector2(14, 16), Vector2(w * 0.6, 16)), ink)
|
|
|
|
|
if lit.has(card.table.id):
|
|
|
|
|
overlay.draw_rect(Rect2(p + Vector2(0, 46), Vector2(w, minf(40.0, card.size.y - 52.0))), Style.BRASS)
|
|
|
|
|
var z := main.board.zoom
|
|
|
|
|
var font := Style.display(true)
|
|
|
|
|
for g in main.data.groups:
|
|
|
|
|
var n := main.group_node(g.id)
|
|
|
|
|
if n == null:
|
|
|
|
|
continue
|
|
|
|
|
var r := Rect2(n.position, n.size)
|
|
|
|
|
var text := Formatter.strip_tags(g.name)
|
|
|
|
|
var fs := int(18.0 / z)
|
|
|
|
|
var tw := font.get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, -1, fs).x
|
|
|
|
|
var room := maxf(r.size.x, 520.0) * 1.1
|
|
|
|
|
if tw > room:
|
|
|
|
|
fs = maxi(8, int(fs * room / tw))
|
|
|
|
|
tw = font.get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, -1, fs).x
|
|
|
|
|
var at := Vector2(r.position.x + (r.size.x - tw) / 2.0, r.position.y + fs * 0.85)
|
|
|
|
|
if g.collapsed:
|
|
|
|
|
at.y = r.position.y + r.size.y / 2.0 + fs * 0.3
|
|
|
|
|
overlay.draw_string_outline(font, at, text, HORIZONTAL_ALIGNMENT_LEFT, -1, fs, maxi(2, int(4.0 / z)), Style.FELT_DEEP)
|
|
|
|
|
overlay.draw_string(font, at, text, HORIZONTAL_ALIGNMENT_LEFT, -1, fs, Style.ON_FELT if not g.collapsed else Style.BRASS)
|