TableTower/ui/lore_level_library.gd

55 lines
1.1 KiB
GDScript3
Raw Permalink Normal View History

class_name LibraryLoreLevel
extends LoreLevel
## "My library": the shared Lore Entries (LoreLibrary), the same in every
## spread and sheet. Saved at once; there is no undo for it.
func _init(p_main: Main) -> void:
super(p_main)
key = LIBRARY
func title() -> String:
return "My library"
func library() -> LoreLibrary:
return SheetLoreLinks.library(m)
func pages() -> Array[BookPage]:
return library().pages if library() else ([] as Array[BookPage])
func get_page(id: String) -> BookPage:
return library().get_page(id) if library() else null
func edit(change: Callable) -> void:
change.call()
library().save()
func changed(_page: BookPage) -> void:
library().save()
func _add_raw(text: String, details: String) -> BookPage:
return library().add_page(text, details)
func remove_page(id: String) -> void:
library().remove_page(id)
func revision() -> int:
return library().revision if library() else 0
func uses_note(_page: BookPage) -> String:
return "In My library: every spread and sheet can use it. Drag it onto a result to copy it into this spread."
func ref(page: BookPage) -> String:
return SheetLoreLinks.LIBRARY + page.id