- 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>
63 lines
2.1 KiB
GDScript
63 lines
2.1 KiB
GDScript
class_name LoreLinkPicker
|
|
extends ModalCard
|
|
## "Link a Lore Entry": a search box over the Lore Entries a sheet can link to
|
|
## (SheetLoreLinks.entries), each with the start of its text. Clicking one
|
|
## calls on_pick(page) and closes; Enter picks the first one shown.
|
|
|
|
var main: Main
|
|
var search: LineEdit
|
|
var _on_pick: Callable
|
|
var _list: VBoxContainer
|
|
var _first: BookPage
|
|
|
|
|
|
func _init(p_main: Main, on_pick: Callable) -> void:
|
|
super("Link a Lore Entry", 460.0)
|
|
main = p_main
|
|
_on_pick = on_pick
|
|
search = LineEdit.new()
|
|
search.name = "Search"
|
|
search.placeholder_text = "Search Lore Entries and tags"
|
|
search.clear_button_enabled = true
|
|
search.text_changed.connect(func(_text: String) -> void: fill())
|
|
search.text_submitted.connect(func(_text: String) -> void:
|
|
if _first:
|
|
choose(_first))
|
|
body.add_child(search)
|
|
_list = VBoxContainer.new()
|
|
_list.name = "Entries"
|
|
_list.add_theme_constant_override("separation", 4)
|
|
body.add_child(_list)
|
|
body.add_child(ModalCard.note("From this spread's Lore Index. The selected words become the link; with none, the entry's name is added."))
|
|
add_button("Cancel", "plain", close)
|
|
fill()
|
|
|
|
|
|
func _ready() -> void:
|
|
super()
|
|
search.grab_focus()
|
|
|
|
|
|
## Lists the entries matching the search.
|
|
func fill() -> void:
|
|
for child in _list.get_children():
|
|
_list.remove_child(child)
|
|
child.queue_free()
|
|
var found := SheetLoreLinks.search(main, search.text)
|
|
_first = found[0] if not found.is_empty() else null
|
|
if found.is_empty():
|
|
var empty := "No Lore Entries yet. Add some in the spread's Lore Index." if SheetLoreLinks.entries(main).is_empty() else "Nothing matches “%s”." % search.text.strip_edges()
|
|
_list.add_child(ModalCard.note(empty))
|
|
for page in found:
|
|
var button := ModalCard.make_button(page.label(), "plain")
|
|
button.name = page.id.validate_node_name()
|
|
button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
|
button.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
|
button.tooltip_text = SheetLoreLinks.excerpt(page)
|
|
button.pressed.connect(choose.bind(page))
|
|
_list.add_child(button)
|
|
|
|
|
|
func choose(page: BookPage) -> void:
|
|
_on_pick.call(page)
|
|
close()
|