- 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>
57 lines
1.7 KiB
GDScript
57 lines
1.7 KiB
GDScript
class_name FieldPalette
|
|
extends VBoxContainer
|
|
## The sheet editor's field palette: every kind of box (SheetKinds) in a
|
|
## PaletteList, like the spread's card palette. Click adds a box in the middle
|
|
## of the canvas; drag drops it where you let go. Greyed in Play under a
|
|
## notice with Switch to Build.
|
|
|
|
const MESSAGE := "Fields are added in Build mode."
|
|
|
|
var ed: SheetEditor
|
|
var list: PaletteList
|
|
var notice: PanelContainer
|
|
|
|
|
|
func setup(p_editor: SheetEditor) -> void:
|
|
ed = p_editor
|
|
add_theme_constant_override("separation", 8)
|
|
notice = BuildModeHint.make_notice(ed.m, func() -> void: ed.set_mode(Main.Mode.BUILD), MESSAGE)
|
|
add_child(notice)
|
|
list = PaletteList.new()
|
|
list.setup("Search fields", "Drag onto the sheet, or click to add", "Add a field", "“number”, “text” or “title”")
|
|
list.size_flags_vertical = SIZE_EXPAND_FILL
|
|
list.sections_for = _sections
|
|
list.can_use = ed.building
|
|
list.on_blocked = func() -> void: ed.m.toast(MESSAGE)
|
|
list.drop_at = drop_at
|
|
add_child(list)
|
|
list.rebuild()
|
|
|
|
|
|
func _process(_delta: float) -> void:
|
|
notice.visible = ed.doc != null and not ed.building()
|
|
|
|
|
|
func _sections(query: String) -> Array:
|
|
var out: Array = []
|
|
for group in SheetKinds.groups():
|
|
var entries: Array = []
|
|
for item: Dictionary in SheetKinds.ITEMS:
|
|
if item["group"] == group and PaletteList.matches(item, query):
|
|
entries.append([item, _add.bind(str(item["id"]))])
|
|
out.append([group, entries])
|
|
return out
|
|
|
|
|
|
func drop_at(on_add: Callable, screen_point: Vector2) -> bool:
|
|
var at := ed.canvas.drop_point(screen_point)
|
|
if at == Vector2.INF:
|
|
return false
|
|
list.use(on_add, at)
|
|
return true
|
|
|
|
|
|
func _add(at: Vector2, kind: String) -> void:
|
|
if ed.phone:
|
|
ed.phone.palette_open = false
|
|
ed.add_box(kind, at)
|