2026-11-10 19:02:46 -06:00
|
|
|
class_name PageEditor
|
|
|
|
|
extends VBoxContainer
|
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's editor for one Lore Entry (BookPage): its name in the
|
|
|
|
|
## list, the result text (with BBCode and a live preview), the details
|
|
|
|
|
## tooltip, picture (spread only) and tags, then LoreEntryActions (copy to the
|
|
|
|
|
## other level, item sheet). Changes go through the list's level (LoreLevel):
|
|
|
|
|
## for the spread, to all results linked to the entry at once (TowerBoard.sync_page).
|
2026-11-10 19:02:46 -06:00
|
|
|
|
|
|
|
|
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
|
|
|
var lore: LoreList
|
2026-11-10 19:02:46 -06:00
|
|
|
var page: BookPage
|
|
|
|
|
var _preview: RichTextLabel
|
|
|
|
|
var _uses: Label
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
func _init(p_lore: LoreList) -> void:
|
|
|
|
|
lore = p_lore
|
|
|
|
|
m = p_lore.m
|
2026-11-10 19:02:46 -06:00
|
|
|
add_theme_constant_override("separation", 8)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func show_page(p: BookPage) -> void:
|
|
|
|
|
page = p
|
|
|
|
|
for c in get_children():
|
|
|
|
|
c.queue_free()
|
|
|
|
|
if p == null:
|
2026-11-15 12:46:05 -06:00
|
|
|
add_child(_note("Pick a Lore Entry to edit it, or press + Lore Entry."))
|
2026-11-10 19:02:46 -06:00
|
|
|
return
|
|
|
|
|
var name_edit := _line(p.name, p.label(), func(s: String) -> void: p.name = s.strip_edges())
|
2026-11-15 12:46:05 -06:00
|
|
|
add_child(_field("Name in the Lore Index", name_edit))
|
2026-11-10 19:02:46 -06:00
|
|
|
var text := TextEdit.new()
|
|
|
|
|
text.text = p.text
|
|
|
|
|
text.placeholder_text = "The result, e.g. [b][color=gold]The Sword of Holy Light[/color][/b]"
|
|
|
|
|
text.wrap_mode = TextEdit.LINE_WRAPPING_BOUNDARY
|
|
|
|
|
text.custom_minimum_size = Vector2(0, 70)
|
|
|
|
|
ModalCard.style_text_edit(text)
|
|
|
|
|
text.text_changed.connect(func() -> void:
|
|
|
|
|
p.text = text.text
|
|
|
|
|
_preview.text = RichText.decorate(p.text)
|
|
|
|
|
_changed())
|
|
|
|
|
add_child(_field("Result text", text))
|
2026-11-15 12:50:14 -06:00
|
|
|
SpellUnderline.attach(text, m)
|
2026-11-10 19:02:46 -06:00
|
|
|
_preview = RichText.label(RichText.decorate(p.text), 16, Style.INK, false, true)
|
|
|
|
|
var pv := PanelContainer.new()
|
|
|
|
|
pv.add_theme_stylebox_override("panel", Style.box(Style.CARD, 6, [10, 6, 10, 6]))
|
|
|
|
|
pv.add_child(_preview)
|
|
|
|
|
add_child(pv)
|
|
|
|
|
var det := TextEdit.new()
|
|
|
|
|
det.text = p.details
|
|
|
|
|
det.placeholder_text = "Shown when the result is hovered (optional)"
|
|
|
|
|
det.wrap_mode = TextEdit.LINE_WRAPPING_BOUNDARY
|
|
|
|
|
det.custom_minimum_size = Vector2(0, 60)
|
|
|
|
|
ModalCard.style_text_edit(det)
|
2026-11-15 12:50:14 -06:00
|
|
|
SpellUnderline.attach(det, m)
|
2026-11-10 19:02:46 -06:00
|
|
|
det.text_changed.connect(func() -> void:
|
|
|
|
|
p.details = det.text
|
|
|
|
|
_changed())
|
|
|
|
|
add_child(_field("Details", det))
|
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:
|
|
|
|
|
add_child(_field("Picture", ImageField.new(m, p.image, func(id: String) -> void:
|
|
|
|
|
p.image = id
|
|
|
|
|
_changed())))
|
2026-11-10 19:02:46 -06:00
|
|
|
var tags := _line(", ".join(p.tags), "e.g. weapon, holy", func(s: String) -> void:
|
|
|
|
|
var list: Array[String] = []
|
|
|
|
|
for t in s.split(","):
|
|
|
|
|
if t.strip_edges() != "":
|
|
|
|
|
list.append(t.strip_edges())
|
|
|
|
|
p.tags = list)
|
|
|
|
|
add_child(_field("Tags", tags))
|
|
|
|
|
_uses = _note("")
|
|
|
|
|
add_child(_uses)
|
|
|
|
|
_refresh_uses()
|
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
|
|
|
add_child(LoreEntryActions.make(lore, p))
|
2026-11-15 12:46:05 -06:00
|
|
|
var del := Style.bar_button("Delete Lore Entry")
|
|
|
|
|
del.tooltip_text = "Results using it keep their text and stop following the Lore Entry"
|
2026-11-10 19:02:46 -06:00
|
|
|
del.size_flags_horizontal = SIZE_SHRINK_BEGIN
|
|
|
|
|
del.pressed.connect(func() -> 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.level.remove_page(p.id)
|
|
|
|
|
show_page(null)
|
|
|
|
|
lore.refresh())
|
2026-11-10 19:02:46 -06:00
|
|
|
add_child(del)
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
## Keeps the change (for the spread: onto its results, redrawing their cards).
|
2026-11-10 19:02:46 -06:00
|
|
|
func _changed() -> 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.level.changed(page)
|
2026-11-10 19:02:46 -06:00
|
|
|
_refresh_uses()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _refresh_uses() -> 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
|
|
|
_uses.text = lore.level.uses_note(page)
|
2026-11-10 19:02:46 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _line(text: String, placeholder: String, on_change: Callable) -> LineEdit:
|
|
|
|
|
var le := LineEdit.new()
|
|
|
|
|
le.text = text
|
|
|
|
|
le.placeholder_text = placeholder
|
|
|
|
|
ModalCard.style_line_edit(le)
|
|
|
|
|
le.text_changed.connect(func(s: String) -> void:
|
|
|
|
|
on_change.call(s)
|
|
|
|
|
_changed())
|
|
|
|
|
return le
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _field(heading: String, c: Control) -> Control:
|
|
|
|
|
var v := VBoxContainer.new()
|
|
|
|
|
v.add_theme_constant_override("separation", 3)
|
|
|
|
|
v.add_child(Style.make_label(heading.to_upper(), Style.caps(), 11, Style.ON_BG_MUTED))
|
|
|
|
|
v.add_child(c)
|
|
|
|
|
return v
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _note(text: String) -> Label:
|
|
|
|
|
var l := Style.make_label(text, Style.body(), 13, Style.ON_BG_MUTED)
|
|
|
|
|
l.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
|
|
|
return l
|