- 25 palette items over 23 kinds: basics, trackers (bars, ticks, clocks, dots, step/usage dice, ladders), formulas and dice buttons (rule language with sheet @names), lists (rows, mini table, chips, point pool that may go negative, bonds), slots, conditions, spell slots, XP, currency, heading, divider, picture. - Per-kind settings in the inspector; hover excerpts and an in-app details panel for list entries; live redraw of dependent boxes. - Canvas: the page stays put after edits (boxes can go anywhere), a screen of room past the boxes, drag-to-pan and edge scrolling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
3.3 KiB
GDScript
66 lines
3.3 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:
|
|
var b := SheetKinds.make_box(item_id, doc.new_box_id(), Vector2(gx, gy) * SheetKinds.GRID)
|
|
b.title = title
|
|
b.w = gw * SheetKinds.GRID
|
|
b.h = gh * SheetKinds.GRID
|
|
boxes.append(b)
|
|
return b
|