TableTower/core/sheet_demo.gd
RobinFiredrake 2661744b06 Sheets phase B: main menu, Sheets list, sheet editor
- Main menu (Spreads, Sheets, Settings, Quit) on the theme background,
  with recent spreads and sheets; logo or ☰ returns to it.
- Sheets: data model, store, templates, snapshot undo; New sheet dialog
  (blank or a template); editor with folder tabs, snap-grid canvas on the
  spread background, field palette, inspector, Play/Build, status strip.
- Field kinds: Number, Text box (BBCode, live {@name}), Heading.
- PaletteList shared by the card and field palettes; shared top bar brand.
- Keys go to the screen that shows; theme reloads keep the screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 15:53:56 -06:00

35 lines
1.4 KiB
GDScript

class_name SheetDemo
extends RefCounted
## A small example sheet (an OSR knight) for screenshots (--sheet-demo) and
## tests. Uses only the kinds built so far.
static func create(id: String = "demo-brin") -> SheetDoc:
var doc := SheetDoc.new(id, "Brin Hollowmere")
var boxes: Array = doc.tabs[0]["boxes"]
var title := _add(doc, boxes, SheetKinds.HEADING, "Brin Hollowmere", Vector2(16, 16), Vector2(28, 3), null)
title.frameless = true
var col := 0
for stat: Array in [["Strength", "str", 14], ["Dexterity", "dex", 9], ["Willpower", "wil", 12]]:
var b := _add(doc, boxes, SheetKinds.NUMBER, stat[0], Vector2(16 + col * 144, 80), Vector2(8, 5), stat[2])
b.var_name = stat[1]
col += 1
var hp := _add(doc, boxes, SheetKinds.NUMBER, "Hit points", Vector2(16, 176), Vector2(8, 5), 6)
hp.color = "#b8382c"
_add(doc, boxes, SheetKinds.TEXT, "Background", Vector2(464, 80), Vector2(18, 8),
"[b]Hedge knight[/b] from the river marches. Strength {@str}.")
_add(doc, boxes, SheetKinds.TEXT, "Notes", Vector2(160, 176), Vector2(18, 7),
"Owes the ferryman two silver.")
doc.add_tab("Spells")
doc.add_tab("Notes")
return doc
static func _add(doc: SheetDoc, boxes: Array, kind: String, title: String, at: Vector2, grid_size: Vector2, value: Variant) -> SheetBox:
var b := SheetKinds.make_box(kind, doc.new_box_id(), at)
b.title = title
b.w = grid_size.x * SheetKinds.GRID
b.h = grid_size.y * SheetKinds.GRID
b.value = value
boxes.append(b)
return b