class_name SpreadLoreLevel extends LoreLevel ## "This spread": the open spread's Lore Entries (TowerBoard.book). Changes ## go through the spread's undo, and linked results follow (TowerBoard.sync_page). func _init(p_main: Main) -> void: super(p_main) key = SPREAD func pages() -> Array[BookPage]: return m.data.book if m.data else ([] as Array[BookPage]) func get_page(id: String) -> BookPage: return m.data.get_page(id) if m.data else null func edit(change: Callable) -> void: m.undo_redo._begin_edit() change.call() m.mark_dirty() m.undo_redo._end_edit() func changed(page: BookPage) -> void: for table_id in m.data.sync_page(page.id): m.inspector_edited(table_id) m.mark_dirty() func _add_raw(text: String, details: String) -> BookPage: return m.data.add_page(text, details) func remove_page(id: String) -> void: edit(func() -> void: m.data.remove_page(id)) func revision() -> int: return m.edit_rev func uses_note(page: BookPage) -> String: var n := m.data.page_uses(page.id) return "Used by %d %s. Drag the Lore Entry from the list onto a result to use it there." % [n, "result" if n == 1 else "results"]