diff --git a/core/recent_spreads.gd b/core/recent_spreads.gd new file mode 100644 index 0000000..0efc83a --- /dev/null +++ b/core/recent_spreads.gd @@ -0,0 +1,44 @@ +class_name RecentSpreads +extends RefCounted +## The spreads opened most recently, newest first (a StateStore setting). +## The spread switcher lists them at the top. + +const KEY := "recent_spreads" +const CAP := 5 + + +static func ids(state: StateStore) -> Array: + var v: Variant = state.get_setting(KEY, []) if state else [] + return (v as Array).duplicate() if v is Array else [] + + +## Puts `id` first. +static func note(state: StateStore, id: String) -> void: + if state == null or id == "": + return + var list := ids(state) + list.erase(id) + list.push_front(id) + if list.size() > CAP: + list.resize(CAP) + state.set_setting(KEY, list) + + +static func forget(state: StateStore, id: String) -> void: + var list := ids(state) + if list.has(id): + list.erase(id) + state.set_setting(KEY, list) + + +## The library entries of the recent spreads, newest first, without +## `current_id` and without spreads that no longer exist. +static func pick(state: StateStore, entries: Array, current_id: String) -> Array[Dictionary]: + var by_id := {} + for entry: Dictionary in entries: + by_id[str(entry["id"])] = entry + var out: Array[Dictionary] = [] + for id in ids(state): + if str(id) != current_id and by_id.has(str(id)): + out.append(by_id[str(id)]) + return out diff --git a/core/recent_spreads.gd.uid b/core/recent_spreads.gd.uid new file mode 100644 index 0000000..7575ea1 --- /dev/null +++ b/core/recent_spreads.gd.uid @@ -0,0 +1 @@ +uid://lfylmsq7iy6 diff --git a/core/spread_folders.gd b/core/spread_folders.gd new file mode 100644 index 0000000..4e5a1cd --- /dev/null +++ b/core/spread_folders.gd @@ -0,0 +1,180 @@ +class_name SpreadFolders +extends RefCounted +## Folders for spreads in the spread switcher. A folder is a path such as +## "Traveller/Worlds" ("/" puts a folder inside another). Each spread saves its +## own path (TowerBoard.folder), so a folder is listed while it holds spreads. +## A folder with no spreads is listed only if the user chose to keep it; those +## paths are a StateStore setting. Rules only, no UI. + +const KEPT := "kept_spread_folders" + + +## Trims each part and drops empty parts: " a / /b " -> "a/b". +static func normalize(path: String) -> String: + var parts := PackedStringArray() + for part in path.split("/"): + if part.strip_edges() != "": + parts.append(part.strip_edges()) + return "/".join(parts) + + +static func parent_of(path: String) -> String: + var i := path.rfind("/") + return "" if i < 0 else path.substr(0, i) + + +static func leaf(path: String) -> String: + return path.substr(path.rfind("/") + 1) + + +static func depth(path: String) -> int: + return path.count("/") + + +## True when `path` is `folder` or a folder inside it. +static func is_inside(path: String, folder: String) -> bool: + return path == folder or path.begins_with(folder + "/") + + +# ---------- Listing ---------- + +## Every folder to show: the spreads' folders and the kept ones, with their +## parents, sorted A–Z part by part (a folder comes just before its inner ones). +static func all_folders(entries: Array, kept_list: Array) -> Array[String]: + var seen := {} + var paths: Array = kept_list.duplicate() + for entry: Dictionary in entries: + paths.append(str(entry.get("folder", ""))) + for p in paths: + var path := normalize(str(p)) + while path != "": + seen[path] = true + path = parent_of(path) + var out: Array[String] = [] + out.assign(seen.keys()) + out.sort_custom(_before) + return out + + +## The folders directly inside `parent` ("" = the top level). +static func children(folders: Array[String], parent: String) -> Array[String]: + var out: Array[String] = [] + for f in folders: + if parent_of(f) == parent: + out.append(f) + return out + + +## The spreads directly in `folder` (not in its inner folders). +static func spreads_in(entries: Array, folder: String) -> Array[Dictionary]: + var out: Array[Dictionary] = [] + for entry: Dictionary in entries: + if str(entry.get("folder", "")) == folder: + out.append(entry) + return out + + +## True when no spread is in `folder` or inside it, and no kept folder is inside it. +static func is_empty(folder: String, entries: Array, kept_list: Array) -> bool: + for entry: Dictionary in entries: + if is_inside(str(entry.get("folder", "")), folder): + return false + for k in kept_list: + if str(k) != folder and is_inside(str(k), folder): + return false + return true + + +## The typed path, with each part spelled like an existing folder that matches +## it without regard to case: "traveller/worlds" -> "Traveller/Worlds". +static func resolve(typed: String, folders: Array[String]) -> String: + var path := "" + for part in normalize(typed).split("/", false): + var want := part if path == "" else path + "/" + part + for f in folders: + if f.to_lower() == want.to_lower(): + want = f + break + path = want + return path + + +static func _before(a: String, b: String) -> bool: + var pa := a.split("/") + var pb := b.split("/") + for i in mini(pa.size(), pb.size()): + var c := pa[i].naturalnocasecmp_to(pb[i]) + if c != 0: + return c < 0 + return pa.size() < pb.size() + + +# ---------- Kept (empty) folders ---------- + +static func kept(state: StateStore) -> Array: + var v: Variant = state.get_setting(KEPT, []) if state else [] + return (v as Array).duplicate() if v is Array else [] + + +static func keep(state: StateStore, folder: String) -> void: + var list := kept(state) + if folder != "" and not list.has(folder): + list.append(folder) + state.set_setting(KEPT, list) + state.save() + + +## Stops keeping `folder`, so it's gone once it has no spreads. +static func forget(state: StateStore, folder: String) -> void: + var list := kept(state) + if list.has(folder): + list.erase(folder) + state.set_setting(KEPT, list) + state.save() + + +# ---------- Changes (saved at once) ---------- + +## Puts `current` in `folder` ("" = none) and saves it. Returns the folder it +## left if that folder is empty now (so the UI can ask to keep it), else "". +static func move(library: LibraryStore, current: TowerBoard, folder: String) -> String: + var old := current.folder + current.folder = normalize(folder) + library.save(current) + if old == "" or is_inside(current.folder, old): + return "" + return old if is_empty(old, library.list(), kept(library.state)) else "" + + +## Renames the last part of `folder`. The spreads and kept folders inside it +## move with it (if the new name is taken, they join that folder). `current` is +## changed in memory too. Returns the new path, or "" for a blank name. +static func rename(library: LibraryStore, current: TowerBoard, folder: String, new_name: String) -> String: + var part := new_name.replace("/", " ").strip_edges() + if part == "" or folder == "": + return "" + var others: Array[String] = [] + for f in all_folders(library.list(), kept(library.state)): + if not is_inside(f, folder): + others.append(f) + var parent := parent_of(folder) + var to := resolve(part if parent == "" else parent + "/" + part, others) + if to == folder: + return to + for entry in library.list(): + var path := str(entry.get("folder", "")) + if not is_inside(path, folder): + continue + var b := current if str(entry["id"]) == current.id else library.load_collection(str(entry["id"])) + if b: + b.folder = to + path.substr(folder.length()) + library.save(b) + var list: Array = [] + for k in kept(library.state): + var path := str(k) + path = to + path.substr(folder.length()) if is_inside(path, folder) else path + if not list.has(path): + list.append(path) + library.state.set_setting(KEPT, list) + library.state.save() + return to diff --git a/core/spread_folders.gd.uid b/core/spread_folders.gd.uid new file mode 100644 index 0000000..c0d6cf6 --- /dev/null +++ b/core/spread_folders.gd.uid @@ -0,0 +1 @@ +uid://dux8ofnvtxp1y diff --git a/core/tower_board.gd b/core/tower_board.gd index 9f59548..6d1344d 100644 --- a/core/tower_board.gd +++ b/core/tower_board.gd @@ -13,7 +13,8 @@ static var _salt: String = "" var id: String = "" ## Display name; free to change. var name: String = "" -## The folder it's listed under in the spread switcher ("" = none). +## The folder it's listed under in the spread switcher ("" = none; "a/b" = +## folder b inside folder a). Rules: core/spread_folders.gd. var folder: String = "" var tables: Array[RollTable] = [] ## Group cards (frames around blocks of tables). Optional; a table is in at @@ -258,7 +259,7 @@ func load_dict(src: Dictionary) -> bool: if str(d.get("name", "")) != "": name = str(d["name"]) if d.has("folder"): - folder = str(d["folder"]).strip_edges() + folder = SpreadFolders.normalize(str(d["folder"])) return true diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 1f1b2f0..93832bf 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -228,6 +228,10 @@ Each original file keeps one-line delegators, so callers are unchanged. - **Interface:** `ui/delete_key.gd`, `ui/sound_panel.gd`, `ui/format_menu.gd` (right-click Format), `ui/text_effects/` (sparkle, shimmer, flash RichTextEffects; `RichText.install_effects`), `ui/colour_dialog.gd` ("Any colour…"). +- **Spread folders:** `core/spread_folders.gd` (paths such as "a/b", listing, move, rename; kept + empty folders are the StateStore setting `kept_spread_folders`), `core/recent_spreads.gd` + (setting `recent_spreads`), `ui/spread_folder_dialogs.gd` (new, rename, "keep it?"). The + switcher's menu items run Callables (`CollectionSwitcher._calls`, id = index). - **Timing:** `tests/perf_roll.gd` (not in the suite). ## 4. Data and storage diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 60b1de6..f792479 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -1,7 +1,7 @@ # Table Tarot (repo: TableTower) — Status and Plan -**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-14 (playtest fixes merged to -`main` and pushed) +**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-14 (spread folders round 2 +pushed to `main`) The short page to read at the start of every session. Everything else is read only when needed: - `docs/ARCHITECTURE.md`: feature summary, file map (§3b lists the 2026-11-10 modules), storage, known gaps. @@ -93,7 +93,10 @@ unsure where to type one: in a result's text, or with "+ Roll a card from anothe the Text field when a result is selected in Build). Placeholder *writing* (help, demos, sample, templates) is on the Theme Art Guide checklist. -**Next, likely:** the user tries spread links; new playtest reports. Older open items in §4. +**Spread folders round 2 (2026-11-14, pushed):** see §4 item 8. Not hand-tested yet. + +**Next, likely:** the user hand-tests spread folders (submenus, nesting, Keep/Remove, Recent) and +spread links; new playtest reports. Older open items in §4. ## 3b. Theme slots plan (2026-11-11, user-approved order) Mockups: "Morgan's Wardrobe" artifact (https://claude.ai/code/artifact/136b4ce8-1ef7-47ca-a39a-a75eb34d64b7): @@ -163,6 +166,16 @@ that works on any theme (solid background, stronger text, thicker borders, no ef Book editor refresh after undo; hint where "Roll it with … instead" is hidden (ranged targets only); call diagram exports "Export as diagram" (only JSON is a full save). 7. ~~Spreads calling other spreads~~ done 2026-11-14: `[[Spread::Card]]` (LOGIC.md §5.3). +8. ~~Spread folders, round 2~~ done 2026-11-14 (pushed to `main`; **not hand-tested yet**). The user's + picks: "Move to folder" is a submenu of existing folders (+ No folder, New folder…; typed names + match existing folders without regard to case); folders nest ("a/b"); an empty folder stays + only if the user says Keep when its last spread leaves (or is deleted), and then has Remove + folder; loose spreads stay above folders; Recent (last 5 opened) at the top; New spread here… + and Rename folder… in each folder (renaming to a taken name joins the two; no warning). Kept + empty folders live in local state (`state.json`), not in spread files, so they don't travel + with a shared spread. List view's "folders" are now called groups in the UI ("+ Group"). + Modules: ARCHITECTURE §3f "Spread folders"; suite `test_spread_folders` (includes the real menu + on a temporary library). **Known, not urgent** - `export_presets.cfg` (and `project.godot`) hold the user's uncommitted edits. The Windows preset's @@ -185,10 +198,10 @@ that works on any theme (solid background, stronger text, thicker borders, no ef ## 5. Working on it - **Godot:** `~/apps/Godot_v4.7.2-stable_linux.x86_64`. New `class_name` files need `godot --headless --path . --import` (the test runner does this). -- **Tests:** `tools/run_tests.sh [filter]`: 43 suites in parallel, ~35 s. One line per suite; a +- **Tests:** `tools/run_tests.sh [filter]`: 47 suites in parallel, ~40 s. One line per suite; a failing suite prints 8 lines; a compile error shared by many suites prints once. Suites extend `TestBase` (`tests/testbase.gd`, named so the `test_*.gd` glob skips it): `start_main()`, - `require_sample()`, `_check`, `_eq`, `_frames`, `finish()`. + `require_sample()`, `_check`, `_eq`, `_frames`, `_wipe` (temp folders), `finish()`. - **Smoke test:** `godot --headless --path . --quit-after 120 -- --sample` (no SCRIPT ERROR; the "resources still in use at exit" line is normal). - **Windowed runs/screenshots: always `tools/test_window.sh -- --sample --screenshot=/path.png [flags]`** diff --git a/help/topics.txt b/help/topics.txt index a95d799..fa55ecf 100644 --- a/help/topics.txt +++ b/help/topics.txt @@ -217,7 +217,7 @@ Groups can hold other groups. Select a group (drag a box around it) along with a # List view [b]List view[/b] (View ▾, ☰ or right-click the spread) shows every card as a plain list, for when you'd rather not use the spread. -- Folders are groups. [b]+ Folder[/b] makes one; drag cards onto a folder, or a folder onto another. +- Groups show as rows that open and close. [b]+ Group[/b] makes one; drag cards onto a group, or a group onto another. - Drag cards up and down to put them in your own order. - [b]←2 →3[/b] counts the threads coming in and going out; hover to see where they lead. - Click [b]Roll[/b] to roll a card. Double-click a card to find it on the spread. @@ -263,7 +263,11 @@ A result or a Book page can have a picture: [b]Picture → Choose…[/b] in its - View, Help and Play/Build are in the [b]☰[/b] menu. # Spreads, import and export -A [b]spread[/b] is one layout of cards, saved under its own name. Use the switcher beside Play | Build (it shows the spread's name) to switch, or to make a new spread, rename, duplicate, delete one, or [b]Move to folder…[/b] to sort spreads into folders (the switcher lists each folder as a submenu). +A [b]spread[/b] is one layout of cards, saved under its own name. Use the switcher beside Play | Build (it shows the spread's name) to switch, or to make a new spread, rename, duplicate, delete one, or sort spreads into folders. +- The spreads you opened last are at the top, under [b]Recent[/b]. Spreads with no folder come next, then each folder as a submenu. +- [b]Move to folder[/b] lists your folders: pick one, or [b]No folder[/b], or [b]New folder…[/b]. Type a name such as [b]Traveller/Worlds[/b] to put a folder inside another. +- Each folder's submenu has [b]New spread here…[/b] and [b]Rename folder…[/b]. +- When the last spread leaves a folder, you can keep the folder or remove it. An empty folder has [b]Remove folder[/b] in its submenu. In Build mode, [b]Spread ▾[/b] has: - [b]Import as new spread…[/b] for Table Tarot JSON, JSON Canvas and GraphML files. diff --git a/tests/test_list_view.gd b/tests/test_list_view.gd index a276da8..6c1494d 100644 --- a/tests/test_list_view.gd +++ b/tests/test_list_view.gd @@ -1,6 +1,6 @@ extends TestBase ## List view: rows for every card with thread counts and Roll, search, new -## folders, and drag-and-drop moves (reorder, into a folder, folder in folder). +## groups, and drag-and-drop moves (reorder, into a group, group in group). ## Run: godot --headless --path . -s res://tests/test_list_view.gd -- --sample @@ -50,18 +50,18 @@ func _test_rows() -> void: func _test_moves() -> void: var lv := main.list_view var n := main.data.groups.size() - lv.new_folder() + lv.new_group() await _frames(2) - _check(main.data.groups.size() == n + 1, "+ Folder adds an empty group") + _check(main.data.groups.size() == n + 1, "+ Group adds an empty group") var g := main.data.groups[main.data.groups.size() - 1] ListOrder.move(main, {"kind": "card", "id": "towns"}, {"kind": "group", "id": g.id}, 0) await _frames(2) - _check(main.data.group_of("towns") == g, "dropping a card on a folder moves it in") + _check(main.data.group_of("towns") == g, "dropping a card on a group moves it in") var f2 := main.data.add_group("Inner", []) ListOrder.move(main, {"kind": "group", "id": f2.id}, {"kind": "group", "id": g.id}, 0) - _check(f2.parent == g.id, "a folder dropped on a folder goes inside it") + _check(f2.parent == g.id, "a group dropped on a group goes inside it") ListOrder.move(main, {"kind": "group", "id": g.id}, {"kind": "group", "id": f2.id}, 0) - _check(g.parent == "", "a folder can't go inside its own inner folder") + _check(g.parent == "", "a group can't go inside its own inner group") var ids := main.data.tables.map(func(t: RollTable) -> String: return t.id) ListOrder.move(main, {"kind": "card", "id": ids[3]}, {"kind": "card", "id": ids[0]}, -1) _check(main.data.tables[0].id == ids[3], "dropping above a card reorders the spread's list") diff --git a/tests/test_shell.gd b/tests/test_shell.gd index 6cd0abb..084e036 100644 --- a/tests/test_shell.gd +++ b/tests/test_shell.gd @@ -151,15 +151,3 @@ func _test_export() -> void: _check(IoMenu.export_text("mermaid_md", s).contains("```mermaid"), "markdown export has a mermaid fence") _check(IoMenu.export_text("json", s).contains("\"tables\""), "json export has tables") _check(IoMenu.default_file_name(s, IoMenu.EXPORTS[1]) == "sample.canvas", "default file name") - - -func _wipe(path: String) -> void: - var abs := ProjectSettings.globalize_path(path) - if not DirAccess.dir_exists_absolute(abs): - return - var d := DirAccess.open(abs) - for sub in d.get_directories(): - _wipe(path.path_join(sub)) - for f in d.get_files(): - DirAccess.remove_absolute(abs.path_join(f)) - DirAccess.remove_absolute(abs) diff --git a/tests/test_spread_folders.gd b/tests/test_spread_folders.gd new file mode 100644 index 0000000..33320ca --- /dev/null +++ b/tests/test_spread_folders.gd @@ -0,0 +1,140 @@ +extends TestBase +## Headless checks for spread folders (core/spread_folders.gd) and the recent +## spreads list (core/recent_spreads.gd), and the spread switcher's menu built +## from them (on a temporary library, never the saved one). +## Run: godot --headless --path . -s res://tests/test_spread_folders.gd -- --sample + +const ROOT := "user://test_spread_folders_tmp" + + +func _init() -> void: + _wipe(ROOT) + _test_paths() + _test_listing() + _test_move_and_keep() + _test_rename() + _test_recent() + if await start_main(): + _test_menu() + _wipe(ROOT) + finish() + + +func _test_paths() -> void: + _eq(SpreadFolders.normalize(" Traveller / /Worlds "), "Traveller/Worlds", "normalize trims parts and drops empty ones") + _eq(SpreadFolders.parent_of("a/b/c"), "a/b", "parent_of") + _eq(SpreadFolders.leaf("a/b/c"), "c", "leaf") + _check(SpreadFolders.is_inside("a/b", "a") and not SpreadFolders.is_inside("ab", "a"), "is_inside matches whole parts only") + var known: Array[String] = ["DnD", "Traveller", "Traveller/Worlds"] + _eq(SpreadFolders.resolve("traveller/worlds", known), "Traveller/Worlds", "typing ignores case for existing folders") + _eq(SpreadFolders.resolve("dnd/New One", known), "DnD/New One", "a new inner folder keeps the parent's spelling") + + +func _test_listing() -> void: + var entries := [{"id": "a", "folder": "Traveller/Worlds"}, {"id": "b", "folder": ""}, {"id": "c", "folder": "apple"}] + var folders := SpreadFolders.all_folders(entries, ["Zed"]) + _eq(folders, ["apple", "Traveller", "Traveller/Worlds", "Zed"] as Array[String], "folders include parents and kept ones, A–Z") + _eq(SpreadFolders.children(folders, ""), ["apple", "Traveller", "Zed"] as Array[String], "top-level folders") + _eq(SpreadFolders.spreads_in(entries, "").size(), 1, "spreads with no folder") + _check(not SpreadFolders.is_empty("Traveller", entries, []), "a folder with a spread in an inner folder isn't empty") + _check(SpreadFolders.is_empty("Zed", entries, ["Zed"]), "a kept folder with nothing in it is empty") + _check(not SpreadFolders.is_empty("Zed", entries, ["Zed/Inner"]), "a kept inner folder keeps its parent from being empty") + + +func _test_move_and_keep() -> void: + var lib := LibraryStore.new(ROOT + "/move") + var a := lib.create("Alpha") + var b := lib.create("Beta") + _eq(SpreadFolders.move(lib, a, "Games/Sci-fi"), "", "moving into a folder leaves no empty folder") + SpreadFolders.move(lib, b, "Games/Sci-fi") + _eq(lib.load_collection(a.id).folder, "Games/Sci-fi", "the folder path is saved") + _eq(SpreadFolders.move(lib, a, ""), "", "a folder that still has a spread isn't reported") + _eq(SpreadFolders.move(lib, b, "Games"), "Games/Sci-fi", "moving up to the parent folder reports the inner one left empty") + SpreadFolders.move(lib, a, "Games/Sci-fi") + _eq(SpreadFolders.move(lib, a, "Games/Sci-fi/Deep"), "", "moving into an inner folder isn't leaving the folder") + SpreadFolders.move(lib, a, "") + _eq(SpreadFolders.move(lib, b, ""), "Games", "the last spread out reports the folder it left") + SpreadFolders.keep(lib.state, "Games") + _check(SpreadFolders.all_folders(lib.list(), SpreadFolders.kept(lib.state)).has("Games"), "a kept folder is still listed") + SpreadFolders.forget(lib.state, "Games") + _check(SpreadFolders.all_folders(lib.list(), SpreadFolders.kept(lib.state)).is_empty(), "a forgotten empty folder is gone") + + +func _test_rename() -> void: + var lib := LibraryStore.new(ROOT + "/rename") + var a := lib.create("Alpha") + var b := lib.create("Beta") + SpreadFolders.move(lib, a, "Old") + SpreadFolders.move(lib, b, "Old/Inner") + SpreadFolders.keep(lib.state, "Old/Inner/Empty") + _eq(SpreadFolders.rename(lib, a, "Old", " "), "", "a blank folder name is refused") + _eq(SpreadFolders.rename(lib, a, "Old", "New"), "New", "rename returns the new path") + _eq(a.folder, "New", "the current spread changes in memory") + _eq(lib.load_collection(b.id).folder, "New/Inner", "spreads in inner folders move too") + _eq(SpreadFolders.kept(lib.state), ["New/Inner/Empty"], "kept inner folders move too") + _eq(SpreadFolders.rename(lib, a, "New/Inner", "a/b"), "New/a b", "a slash in a new name can't nest it") + SpreadFolders.move(lib, b, "Other") + _eq(SpreadFolders.rename(lib, a, "New", "other"), "Other", "renaming to a taken name (any case) joins that folder") + _eq(lib.load_collection(a.id).folder, "Other", "the joined folder holds both spreads") + + +func _test_recent() -> void: + var state := StateStore.new(ROOT + "/recent") + for id in ["a", "b", "c", "d", "e", "f"]: + RecentSpreads.note(state, id) + _eq(RecentSpreads.ids(state), ["f", "e", "d", "c", "b"], "newest first, at most five") + RecentSpreads.note(state, "c") + _eq(RecentSpreads.ids(state)[0], "c", "opening again moves it first") + RecentSpreads.forget(state, "e") + var entries := [{"id": "c"}, {"id": "f"}, {"id": "b"}] + var picked := RecentSpreads.pick(state, entries, "c") + _eq(picked.map(func(e: Dictionary) -> String: return e["id"]), ["f", "b"], "pick skips the open spread and missing ones") + + +## The switcher's menu on a temporary library: Recent, loose spreads, folders +## with inner folders, folder actions and the Move to folder list. +func _test_menu() -> void: + main.state = StateStore.new(ROOT + "/menu") + main.library = LibraryStore.new(ROOT + "/menu", main.state) + var lib := main.library + var loose := lib.create("Loose") + var deep := lib.create("Deep") + SpreadFolders.move(lib, deep, "Games/Sci-fi") + SpreadFolders.keep(main.state, "Empty one") + RecentSpreads.note(main.state, deep.id) + main.data = loose + main._saving_enabled = true + var sw := main.top_bar._switcher + sw._fill() + var pm := sw.get_popup() + var labels := _labels(pm) + _check(labels.has("Recent") and labels.find("Recent") < labels.find("● Loose"), "Recent comes first: %s" % str(labels)) + _check(labels.find("● Loose") < labels.find(" Games"), "spreads with no folder come before the folders") + _check(labels.has(" Empty one"), "a kept empty folder is listed") + var games := _submenu(pm, " Games") + _check(games != null and _labels(games).has(" Sci-fi"), "a folder lists its inner folders") + if games: + var g := _labels(games) + _check(g.has("New spread here…") and g.has("Rename folder…") and not g.has("Remove folder"), "folder actions; no Remove for a folder with spreads: %s" % str(g)) + var empty := _submenu(pm, " Empty one") + _check(empty != null and _labels(empty).has("Remove folder"), "an empty folder can be removed") + var move := _submenu(pm, "Move to folder") + if move: + var m := _labels(move) + _check(m.has("● No folder") and m.has(" Sci-fi") and m.has("New folder…"), "Move to folder lists every folder, inner ones indented: %s" % str(m)) + var i := m.find(" Games") + sw._on_id(move.get_item_id(i)) + _eq(loose.folder, "Games", "picking a folder in Move to folder moves the spread") + main._saving_enabled = false + + +func _labels(pm: PopupMenu) -> Array[String]: + var out: Array[String] = [] + for i in pm.item_count: + out.append(pm.get_item_text(i)) + return out + + +func _submenu(pm: PopupMenu, label: String) -> PopupMenu: + var i := _labels(pm).find(label) + return pm.get_item_submenu_node(i) if i >= 0 else null diff --git a/tests/test_spread_folders.gd.uid b/tests/test_spread_folders.gd.uid new file mode 100644 index 0000000..46fb63f --- /dev/null +++ b/tests/test_spread_folders.gd.uid @@ -0,0 +1 @@ +uid://bmg3uiq507l2w diff --git a/tests/test_storage.gd b/tests/test_storage.gd index 04b411d..dd137c6 100644 --- a/tests/test_storage.gd +++ b/tests/test_storage.gd @@ -56,13 +56,13 @@ func _test_library() -> void: _check(lib.load_collection("fantasy-loot").name == "Dark Loot", "rename keeps id, changes name") var dark := lib.load_collection("fantasy-loot") - CollectionSwitcher.set_folder(lib, dark, " Campaign ") + SpreadFolders.move(lib, dark, " Campaign ") _eq(lib.load_collection("fantasy-loot").folder, "Campaign", "a spread can be put in a folder (saved, trimmed)") _check(lib.list().any(func(entry: Dictionary) -> bool: return entry["folder"] == "Campaign"), "the library lists its folder") var copy := lib.duplicate("fantasy-loot", "Dark Loot Copy") _check(copy != null and copy.id == "dark-loot-copy" and copy.tables.size() == a.tables.size(), "duplicate copies tables") _eq(copy.folder, "Campaign", "a copy stays in the same folder") - CollectionSwitcher.set_folder(lib, copy, "") + SpreadFolders.move(lib, copy, "") _eq(lib.load_collection("dark-loot-copy").folder, "", "an empty folder takes it out again") var names: Array = [] for e in lib.list(): @@ -191,13 +191,3 @@ func _test_state() -> void: st2.save() var st3 := StateStore.new(root) _check(st3.get_history().is_empty() and st3.get_deck("c1", "t1").is_empty(), "cleared state persists") - - -func _wipe(path: String) -> void: - if not DirAccess.dir_exists_absolute(path): - return - for d in DirAccess.get_directories_at(path): - _wipe(path.path_join(d)) - for f in DirAccess.get_files_at(path): - DirAccess.remove_absolute(path.path_join(f)) - DirAccess.remove_absolute(path) diff --git a/tests/testbase.gd b/tests/testbase.gd index 7dcdfcb..2412c38 100644 --- a/tests/testbase.gd +++ b/tests/testbase.gd @@ -61,3 +61,15 @@ func _eq(got: Variant, want: Variant, what: String) -> void: func finish() -> void: print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures]) quit(1 if _failures else 0) + + +## Deletes a folder and everything in it (for temporary test folders). +func _wipe(path: String) -> void: + var abs := ProjectSettings.globalize_path(path) + if not DirAccess.dir_exists_absolute(abs): + return + for sub in DirAccess.get_directories_at(abs): + _wipe(path.path_join(sub)) + for f in DirAccess.get_files_at(abs): + DirAccess.remove_absolute(abs.path_join(f)) + DirAccess.remove_absolute(abs) diff --git a/ui/actions.gd b/ui/actions.gd index 70f2883..9a13bbd 100644 --- a/ui/actions.gd +++ b/ui/actions.gd @@ -181,7 +181,7 @@ static func background(m: Main, at: Vector2) -> Array: "tip": "Put every Deck-mode card's results back"}) 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 folders"}) + "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({"sep": ""}) diff --git a/ui/collection_switcher.gd b/ui/collection_switcher.gd index 3fa2823..a7a99a2 100644 --- a/ui/collection_switcher.gd +++ b/ui/collection_switcher.gd @@ -1,20 +1,19 @@ class_name CollectionSwitcher extends MenuButton -## Top-bar dropdown that names the current collection and offers switching, -## New, Rename, Duplicate, Move to folder and Delete. Spreads in a folder are -## listed in that folder's submenu. The storage rules are static functions -## (create_collection and friends) so tests can run them on a temporary -## LibraryStore; Main does the UI side (rebuilding cards, dialogs). +## Top-bar dropdown that names the current spread and offers switching, New, +## Rename, Duplicate, Move to folder and Delete. Recent spreads come first, +## then spreads with no folder, then the folders as submenus (folders can hold +## folders). The storage rules are static functions (create_collection and +## friends; folders in core/spread_folders.gd) so tests can run them on a +## temporary LibraryStore; Main does the UI side (rebuilding cards, dialogs). -const ID_NEW := 1000 -const ID_RENAME := 1001 -const ID_DUPLICATE := 1002 -const ID_DELETE := 1003 -const ID_FOLDER := 1004 const MAX_LABEL := 22 +const MARK := "● " +const NO_MARK := " " var main: Main -var _ids: Array[String] = [] +## What each menu item does; an item's id is its index here. +var _calls: Array[Callable] = [] func setup(p_main: Main) -> void: @@ -32,97 +31,109 @@ func setup(p_main: Main) -> void: func refresh() -> void: var n := main.data.name if main.data.name != "" else "Untitled" text = "%s ▾" % (n if n.length() <= MAX_LABEL else n.substr(0, MAX_LABEL - 1) + "…") - var where := " (in %s)" % main.data.folder if main.data.folder != "" else "" + var where := " (in %s)" % main.data.folder.replace("/", " ▸ ") if main.data.folder != "" else "" tooltip_text = "%s%s · %d cards\nSwitch spreads, or make, rename, copy, sort into folders or delete one" % [n, where, main.data.tables.size()] func _fill() -> void: var pm := get_popup() pm.clear() - _ids.clear() - var can := main.collections_enabled() + _calls.clear() for child in pm.get_children(): if child is PopupMenu: pm.remove_child(child) child.queue_free() + var can := main.collections_enabled() + var folders: Array[String] = [] if can: - var folders := {} - for entry in main.library.list(): - var folder := str(entry.get("folder", "")) - if folder != "": - if not folders.has(folder): - folders[folder] = [] - (folders[folder] as Array).append(entry) - continue + var entries := main.library.list() + folders = SpreadFolders.all_folders(entries, SpreadFolders.kept(main.state)) + var recent := RecentSpreads.pick(main.state, entries, main.data.id) + if not folders.is_empty() and not recent.is_empty(): + pm.add_separator("Recent") + for entry in recent: + _add_spread(pm, entry) + pm.add_separator() + for entry in SpreadFolders.spreads_in(entries, ""): _add_spread(pm, entry) - var names: Array = folders.keys() - names.sort_custom(func(left: String, right: String) -> bool: return left.naturalnocasecmp_to(right) < 0) - for folder: String in names: - var sub := PopupMenu.new() - ModalCard.style_popup(sub) - sub.id_pressed.connect(_on_id) - var holds_current := false - for entry: Dictionary in folders[folder]: - _add_spread(sub, entry) - holds_current = holds_current or str(entry["id"]) == main.data.id - pm.add_submenu_node_item(("● " if holds_current else " ") + folder, sub) + for f in SpreadFolders.children(folders, ""): + _add_folder(pm, f, folders, entries) else: - pm.add_item("● " + main.data.name, 0) - pm.set_item_disabled(0, true) - _ids.append(main.data.id) + _item(pm, MARK + main.data.name, Callable(), true) pm.add_separator() - pm.add_item("New spread…", ID_NEW) - pm.add_item("Rename…", ID_RENAME) - pm.add_item("Duplicate", ID_DUPLICATE) - pm.add_item("Move to folder…", ID_FOLDER) - pm.add_item("Delete…", ID_DELETE) + _item(pm, "New spread…", main.new_collection, not can) + _item(pm, "Rename…", main.rename_collection, not can) + _item(pm, "Duplicate", main.duplicate_collection, not can) + if can: + pm.add_submenu_node_item("Move to folder", _move_menu(folders)) + else: + _item(pm, "Move to folder", Callable(), true) + _item(pm, "Delete…", main.delete_collection, not can) if not can: - for id in [ID_NEW, ID_RENAME, ID_DUPLICATE, ID_FOLDER, ID_DELETE]: - pm.set_item_disabled(pm.get_item_index(id), true) pm.add_separator() - pm.add_item("Saving is off in this session", -1) - pm.set_item_disabled(pm.item_count - 1, true) + _item(pm, "Saving is off in this session", Callable(), true) func _on_id(id: int) -> void: - match id: - ID_NEW: main.new_collection() - ID_RENAME: main.rename_collection() - ID_DUPLICATE: main.duplicate_collection() - ID_DELETE: main.delete_collection() - ID_FOLDER: _ask_folder() - _: - if id >= 0 and id < _ids.size() and _ids[id] != main.data.id: - main.switch_collection(_ids[id]) + if id >= 0 and id < _calls.size() and _calls[id].is_valid(): + _calls[id].call() + + +## Adds an item that runs `call` when picked. +func _item(menu: PopupMenu, label: String, call: Callable, disabled: bool = false) -> void: + menu.add_item(label, _calls.size()) + menu.set_item_disabled(menu.item_count - 1, disabled) + _calls.append(call) + + +func _sub() -> PopupMenu: + var sub := PopupMenu.new() + ModalCard.style_popup(sub) + sub.id_pressed.connect(_on_id) + return sub func _add_spread(menu: PopupMenu, entry: Dictionary) -> void: var id := str(entry["id"]) - menu.add_item(("● " if id == main.data.id else " ") + str(entry["name"]), _ids.size()) - _ids.append(id) + _item(menu, (MARK if id == main.data.id else NO_MARK) + str(entry["name"]), main.switch_collection.bind(id)) -## Asks for the folder to list the current spread under (empty = none). -func _ask_folder() -> void: - var known := {} - for entry in main.library.list(): - if str(entry.get("folder", "")) != "": - known[str(entry["folder"])] = true - var prompt := "Folder (leave empty for none)" - if not known.is_empty(): - prompt += ". Folders so far: " + ", ".join(known.keys()) - main._add_modal(ModalCard.ask_text("Move to folder", prompt, main.data.folder, "Move", func(folder: String) -> void: - set_folder(main.library, main.data, folder) - refresh(), true)) +## A folder's submenu: its inner folders, its spreads, then folder actions. +func _add_folder(menu: PopupMenu, folder: String, folders: Array[String], entries: Array) -> void: + var sub := _sub() + for f in SpreadFolders.children(folders, folder): + _add_folder(sub, f, folders, entries) + for entry in SpreadFolders.spreads_in(entries, folder): + _add_spread(sub, entry) + var empty := SpreadFolders.is_empty(folder, entries, SpreadFolders.kept(main.state)) + if empty: + _item(sub, NO_MARK + "(empty)", Callable(), true) + sub.add_separator() + _item(sub, "New spread here…", main.new_collection.bind(folder)) + _item(sub, "Rename folder…", SpreadFolderDialogs.ask_rename.bind(main, folder)) + if empty: + _item(sub, "Remove folder", SpreadFolderDialogs.delete_empty.bind(main, folder)) + var here := SpreadFolders.is_inside(main.data.folder, folder) + menu.add_submenu_node_item((MARK if here else NO_MARK) + SpreadFolders.leaf(folder), sub) + + +## "Move to folder": No folder, every folder (inner ones indented), New folder. +func _move_menu(folders: Array[String]) -> PopupMenu: + var sub := _sub() + var at := main.data.folder + _item(sub, (MARK if at == "" else NO_MARK) + "No folder", SpreadFolderDialogs.move_current.bind(main, "")) + if not folders.is_empty(): + sub.add_separator() + for f in folders: + var label := " ".repeat(SpreadFolders.depth(f)) + SpreadFolders.leaf(f) + _item(sub, (MARK if at == f else NO_MARK) + label, SpreadFolderDialogs.move_current.bind(main, f)) + sub.add_separator() + _item(sub, "New folder…", SpreadFolderDialogs.ask_new.bind(main)) + return sub # ---------- Storage rules (no UI) ---------- -## Lists `current` under `folder` ("" = none) and saves it. -static func set_folder(library: LibraryStore, current: TowerBoard, folder: String) -> void: - current.folder = folder.strip_edges() - library.save(current) - ## Saves `current`, then makes and returns a new empty collection. static func create_collection(library: LibraryStore, current: TowerBoard, coll_name: String) -> TowerBoard: if current: diff --git a/ui/list_tree.gd b/ui/list_tree.gd index cbd564f..af1f3a5 100644 --- a/ui/list_tree.gd +++ b/ui/list_tree.gd @@ -1,7 +1,7 @@ class_name ListTree extends Tree -## List view's tree: groups as folders (nested), cards as rows with their -## threads and a Roll cell. Drag a row to reorder it or drop it on a folder to +## List view's tree: groups (nested), cards as rows with their +## threads and a Roll cell. Drag a row to reorder it or drop it on a group to ## move it in; the order is the spread's own (TowerBoard.tables and .groups). const COL_NAME := 0 @@ -42,10 +42,10 @@ func _init(p_main: Main) -> void: add_theme_color_override(colour_name, Style.INK) item_mouse_selected.connect(_on_click) item_activated.connect(_on_activated) - item_collapsed.connect(_on_folder_toggled) + item_collapsed.connect(_on_group_toggled) -## Rebuilds every row from the spread, keeping the open folders and selection. +## Rebuilds every row from the spread, keeping the open groups and selection. func rebuild() -> void: var sel := _meta(get_selected()) clear() @@ -63,7 +63,7 @@ func _fill(parent: TreeItem, gid: String) -> void: it.set_custom_font(COL_NAME, Style.body_bold()) it.set_custom_color(COL_NAME, Style.TRIM_DARK) it.set_metadata(COL_NAME, {"kind": "group", "id": g.id}) - it.set_tooltip_text(COL_NAME, "Folder (a group on the spread): %s" % MainSelection.describe_counts(m.data.tables_in(g.id).size(), m.data.groups_in(g.id).size() - 1)) + it.set_tooltip_text(COL_NAME, "Group: %s" % MainSelection.describe_counts(m.data.tables_in(g.id).size(), m.data.groups_in(g.id).size() - 1)) _fill(it, g.id) it.collapsed = g.collapsed and filter == "" if filter != "" and it.get_first_child() == null: @@ -161,8 +161,8 @@ func _on_activated() -> void: m.focus_table(str(meta["id"])) -## Opening or closing a folder opens or closes its group on the spread too. -func _on_folder_toggled(it: TreeItem) -> void: +## Opening or closing a group row opens or closes the group on the spread too. +func _on_group_toggled(it: TreeItem) -> void: var meta := _meta(it) if meta.get("kind") == "group" and filter == "": var g := m.data.get_group(meta["id"]) diff --git a/ui/list_view.gd b/ui/list_view.gd index 88035f9..d81d36a 100644 --- a/ui/list_view.gd +++ b/ui/list_view.gd @@ -1,9 +1,9 @@ class_name ListView extends PanelContainer ## List view: the spread's cards as a plain list, docked on the left (or -## filling the window on phones). Groups are folders; rows roll, select +## filling the window on phones). Groups show as nested rows; rows roll, select ## (Build) and show where their threads go. It has its own search and -## "+ Folder". Shown from View ▾, ☰ or right-clicking the spread. +## "+ Group". Shown from View ▾, ☰ or right-clicking the spread. const WIDTH := 320.0 const MIN_WIDTH := 220.0 @@ -29,10 +29,10 @@ func setup(p_main: Main) -> void: var title := Style.make_label("List", Style.display(), 20, Style.ON_BG) title.size_flags_horizontal = SIZE_EXPAND_FILL head.add_child(title) - var folder := Style.bar_button("+ Folder") - folder.tooltip_text = "A new folder (a group on the spread). Drag cards onto it." - folder.pressed.connect(new_folder) - head.add_child(folder) + var group := Style.bar_button("+ Group") + group.tooltip_text = "A new, empty group on the spread. Drag cards onto it." + group.pressed.connect(new_group) + head.add_child(group) close_button = Style.bar_button("×") var close := close_button close.tooltip_text = "Close the list" @@ -49,7 +49,7 @@ func setup(p_main: Main) -> void: tree = ListTree.new(m) tree.size_flags_vertical = SIZE_EXPAND_FILL col.add_child(tree) - var hint := Style.make_label("Drag to reorder or into a folder. Double-click shows the card on the spread.", Style.body(), 12, Style.ON_BG_MUTED) + var hint := Style.make_label("Drag to reorder or into a group. Double-click shows the card on the spread.", Style.body(), 12, Style.ON_BG_MUTED) hint.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART col.add_child(hint) @@ -79,8 +79,8 @@ func toggle() -> void: set_shown(not visible) -## A new, empty folder: a group in the middle of the view. -func new_folder() -> void: +## A new, empty group in the middle of the view. +func new_group() -> void: m.undo_redo._begin_edit() var g := m.data.add_group(m.grouping._free_group_name(), []) var c := m.board.screen_to_world(m.board.size / 2.0) diff --git a/ui/main.gd b/ui/main.gd index 8b07b7b..e27210c 100644 --- a/ui/main.gd +++ b/ui/main.gd @@ -251,8 +251,8 @@ func open_table_settings(table_id: String) -> void: collections.open_table_settings(table_id) func switch_collection(id: String) -> void: collections.switch_collection(id) -func new_collection() -> void: - collections.new_collection() +func new_collection(folder: String = "") -> void: + collections.new_collection(folder) func rename_collection() -> void: collections.rename_collection() func duplicate_collection() -> void: diff --git a/ui/main_collections.gd b/ui/main_collections.gd index 1810dda..e0660ba 100644 --- a/ui/main_collections.gd +++ b/ui/main_collections.gd @@ -74,6 +74,7 @@ func _show_collection(b: TowerBoard) -> void: m.tray.render() if m.state: m.state.set_setting("last_collection", m.data.id) + RecentSpreads.note(m.state, m.data.id) m.state.save() m.top_bar._switcher.refresh() m.top_bar._update_endless_chip() @@ -82,11 +83,16 @@ func _show_collection(b: TowerBoard) -> void: m.board.fit() -func new_collection() -> void: +## Asks for a name, then makes an empty spread (in `folder`, "" = none). +func new_collection(folder: String = "") -> void: if not collections_enabled(): return m._add_modal(ModalCard.ask_text("New spread", "Name", "", "Create", func(n: String) -> void: - _show_collection(CollectionSwitcher.create_collection(m.library, m.data, n)) + var b := CollectionSwitcher.create_collection(m.library, m.data, n) + if folder != "": + b.folder = folder + m.library.save(b) + _show_collection(b) m.toast("Created “%s”" % m.data.name) )) @@ -118,11 +124,15 @@ func delete_collection() -> void: m._add_modal(ModalCard.confirm("Delete spread", msg, "Delete", func() -> void: var gone := m.data.name var gone_id := m.data.id + var gone_folder := m.data.folder var next := CollectionSwitcher.delete_collection(m.library, m.data) if next: m.undo_redo._histories.erase(gone_id) + RecentSpreads.forget(m.state, gone_id) _show_collection(next) m.toast("Deleted “%s”" % gone) + if gone_folder != "" and SpreadFolders.is_empty(gone_folder, m.library.list(), SpreadFolders.kept(m.state)): + SpreadFolderDialogs.ask_keep(m, gone_folder) , true)) diff --git a/ui/main_layout.gd b/ui/main_layout.gd index 769910a..d790b9d 100644 --- a/ui/main_layout.gd +++ b/ui/main_layout.gd @@ -30,6 +30,7 @@ func _open_library() -> void: m.data.tables = SampleBoard.create().tables m.library.save(m.data) m.state.set_setting("last_collection", m.data.id) + RecentSpreads.note(m.state, m.data.id) func _save_now() -> void: diff --git a/ui/spread_folder_dialogs.gd b/ui/spread_folder_dialogs.gd new file mode 100644 index 0000000..09fe4c8 --- /dev/null +++ b/ui/spread_folder_dialogs.gd @@ -0,0 +1,55 @@ +class_name SpreadFolderDialogs +extends RefCounted +## The spread switcher's folder questions: name a new folder, rename a folder, +## and "keep this empty folder?". The rules are in core/spread_folders.gd. + + +## Asks for a new folder's name, then moves the current spread into it. +static func ask_new(m: Main) -> void: + var prompt := "Folder name. Use / to put it inside another folder, such as Traveller/Worlds." + m._add_modal(ModalCard.ask_text("New folder", prompt, "", "Move here", func(typed: String) -> void: + var path := SpreadFolders.resolve(typed, SpreadFolders.all_folders(m.library.list(), SpreadFolders.kept(m.state))) + if path != "": + move_current(m, path) + )) + + +## Moves the current spread to `folder` ("" = none), then asks about the +## folder it left if that one is empty now. +static func move_current(m: Main, folder: String) -> void: + var left := SpreadFolders.move(m.library, m.data, folder) + m.top_bar._switcher.refresh() + m.toast("Moved to %s" % (SpreadFolders.leaf(m.data.folder) if m.data.folder != "" else "no folder")) + if left != "": + ask_keep(m, left) + + +static func ask_rename(m: Main, folder: String) -> void: + m._add_modal(ModalCard.ask_text("Rename folder", "Name", SpreadFolders.leaf(folder), "Rename", func(typed: String) -> void: + var to := SpreadFolders.rename(m.library, m.data, folder, typed) + if to != "" and to != folder: + m.top_bar._switcher.refresh() + m.toast("Renamed the folder to %s" % SpreadFolders.leaf(to)) + )) + + +## Asks whether to keep `folder` now that it has no spreads. Closing the +## question without an answer removes it. +static func ask_keep(m: Main, folder: String) -> void: + var d := ModalCard.new("Empty folder", 420.0) + d.body.add_child(ModalCard.note("“%s” has no spreads now. Keep it as an empty folder?" % SpreadFolders.leaf(folder), Style.INK)) + d.add_button("Remove it", "plain", func() -> void: + d.close() + SpreadFolders.forget(m.state, folder) + ) + d.add_button("Keep", "primary", func() -> void: + d.close() + SpreadFolders.keep(m.state, folder) + ) + m._add_modal(d) + + +## Removes an empty folder from the list. +static func delete_empty(m: Main, folder: String) -> void: + SpreadFolders.forget(m.state, folder) + m.toast("Removed the folder %s" % SpreadFolders.leaf(folder)) diff --git a/ui/spread_folder_dialogs.gd.uid b/ui/spread_folder_dialogs.gd.uid new file mode 100644 index 0000000..37403c0 --- /dev/null +++ b/ui/spread_folder_dialogs.gd.uid @@ -0,0 +1 @@ +uid://cuwffhkf03u6n diff --git a/ui/view_menu.gd b/ui/view_menu.gd index 0ef9c2c..ef042db 100644 --- a/ui/view_menu.gd +++ b/ui/view_menu.gd @@ -39,7 +39,7 @@ func setup(p_main: Main) -> void: 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.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_LIST), "The cards as a list with folders, beside the spread") + 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) pm.set_item_tooltip(pm.get_item_index(ID_THEME), "Colours, background, fonts and logo; save your own theme")