Lore Index: the Book is renamed and is a tab beside the inspector

UI words only: Book -> Lore Index, Page -> Lore Entry (code keeps book and
BookPage). In Build the Inspector and the Lore Index share the dock as two
tabs (SideTabs); selecting on the spread goes back to the Inspector. In
Play the Lore Index opens alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
RobinFiredrake 2026-11-15 12:46:05 -06:00
parent 48b57e284c
commit cc7cd0f660
15 changed files with 123 additions and 36 deletions

View file

@ -11,7 +11,7 @@ const TITLES := {
"pause": "Demo: pausing a roll",
"costs": "Demo: options that cost",
"limits": "Demo: one table adjusting another",
"book": "Demo: the Book",
"book": "Demo: the Lore Index",
"groups": "Demo: groups inside groups",
"sheet": "Demo: a sheet",
}

View file

@ -196,7 +196,7 @@ Right-click almost anything for what you can do with it. On a phone or tablet, p
- [b]A card[/b]: roll it, roll it several times, shuffle its deck, collapse it, and in Build its settings, colour, template and delete.
- [b]A thread[/b]: go to either end, and in Build edit it, colour it or delete it.
- [b]A group[/b]: expand or collapse it, and in Build its details, template, ungroup or delete.
- [b]Empty space[/b]: a new card right there, group the selection, search, shuffle all decks, fit the spread, List view, the Book and the theme.
- [b]Empty space[/b]: a new card right there, group the selection, search, shuffle all decks, fit the spread, List view, the Lore Index and the theme.
The [b]☰[/b] button in the top bar has the same things as right-clicking empty space.
# Selecting, moving and resizing
@ -223,11 +223,11 @@ Groups can hold other groups. Select a group (drag a box around it) along with a
- Click [b]Roll[/b] to roll a card. Double-click a card to find it on the spread.
- The list has its own search box.
# The Book
The [b]Book[/b] holds [b]Pages[/b]: results you want to use on more than one table, with their formatting, details, tags and picture.
- Open it from View ▾, ☰ or right-click the spread. [b]+ Page[/b] adds one; in Build, a result's inspector has [b]Save to the Book[/b].
- Drag a page onto a result to use it there, or onto a card to add it as a new result. Results using a page show a small §.
- Edit a page and every result using it changes. Change a result's own text and it stops following the page ([b]Unlink[/b] does the same).
# The Lore Index
The [b]Lore Index[/b] holds [b]Lore Entries[/b]: results you want to use on more than one table, with their formatting, details, tags and picture.
- Open it from View ▾, ☰ or right-click the spread. In Build it is a tab beside the inspector. [b]+ Lore Entry[/b] adds one; in Build, a result's inspector has [b]Save to the Lore Index[/b].
- Drag a Lore Entry onto a result to use it there, or onto a card to add it as a new result. Results using a Lore Entry show a small §.
- Edit a Lore Entry and every result using it changes. Change a result's own text and it stops following the Lore Entry ([b]Unlink[/b] does the same).
[demo]book[/demo]
# Rolling more than once
@ -255,7 +255,7 @@ To keep a result outside the app, use the tray's [b]Copy ▾ → Save as a file[
[demo]sheet[/demo]
# Pictures
A result or a Book page can have a picture: [b]Picture → Choose…[/b] in its inspector or page. It shows as a small picture on the card and a bigger one when you hover. Pictures are kept inside the spread, so exports and imports bring them along.
A result or a Lore Entry can have a picture: [b]Picture → Choose…[/b] in its inspector or Lore Entry. It shows as a small picture on the card and a bigger one when you hover. Pictures are kept inside the spread, so exports and imports bring them along.
# On a phone or tablet
- The list fills the screen; [b]Spread[/b] and [b]List[/b] swap between them.
@ -314,7 +314,7 @@ Click any item in the report to jump to that card. A spread that can loop foreve
- [b]Middle-drag[/b], or [b]Space[/b] + drag: move around the spread
- [b]Wheel[/b]: scroll. [b]Shift+wheel[/b]: sideways. [b]Ctrl+wheel[/b]: zoom
- A card's bottom-right corner: drag to resize, double-click for its own size
- Double-click the edge of the tray, inspector, list or Book: reset its size
- Double-click the edge of the tray, inspector, list or Lore Index: reset its size
## Touch
- Press and hold: the menu
- Two fingers: move and zoom

View file

@ -28,6 +28,7 @@ func _init() -> void:
await _test_sections()
await _test_open_by_hand()
await _test_position_and_weight()
await _test_lore_tab()
finish()
@ -87,3 +88,19 @@ func _test_position_and_weight() -> void:
RangeWeights.set_mode(t, RangeWeights.RANGES)
InspectorRange.set_range(insp, t, t.find_entry("d"), 120, 125)
_eq(t.entries.back().id, "d", "auto-sort puts an edited range in roll order")
## In Build the Lore Index is a tab beside the inspector; in Play it opens alone.
func _test_lore_tab() -> void:
SideTabs.show_tab(main, SideTabs.LORE)
_check(main.book.visible and not insp.visible, "Build: the Lore Index tab replaces the inspector")
_check(main.book._tabs.visible, "Build: the Lore Index shows the tab row")
main.select_result("work", "a")
await _frames()
_check(insp.visible and not main.book.visible, "selecting on the spread goes back to the Inspector tab")
main.set_mode(Main.Mode.PLAY)
main.book.toggle()
_check(main.book.visible and not insp.visible and not main.book._tabs.visible, "Play: the Lore Index opens alone, with no tabs")
main.book.toggle()
main.set_mode(Main.Mode.BUILD)
_check(insp.visible, "back in Build the inspector shows")

View file

@ -185,8 +185,8 @@ static func background(m: Main, at: Vector2) -> Array:
list.append({"text": "Fit spread", "do": m.board.fit})
list.append({"text": "Hide the list" if m.list_view.visible else "List view", "do": m.list_view.toggle,
"tip": "The cards as a list with their groups"})
list.append({"text": "Close the Book" if m.book.visible else "Book", "do": m.book.toggle,
"tip": "Reusable results (Pages) to drag onto tables"})
list.append({"text": "Close the Lore Index" if m.book.visible else "Lore Index", "do": m.book.toggle,
"tip": "Reusable results (Lore Entries) to drag onto tables"})
list.append({"sep": ""})
list.append({"text": "Theme…", "do": func() -> void: m.add_child(ThemeDialog.new(m))})
if m.sound:

View file

@ -1,6 +1,8 @@
class_name BookPanel
extends PanelContainer
## The Book: the spread's reusable results (Pages), docked beside the spread.
## The Lore Index (Book in code): the spread's reusable results, its Lore
## Entries (BookPage), docked beside the spread; in Build it is a tab beside
## the inspector (SideTabs).
## A searchable list (name, text and tags) above the page editor. Drag a page
## onto a result to link it there, or onto a card to add it as a new result.
## Open from View ▾, ☰ or right-clicking the spread; × closes it.
@ -16,6 +18,8 @@ var _search: LineEdit
var _ids: Array[String] = []
var _rev := -1
var _dragging := ""
var _tabs: Control
var _title: Label
func setup(p_main: Main) -> void:
@ -24,22 +28,24 @@ func setup(p_main: Main) -> void:
var col := VBoxContainer.new()
col.add_theme_constant_override("separation", 8)
add_child(col)
_tabs = SideTabs.make_row(m, SideTabs.LORE)
col.add_child(_tabs)
var head := HBoxContainer.new()
head.add_theme_constant_override("separation", 6)
col.add_child(head)
var title := Style.make_label("Book", Style.display(), 20, Style.ON_BG)
title.size_flags_horizontal = SIZE_EXPAND_FILL
head.add_child(title)
var add := Style.bar_button("+ Page")
add.tooltip_text = "A new page: a result you can reuse on any table"
_title = Style.make_label("Lore Index", Style.display(), 20, Style.ON_BG)
_title.size_flags_horizontal = SIZE_EXPAND_FILL
head.add_child(_title)
var add := Style.bar_button("+ Lore Entry")
add.tooltip_text = "A new Lore Entry: a result you can reuse on any table"
add.pressed.connect(new_page)
head.add_child(add)
var close := Style.bar_button("×")
close.tooltip_text = "Close the Book"
close.tooltip_text = "Close the Lore Index"
close.pressed.connect(func() -> void: set_shown(false))
head.add_child(close)
_search = LineEdit.new()
_search.placeholder_text = "Search pages and tags"
_search.placeholder_text = "Search Lore Entries and tags"
_search.clear_button_enabled = true
ModalCard.style_line_edit(_search)
_search.text_changed.connect(func(_s: String) -> void: refresh())
@ -110,15 +116,22 @@ func set_shown(on: bool) -> void:
if m.state:
m.state.set_setting(SETTING, on)
m.state.save()
SideTabs.sync(m)
func toggle() -> void:
set_shown(not visible)
SideTabs.show_tab(m, SideTabs.INSPECTOR if visible else SideTabs.LORE)
## Build shows the Inspector | Lore Index tabs in place of the title.
func show_tabs(on: bool) -> void:
_tabs.visible = on
_title.visible = not on
func new_page() -> BookPage:
m.undo_redo._begin_edit()
var p := m.data.add_page("New page")
var p := m.data.add_page("New Lore Entry")
m.mark_dirty()
m.undo_redo._end_edit()
if not visible:
@ -140,7 +153,7 @@ func save_result(t: RollTable, e: TableEntry) -> BookPage:
set_shown(true)
refresh()
select_page(p.id)
m.toast("Saved “%s” to the Book" % p.label())
m.toast("Saved “%s” to the Lore Index" % p.label())
return p

View file

@ -83,7 +83,7 @@ static func label_for(a: Dictionary, b: Dictionary, d: Dictionary = {}) -> Strin
if d.is_empty():
d = diff(a, b)
if d.get("book", false) and (d["changed"] as Array).is_empty() and (d["added"] as Array).is_empty():
return "Edit the Book"
return "Edit the Lore Index"
var added: Array = d["added"]
var removed: Array = d["removed"]
var gadded: Array = d["gadded"]

View file

@ -65,6 +65,8 @@ func setup(p_main: Main) -> void:
func select(sel: Dictionary) -> void:
if collapsed:
set_collapsed(false)
if main and main.book and main.book.visible:
SideTabs.show_tab(main, SideTabs.INSPECTOR)
selection = sel
var kind := str(sel.get("kind", ""))
if kind == "card" or kind == "result":

View file

@ -20,6 +20,11 @@ static func build(insp: Inspector) -> void:
insp._body.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
insp._body.add_theme_constant_override("separation", 0)
stack.add_child(insp._body)
var tabs_pad := MarginContainer.new()
for side: String in ["margin_left", "margin_right", "margin_top"]:
tabs_pad.add_theme_constant_override(side, 10)
tabs_pad.add_child(SideTabs.make_row(insp.main, SideTabs.INSPECTOR))
insp._body.add_child(tabs_pad)
insp._scroll = ScrollContainer.new()
insp._scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
insp._scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL

View file

@ -9,17 +9,17 @@ extends RefCounted
static func book_line(insp: Inspector, t: RollTable, e: TableEntry) -> Control:
var p := insp.main.data.get_page(e.page)
if p == null:
var save := InspectorKit.link("Save to the Book", "Keep this result as a Page to reuse on other tables")
var save := InspectorKit.link("Save to the Lore Index", "Keep this result as a Lore Entry to reuse on other tables")
save.pressed.connect(func() -> void: insp.main.book.save_result(t, e))
return save
var row := InspectorKit.hbox(8)
var open := InspectorKit.link("§ From the Book: %s" % p.label(), "Edit the page; every result using it changes")
var open := InspectorKit.link("§ Lore Entry: %s" % p.label(), "Edit the Lore Entry; every result using it changes")
open.pressed.connect(func() -> void:
insp.main.book.set_shown(true)
insp.main.book.refresh()
insp.main.book.select_page(p.id))
row.add_child(open)
var unlink := InspectorKit.link("Unlink", "Keep the text here but stop following the page")
var unlink := InspectorKit.link("Unlink", "Keep the text here but stop following the Lore Entry")
unlink.pressed.connect(func() -> void:
e.page = ""
insp.wrote(t, false, true))

View file

@ -90,7 +90,7 @@ func _build_ui() -> void:
if m.state and bool(m.state.get_setting("inspector_collapsed", false)):
m.inspector.set_collapsed(true)
middle.add_child(m.inspector)
m.inspector._sync_splitter()
SideTabs.sync(m)
m.editing._build_selection_bar()
m.tray = ResultTray.new()
m.tray.setup(m)
@ -160,7 +160,7 @@ func set_mode(new_mode: Main.Mode) -> void:
m.top_bar.play_add_button.visible = new_mode == Main.Mode.PLAY
m.board.pipes.hover_key = ""
m.clear_selection()
m.inspector.visible = new_mode == Main.Mode.BUILD
SideTabs.sync(m)
if new_mode != Main.Mode.BUILD:
m.inspector.clear()
for card in m.cards.values():

View file

@ -20,10 +20,10 @@ func show_page(p: BookPage) -> void:
for c in get_children():
c.queue_free()
if p == null:
add_child(_note("Pick a page to edit it, or press + Page."))
add_child(_note("Pick a Lore Entry to edit it, or press + Lore Entry."))
return
var name_edit := _line(p.name, p.label(), func(s: String) -> void: p.name = s.strip_edges())
add_child(_field("Name in the Book", name_edit))
add_child(_field("Name in the Lore Index", name_edit))
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]"
@ -63,8 +63,8 @@ func show_page(p: BookPage) -> void:
_uses = _note("")
add_child(_uses)
_refresh_uses()
var del := Style.bar_button("Delete page")
del.tooltip_text = "Results using it keep their text and stop following the page"
var del := Style.bar_button("Delete Lore Entry")
del.tooltip_text = "Results using it keep their text and stop following the Lore Entry"
del.size_flags_horizontal = SIZE_SHRINK_BEGIN
del.pressed.connect(func() -> void:
m.undo_redo._begin_edit()
@ -85,7 +85,7 @@ func _changed() -> void:
func _refresh_uses() -> void:
var n := m.data.page_uses(page.id)
_uses.text = "Used by %d %s. Drag the page from the list onto a result to use it there." % [n, "result" if n == 1 else "results"]
_uses.text = "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"]
func _line(text: String, placeholder: String, on_change: Callable) -> LineEdit:

49
ui/side_tabs.gd Normal file
View file

@ -0,0 +1,49 @@
class_name SideTabs
extends RefCounted
## In Build, the Inspector and the Lore Index share the right-hand dock as two
## tabs ("Inspector | Lore Index"); only one shows at a time. In Play there is
## no inspector, so the Lore Index opens on its own (no tab row).
## The Lore Index is BookPanel in code (TowerBoard.book, BookPage).
const INSPECTOR := "inspector"
const LORE := "lore"
## The tab row put at the top of both panels. `active` is the panel it sits on.
static func make_row(m: Main, active: String) -> HBoxContainer:
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 4)
for tab: Array in [[INSPECTOR, "Inspector"], [LORE, "Lore Index"]]:
var b := Button.new()
b.text = tab[1]
b.toggle_mode = true
b.button_pressed = tab[0] == active
b.focus_mode = Control.FOCUS_NONE
b.size_flags_horizontal = Control.SIZE_EXPAND_FILL
b.add_theme_font_override("font", Style.body_bold())
b.add_theme_font_size_override("font_size", 14)
var normal := Style.box(Color(0, 0, 0, 0.06), 6, [10, 5, 10, 5])
var hover := Style.box(Color(0, 0, 0, 0.12), 6, [10, 5, 10, 5])
var on := Style.bordered(Style.box(Style.CARD, 6, [10, 5, 10, 5]), 2, Style.TRIM)
Style.skin_button(b, normal, hover, on, Style.MUTED, Style.INK, Style.INK)
var which: String = tab[0]
b.pressed.connect(func() -> void: show_tab(m, which))
row.add_child(b)
return row
## Shows one tab. The Lore Index tab opens the Lore Index; the Inspector tab closes it.
static func show_tab(m: Main, which: String) -> void:
if m.book:
m.book.set_shown(which == LORE)
## Brings the dock in line with the mode: in Build an open Lore Index hides the
## inspector; in Play the inspector is always hidden.
static func sync(m: Main) -> void:
if m.inspector == null or m.book == null:
return
var build := m.mode == Main.Mode.BUILD
m.inspector.visible = build and not m.book.visible
m.inspector._sync_splitter()
m.book.show_tabs(build)

1
ui/side_tabs.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://bjqt8hiravlht

View file

@ -193,7 +193,7 @@ func make_row(e: TableEntry, index: int, build: bool, ranged: bool, numw: float)
var mark := Style.make_label("§", Style.body_bold(true), 13, Style.TRIM)
mark.size_flags_vertical = Control.SIZE_SHRINK_CENTER
mark.mouse_filter = Control.MOUSE_FILTER_PASS
mark.tooltip_text = "From the Book: %s" % (pg.label() if pg else "a deleted page")
mark.tooltip_text = "Lore Entry: %s" % (pg.label() if pg else "a deleted Lore Entry")
h.add_child(mark)
h.move_child(mark, mini(1, h.get_child_count() - 1))
register(e, row, num, text, index)

View file

@ -36,12 +36,12 @@ func setup(p_main: Main) -> void:
pm.add_check_item("Striped rows", ID_STRIPES)
pm.add_check_item("Minimap (M)", ID_MINIMAP)
pm.add_check_item("List view", ID_LIST)
pm.add_check_item("Book", ID_BOOK)
pm.add_check_item("Lore Index", ID_BOOK)
pm.add_check_item("Ask before deleting", ID_CONFIRM_DELETE)
pm.set_item_tooltip(pm.get_item_index(ID_CONFIRM_DELETE), "The Delete key asks “Are you sure?” first")
pm.add_check_item("Skip animations", ID_SKIP_ANIM)
pm.set_item_tooltip(pm.get_item_index(ID_SKIP_ANIM), "Rolls show their result at once, with no flicker, beads or pop-up motion.\nShift-click a die to skip them for one roll.")
pm.set_item_tooltip(pm.get_item_index(ID_BOOK), "Reusable results (Pages) to drag onto tables")
pm.set_item_tooltip(pm.get_item_index(ID_BOOK), "Reusable results (Lore Entries) to drag onto tables")
pm.set_item_tooltip(pm.get_item_index(ID_LIST), "The cards as a list with their groups, beside the spread")
pm.add_separator()
pm.add_item("Theme…", ID_THEME)