- 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>
91 lines
2.4 KiB
GDScript
91 lines
2.4 KiB
GDScript
class_name LoreLevel
|
|
extends RefCounted
|
|
## One level of the Lore Index, as the Lore Index panels (LoreList,
|
|
## PageEditor) see it: "This spread" (SpreadLoreLevel) or the shared
|
|
## "My library" (LibraryLoreLevel). The panels call these and never touch
|
|
## the spread or the library file themselves.
|
|
|
|
const SPREAD := "spread"
|
|
const LIBRARY := "library"
|
|
|
|
var m: Main
|
|
## SPREAD or LIBRARY.
|
|
var key := SPREAD
|
|
|
|
|
|
func _init(p_main: Main) -> void:
|
|
m = p_main
|
|
|
|
|
|
## The level's name on its tab and in buttons.
|
|
func title() -> String:
|
|
return "This spread"
|
|
|
|
|
|
func pages() -> Array[BookPage]:
|
|
return []
|
|
|
|
|
|
func get_page(_id: String) -> BookPage:
|
|
return null
|
|
|
|
|
|
## Runs `change` as one step (one undo step for the spread) and keeps it.
|
|
func edit(change: Callable) -> void:
|
|
change.call()
|
|
|
|
|
|
## After the page editor changed `page`: keep it and update what shows it.
|
|
func changed(_page: BookPage) -> void:
|
|
pass
|
|
|
|
|
|
## A new entry in this level, as one step.
|
|
func add_page(text: String, details: String = "") -> BookPage:
|
|
# Lambdas copy local variables, so the result comes back in an Array.
|
|
var made: Array[BookPage] = []
|
|
edit(func() -> void: made.append(_add_raw(text, details)))
|
|
return made[0]
|
|
|
|
|
|
## Adds an entry without making a step (add_page and add_copy wrap it).
|
|
func _add_raw(_text: String, _details: String) -> BookPage:
|
|
return null
|
|
|
|
|
|
func remove_page(_id: String) -> void:
|
|
pass
|
|
|
|
|
|
## Goes up when the entries change, so an open list knows to refresh.
|
|
func revision() -> int:
|
|
return 0
|
|
|
|
|
|
## The line under the editor: where the entry is used.
|
|
func uses_note(_page: BookPage) -> String:
|
|
return ""
|
|
|
|
|
|
## What a sheet link to `page` holds after "lore:" (SheetLoreLinks).
|
|
func ref(page: BookPage) -> String:
|
|
return page.id
|
|
|
|
|
|
## Adds a copy of `page` (from another level) here and returns it. Its item
|
|
## sheet is copied too, so the two don't share one. Pictures belong to a
|
|
## spread, so only a copy into the spread keeps one.
|
|
func add_copy(page: BookPage) -> BookPage:
|
|
var made: Array[BookPage] = []
|
|
edit(func() -> void: made.append(copy_raw(page)))
|
|
return made[0]
|
|
|
|
|
|
## add_copy without making a step, for a caller that already has one open.
|
|
func copy_raw(page: BookPage) -> BookPage:
|
|
var added := _add_raw(page.text, page.details)
|
|
added.name = page.name
|
|
added.tags = page.tags.duplicate()
|
|
added.image = page.image if key == SPREAD else ""
|
|
added.sheet = SheetItems.copy_sheet(m.screens.sheets.store, page.sheet)
|
|
return added
|