TableTower/ui/lore_entry_actions.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

39 lines
1.9 KiB
GDScript

class_name LoreEntryActions
extends RefCounted
## The buttons under a Lore Entry in the page editor: copy it to the other
## Lore Index level (This spread ↔ My library), and its item sheet: "Make a
## sheet for this entry" (SheetItems.make_sheet) or "Open its sheet".
static func make(lore: LoreList, page: BookPage) -> Control:
var row := HFlowContainer.new()
row.add_theme_constant_override("h_separation", 6)
row.add_theme_constant_override("v_separation", 6)
var other_key := LoreLevel.LIBRARY if lore.level.key == LoreLevel.SPREAD else LoreLevel.SPREAD
var other: LoreLevel = lore.levels[other_key]
var copy := Style.bar_button("Copy to %s" % other.title())
copy.name = "CopyToLevel"
copy.tooltip_text = "My library is shared by every spread and sheet" if other_key == LoreLevel.LIBRARY else "Add a copy to this spread's Lore Index"
copy.pressed.connect(func() -> void: copy_to(lore, page, other))
row.add_child(copy)
var sheet := Style.bar_button("Open its sheet" if page.sheet != "" else "Make a sheet for this entry")
sheet.name = "ItemSheet"
sheet.tooltip_text = "Its item sheet, e.g. Damage, Charges and Notes. Drag the entry into a character's inventory to take it along."
sheet.pressed.connect(func() -> void: open_or_make_sheet(lore, page))
row.add_child(sheet)
return row
static func copy_to(lore: LoreList, page: BookPage, other: LoreLevel) -> BookPage:
var added := other.add_copy(page)
lore.m.toast("Copied “%s” to %s" % [page.label(), other.title()])
return added
## Opens the entry's item sheet, making one first when it has none.
static func open_or_make_sheet(lore: LoreList, page: BookPage) -> void:
if page.sheet == "" or lore.m.screens.sheets.store.load_sheet(page.sheet) == null:
lore.level.edit(func() -> void: SheetItems.make_sheet(lore.m.screens.sheets.store, page))
lore.refresh()
if lore.open_sheet.is_valid():
lore.open_sheet.call(page.sheet)