TableTower/docs/SHEETS.md
RobinFiredrake 5941733af1 Sheets phase D: sheets on spreads as linked Sheet cards
- A Sheet card can show a sheet file (sheet, prefix): first-tab preview,
  Open sheet with a way back, the spread's Play/Build in the editor.
- Rolls read and write "Use in tables" boxes as @name or @prefix_name;
  locked boxes and formulas/lists keep their values; changed boxes glow.
- A roll reaching the card shows the sheet's text (SheetText) in the
  tray; text boxes also show spread values when on the spread.
- Old template Sheet cards migrate to a sheet with one text box (not in
  Help demos). Card palette lists your sheets.
- Sheet canvas: tiled grid (smooth panning); boxes no longer overlap
  (nearest free spot, drags stop short; Alt places freely).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 16:52:41 -06:00

7.4 KiB
Raw Blame History

Sheets and the unified editor: spec and plan

Agreed with the user 2026-11-29. Mockup canvas (design only, not code): https://claude.ai/code/artifact/4311ebce-47e0-479c-bc1b-40800339b50b

1. Goal

A sheet builder for any TTRPG: odd OSR stats, point buy, a vehicle with only description boxes. Sheets can be used on their own or as a node in a spread, and tables can read and write them. The new Sheets replace today's Sheet card kind (RollTable.KIND_SHEET, a BBCode template): an old sheet card becomes a sheet with one text box.

2. Decisions

  • Main menu: Spreads / Sheets / Settings / Quit, titles only (no descriptions). Room for more.
  • Sheets standalone or in a spread. On a spread the node shows a preview of the sheet's first tab. Double-click opens it in an in-app tab (view only in Play).
  • Layout: free placement with a snap grid; Alt places freely. A sheet has tabs, each its own canvas. One Play/Build toggle; in a spread, the spread's toggle.
  • Multi-entry boxes ("repeating section" elsewhere): each box picks rows, mini table or chips.
  • Point pools: may go negative, shown red. Reuse the result cost {value, amount} variable.
  • Details: hover tooltip (short, cut with "…"); click opens an in-app side panel.
  • Field types: number, text, notes, checkbox, dropdown; current/max bars, tick rows, clocks; computed fields, dice buttons; image, heading, divider; dots, step dice, usage dice, ladders; slot inventory with encumbrance; tag/condition chips, aspects, bonds; spell slots, XP, currency.
  • Tables ↔ sheets: tables write and read fields. A field gets an @variable only when "Use in tables" is on. Each field has a lock: locked fields ignore roll writes. Later: a sheet event triggers a table roll (fumble → critical-failure table).
  • Templates and one-off sheets. New sheet = blank canvas or one of your templates.
  • Look: app theme, plus per-box colour and per-sheet tint; frameless boxes.
  • Text: all BBCode, buttons for common tags, live {@var}, links to Lore Entries.
  • Lore Index: opens in Play and Build, in spreads and sheets. Holds sheet entries and whole sheets as items (a rolled sword → a character's inventory). Gains a shared "My library" level beside "This spread". Drop copies; Shift keeps it linked.
  • Undo/redo for values and layout. Export: share file, PDF/print, PNG.
  • Phone: Play stacks boxes full width in reading order (top-down, then left-right), with a manual "Phone order" per box; a Canvas switch shows the real layout with pan/zoom.

3. Unified editor (spreads and sheets look alike)

  • Card palette replaces "+ Card ▾": a left dock with tabs Cards | List. Cards has a search box at the top, grouped kinds, templates as a group; drag onto the spread (click adds at the view centre). Roll table, Dice table and Deck are separate items (same kind, different start settings). Right-click › New card stays.
  • Play mode: the Cards tab stays, greyed, with "Cards are added in Build mode" and a Switch to Build button. This replaces the greyed "+ Card" button.
  • Right dock: Inspector | Lore Index (as today), same tab style as the left dock.
  • Top bar: "Board ▾" is renamed "Spread ▾". Later one shared top bar for spreads and sheets.
  • Open documents as tabs (needed for sheets opened from a spread node).
  • Sheet editor uses the same palette (with search) for fields.

4. Phases

  • A. Card palette — done 2026-11-29 (commit 16b34c4 on card-palette): left dock Cards | List, search, drag/click to add, Play-mode notice, remove "+ Card ▾", rename Board ▾ → Spread ▾. Phone: "+" opens a searchable list.
  • B. Sheets core — base built 2026-11-29 (branch sheets): main menu, Sheets list, New sheet dialog, sheet editor with tabs, snap canvas (Alt = free), field palette (shared PaletteList), inspector, Play/Build, snapshot undo, saving. Kinds so far: Number, Text box, Heading. Theme changes keep the screen (MainScreens.resume). Was planned as: data model + storage (sheets and templates), main menu, Sheets list, New sheet dialog, sheet editor (tabs, snap canvas, palette, inspector, Play/Build, undo).
  • C. Field types — built 2026-11-29 (branch sheets): every kind in §2 (SheetKinds.ITEMS, 25 palette items over 23 kinds). Values for formulas/dice/live text: core/sheet_values.gd (rule language with sheet @names; loops are errors). Views: ui/sheet_field_views.gd (basics, dispatch), sheet_fields_trackers/smart/list/niche.gd; settings: ui/sheet_kind_settings.gd; details side panel: ui/sheet_detail_panel.gd. Pictures are copied to sheets/pictures/. Not yet: per-entry variables in lists (phase D), BBCode buttons and Lore links in text (E).
  • D. Sheets on spreads — built 2026-11-29: a sheet on a spread is a Sheet card linked to a sheet file (RollTable.sheet_id, sheet_prefix; JSON sheet, prefix), so threads, groups, undo, List view and the tray headline work as for any card. The card shows SheetPreview (first tab, values, gold outline on boxes the last roll changed; double-click / "Open sheet" opens it with "← spread"; the sheet editor then uses the spread's Play/Build). A roll reaching the card rolls SheetText.summary (boxes as "Title: value", linked ones as {@prefix_name}) through Roller.sheet_text. Bridge core/sheet_links.gd + ui/main_sheet_links.gd: before a roll "Use in tables" boxes become @name / @prefix_name; after it changed values go back unless locked or not writable. Text boxes on a sheet that is on the open spread also show spread values ({@answer}). Migration: an old template Sheet card gets a sheet file (id <spread>-<card>, one text box with its template) when the spread loads or the card arrives (not inside Help demos). The user's picks: prefix per card (blank allowed; the second sheet gets one from its name), only "Use in tables" boxes. Card palette › Sheets: "New sheet" + your sheets. Sheet canvas: grid is one tiled texture (smooth panning); boxes don't overlap (new ones take the nearest free spot, drags stop short; Alt = free).
  • E. Lore Index library + items, export (PDF, PNG, share file), phone stacked view.

5. Code map (phase B)

  • Data: core/sheet_doc.gd (tabs of boxes), core/sheet_box.gd, core/sheet_kinds.gd (the kinds list, grid step, make_box), core/sheet_store.gd (user://sheets, user://sheet_templates; a scratch folder when not saving), core/snapshot_history.gd, core/sheet_demo.gd.
  • Screens: ui/main_screens.gd (menu / spread / sheets; start screen; resume after a theme change), ui/main_menu.gd, ui/sheets_screen.gd, ui/new_sheet_dialog.gd.
  • Editor: ui/sheet_editor.gd (mode, tab, selection, edit/undo/save), ui/sheet_top_bar.gd, ui/sheet_tabs_bar.gd, ui/sheet_canvas.gd, ui/sheet_box_view.gd, ui/sheet_field_views.gd, ui/sheet_inspector.gd, ui/field_palette.gd; ui/palette_list.gd is shared with the card palette.
  • Look (2026-11-29, matched to the mockup): ui/menu_icons.gd (drawn icons), MainTopBar.make_brand (shared brand), SheetBoxView.look (tinted card, band, border), canvas and menu draw the theme's spread background (BoardBackdrop). Sheets in Play keep the greyed palette (user's rule).
  • Keys: MainLayout._shortcut_input sends keys to the screen that shows.
  • CLI: --menu, --sheets, --sheet-demo (+ --sheet-build), --new-sheet. Suites: test_sheets, test_sheet_editor.