TableTower/docs/SHEETS.md

82 lines
6.2 KiB
Markdown
Raw Normal View 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. Spread integration:** sheet node (first-tab preview), variables read/write, locks,
replace and migrate `KIND_SHEET`, document tabs.
- **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`.