2026-11-10 19:02:46 -06:00
|
|
|
|
class_name BookPanel
|
|
|
|
|
|
extends PanelContainer
|
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
|
|
|
|
## The Lore Index (Book in code) docked beside the spread: its Lore Entries
|
|
|
|
|
|
## (BookPage) on two levels, This spread and My library (LoreList). In Build
|
|
|
|
|
|
## it is a tab beside the inspector (SideTabs); in Play it opens on its own.
|
|
|
|
|
|
## Drag an entry onto a result to link it there, or onto a card to add it as
|
|
|
|
|
|
## a new result (a My library entry is copied into the spread first).
|
2026-11-10 19:02:46 -06:00
|
|
|
|
## Open from View ▾, ☰ or right-clicking the spread; × closes it.
|
|
|
|
|
|
|
|
|
|
|
|
const WIDTH := 340.0
|
|
|
|
|
|
const SETTING := "book"
|
|
|
|
|
|
|
|
|
|
|
|
var m: Main
|
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
|
|
|
|
## The shared list, search and editor.
|
|
|
|
|
|
var lore: LoreList
|
2026-11-10 19:02:46 -06:00
|
|
|
|
var list: ItemList
|
|
|
|
|
|
var editor: PageEditor
|
|
|
|
|
|
var splitter: PanelSplitter
|
|
|
|
|
|
var _search: LineEdit
|
2026-11-15 12:46:05 -06:00
|
|
|
|
var _tabs: Control
|
2026-11-10 19:02:46 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func setup(p_main: Main) -> void:
|
|
|
|
|
|
m = p_main
|
|
|
|
|
|
add_theme_stylebox_override("panel", Style.panel_box([10, 10, 10, 10]))
|
|
|
|
|
|
var col := VBoxContainer.new()
|
|
|
|
|
|
col.add_theme_constant_override("separation", 8)
|
|
|
|
|
|
add_child(col)
|
2026-11-15 12:46:05 -06:00
|
|
|
|
_tabs = SideTabs.make_row(m, SideTabs.LORE)
|
|
|
|
|
|
col.add_child(_tabs)
|
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
|
|
|
|
lore = LoreList.new()
|
|
|
|
|
|
lore.size_flags_vertical = SIZE_EXPAND_FILL
|
|
|
|
|
|
lore.setup(m, func() -> void: set_shown(false))
|
|
|
|
|
|
lore.dropped.connect(func(page: BookPage, level: LoreLevel, at: Vector2) -> void: drop_page(page.id, at, level))
|
|
|
|
|
|
lore.open_sheet = func(id: String) -> void: m.sheet_links.open_sheet(id)
|
|
|
|
|
|
col.add_child(lore)
|
|
|
|
|
|
list = lore.list
|
|
|
|
|
|
editor = lore.editor
|
|
|
|
|
|
_search = lore.search
|
2026-11-10 19:02:46 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Refills the list (search applied), keeping the selection.
|
|
|
|
|
|
func refresh() -> void:
|
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
|
|
|
|
lore.refresh()
|
2026-11-10 19:02:46 -06:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
## After undo or redo: shows the entry in the editor again.
|
2026-11-14 14:39:26 -06:00
|
|
|
|
func reload_page() -> void:
|
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
|
|
|
|
lore.reload_page()
|
2026-11-14 14:39:26 -06:00
|
|
|
|
|
|
|
|
|
|
|
2026-11-10 19:02:46 -06:00
|
|
|
|
func set_width(px: float) -> void:
|
|
|
|
|
|
custom_minimum_size.x = px
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func set_shown(on: bool) -> void:
|
|
|
|
|
|
visible = on
|
|
|
|
|
|
if splitter:
|
|
|
|
|
|
splitter.visible = on
|
|
|
|
|
|
if m.state:
|
|
|
|
|
|
m.state.set_setting(SETTING, on)
|
|
|
|
|
|
m.state.save()
|
2026-11-15 12:46:05 -06:00
|
|
|
|
SideTabs.sync(m)
|
2026-11-10 19:02:46 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func toggle() -> void:
|
2026-11-15 12:46:05 -06:00
|
|
|
|
SideTabs.show_tab(m, SideTabs.INSPECTOR if visible else SideTabs.LORE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Build shows the Inspector | Lore Index tabs in place of the title.
|
|
|
|
|
|
func show_tabs(on: bool) -> void:
|
|
|
|
|
|
_tabs.visible = on
|
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
|
|
|
|
lore.title.visible = not on
|
2026-11-10 19:02:46 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func new_page() -> BookPage:
|
|
|
|
|
|
if not visible:
|
|
|
|
|
|
set_shown(true)
|
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
|
|
|
|
return lore.new_page()
|
2026-11-10 19:02:46 -06:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
## Adds a result's text and details to the spread's Lore Index and links the result to it.
|
2026-11-10 19:02:46 -06:00
|
|
|
|
func save_result(t: RollTable, e: TableEntry) -> BookPage:
|
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
|
|
|
|
# Lambdas copy local variables, so the page comes back in an Array.
|
|
|
|
|
|
var made: Array[BookPage] = []
|
|
|
|
|
|
lore.levels[LoreLevel.SPREAD].edit(func() -> void:
|
|
|
|
|
|
var added := m.data.add_page(e.text, e.details)
|
|
|
|
|
|
added.image = e.image
|
|
|
|
|
|
e.page = added.id
|
|
|
|
|
|
m.inspector_edited(t.id)
|
|
|
|
|
|
made.append(added))
|
|
|
|
|
|
var p := made[0]
|
2026-11-10 19:02:46 -06:00
|
|
|
|
set_shown(true)
|
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
|
|
|
|
lore.set_level(LoreLevel.SPREAD)
|
2026-11-10 19:02:46 -06:00
|
|
|
|
select_page(p.id)
|
2026-11-15 12:46:05 -06:00
|
|
|
|
m.toast("Saved “%s” to the Lore Index" % p.label())
|
2026-11-10 19:02:46 -06:00
|
|
|
|
return p
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func select_page(pid: String) -> void:
|
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
|
|
|
|
if lore.level.key != LoreLevel.SPREAD and m.data.get_page(pid):
|
|
|
|
|
|
lore.set_level(LoreLevel.SPREAD)
|
|
|
|
|
|
lore.select_page(pid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Drops an entry at a screen point: onto a result links it there; onto a card
|
|
|
|
|
|
## (not a result) adds it as a new result. An entry from `from_level` My
|
|
|
|
|
|
## library is copied into the spread first (one undo step). True when it landed.
|
|
|
|
|
|
func drop_page(pid: String, at: Vector2, from_level: LoreLevel = null) -> bool:
|
2026-11-10 19:02:46 -06:00
|
|
|
|
for c: TableCard in m.cards.values():
|
|
|
|
|
|
if not c.is_visible_in_tree() or not c.get_global_rect().has_point(at) or c.table.kind == RollTable.KIND_VARIABLE:
|
|
|
|
|
|
continue
|
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
|
|
|
|
var linked := pid
|
2026-11-10 19:02:46 -06:00
|
|
|
|
m.undo_redo._begin_edit()
|
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
|
|
|
|
if from_level and from_level.key == LoreLevel.LIBRARY:
|
|
|
|
|
|
linked = lore.levels[LoreLevel.SPREAD].copy_raw(from_level.get_page(pid)).id
|
2026-11-10 19:02:46 -06:00
|
|
|
|
var target: TableEntry = null
|
|
|
|
|
|
for eid: String in c.rows:
|
|
|
|
|
|
var row: Control = c.rows[eid]
|
|
|
|
|
|
if is_instance_valid(row) and row.get_global_rect().has_point(at):
|
|
|
|
|
|
target = c.table.find_entry(eid)
|
|
|
|
|
|
if target == null:
|
|
|
|
|
|
m.editing.add_entry(c.table.id)
|
|
|
|
|
|
target = c.table.entries[c.table.entries.size() - 1]
|
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
|
|
|
|
m.data.link_page(target, linked)
|
2026-11-10 19:02:46 -06:00
|
|
|
|
m.inspector_edited(c.table.id)
|
|
|
|
|
|
m.mark_dirty()
|
|
|
|
|
|
m.undo_redo._end_edit()
|
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
|
|
|
|
m.toast("“%s” now shows on %s" % [m.data.get_page(linked).label(), Formatter.strip_tags(c.table.name)])
|
2026-11-10 19:02:46 -06:00
|
|
|
|
return true
|
|
|
|
|
|
return false
|
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
|
|
|
|
|