TableTower/core/book_page.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

55 lines
1.6 KiB
GDScript

class_name BookPage
extends RefCounted
## A Page in the spread's Book: a reusable result (its text with any BBCode,
## its details tooltip and tags). Results linked to a page (TableEntry.page)
## show its text and details; editing the page updates every linked result
## (TowerBoard.sync_page). Saved in the spread file under "book".
var id: String = ""
## The page's name in the Book's list ("" = its text without formatting).
var name: String = ""
var text: String = ""
var details: String = ""
var tags: Array[String] = []
## A picture (BoardImages id). "" = none.
var image: String = ""
## Its item sheet (a SheetStore sheet id, e.g. a sword's Damage and Charges).
## "" = none. Saved as "sheet".
var sheet: String = ""
func label() -> String:
return name if name.strip_edges() != "" else Formatter.strip_tags(text).strip_edges()
func to_dict() -> Dictionary:
var d := {"id": id, "text": text}
if name != "":
d["name"] = name
if details != "":
d["details"] = details
if not tags.is_empty():
d["tags"] = tags.duplicate()
if image != "":
d["image"] = image
if sheet != "":
d["sheet"] = sheet
return d
static func from_dict(d: Dictionary) -> BookPage:
var p := BookPage.new()
p.id = str(d.get("id", ""))
p.name = str(d.get("name", ""))
p.text = str(d.get("text", ""))
p.details = str(d.get("details", ""))
p.image = str(d.get("image", ""))
p.sheet = str(d.get("sheet", ""))
for t: Variant in d.get("tags", []):
p.tags.append(str(t))
return p
## A copy with the same fields (the caller gives it a new id).
func copy() -> BookPage:
return BookPage.from_dict(to_dict())