TableTower/core/sheet_demo.gd
RobinFiredrake 317cac7a78 Sheets phase E: export/import, text toolbar and Lore links, Lore library and items, phone view
- E1: Export ▾ (share file with embedded pictures, print/PDF web page,
  PNG of the tab); Import a sheet file from Sheets and New sheet.
- E2: formatting toolbar (FormatMenu) in sheet text boxes; Lore links
  ([url=lore:ID]) with hover excerpt and the details panel.
- E3: Lore Index in Play and in sheets (shared LoreList); This spread |
  My library; item sheets on Lore Entries; drag entries into lists,
  slots and notes (copy, Shift keeps linked).
- E4: phone stacked view in phone order, Stacked | Canvas switch, 44 px
  touch sizes, bottom panels; sheet CLI flags split out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 17:25:09 -06:00

61 lines
3.2 KiB
GDScript

class_name SheetDemo
extends RefCounted
## An example sheet (an OSR knight, after the mockup) for screenshots
## (--sheet-demo) and tests: every kind of box on three tabs.
static func create(id: String = "demo-brin") -> SheetDoc:
var doc := SheetDoc.new(id, "Brin Hollowmere")
var main: Array = doc.tabs[0]["boxes"]
var title := _add(doc, main, "heading", "Brin Hollowmere", 1, 1, 26, 4)
title.frameless = true
var kit := _add(doc, main, "short_text", "Class", 28, 1, 12, 4)
kit.value = "Hedge Knight"
var col := 0
for stat: Array in [["Strength", "str", 14], ["Dexterity", "dex", 9], ["Willpower", "wil", 12]]:
var b := _add(doc, main, "number", stat[0], 1 + col * 9, 6, 8, 5)
b.var_name = stat[1]
b.value = stat[2]
col += 1
var mod := _add(doc, main, "formula", "STR mod", 28, 6, 8, 5)
mod.config["expr"] = "floor((@str - 10) / 2)"
mod.var_name = "str_mod"
var hp := _add(doc, main, "resource", "Hit points", 1, 12, 17, 4)
hp.value = {"cur": 6, "max": 10}
_add(doc, main, "ticks", "Stress", 19, 12, 12, 4).value = 2
var conditions := _add(doc, main, "conditions", "Conditions", 1, 17, 30, 5)
conditions.value = ["Exhausted"]
var talents := _add(doc, main, "pool", "Talents", 1, 23, 26, 12)
talents.value = [
{"Name": "Shield Wall", "Cost": 6, "Effect": "+2 Armour beside allies", "details": "When an ally stands beside you, both of you gain +2 Armour until one of you moves."},
{"Name": "Keen Eye", "Cost": 4, "Effect": "Spot hidden things", "details": "You notice traps, secret doors and lies more often than not. Roll twice and keep the better when searching."},
{"Name": "Second Wind", "Cost": 8, "Effect": "Heal once a day", "details": "Once a day, catch your breath and regain 1d6 hit points."},
]
var attack := _add(doc, main, "dice", "Longsword", 28, 23, 11, 6)
attack.config["dice"] = "1d20 + @str_mod"
_add(doc, main, "clock", "Barrow wakes", 28, 29, 8, 7).value = 2
_add(doc, main, "slots", "Inventory", 40, 1, 17, 11)
_add(doc, main, "xp", "XP", 40, 13, 17, 5).value = 2600
var oath := _add(doc, main, "text", "Oath", 40, 19, 17, 8)
oath.value = "I swore to carry the crown back to the abbey at Vel. My blows land harder ([b]+{@str_mod}[/b] to damage)."
var spells := doc.add_tab("Spells")
var magic: Array = spells["boxes"]
_add(doc, magic, "spell_slots", "Spell slots", 1, 1, 15, 8).value = [1, 0]
_add(doc, magic, "step_die", "Faith", 17, 1, 9, 5).value = "d8"
_add(doc, magic, "usage_die", "Torches", 27, 1, 10, 5)
_add(doc, magic, "ladder", "Resolve", 17, 7, 20, 5).value = 4
_add(doc, magic, "dots", "Holy favour", 1, 10, 15, 4).value = 3
var notes := doc.add_tab("Notes")
var extra: Array = notes["boxes"]
_add(doc, extra, "currency", "Purse", 1, 1, 16, 8).value = {"gp": 12, "sp": 7, "cp": 30}
_add(doc, extra, "bonds", "Bonds", 18, 1, 16, 9)
_add(doc, extra, "chips", "Aspects", 1, 9, 16, 6)
_add(doc, extra, "checkbox", "Oath kept", 18, 11, 10, 4)
_add(doc, extra, "dropdown", "Alignment", 29, 11, 12, 4)
_add(doc, extra, "divider", "", 1, 16, 40, 2)
_add(doc, extra, "table", "Gear", 1, 18, 24, 9)
return doc
static func _add(doc: SheetDoc, boxes: Array, item_id: String, title: String, gx: int, gy: int, gw: int, gh: int) -> SheetBox:
return SheetKinds.place(doc, boxes, item_id, title, Rect2i(gx, gy, gw, gh))