Card palette: left dock Cards | List, search, click or drag to add
- CardCatalog: one list of card kinds for the palette, right-click New card and new-card names; Dice table and Deck are their own items. - LeftDock holds the palette and List view in the shared dock tab style. - Play greys the palette under a Switch to Build notice (replaces the greyed + Card button); + Card menu removed; Card palette button in Build. - Templates dropped from the palette land where they are let go. - Phones: + opens the palette full screen. - docs/SHEETS.md: the Sheets and unified editor plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7ea2bbf3a8
commit
16b34c40f6
34 changed files with 714 additions and 206 deletions
|
|
@ -24,7 +24,7 @@ const KIND_LABELS := {
|
||||||
RollTable.KIND_ROUTER: "Branch", RollTable.KIND_CHECK: "Check", RollTable.KIND_VARIABLE: "Variable",
|
RollTable.KIND_ROUTER: "Branch", RollTable.KIND_CHECK: "Check", RollTable.KIND_VARIABLE: "Variable",
|
||||||
RollTable.KIND_SHEET: "Sheet",
|
RollTable.KIND_SHEET: "Sheet",
|
||||||
}
|
}
|
||||||
## What each kind of choice is called (the + Card menu, settings, card, previews).
|
## What each kind of choice is called (the card palette, settings, card, previews).
|
||||||
const CHOICE_LABELS := {"pick": "Which option", "number": "How many", "text": "Open ended"}
|
const CHOICE_LABELS := {"pick": "Which option", "number": "How many", "text": "Open ended"}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ Read on demand (not every session). Status and plan: `docs/DESIGN.md`.
|
||||||
- **Play / Build modes.** Collapse a card, or every table from **View ▾**. Pan, zoom (8%–150%) with the
|
- **Play / Build modes.** Collapse a card, or every table from **View ▾**. Pan, zoom (8%–150%) with the
|
||||||
**− 90% ▾ +** control (the percentage opens Fit board, Zoom to 100% and the minimap), minimap (M).
|
**− 90% ▾ +** control (the percentage opens Fit board, Zoom to 100% and the minimap), minimap (M).
|
||||||
- **Top bar.** Search (icon, Ctrl+F), **View ▾** (rules as Plain words or Rule text, Collapse/Expand
|
- **Top bar.** Search (icon, Ctrl+F), **View ▾** (rules as Plain words or Rule text, Collapse/Expand
|
||||||
all tables, Striped rows, Minimap), **Help ▾** and the zoom control. Build adds undo/redo, + Card ▾
|
all tables, Striped rows, Minimap), **Help ▾** and the zoom control. Build adds undo/redo
|
||||||
and Board ▾ (Test board, Reset sample, Pack collapsed groups, import, export).
|
and Spread ▾ (Test board, Reset sample, Pack collapsed groups, import, export).
|
||||||
- **Striped rows.** Every second result row on a card is tinted (`Style.STRIPE`); lit, flicker and
|
- **Striped rows.** Every second result row on a card is tinted (`Style.STRIPE`); lit, flicker and
|
||||||
selection paint over it. On by default; the `striped_rows` local setting.
|
selection paint over it. On by default; the `striped_rows` local setting.
|
||||||
- **Help.** Help ▾ lists the topics; F1 opens the window. Text in `help/topics.txt` (a small markup,
|
- **Help.** Help ▾ lists the topics; F1 opens the window. Text in `help/topics.txt` (a small markup,
|
||||||
|
|
@ -63,13 +63,13 @@ Read on demand (not every session). Status and plan: `docs/DESIGN.md`.
|
||||||
- Rolls, variables and decks aren't undoable.
|
- Rolls, variables and decks aren't undoable.
|
||||||
- Collection members aren't undoable either.
|
- Collection members aren't undoable either.
|
||||||
- **Group cards.** Frames that collapse whole blocks. Ctrl/Shift-click or Ctrl-drag to
|
- **Group cards.** Frames that collapse whole blocks. Ctrl/Shift-click or Ctrl-drag to
|
||||||
select, Ctrl+G to group, then drag cards in or out, rename, ungroup or delete. Board ▾ → Pack collapsed groups.
|
select, Ctrl+G to group, then drag cards in or out, rename, ungroup or delete. Spread ▾ → Pack collapsed groups.
|
||||||
- **Templates.** Save a card, group or selection, with `{$param}` fill-ins. Insert from
|
- **Templates.** Save a card, group or selection, with `{$param}` fill-ins. Insert from
|
||||||
"+ Card ▾ → From template…". The library is in `user://templates/`, and generic built-ins are in `templates/`:
|
the card palette's Templates group ("All templates…" opens the picker). The library is in `user://templates/`, and generic built-ins are in `templates/`:
|
||||||
skill check (a Check card, 2d6 + modifier vs target), ask-and-repeat, pick menu, counter
|
skill check (a Check card, 2d6 + modifier vs target), ask-and-repeat, pick menu, counter
|
||||||
and simple sheet.
|
and simple sheet.
|
||||||
- **Search** (button or Ctrl+F) jumps to cards, opens groups and flashes the card.
|
- **Search** (button or Ctrl+F) jumps to cards, opens groups and flashes the card.
|
||||||
- **Test board** (Board ▾): hundreds of random rolls plus static checks. It reports
|
- **Test board** (Spread ▾): hundreds of random rolls plus static checks. It reports
|
||||||
errors, dead ends, unreached cards and lint, and clicking an item jumps to the card.
|
errors, dead ends, unreached cards and lint, and clicking an item jumps to the card.
|
||||||
- **Collections** (switcher in the top bar). Import and export via Board ▾: TableTower
|
- **Collections** (switcher in the top bar). Import and export via Board ▾: TableTower
|
||||||
JSON, JSON Canvas, GraphML (both ways), plus Mermaid and DOT (export only).
|
JSON, JSON Canvas, GraphML (both ways), plus Mermaid and DOT (export only).
|
||||||
|
|
@ -154,6 +154,10 @@ templates/ built-in templates · examples/logic_demo.json (original demo board)
|
||||||
geometry/list/kind_rows.gd` (next to header/rows/editing/value/text).
|
geometry/list/kind_rows.gd` (next to header/rows/editing/value/text).
|
||||||
- **Menus and selection:** `ui/actions.gd` (all menus), `ui/main_selection.gd` (groups in the
|
- **Menus and selection:** `ui/actions.gd` (all menus), `ui/main_selection.gd` (groups in the
|
||||||
selection), `ui/main_layout.gd` (Main's layout, saving, mode, input; Main keeps delegators).
|
selection), `ui/main_layout.gd` (Main's layout, saving, mode, input; Main keeps delegators).
|
||||||
|
- **Left dock and card palette (2026-11-29):** `ui/left_dock.gd` ("Cards | List" tabs, setting
|
||||||
|
`left_dock`), `ui/card_palette.gd` (search, groups, click/drag to add, Play notice),
|
||||||
|
`ui/card_catalog.gd` (every card kind: one list for the palette, right-click › New card and
|
||||||
|
new-card names; variants "dice" and "deck"). `SideTabs.tab_row` is the shared dock tab style.
|
||||||
- **Lists and phones:** `ui/list_view.gd`, `ui/list_tree.gd`, `ui/list_order.gd`,
|
- **Lists and phones:** `ui/list_view.gd`, `ui/list_tree.gd`, `ui/list_order.gd`,
|
||||||
`ui/mobile_layout.gd`, `ui/touch_input.gd`.
|
`ui/mobile_layout.gd`, `ui/touch_input.gd`.
|
||||||
- **Book and pictures:** `core/book_page.gd`, `core/board_images.gd`, `ui/book_panel.gd`,
|
- **Book and pictures:** `core/book_page.gd`, `core/board_images.gd`, `ui/book_panel.gd`,
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,10 @@ mascot, **Morgan Fortuna** ("Morgan"; they/them in any UI text, kept gender-neut
|
||||||
| Ledger (card kind; "for the time being", user 2026-11-11) | variable card, `var_type: "collection"` |
|
| Ledger (card kind; "for the time being", user 2026-11-11) | variable card, `var_type: "collection"` |
|
||||||
Card, Result, Change, Reset, Dice wording rules: `docs/HISTORY.md` §6 "Terminology".
|
Card, Result, Change, Reset, Dice wording rules: `docs/HISTORY.md` §6 "Terminology".
|
||||||
|
|
||||||
|
## 3a. Now: Sheets and the unified editor (2026-11-29)
|
||||||
|
Spec, decisions and phases: `docs/SHEETS.md`. Phase A (card palette, branch `card-palette`) built,
|
||||||
|
tests pass; not yet hand-tested or merged.
|
||||||
|
|
||||||
## 3. Where things stand (2026-11-11)
|
## 3. Where things stand (2026-11-11)
|
||||||
- **Everything from the 2026-11-10 plan is built, tested and on `main`** (pushed): theme system,
|
- **Everything from the 2026-11-10 plan is built, tested and on `main`** (pushed): theme system,
|
||||||
rename and reskin, spread interaction, menus, Deck mode, nested groups, List view, phone layout,
|
rename and reskin, spread interaction, menus, Deck mode, nested groups, List view, phone layout,
|
||||||
|
|
@ -103,7 +107,7 @@ animations (+ Shift); questions animate like pauses; pop-ups fade in; ranged car
|
||||||
**Ranges** (auto-sort on by default); whole rows drag; empty cards can switch Plain/Ranged;
|
**Ranges** (auto-sort on by default); whole rows drag; empty cards can switch Plain/Ranged;
|
||||||
Inspector is one list (card + each result, collapsible; spread clicks open one, hand-opened stay);
|
Inspector is one list (card + each result, collapsible; spread clicks open one, hand-opened stay);
|
||||||
result weight/range/position in the Inspector; thicker coloured header (`CARD_HEAD`), Build move
|
result weight/range/position in the Inspector; thicker coloured header (`CARD_HEAD`), Build move
|
||||||
handle, green selection glow (`SELECTED`, also on the inspected card); Play's greyed + Card and ☰
|
handle, green selection glow (`SELECTED`, also on the inspected card); Play's greyed card palette and ☰
|
||||||
New card point to Build; Book → Lore Index / Lore Entries, a tab beside the Inspector in Build;
|
New card point to Build; Book → Lore Index / Lore Entries, a tab beside the Inspector in Build;
|
||||||
spellcheck (Hunspell; per-spread dictionary; off on Android). Modules: ARCHITECTURE §3g.
|
spellcheck (Hunspell; per-spread dictionary; off on Android). Modules: ARCHITECTURE §3g.
|
||||||
**Spellcheck:** the Godot-Hunspell prebuilt libraries (MIT, github.com/brunogbrito/Godot-Hunspell)
|
**Spellcheck:** the Godot-Hunspell prebuilt libraries (MIT, github.com/brunogbrito/Godot-Hunspell)
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ lazy). No existing test changed.
|
||||||
|
|
||||||
## 3b. Router cards
|
## 3b. Router cards
|
||||||
|
|
||||||
A router (`kind: "router"`, "Router" in the **+ Card ▾** menu, "if / else if / otherwise")
|
A router (`kind: "router"`, "Branch" in the card palette, "if / else if / otherwise")
|
||||||
has no dice. Its entries are **cases**, each with an entry-level `when` expression.
|
has no dice. Its entries are **cases**, each with an entry-level `when` expression.
|
||||||
|
|
||||||
- When the chain reaches it, the cases are checked top to bottom and the **first** true case
|
- When the chain reaches it, the cases are checked top to bottom and the **first** true case
|
||||||
|
|
|
||||||
58
docs/SHEETS.md
Normal file
58
docs/SHEETS.md
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
# Sheets and the unified editor: spec and plan
|
||||||
|
|
||||||
|
Agreed with the user 2026-11-29. Mockup canvas (design only, not code):
|
||||||
|
https://claude.ai/code/artifact/4311ebce-47e0-479c-bc1b-40800339b50b
|
||||||
|
|
||||||
|
## 1. Goal
|
||||||
|
A sheet builder for any TTRPG: odd OSR stats, point buy, a vehicle with only description
|
||||||
|
boxes. Sheets can be used on their own or as a node in a spread, and tables can read and write
|
||||||
|
them. The new Sheets replace today's Sheet card kind (`RollTable.KIND_SHEET`, a BBCode template):
|
||||||
|
an old sheet card becomes a sheet with one text box.
|
||||||
|
|
||||||
|
## 2. Decisions
|
||||||
|
- **Main menu:** Spreads / Sheets / Settings / Quit, titles only (no descriptions). Room for more.
|
||||||
|
- **Sheets standalone or in a spread.** On a spread the node shows a preview of the sheet's
|
||||||
|
**first tab**. Double-click opens it in an in-app tab (view only in Play).
|
||||||
|
- **Layout:** free placement with a snap grid; Alt places freely. A sheet has tabs, each its
|
||||||
|
own canvas. One Play/Build toggle; in a spread, the spread's toggle.
|
||||||
|
- **Multi-entry boxes** ("repeating section" elsewhere): each box picks rows, mini table or chips.
|
||||||
|
- **Point pools:** may go negative, shown red. Reuse the result `cost {value, amount}` variable.
|
||||||
|
- **Details:** hover tooltip (short, cut with "…"); click opens an in-app side panel.
|
||||||
|
- **Field types:** number, text, notes, checkbox, dropdown; current/max bars, tick rows, clocks;
|
||||||
|
computed fields, dice buttons; image, heading, divider; dots, step dice, usage dice, ladders;
|
||||||
|
slot inventory with encumbrance; tag/condition chips, aspects, bonds; spell slots, XP, currency.
|
||||||
|
- **Tables ↔ sheets:** tables write and read fields. A field gets an @variable only when
|
||||||
|
"Use in tables" is on. Each field has a lock: locked fields ignore roll writes.
|
||||||
|
Later: a sheet event triggers a table roll (fumble → critical-failure table).
|
||||||
|
- **Templates and one-off sheets.** New sheet = blank canvas or one of your templates.
|
||||||
|
- **Look:** app theme, plus per-box colour and per-sheet tint; frameless boxes.
|
||||||
|
- **Text:** all BBCode, buttons for common tags, live {@var}, links to Lore Entries.
|
||||||
|
- **Lore Index:** opens in Play and Build, in spreads and sheets. Holds sheet entries and whole
|
||||||
|
sheets as items (a rolled sword → a character's inventory). Gains a shared "My library" level
|
||||||
|
beside "This spread". Drop copies; Shift keeps it linked.
|
||||||
|
- **Undo/redo** for values and layout. **Export:** share file, PDF/print, PNG.
|
||||||
|
- **Phone:** Play stacks boxes full width in reading order (top-down, then left-right), with a
|
||||||
|
manual "Phone order" per box; a Canvas switch shows the real layout with pan/zoom.
|
||||||
|
|
||||||
|
## 3. Unified editor (spreads and sheets look alike)
|
||||||
|
- **Card palette** replaces "+ Card ▾": a left dock with tabs **Cards | List**. Cards has a
|
||||||
|
search box at the top, grouped kinds, templates as a group; drag onto the spread (click adds
|
||||||
|
at the view centre). Roll table, Dice table and Deck are separate items (same kind, different
|
||||||
|
start settings). Right-click › New card stays.
|
||||||
|
- **Play mode:** the Cards tab stays, greyed, with "Cards are added in Build mode" and a
|
||||||
|
**Switch to Build** button. This replaces the greyed "+ Card" button.
|
||||||
|
- **Right dock:** Inspector | Lore Index (as today), same tab style as the left dock.
|
||||||
|
- **Top bar:** "Board ▾" is renamed "Spread ▾". Later one shared top bar for spreads and sheets.
|
||||||
|
- **Open documents as tabs** (needed for sheets opened from a spread node).
|
||||||
|
- Sheet editor uses the same palette (with search) for fields.
|
||||||
|
|
||||||
|
## 4. Phases
|
||||||
|
- **A. Card palette** (branch `card-palette`): left dock Cards | List, search, drag/click to
|
||||||
|
add, Play-mode notice, remove "+ Card ▾", rename Board ▾ → Spread ▾. Phone: "+" opens a
|
||||||
|
searchable list.
|
||||||
|
- **B. Sheets core:** data model + storage (sheets and templates), main menu, Sheets list,
|
||||||
|
New sheet dialog, sheet editor (tabs, snap canvas, palette, inspector, Play/Build, undo).
|
||||||
|
- **C. Field types:** basics → trackers → computed and dice → niche kinds.
|
||||||
|
- **D. Spread integration:** sheet node (first-tab preview), variables read/write, locks,
|
||||||
|
replace and migrate `KIND_SHEET`, document tabs.
|
||||||
|
- **E. Lore Index library + items, export (PDF, PNG, share file), phone stacked view.**
|
||||||
|
|
@ -33,7 +33,8 @@ Drag the tray's top edge to make it taller or shorter. Double-click the edge to
|
||||||
|
|
||||||
# Building tables
|
# Building tables
|
||||||
Switch to [b]Build[/b] to edit.
|
Switch to [b]Build[/b] to edit.
|
||||||
- [b]+ Card ▾[/b] adds a new roll table or one of the logic cards.
|
- The [b]Cards[/b] tab on the left lists every kind of card and your templates. Search it, then click a card to add it in the middle of the view, or drag it onto the spread. Press Enter in the search box to add the first match.
|
||||||
|
- No Cards tab? Open it from [b]View ▾ → Card palette[/b].
|
||||||
- Type straight into a card's name and results. [b]+ Add result[/b] adds a row at the bottom.
|
- Type straight into a card's name and results. [b]+ Add result[/b] adds a row at the bottom.
|
||||||
- The [b]×1[/b] beside a result is its weight. A weight of 3 makes that result three times as likely as a weight of 1.
|
- The [b]×1[/b] beside a result is its weight. A weight of 3 makes that result three times as likely as a weight of 1.
|
||||||
- Hover a row to show its [b]×[/b] delete button.
|
- Hover a row to show its [b]×[/b] delete button.
|
||||||
|
|
@ -124,7 +125,7 @@ Deck mode decks ignore the modifier.
|
||||||
[demo]deck[/demo]
|
[demo]deck[/demo]
|
||||||
|
|
||||||
# Choice cards
|
# Choice cards
|
||||||
A choice card stops the roll and asks the player. Add one from [b]+ Card ▾[/b].
|
A choice card stops the roll and asks the player. Add one from the [b]Cards[/b] tab (Ask the player).
|
||||||
- [b]Which option[/b] lists the card's options to pick from. [b]Random[/b] is always offered too. The picked option runs exactly as if it had been rolled: its changes happen and its threads follow.
|
- [b]Which option[/b] lists the card's options to pick from. [b]Random[/b] is always offered too. The picked option runs exactly as if it had been rolled: its changes happen and its threads follow.
|
||||||
- [b]How many[/b] asks for a number between a lowest and highest value.
|
- [b]How many[/b] asks for a number between a lowest and highest value.
|
||||||
- [b]Open ended[/b] asks for any text.
|
- [b]Open ended[/b] asks for any text.
|
||||||
|
|
@ -152,7 +153,7 @@ A spread can remember [b]values[/b] between rolls, such as Luck, Gold or the cur
|
||||||
Conditions are used by Only if threads, branches, repeats, Show only if on options, and [b]Can come up only if[/b] on results (a result whose condition is false is rolled again). In plain words they read "Luck is at least 2". As text: `@luck >= 2`, `@town = "Saltmere"`, `@gold > 0 and @luck < 3`.
|
Conditions are used by Only if threads, branches, repeats, Show only if on options, and [b]Can come up only if[/b] on results (a result whose condition is false is rolled again). In plain words they read "Luck is at least 2". As text: `@luck >= 2`, `@town = "Saltmere"`, `@gold > 0 and @luck < 3`.
|
||||||
|
|
||||||
# Scales
|
# Scales
|
||||||
A [b]Scale[/b] is a value that moves along steps in order, lowest first, such as a Climate that runs [b]Supercold, Cold, Temperate, Hot, Superhot[/b]. Add one with [b]+ Card ▾ → Scale (ordered steps)[/b], then list its steps, one per line, and pick the step it starts at. The card shows the current step, and the row of steps under it shows where that sits.
|
A [b]Scale[/b] is a value that moves along steps in order, lowest first, such as a Climate that runs [b]Supercold, Cold, Temperate, Hot, Superhot[/b]. Add one from the [b]Cards[/b] tab ([b]Values → Scale[/b]), then list its steps, one per line, and pick the step it starts at. The card shows the current step, and the row of steps under it shows where that sits.
|
||||||
- Changes move it a step at a time and stop at the ends, so a result such as [i]Unexpectedly warmer[/i] can say [b]Climate 1 step up[/b]. Other changes: [b]Climate 2 steps down[/b], [b]Set Climate to Hot[/b], [b]Climate 1 step toward Temperate[/b], [b]Atmosphere at least Medium[/b] (raises it if it's lower) and [b]Atmosphere at most Thin[/b] (lowers it if it's higher).
|
- Changes move it a step at a time and stop at the ends, so a result such as [i]Unexpectedly warmer[/i] can say [b]Climate 1 step up[/b]. Other changes: [b]Climate 2 steps down[/b], [b]Set Climate to Hot[/b], [b]Climate 1 step toward Temperate[/b], [b]Atmosphere at least Medium[/b] (raises it if it's lower) and [b]Atmosphere at most Thin[/b] (lowers it if it's higher).
|
||||||
- Conditions compare steps by their order: a thread can go [b]only if Atmosphere is at least Thin[/b], which is true for Thin and every step above it.
|
- Conditions compare steps by their order: a thread can go [b]only if Atmosphere is at least Thin[/b], which is true for Thin and every step above it.
|
||||||
- Text shows the step's name: `{@climate}` reads "Cold".
|
- Text shows the step's name: `{@climate}` reads "Cold".
|
||||||
|
|
@ -164,7 +165,7 @@ A [b]Scale[/b] is a value that moves along steps in order, lowest first, such as
|
||||||
- `@atmo >= "Thin"` is a condition.
|
- `@atmo >= "Thin"` is a condition.
|
||||||
|
|
||||||
# Logic cards
|
# Logic cards
|
||||||
Besides roll tables and choices, [b]+ Card ▾[/b] adds:
|
Besides roll tables and choices, the [b]Cards[/b] tab adds:
|
||||||
- [b]Check card[/b]: rolls dice plus a modifier against a target, such as 2d6 + Skill against 8, and follows its Success or Failure result.
|
- [b]Check card[/b]: rolls dice plus a modifier against a target, such as 2d6 + Skill against 8, and follows its Success or Failure result.
|
||||||
- [b]Repeat[/b]: repeats its Each time result a number of times, or while or until a condition holds, then runs Afterwards once.
|
- [b]Repeat[/b]: repeats its Each time result a number of times, or while or until a condition holds, then runs Afterwards once.
|
||||||
- [b]Branch[/b]: checks its cases from top to bottom (if, else if, otherwise) and follows the first one that's true.
|
- [b]Branch[/b]: checks its cases from top to bottom (if, else if, otherwise) and follows the first one that's true.
|
||||||
|
|
@ -197,7 +198,7 @@ Result text can do more than plain words:
|
||||||
## Templates
|
## Templates
|
||||||
A template is a saved card, group or selection that you can insert again, with blanks to fill in.
|
A template is a saved card, group or selection that you can insert again, with blanks to fill in.
|
||||||
- Save one from a card's ⋯ menu, a group's ⋯ menu, or the selection bar.
|
- Save one from a card's ⋯ menu, a group's ⋯ menu, or the selection bar.
|
||||||
- Insert one from [b]+ Card ▾ → From template…[/b].
|
- Insert one from the [b]Cards[/b] tab ([b]Templates[/b]). [b]All templates…[/b] there also imports, renames and deletes them.
|
||||||
- Built-in templates include a skill check, ask-and-repeat, a pick menu, a counter and a simple sheet.
|
- Built-in templates include a skill check, ask-and-repeat, a pick menu, a counter and a simple sheet.
|
||||||
|
|
||||||
# Menus: right-click and ☰
|
# Menus: right-click and ☰
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ func _test_popup_and_run() -> void:
|
||||||
for c in pm.get_children():
|
for c in pm.get_children():
|
||||||
if c is PopupMenu and sub == null:
|
if c is PopupMenu and sub == null:
|
||||||
sub = c
|
sub = c
|
||||||
_check(sub != null and sub.item_count == MainEditing.ADD_KINDS.size(), "New card ▸ lists every kind")
|
_check(sub != null and sub.item_count == CardCatalog.ITEMS.size(), "New card ▸ lists every kind")
|
||||||
var before := main.data.tables.size()
|
var before := main.data.tables.size()
|
||||||
_check(Actions.press(sub, "Roll table"), "pressing an item runs it")
|
_check(Actions.press(sub, "Roll table"), "pressing an item runs it")
|
||||||
await _frames()
|
await _frames()
|
||||||
|
|
|
||||||
|
|
@ -545,11 +545,10 @@ func _test_other_cards() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _test_add_kinds() -> void:
|
func _test_add_kinds() -> void:
|
||||||
print("+ Card ▾")
|
print("Card kinds")
|
||||||
var labels: Array = main.editing.ADD_KINDS.map(func(k: Array) -> String: return k[0])
|
var labels: Array = CardCatalog.ITEMS.map(func(item: Dictionary) -> String: return item["label"])
|
||||||
_check(labels.any(func(s: String) -> bool: return s.begins_with("Check")), "Check card is in the menu")
|
_check(labels.has("Check"), "Check card is in the catalog")
|
||||||
_check(labels.any(func(s: String) -> bool: return s.begins_with("Ledger")), "Ledger is in the menu")
|
_check(labels.has("Ledger"), "Ledger is in the catalog")
|
||||||
_eq(main.editing._add_menu.text, "+ Card ▾", "the button reads + Card ▾")
|
|
||||||
var c := main.editing.add_table(RollTable.KIND_CHECK)
|
var c := main.editing.add_table(RollTable.KIND_CHECK)
|
||||||
_check(c.kind == RollTable.KIND_CHECK and c.name == "Check" and c.entries.size() == 2, "adding a check card")
|
_check(c.kind == RollTable.KIND_CHECK and c.name == "Check" and c.entries.size() == 2, "adding a check card")
|
||||||
_eq(insp.selection.get("tid"), c.id, "a new card is selected in the inspector")
|
_eq(insp.selection.get("tid"), c.id, "a new card is selected in the inspector")
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func _find(id: String) -> TreeItem:
|
||||||
|
|
||||||
func _test_rows() -> void:
|
func _test_rows() -> void:
|
||||||
var lv := main.list_view
|
var lv := main.list_view
|
||||||
_check(not lv.visible, "the list starts hidden")
|
_check(not lv.shown(), "the list starts hidden")
|
||||||
lv.set_shown(true)
|
lv.set_shown(true)
|
||||||
await _frames(2)
|
await _frames(2)
|
||||||
var rows := _rows(lv.tree.get_root(), [])
|
var rows := _rows(lv.tree.get_root(), [])
|
||||||
|
|
|
||||||
|
|
@ -373,10 +373,14 @@ func _test_settings_rules() -> void:
|
||||||
func _test_add_kinds() -> void:
|
func _test_add_kinds() -> void:
|
||||||
main.set_mode(Main.Mode.BUILD)
|
main.set_mode(Main.Mode.BUILD)
|
||||||
var n := main.data.tables.size()
|
var n := main.data.tables.size()
|
||||||
for k: Array in MainEditing.ADD_KINDS:
|
for item: Dictionary in CardCatalog.ITEMS:
|
||||||
var t := main.editing.add_table(str(k[1]), str(k[2]))
|
var t := main.editing.add_table(str(item["kind"]), str(item["sub"]), Vector2.INF, str(item["variant"]))
|
||||||
_check(t.kind == k[1] and main.card_for(t.id) != null, "+ Table adds a %s" % str(k[0]))
|
_check(t.kind == item["kind"] and main.card_for(t.id) != null and t.name == item["name"], "the palette adds a %s" % str(item["label"]))
|
||||||
_eq(main.data.tables.size(), n + MainEditing.ADD_KINDS.size(), "one card per menu item")
|
if item["variant"] == CardCatalog.VARIANT_DICE:
|
||||||
|
_check(t.is_ranged() and t.entries[0].has_range, "a dice table starts ranged")
|
||||||
|
if item["variant"] == CardCatalog.VARIANT_DECK:
|
||||||
|
_check(t.card_mode, "a deck starts in Deck mode")
|
||||||
|
_eq(main.data.tables.size(), n + CardCatalog.ITEMS.size(), "one card per catalog item")
|
||||||
var v1 := main.editing.add_table(RollTable.KIND_VARIABLE, "number")
|
var v1 := main.editing.add_table(RollTable.KIND_VARIABLE, "number")
|
||||||
var v2 := main.editing.add_table(RollTable.KIND_VARIABLE, "number")
|
var v2 := main.editing.add_table(RollTable.KIND_VARIABLE, "number")
|
||||||
_check(v1.var_name != v2.var_name, "new variable cards get distinct names")
|
_check(v1.var_name != v2.var_name, "new variable cards get distinct names")
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,14 @@ func _test_layout() -> void:
|
||||||
main.mobile = MobileLayout.new(main)
|
main.mobile = MobileLayout.new(main)
|
||||||
main.mobile.apply()
|
main.mobile.apply()
|
||||||
await _frames()
|
await _frames()
|
||||||
_check(main.list_view.visible and not main.board.visible, "the list fills the screen")
|
_check(main.list_view.is_visible_in_tree() and not main.board.visible, "the list fills the screen")
|
||||||
_check(not main.top_bar.view_menu.visible and not main.top_bar.help_menu.visible and not main.tray.side_panel.visible, "the bar and tray slim down")
|
_check(not main.top_bar.view_menu.visible and not main.top_bar.help_menu.visible and not main.tray.side_panel.visible, "the bar and tray slim down")
|
||||||
main.mobile.swap.pressed.emit()
|
main.mobile.swap.pressed.emit()
|
||||||
_check(main.board.visible and not main.list_view.visible and main.mobile.swap.text == "List", "Spread/List swaps to the spread")
|
_check(main.board.visible and not main.list_view.is_visible_in_tree() and main.mobile.swap.text == "List", "Spread/List swaps to the spread")
|
||||||
|
main.mobile.add_button.pressed.emit()
|
||||||
|
_check(main.left_dock.palette.is_visible_in_tree() and not main.board.visible, "+ opens the card palette full screen")
|
||||||
|
main.left_dock.show_tab(LeftDock.LIST)
|
||||||
|
main.mobile.show_list(false)
|
||||||
main.mobile.swap.pressed.emit()
|
main.mobile.swap.pressed.emit()
|
||||||
var texts: Array = Actions.background(main, Vector2.ZERO).map(func(a: Dictionary) -> String: return str(a.get("text", "")))
|
var texts: Array = Actions.background(main, Vector2.ZERO).map(func(a: Dictionary) -> String: return str(a.get("text", "")))
|
||||||
_check(texts.has("Switch to Build") and texts.has("Help…"), "☰ carries Play/Build and Help: %s" % str(texts))
|
_check(texts.has("Switch to Build") and texts.has("Help…"), "☰ carries Play/Build and Help: %s" % str(texts))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
extends AppTestBase
|
extends AppTestBase
|
||||||
## The top bar's menus (View ▾, the zoom control, Board ▾ with Pack, Help ▾),
|
## The top bar's menus (View ▾, the zoom control, Spread ▾ with Pack, Help ▾),
|
||||||
## striped result rows, the Build card's ⋯ menu and the row × that shows on
|
## striped result rows, the Build card's ⋯ menu and the row × that shows on
|
||||||
## hover or selection, and the Help window's topics and links.
|
## hover or selection, and the Help window's topics and links.
|
||||||
## Run: tools/run_tests.sh top_bar
|
## Run: tools/run_tests.sh top_bar
|
||||||
|
|
@ -17,6 +17,7 @@ func run() -> void:
|
||||||
await _test_card_menu()
|
await _test_card_menu()
|
||||||
await _test_help()
|
await _test_help()
|
||||||
await _test_build_hint()
|
await _test_build_hint()
|
||||||
|
await _test_palette()
|
||||||
await _test_welcome()
|
await _test_welcome()
|
||||||
finish()
|
finish()
|
||||||
|
|
||||||
|
|
@ -138,22 +139,29 @@ func _test_help() -> void:
|
||||||
await _frames()
|
await _frames()
|
||||||
|
|
||||||
|
|
||||||
## Play shows that Build mode exists: a greyed "+ Card" that explains and
|
## Play shows that Build mode exists: the card palette is greyed under a
|
||||||
## offers to switch, and a greyed "New card" in the ☰ menu.
|
## notice with Switch to Build, a greyed item explains, and the ☰ menu shows
|
||||||
|
## a greyed "New card".
|
||||||
func _test_build_hint() -> void:
|
func _test_build_hint() -> void:
|
||||||
main.set_mode(Main.Mode.PLAY)
|
main.set_mode(Main.Mode.PLAY)
|
||||||
var bar := main.top_bar
|
var bar := main.top_bar
|
||||||
_check(bar.play_add_button.visible and not bar._build_tools.visible, "Play shows the greyed + Card, not the Build tools")
|
var palette := main.left_dock.palette
|
||||||
|
main.left_dock.show_tab(LeftDock.CARDS)
|
||||||
|
await _frames()
|
||||||
|
_check(palette.notice.visible and not bar._build_tools.visible, "Play shows the palette notice, not the Build tools")
|
||||||
var names := Actions.background(main, Vector2.ZERO).map(func(a: Dictionary) -> String: return str(a.get("text", "")))
|
var names := Actions.background(main, Vector2.ZERO).map(func(a: Dictionary) -> String: return str(a.get("text", "")))
|
||||||
var item: Dictionary = Actions.background(main, Vector2.ZERO)[names.find("New card")] if names.has("New card") else {}
|
var item: Dictionary = Actions.background(main, Vector2.ZERO)[names.find("New card")] if names.has("New card") else {}
|
||||||
_check(item.get("disabled", false), "the ☰ menu shows New card greyed in Play")
|
_check(item.get("disabled", false), "the ☰ menu shows New card greyed in Play")
|
||||||
bar.play_add_button.pressed.emit()
|
var before := main.data.tables.size()
|
||||||
|
(palette.find_child("Roll table", true, false) as Button).pressed.emit()
|
||||||
|
_eq(main.data.tables.size(), before, "a greyed palette item adds nothing in Play")
|
||||||
_eq(bar._toast_label.text, BuildModeHint.MESSAGE, "clicking it explains Build mode")
|
_eq(bar._toast_label.text, BuildModeHint.MESSAGE, "clicking it explains Build mode")
|
||||||
_check(bar._toast_undo.visible and bar._toast_undo.text == "Switch to Build", "the toast offers Switch to Build")
|
_check(bar._toast_undo.visible and bar._toast_undo.text == "Switch to Build", "the toast offers Switch to Build")
|
||||||
bar._toast_undo.pressed.emit()
|
bar._toast_undo.pressed.emit()
|
||||||
await _frames()
|
await _frames()
|
||||||
_eq(main.mode, Main.Mode.BUILD, "Switch to Build switches")
|
_eq(main.mode, Main.Mode.BUILD, "Switch to Build switches")
|
||||||
_check(not bar.play_add_button.visible, "Build hides the greyed button")
|
await _frames()
|
||||||
|
_check(not palette.notice.visible, "Build hides the palette notice")
|
||||||
main.toast("Saved")
|
main.toast("Saved")
|
||||||
_eq(bar._toast_undo.text, "Undo", "a later toast's button is Undo again")
|
_eq(bar._toast_undo.text, "Undo", "a later toast's button is Undo again")
|
||||||
|
|
||||||
|
|
@ -171,3 +179,52 @@ func _test_welcome() -> void:
|
||||||
(dialog.footer.get_child(2) as Button).pressed.emit()
|
(dialog.footer.get_child(2) as Button).pressed.emit()
|
||||||
await _frames(20)
|
await _frames(20)
|
||||||
_check(not is_instance_valid(dialog) or dialog.is_queued_for_deletion(), "Explore the demo closes it")
|
_check(not is_instance_valid(dialog) or dialog.is_queued_for_deletion(), "Explore the demo closes it")
|
||||||
|
|
||||||
|
|
||||||
|
## The card palette: search narrows it, a click adds in the middle of the
|
||||||
|
## view, a drop on the spread adds there, Enter adds the first match.
|
||||||
|
func _test_palette() -> void:
|
||||||
|
main.set_mode(Main.Mode.BUILD)
|
||||||
|
var palette := main.left_dock.palette
|
||||||
|
main.left_dock.show_tab(LeftDock.CARDS)
|
||||||
|
palette.search.text = "dice"
|
||||||
|
palette.search.text_changed.emit("dice")
|
||||||
|
_check(palette.find_child("Dice table", true, false) != null and palette.find_child("Branch", true, false) == null, "search narrows the palette")
|
||||||
|
palette.search.text = "zzqx"
|
||||||
|
palette.search.text_changed.emit("zzqx")
|
||||||
|
_check(palette.find_child("Dice table", true, false) == null, "a search with no match empties it")
|
||||||
|
palette.search.text = ""
|
||||||
|
palette.search.text_changed.emit("")
|
||||||
|
var before := main.data.tables.size()
|
||||||
|
(palette.find_child("Deck", true, false) as Button).pressed.emit()
|
||||||
|
var deck := main.data.tables[main.data.tables.size() - 1]
|
||||||
|
_check(main.data.tables.size() == before + 1 and deck.card_mode, "clicking Deck adds a deck")
|
||||||
|
var spot := main.board.global_position + main.board.size / 2.0 + Vector2(40, 30)
|
||||||
|
var item: Dictionary = CardCatalog.find(RollTable.KIND_CHECK)
|
||||||
|
_check(palette.drop_at(palette._add_card.bind(item), spot), "a drop on the spread is taken")
|
||||||
|
var check := main.data.tables[main.data.tables.size() - 1]
|
||||||
|
var want := (main.board.screen_to_world(spot - main.board.global_position) - Vector2(128, 20)).round()
|
||||||
|
_check(check.kind == RollTable.KIND_CHECK and check.position == want, "the dropped card sits where it was let go")
|
||||||
|
_check(not palette.drop_at(palette._add_card.bind(item), Vector2(-50, -50)), "a drop off the spread adds nothing")
|
||||||
|
var button := main.top_bar.palette_button
|
||||||
|
_check(button.is_visible_in_tree() and button.button_pressed, "Build shows a lit Card palette button")
|
||||||
|
button.pressed.emit()
|
||||||
|
_check(not main.left_dock.visible and not button.button_pressed, "the button closes the palette")
|
||||||
|
button.pressed.emit()
|
||||||
|
_check(main.left_dock.showing(LeftDock.CARDS) and button.button_pressed, "and opens it again")
|
||||||
|
var tpl_id := str(main.templating.templates().list()[0]["id"])
|
||||||
|
var spot2 := spot + Vector2(-200, 60)
|
||||||
|
var at2 := (main.board.screen_to_world(spot2 - main.board.global_position) - Vector2(128, 20)).round()
|
||||||
|
var tpl := main.templating.templates().get_template(tpl_id)
|
||||||
|
var made: Dictionary = main.templating.insert_template(tpl, {}, at2)
|
||||||
|
var top_left := Vector2(INF, INF)
|
||||||
|
for t: RollTable in made["tables"]:
|
||||||
|
top_left = Vector2(minf(top_left.x, t.position.x), minf(top_left.y, t.position.y))
|
||||||
|
for g: TableGroup in made.get("groups", []):
|
||||||
|
top_left = Vector2(minf(top_left.x, g.position.x), minf(top_left.y, g.position.y))
|
||||||
|
_eq(top_left, at2, "a template dropped on the spread lands where it was let go")
|
||||||
|
palette.search.text = "branch"
|
||||||
|
palette.search.text_submitted.emit("branch")
|
||||||
|
_eq(main.data.tables[main.data.tables.size() - 1].kind, RollTable.KIND_ROUTER, "Enter adds the first match")
|
||||||
|
palette.search.text = ""
|
||||||
|
palette.search.text_changed.emit("")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
extends AppTestBase
|
extends AppTestBase
|
||||||
## Scale values in the UI (Scales): making one (+ Card, the inspector's steps
|
## Scale values in the UI (Scales): making one (the card palette, the inspector's steps
|
||||||
## and starting step, switching type), showing one (the card's value and row
|
## and starting step, switching type), showing one (the card's value and row
|
||||||
## of steps, the Variables tab), the effect and condition rows for a scale,
|
## of steps, the Variables tab), the effect and condition rows for a scale,
|
||||||
## and the help topic.
|
## and the help topic.
|
||||||
|
|
@ -51,9 +51,9 @@ func _t(id: String) -> RollTable:
|
||||||
|
|
||||||
func _test_add_card() -> void:
|
func _test_add_card() -> void:
|
||||||
var found := false
|
var found := false
|
||||||
for k: Array in MainEditing.ADD_KINDS:
|
for item: Dictionary in CardCatalog.ITEMS:
|
||||||
found = found or (k[1] == RollTable.KIND_VARIABLE and k[2] == RollTable.VAR_SCALE and str(k[0]).begins_with("Scale"))
|
found = found or (item["kind"] == RollTable.KIND_VARIABLE and item["sub"] == RollTable.VAR_SCALE and item["label"] == "Scale")
|
||||||
_check(found, "+ Card lists Scale (ordered steps)")
|
_check(found, "the card catalog lists Scale")
|
||||||
var t := main.editing.add_table(RollTable.KIND_VARIABLE, RollTable.VAR_SCALE)
|
var t := main.editing.add_table(RollTable.KIND_VARIABLE, RollTable.VAR_SCALE)
|
||||||
_check(t.is_scale() and t.steps == (["Low", "Medium", "High"] as Array[String]) and t.initial == "Low", "a new scale has Low, Medium, High and starts Low")
|
_check(t.is_scale() and t.steps == (["Low", "Medium", "High"] as Array[String]) and t.initial == "Low", "a new scale has Low, Medium, High and starts Low")
|
||||||
main.data.remove_table(t.id)
|
main.data.remove_table(t.id)
|
||||||
|
|
|
||||||
|
|
@ -167,14 +167,16 @@ static func background(m: Main, at: Vector2) -> Array:
|
||||||
var list: Array = []
|
var list: Array = []
|
||||||
if m.mode == Main.Mode.BUILD:
|
if m.mode == Main.Mode.BUILD:
|
||||||
var kinds: Array = []
|
var kinds: Array = []
|
||||||
for i in MainEditing.ADD_KINDS.size():
|
for item: Dictionary in CardCatalog.ITEMS:
|
||||||
var k: Array = MainEditing.ADD_KINDS[i]
|
kinds.append({"text": str(item["label"]), "tip": str(item["tip"]),
|
||||||
kinds.append({"text": str(k[0]), "do": func() -> void: m.editing.add_table(str(k[1]), str(k[2]), at)})
|
"do": func() -> void: m.editing.add_table(str(item["kind"]), str(item["sub"]), at, str(item["variant"]))})
|
||||||
list.append({"text": "New card", "sub": kinds})
|
list.append({"text": "New card", "sub": kinds})
|
||||||
list.append({"text": "New card from template…", "do": m.templating.open_template_picker})
|
list.append({"text": "New card from template…", "do": m.templating.open_template_picker})
|
||||||
var picked := m.selection.size()
|
var picked := m.selection.size()
|
||||||
list.append({"text": "Group the selection Ctrl+G", "do": m.grouping.group_selection, "disabled": picked == 0 and m.selecting.groups.is_empty(),
|
list.append({"text": "Group the selection Ctrl+G", "do": m.grouping.group_selection, "disabled": picked == 0 and m.selecting.groups.is_empty(),
|
||||||
"tip": "Select cards first: drag a box around them"})
|
"tip": "Select cards first: drag a box around them"})
|
||||||
|
list.append({"text": "Save selection as template…", "do": m.templating.save_selection_as_template, "disabled": picked == 0,
|
||||||
|
"tip": "Select cards first: drag a box around them"})
|
||||||
list.append({"sep": ""})
|
list.append({"sep": ""})
|
||||||
else:
|
else:
|
||||||
list.append(BuildModeHint.menu_item())
|
list.append(BuildModeHint.menu_item())
|
||||||
|
|
@ -183,7 +185,9 @@ static func background(m: Main, at: Vector2) -> Array:
|
||||||
list.append({"text": "Shuffle all decks", "do": m.local_state.reshuffle_all, "disabled": not has_decks(m),
|
list.append({"text": "Shuffle all decks", "do": m.local_state.reshuffle_all, "disabled": not has_decks(m),
|
||||||
"tip": "Put every Deck-mode card's results back"})
|
"tip": "Put every Deck-mode card's results back"})
|
||||||
list.append({"text": "Fit spread", "do": m.board.fit})
|
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,
|
list.append({"text": "Hide the card palette" if m.left_dock.showing(LeftDock.CARDS) else "Card palette", "do": m.left_dock.toggle_tab.bind(LeftDock.CARDS),
|
||||||
|
"tip": "Every kind of card and your templates, to click or drag onto the spread"})
|
||||||
|
list.append({"text": "Hide the list" if m.list_view.shown() else "List view", "do": m.list_view.toggle,
|
||||||
"tip": "The cards as a list with their groups"})
|
"tip": "The cards as a list with their groups"})
|
||||||
list.append({"text": "Close the Lore Index" if m.book.visible else "Lore Index", "do": m.book.toggle,
|
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"})
|
"tip": "Reusable results (Lore Entries) to drag onto tables"})
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,15 @@
|
||||||
class_name BuildModeHint
|
class_name BuildModeHint
|
||||||
extends RefCounted
|
extends RefCounted
|
||||||
## Play mode tells new players that Build mode exists: a greyed "+ Card"
|
## Play mode tells new players that Build mode exists: the card palette is
|
||||||
## button in the top bar and a greyed "New card" in the ☰ menu. Clicking the
|
## greyed under a notice with "Switch to Build" (CardPalette), and the ☰ menu
|
||||||
## button explains, offers "Switch to Build" and makes the Build switch pulse.
|
## has a greyed "New card". Clicking a greyed palette item explains, offers
|
||||||
|
## "Switch to Build" and makes the Build switch pulse.
|
||||||
|
|
||||||
const MESSAGE := "Cards are added and edited in Build mode."
|
const MESSAGE := "Cards are added and edited in Build mode."
|
||||||
|
const PALETTE_MESSAGE := "Cards are added in Build mode."
|
||||||
const TIP := "Switch to Build mode (top left) to add and edit cards"
|
const TIP := "Switch to Build mode (top left) to add and edit cards"
|
||||||
|
|
||||||
|
|
||||||
## The greyed "+ Card" shown in Play in place of the real one.
|
|
||||||
static func make_button(m: Main) -> Button:
|
|
||||||
var b := Style.bar_button("+ Card")
|
|
||||||
b.modulate.a = 0.5
|
|
||||||
b.tooltip_text = TIP
|
|
||||||
b.focus_mode = Control.FOCUS_NONE
|
|
||||||
b.pressed.connect(func() -> void: explain(m))
|
|
||||||
return b
|
|
||||||
|
|
||||||
|
|
||||||
## The ☰ menu's greyed "New card" in Play (Actions.background).
|
## The ☰ menu's greyed "New card" in Play (Actions.background).
|
||||||
static func menu_item() -> Dictionary:
|
static func menu_item() -> Dictionary:
|
||||||
return {"text": "New card", "disabled": true, "tip": TIP}
|
return {"text": "New card", "disabled": true, "tip": TIP}
|
||||||
|
|
|
||||||
96
ui/card_catalog.gd
Normal file
96
ui/card_catalog.gd
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
class_name CardCatalog
|
||||||
|
extends RefCounted
|
||||||
|
## Every kind of card you can add, in one list: the card palette (CardPalette),
|
||||||
|
## right-click › New card (Actions.background) and the new card's starting name
|
||||||
|
## (MainEditing.add_table) all read it.
|
||||||
|
## `variant` gives the same kind different start settings: "dice" makes a
|
||||||
|
## ranged dice table, "deck" turns on Deck mode.
|
||||||
|
|
||||||
|
const GROUP_TABLES := "Tables"
|
||||||
|
const GROUP_ASK := "Ask the player"
|
||||||
|
const GROUP_LOGIC := "Logic"
|
||||||
|
const GROUP_VALUES := "Values"
|
||||||
|
const GROUP_SHEETS := "Sheets"
|
||||||
|
const GROUP_TEMPLATES := "Templates"
|
||||||
|
const GROUP_OTHER := "Other"
|
||||||
|
|
||||||
|
const VARIANT_DICE := "dice"
|
||||||
|
const VARIANT_DECK := "deck"
|
||||||
|
|
||||||
|
## Each item: label, group, kind, sub, variant, the new card's name, a tip and
|
||||||
|
## extra search words.
|
||||||
|
const ITEMS := [
|
||||||
|
{"label": "Roll table", "group": GROUP_TABLES, "kind": RollTable.KIND_ROLL, "sub": "", "variant": "",
|
||||||
|
"name": "New table", "tip": "Pick a result at random, by weight", "words": "random weight results"},
|
||||||
|
{"label": "Dice table", "group": GROUP_TABLES, "kind": RollTable.KIND_ROLL, "sub": "", "variant": VARIANT_DICE,
|
||||||
|
"name": "New dice table", "tip": "Results on number ranges, rolled with dice (1d100)", "words": "ranged d100 d20 d6 range"},
|
||||||
|
{"label": "Deck", "group": GROUP_TABLES, "kind": RollTable.KIND_ROLL, "sub": "", "variant": VARIANT_DECK,
|
||||||
|
"name": "New deck", "tip": "Draw results like cards: each comes up once until you shuffle", "words": "draw shuffle cards no repeats"},
|
||||||
|
{"label": "Check", "group": GROUP_TABLES, "kind": RollTable.KIND_CHECK, "sub": "", "variant": "",
|
||||||
|
"name": "Check", "tip": "Roll against a target: success or failure", "words": "target skill test success failure"},
|
||||||
|
{"label": "Which option", "group": GROUP_ASK, "kind": RollTable.KIND_CHOICE, "sub": "pick", "variant": "",
|
||||||
|
"name": "New choice", "tip": "The player picks one of a few options", "words": "choice pick question"},
|
||||||
|
{"label": "How many", "group": GROUP_ASK, "kind": RollTable.KIND_CHOICE, "sub": "number", "variant": "",
|
||||||
|
"name": "How many?", "tip": "The player types a number", "words": "choice number question count"},
|
||||||
|
{"label": "Open answer", "group": GROUP_ASK, "kind": RollTable.KIND_CHOICE, "sub": "text", "variant": "",
|
||||||
|
"name": "What is it?", "tip": "The player types any answer, like a name", "words": "choice text question name"},
|
||||||
|
{"label": "Branch", "group": GROUP_LOGIC, "kind": RollTable.KIND_ROUTER, "sub": "", "variant": "",
|
||||||
|
"name": "Branch", "tip": "If / else if / otherwise: go one way or another", "words": "if else condition router"},
|
||||||
|
{"label": "Repeat", "group": GROUP_LOGIC, "kind": RollTable.KIND_LOOP, "sub": "times", "variant": "",
|
||||||
|
"name": "Repeat", "tip": "Do the next cards several times", "words": "loop times while"},
|
||||||
|
{"label": "Variable", "group": GROUP_VALUES, "kind": RollTable.KIND_VARIABLE, "sub": "number", "variant": "",
|
||||||
|
"name": "New variable", "tip": "A value that rolls can read and change, like @gold", "words": "value number text @"},
|
||||||
|
{"label": "Ledger", "group": GROUP_VALUES, "kind": RollTable.KIND_VARIABLE, "sub": RollTable.VAR_COLLECTION, "variant": "",
|
||||||
|
"name": "Skills", "tip": "A named list of values: skills, contacts…", "words": "collection list skills contacts"},
|
||||||
|
{"label": "Scale", "group": GROUP_VALUES, "kind": RollTable.KIND_VARIABLE, "sub": RollTable.VAR_SCALE, "variant": "",
|
||||||
|
"name": "New scale", "tip": "Ordered steps that move up or down", "words": "steps ladder ordered"},
|
||||||
|
{"label": "Sheet", "group": GROUP_SHEETS, "kind": RollTable.KIND_SHEET, "sub": "", "variant": "",
|
||||||
|
"name": "Sheet", "tip": "Shows values as formatted text that stays up to date", "words": "character summary text"},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
## The item for a kind, sub and variant: an exact match first, then the first
|
||||||
|
## item of that kind (a choice card also needs its sub to match). {} if none.
|
||||||
|
static func find(kind: String, sub: String = "", variant: String = "") -> Dictionary:
|
||||||
|
for item: Dictionary in ITEMS:
|
||||||
|
if item["kind"] == kind and item["sub"] == sub and item["variant"] == variant:
|
||||||
|
return item
|
||||||
|
for item: Dictionary in ITEMS:
|
||||||
|
if item["kind"] != kind or item["variant"] != variant:
|
||||||
|
continue
|
||||||
|
if kind == RollTable.KIND_CHOICE and sub != "":
|
||||||
|
continue
|
||||||
|
if item["sub"] == RollTable.VAR_COLLECTION:
|
||||||
|
continue
|
||||||
|
return item
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
## The group names in palette order (the templates group sits before Other).
|
||||||
|
static func groups() -> Array[String]:
|
||||||
|
var out: Array[String] = []
|
||||||
|
for item: Dictionary in ITEMS:
|
||||||
|
if not out.has(item["group"]):
|
||||||
|
out.append(item["group"])
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
## True when `query` (lower case, may be "") matches the item's label, tip,
|
||||||
|
## group or search words.
|
||||||
|
static func matches(item: Dictionary, query: String) -> bool:
|
||||||
|
if query == "":
|
||||||
|
return true
|
||||||
|
var hay := " ".join([item.get("label", ""), item.get("tip", ""), item.get("group", ""), item.get("words", "")]).to_lower()
|
||||||
|
for word in query.split(" ", false):
|
||||||
|
if not hay.contains(word):
|
||||||
|
return false
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
## Gives a new card its variant's start settings.
|
||||||
|
static func apply_variant(t: RollTable, variant: String) -> void:
|
||||||
|
match variant:
|
||||||
|
VARIANT_DICE:
|
||||||
|
TableSettingsRules.assign_ranges(t)
|
||||||
|
VARIANT_DECK:
|
||||||
|
t.card_mode = true
|
||||||
1
ui/card_catalog.gd.uid
Normal file
1
ui/card_catalog.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://b5xhhmmdaceqg
|
||||||
203
ui/card_palette.gd
Normal file
203
ui/card_palette.gd
Normal file
|
|
@ -0,0 +1,203 @@
|
||||||
|
class_name CardPalette
|
||||||
|
extends VBoxContainer
|
||||||
|
## The Cards tab of the left dock: every kind of card (CardCatalog) and your
|
||||||
|
## templates, in groups, with a search box at the top. Click an item to add it
|
||||||
|
## in the middle of the view; drag it to place it on the spread.
|
||||||
|
## In Play the items are greyed under a notice with "Switch to Build"
|
||||||
|
## (BuildModeHint), so players learn where cards are added.
|
||||||
|
|
||||||
|
## Palette-only items that aren't card kinds.
|
||||||
|
const GROUP_ITEM := {"label": "Empty group", "group": CardCatalog.GROUP_OTHER,
|
||||||
|
"tip": "A new, empty group. Drag cards onto it.", "words": "group frame folder"}
|
||||||
|
const ALL_TEMPLATES := {"label": "All templates…", "group": CardCatalog.GROUP_TEMPLATES,
|
||||||
|
"tip": "Search, import, rename and delete templates", "words": "import manage"}
|
||||||
|
|
||||||
|
var m: Main
|
||||||
|
var search: LineEdit
|
||||||
|
var notice: PanelContainer
|
||||||
|
var _items: VBoxContainer
|
||||||
|
var _templates: Array[Dictionary] = []
|
||||||
|
var _dragging: Dictionary = {}
|
||||||
|
var _mode := -1
|
||||||
|
|
||||||
|
|
||||||
|
func setup(p_main: Main) -> void:
|
||||||
|
m = p_main
|
||||||
|
add_theme_constant_override("separation", 8)
|
||||||
|
notice = _make_notice()
|
||||||
|
add_child(notice)
|
||||||
|
search = LineEdit.new()
|
||||||
|
search.placeholder_text = "Search cards and templates"
|
||||||
|
search.clear_button_enabled = true
|
||||||
|
ModalCard.style_line_edit(search)
|
||||||
|
search.text_changed.connect(func(_s: String) -> void: rebuild())
|
||||||
|
search.text_submitted.connect(func(_s: String) -> void: _add_first())
|
||||||
|
add_child(search)
|
||||||
|
var scroll := ScrollContainer.new()
|
||||||
|
scroll.size_flags_vertical = SIZE_EXPAND_FILL
|
||||||
|
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||||
|
add_child(scroll)
|
||||||
|
_items = VBoxContainer.new()
|
||||||
|
_items.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||||
|
_items.add_theme_constant_override("separation", 4)
|
||||||
|
scroll.add_child(_items)
|
||||||
|
var hint := Style.make_label("Click to add in the middle of the view, or drag onto the spread.", Style.body(), 12, Style.ON_BG_MUTED)
|
||||||
|
hint.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||||
|
add_child(hint)
|
||||||
|
rebuild()
|
||||||
|
|
||||||
|
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
|
if int(m.mode) != _mode:
|
||||||
|
_mode = int(m.mode)
|
||||||
|
var play := m.mode != Main.Mode.BUILD
|
||||||
|
notice.visible = play
|
||||||
|
_items.modulate.a = 0.45 if play else 1.0
|
||||||
|
|
||||||
|
|
||||||
|
func _make_notice() -> PanelContainer:
|
||||||
|
var box := PanelContainer.new()
|
||||||
|
box.add_theme_stylebox_override("panel", Style.bordered(Style.box(Style.CARD, 8, [10, 8, 10, 8]), 2, Style.TRIM))
|
||||||
|
var col := VBoxContainer.new()
|
||||||
|
col.add_theme_constant_override("separation", 6)
|
||||||
|
box.add_child(col)
|
||||||
|
var text := Style.make_label(BuildModeHint.PALETTE_MESSAGE, Style.body_bold(), 14, Style.INK)
|
||||||
|
text.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||||
|
col.add_child(text)
|
||||||
|
var go := ModalCard.make_button("Switch to Build", "primary")
|
||||||
|
go.name = "SwitchToBuild"
|
||||||
|
go.pressed.connect(func() -> void: m.set_mode(Main.Mode.BUILD))
|
||||||
|
col.add_child(go)
|
||||||
|
return box
|
||||||
|
|
||||||
|
|
||||||
|
## Reads the template list again (it lives in files, so not on every keystroke).
|
||||||
|
func refresh_templates() -> void:
|
||||||
|
_templates = m.templating.templates().list() if m.templating else []
|
||||||
|
rebuild()
|
||||||
|
|
||||||
|
|
||||||
|
## Rebuilds the item list from the catalog, filtered by the search text.
|
||||||
|
func rebuild() -> void:
|
||||||
|
for c in _items.get_children():
|
||||||
|
_items.remove_child(c)
|
||||||
|
c.queue_free()
|
||||||
|
var query := search.text.strip_edges().to_lower()
|
||||||
|
var any := false
|
||||||
|
for group in CardCatalog.groups():
|
||||||
|
var shown: Array = CardCatalog.ITEMS.filter(func(item: Dictionary) -> bool:
|
||||||
|
return item["group"] == group and CardCatalog.matches(item, query))
|
||||||
|
any = _add_group(group, shown.map(func(item: Dictionary) -> Array: return [item, _add_card.bind(item)])) or any
|
||||||
|
var templates: Array = []
|
||||||
|
for row: Dictionary in _templates:
|
||||||
|
var item := {"label": row["name"], "group": CardCatalog.GROUP_TEMPLATES, "tip": row.get("description", ""), "words": "template"}
|
||||||
|
if CardCatalog.matches(item, query):
|
||||||
|
templates.append([item, _add_template.bind(str(row["id"]))])
|
||||||
|
if CardCatalog.matches(ALL_TEMPLATES, query):
|
||||||
|
templates.append([ALL_TEMPLATES, func(_at: Vector2) -> void: m.templating.open_template_picker()])
|
||||||
|
any = _add_group(CardCatalog.GROUP_TEMPLATES, templates) or any
|
||||||
|
if CardCatalog.matches(GROUP_ITEM, query):
|
||||||
|
any = _add_group(CardCatalog.GROUP_OTHER, [[GROUP_ITEM, _add_group_card]]) or any
|
||||||
|
if not any:
|
||||||
|
var none := Style.make_label("Nothing matches “%s”." % search.text.strip_edges(), Style.body(), 14, Style.ON_BG_MUTED)
|
||||||
|
none.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||||
|
_items.add_child(none)
|
||||||
|
|
||||||
|
|
||||||
|
## A group heading and its items in two columns. `entries` holds
|
||||||
|
## [item, on_add(at)] pairs; at = Vector2.INF means the middle of the view.
|
||||||
|
func _add_group(title: String, entries: Array) -> bool:
|
||||||
|
if entries.is_empty():
|
||||||
|
return false
|
||||||
|
_items.add_child(Style.make_label(title.to_upper(), Style.caps(), 11, Style.ON_BG_MUTED))
|
||||||
|
var grid := GridContainer.new()
|
||||||
|
grid.columns = 2
|
||||||
|
grid.add_theme_constant_override("h_separation", 4)
|
||||||
|
grid.add_theme_constant_override("v_separation", 4)
|
||||||
|
_items.add_child(grid)
|
||||||
|
for entry: Array in entries:
|
||||||
|
grid.add_child(_item_button(entry[0], entry[1]))
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
func _item_button(item: Dictionary, on_add: Callable) -> Button:
|
||||||
|
var b := Style.bar_button(str(item["label"]))
|
||||||
|
b.name = str(item["label"]).validate_node_name()
|
||||||
|
b.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||||
|
b.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||||
|
b.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||||
|
b.clip_text = true
|
||||||
|
b.custom_minimum_size.x = 60
|
||||||
|
b.tooltip_text = str(item.get("tip", ""))
|
||||||
|
b.focus_mode = Control.FOCUS_NONE
|
||||||
|
b.pressed.connect(func() -> void: _use(on_add, Vector2.INF))
|
||||||
|
b.set_drag_forwarding(func(_at: Vector2) -> Variant: return _start_drag(item, on_add), Callable(), Callable())
|
||||||
|
return b
|
||||||
|
|
||||||
|
|
||||||
|
## Adds the item, or explains Build mode in Play.
|
||||||
|
func _use(on_add: Callable, at: Vector2) -> void:
|
||||||
|
if m.mode != Main.Mode.BUILD:
|
||||||
|
BuildModeHint.explain(m)
|
||||||
|
return
|
||||||
|
on_add.call(at)
|
||||||
|
if m.mobile:
|
||||||
|
m.mobile.show_list(false)
|
||||||
|
|
||||||
|
|
||||||
|
## Enter in the search box adds the first card that matches.
|
||||||
|
func _add_first() -> void:
|
||||||
|
var query := search.text.strip_edges().to_lower()
|
||||||
|
for item: Dictionary in CardCatalog.ITEMS:
|
||||||
|
if CardCatalog.matches(item, query):
|
||||||
|
_use(_add_card.bind(item), Vector2.INF)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
func _start_drag(item: Dictionary, on_add: Callable) -> Variant:
|
||||||
|
if m.mode != Main.Mode.BUILD:
|
||||||
|
return null
|
||||||
|
_dragging = {"on_add": on_add}
|
||||||
|
var label := Style.make_label(str(item["label"]), Style.body_bold(), 15, Style.INK)
|
||||||
|
var chip := PanelContainer.new()
|
||||||
|
chip.add_theme_stylebox_override("panel", Style.box(Style.LIT, 6, [8, 4, 8, 4]))
|
||||||
|
chip.add_child(label)
|
||||||
|
set_drag_preview(chip)
|
||||||
|
return {"palette_item": item["label"]}
|
||||||
|
|
||||||
|
|
||||||
|
## Nothing took the drop, so the palette places the card where it was let go
|
||||||
|
## (only on the spread; let go anywhere else and nothing is added).
|
||||||
|
func _notification(what: int) -> void:
|
||||||
|
if what == NOTIFICATION_DRAG_END and not _dragging.is_empty():
|
||||||
|
var on_add: Callable = _dragging["on_add"]
|
||||||
|
_dragging = {}
|
||||||
|
if get_viewport().gui_is_drag_successful():
|
||||||
|
return
|
||||||
|
drop_at(on_add, get_global_mouse_position())
|
||||||
|
|
||||||
|
|
||||||
|
## Adds through `on_add` with its top-left corner under a screen point on the spread.
|
||||||
|
func drop_at(on_add: Callable, screen_point: Vector2) -> bool:
|
||||||
|
var board := m.board
|
||||||
|
if not board.is_visible_in_tree() or not board.get_global_rect().has_point(screen_point):
|
||||||
|
return false
|
||||||
|
var world := board.screen_to_world(screen_point - board.global_position)
|
||||||
|
_use(on_add, (world - Vector2(128, 20)).round())
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
func _add_card(at: Vector2, item: Dictionary) -> void:
|
||||||
|
m.editing.add_table(str(item["kind"]), str(item["sub"]), at, str(item["variant"]))
|
||||||
|
|
||||||
|
|
||||||
|
func _add_template(at: Vector2, id: String) -> void:
|
||||||
|
var tpl := m.templating.templates().get_template(id)
|
||||||
|
if tpl.is_empty():
|
||||||
|
m.toast("Couldn't read that template")
|
||||||
|
return
|
||||||
|
m.templating.begin_template_insert(tpl, at)
|
||||||
|
|
||||||
|
|
||||||
|
func _add_group_card(at: Vector2) -> void:
|
||||||
|
m.list_view.new_group(at)
|
||||||
1
ui/card_palette.gd.uid
Normal file
1
ui/card_palette.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://d3kx4jf3q4ukx
|
||||||
|
|
@ -60,7 +60,7 @@ static func _options(insp: Inspector, card: RollTable, plain: bool, err: Label)
|
||||||
else:
|
else:
|
||||||
var first := _first_source(main.data)
|
var first := _first_source(main.data)
|
||||||
if first == "":
|
if first == "":
|
||||||
InspectorKit.show_error(err, "Add a ledger (+ Card ▾ → Ledger) or a list value first, then pick it here.")
|
InspectorKit.show_error(err, "Add a ledger (Cards tab → Values → Ledger) or a list value first, then pick it here.")
|
||||||
return
|
return
|
||||||
InspectorKit.show_error(err, set_options(insp, first, ""))
|
InspectorKit.show_error(err, set_options(insp, first, ""))
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class_name IoMenu
|
class_name IoMenu
|
||||||
extends MenuButton
|
extends MenuButton
|
||||||
## The Build-mode "Board ▾" menu (test, reset, arrange, import, export) plus the import and
|
## The Build-mode "Spread ▾" menu (test, reset, arrange, import, export) plus the import and
|
||||||
## export logic as static functions, so it can be tested without a window.
|
## export logic as static functions, so it can be tested without a window.
|
||||||
|
|
||||||
const ID_RESET := 1
|
const ID_RESET := 1
|
||||||
|
|
|
||||||
108
ui/left_dock.gd
Normal file
108
ui/left_dock.gd
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
class_name LeftDock
|
||||||
|
extends PanelContainer
|
||||||
|
## The left-hand dock with two tabs, "Cards | List" (the same tab style as the
|
||||||
|
## right dock's "Inspector | Lore Index", SideTabs.tab_row). Cards is the card
|
||||||
|
## palette (CardPalette); List is List view (ListView). On phones the dock
|
||||||
|
## fills the screen and swaps with the spread (MobileLayout).
|
||||||
|
## The local setting `left_dock` keeps the open tab ("" = closed).
|
||||||
|
|
||||||
|
const WIDTH := 320.0
|
||||||
|
const MIN_WIDTH := 220.0
|
||||||
|
const SETTING := "left_dock"
|
||||||
|
const CARDS := "cards"
|
||||||
|
const LIST := "list"
|
||||||
|
|
||||||
|
var m: Main
|
||||||
|
var splitter: PanelSplitter
|
||||||
|
var palette: CardPalette
|
||||||
|
var list: ListView
|
||||||
|
var close_button: Button
|
||||||
|
var tab := CARDS
|
||||||
|
var _tabs: HBoxContainer
|
||||||
|
|
||||||
|
|
||||||
|
func setup(p_main: Main) -> void:
|
||||||
|
m = p_main
|
||||||
|
add_theme_stylebox_override("panel", Style.panel_box([10, 10, 10, 10]))
|
||||||
|
var col := VBoxContainer.new()
|
||||||
|
col.add_theme_constant_override("separation", 8)
|
||||||
|
add_child(col)
|
||||||
|
var head := HBoxContainer.new()
|
||||||
|
head.add_theme_constant_override("separation", 6)
|
||||||
|
col.add_child(head)
|
||||||
|
_tabs = SideTabs.tab_row([[CARDS, "Cards"], [LIST, "List"]], tab, show_tab)
|
||||||
|
_tabs.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||||
|
head.add_child(_tabs)
|
||||||
|
close_button = Style.bar_button("×")
|
||||||
|
close_button.tooltip_text = "Close this panel (View ▾ opens it again)"
|
||||||
|
close_button.pressed.connect(hide_dock)
|
||||||
|
head.add_child(close_button)
|
||||||
|
palette = CardPalette.new()
|
||||||
|
palette.setup(m)
|
||||||
|
palette.size_flags_vertical = SIZE_EXPAND_FILL
|
||||||
|
col.add_child(palette)
|
||||||
|
list = ListView.new()
|
||||||
|
list.setup(m)
|
||||||
|
list.size_flags_vertical = SIZE_EXPAND_FILL
|
||||||
|
col.add_child(list)
|
||||||
|
|
||||||
|
|
||||||
|
func set_width(px: float) -> void:
|
||||||
|
custom_minimum_size.x = px
|
||||||
|
|
||||||
|
|
||||||
|
## The tab open when the app starts. First run: Cards, so new players see where
|
||||||
|
## cards come from. Older settings that only kept "List view on" open List.
|
||||||
|
func restore() -> void:
|
||||||
|
var saved: Variant = m.state.get_setting(SETTING, null) if m.state else null
|
||||||
|
if saved == null:
|
||||||
|
var old_list := m.state != null and bool(m.state.get_setting(ListView.SETTING, false))
|
||||||
|
saved = LIST if old_list else CARDS
|
||||||
|
if str(saved) == "":
|
||||||
|
_show(false, tab)
|
||||||
|
else:
|
||||||
|
_show(true, LIST if str(saved) == LIST else CARDS)
|
||||||
|
|
||||||
|
|
||||||
|
## True when the dock is open on `which`.
|
||||||
|
func showing(which: String) -> bool:
|
||||||
|
return visible and tab == which
|
||||||
|
|
||||||
|
|
||||||
|
func show_tab(which: String) -> void:
|
||||||
|
_show(true, which)
|
||||||
|
_remember()
|
||||||
|
|
||||||
|
|
||||||
|
func hide_dock() -> void:
|
||||||
|
_show(false, tab)
|
||||||
|
_remember()
|
||||||
|
|
||||||
|
|
||||||
|
## Opens `which`, or closes the dock when it is already showing.
|
||||||
|
func toggle_tab(which: String) -> void:
|
||||||
|
if showing(which):
|
||||||
|
hide_dock()
|
||||||
|
else:
|
||||||
|
show_tab(which)
|
||||||
|
|
||||||
|
|
||||||
|
func _show(on: bool, which: String) -> void:
|
||||||
|
tab = which
|
||||||
|
visible = on
|
||||||
|
if splitter:
|
||||||
|
splitter.visible = on and not (m.mobile != null)
|
||||||
|
palette.visible = which == CARDS
|
||||||
|
list.visible = which == LIST
|
||||||
|
SideTabs.press(_tabs, which)
|
||||||
|
list._rev = -1
|
||||||
|
if on and which == CARDS:
|
||||||
|
palette.refresh_templates()
|
||||||
|
if m.top_bar.palette_button:
|
||||||
|
m.top_bar.palette_button.set_pressed_no_signal(showing(CARDS))
|
||||||
|
|
||||||
|
|
||||||
|
func _remember() -> void:
|
||||||
|
if m.state and m.mobile == null:
|
||||||
|
m.state.set_setting(SETTING, tab if visible else "")
|
||||||
|
m.state.save()
|
||||||
1
ui/left_dock.gd.uid
Normal file
1
ui/left_dock.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cl2g0ahh2j70a
|
||||||
|
|
@ -1,90 +1,79 @@
|
||||||
class_name ListView
|
class_name ListView
|
||||||
extends PanelContainer
|
extends VBoxContainer
|
||||||
## List view: the spread's cards as a plain list, docked on the left (or
|
## List view: the spread's cards as a plain list, the List tab of the left dock
|
||||||
## filling the window on phones). Groups show as nested rows; rows roll, select
|
## (LeftDock; it fills the window on phones). Groups show as nested rows; rows
|
||||||
## (Build) and show where their threads go. It has its own search and
|
## roll, select (Build) and show where their threads go. It has its own search
|
||||||
## "+ Group". Shown from View ▾, ☰ or right-clicking the spread.
|
## and "+ Group". Shown from View ▾, ☰ or right-clicking the spread.
|
||||||
|
|
||||||
const WIDTH := 320.0
|
## The old "List view on" setting; LeftDock.restore reads it once.
|
||||||
const MIN_WIDTH := 220.0
|
|
||||||
const SETTING := "list_view"
|
const SETTING := "list_view"
|
||||||
|
|
||||||
var m: Main
|
var m: Main
|
||||||
var tree: ListTree
|
var tree: ListTree
|
||||||
var splitter: PanelSplitter
|
|
||||||
var _search: LineEdit
|
var _search: LineEdit
|
||||||
var close_button: Button
|
|
||||||
var _rev := -1
|
var _rev := -1
|
||||||
|
|
||||||
|
|
||||||
func setup(p_main: Main) -> void:
|
func setup(p_main: Main) -> void:
|
||||||
m = p_main
|
m = p_main
|
||||||
add_theme_stylebox_override("panel", Style.panel_box([10, 10, 10, 10]))
|
add_theme_constant_override("separation", 8)
|
||||||
var col := VBoxContainer.new()
|
|
||||||
col.add_theme_constant_override("separation", 8)
|
|
||||||
add_child(col)
|
|
||||||
var head := HBoxContainer.new()
|
var head := HBoxContainer.new()
|
||||||
head.add_theme_constant_override("separation", 6)
|
head.add_theme_constant_override("separation", 6)
|
||||||
col.add_child(head)
|
add_child(head)
|
||||||
var title := Style.make_label("List", Style.display(), 20, Style.ON_BG)
|
|
||||||
title.size_flags_horizontal = SIZE_EXPAND_FILL
|
|
||||||
head.add_child(title)
|
|
||||||
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"
|
|
||||||
close.pressed.connect(func() -> void: set_shown(false))
|
|
||||||
head.add_child(close)
|
|
||||||
_search = LineEdit.new()
|
_search = LineEdit.new()
|
||||||
_search.placeholder_text = "Search the list"
|
_search.placeholder_text = "Search the list"
|
||||||
_search.clear_button_enabled = true
|
_search.clear_button_enabled = true
|
||||||
|
_search.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||||
ModalCard.style_line_edit(_search)
|
ModalCard.style_line_edit(_search)
|
||||||
_search.text_changed.connect(func(s: String) -> void:
|
_search.text_changed.connect(func(s: String) -> void:
|
||||||
tree.filter = s.strip_edges().to_lower()
|
tree.filter = s.strip_edges().to_lower()
|
||||||
tree.rebuild())
|
tree.rebuild())
|
||||||
col.add_child(_search)
|
head.add_child(_search)
|
||||||
|
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)
|
||||||
tree = ListTree.new(m)
|
tree = ListTree.new(m)
|
||||||
tree.size_flags_vertical = SIZE_EXPAND_FILL
|
tree.size_flags_vertical = SIZE_EXPAND_FILL
|
||||||
col.add_child(tree)
|
add_child(tree)
|
||||||
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)
|
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
|
hint.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||||
col.add_child(hint)
|
add_child(hint)
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if visible and m.data and m.edit_rev != _rev:
|
if is_visible_in_tree() and m.data and m.edit_rev != _rev:
|
||||||
_rev = m.edit_rev
|
_rev = m.edit_rev
|
||||||
tree.rebuild()
|
tree.rebuild()
|
||||||
|
|
||||||
|
|
||||||
func set_width(px: float) -> void:
|
## Shows or hides the list (the left dock's List tab).
|
||||||
custom_minimum_size.x = px
|
|
||||||
|
|
||||||
|
|
||||||
## Shows or hides the list and remembers it.
|
|
||||||
func set_shown(on: bool) -> void:
|
func set_shown(on: bool) -> void:
|
||||||
visible = on
|
if on:
|
||||||
if splitter:
|
m.left_dock.show_tab(LeftDock.LIST)
|
||||||
splitter.visible = on
|
elif m.left_dock.showing(LeftDock.LIST):
|
||||||
_rev = -1
|
m.left_dock.hide_dock()
|
||||||
if m.state:
|
|
||||||
m.state.set_setting(SETTING, on)
|
|
||||||
m.state.save()
|
|
||||||
|
|
||||||
|
|
||||||
func toggle() -> void:
|
func toggle() -> void:
|
||||||
set_shown(not visible)
|
m.left_dock.toggle_tab(LeftDock.LIST)
|
||||||
|
|
||||||
|
|
||||||
## A new, empty group in the middle of the view.
|
## True when the list is on screen.
|
||||||
func new_group() -> void:
|
func shown() -> bool:
|
||||||
|
return m.left_dock.showing(LeftDock.LIST)
|
||||||
|
|
||||||
|
|
||||||
|
## A new, empty group in the middle of the view, or with its top-left corner
|
||||||
|
## at `at` (world coordinates).
|
||||||
|
func new_group(at: Vector2 = Vector2.INF) -> void:
|
||||||
m.undo_redo._begin_edit()
|
m.undo_redo._begin_edit()
|
||||||
var g := m.data.add_group(m.grouping._free_group_name(), [])
|
var g := m.data.add_group(m.grouping._free_group_name(), [])
|
||||||
var c := m.board.screen_to_world(m.board.size / 2.0)
|
if at == Vector2.INF:
|
||||||
g.position = (c - g.size / 2.0).round()
|
var c := m.board.screen_to_world(m.board.size / 2.0)
|
||||||
|
g.position = (c - g.size / 2.0).round()
|
||||||
|
else:
|
||||||
|
g.position = at
|
||||||
m.grouping._groups_changed()
|
m.grouping._groups_changed()
|
||||||
m.mark_dirty()
|
m.mark_dirty()
|
||||||
m.undo_redo._end_edit()
|
m.undo_redo._end_edit()
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ var selection: Dictionary = {}
|
||||||
var selecting: MainSelection
|
var selecting: MainSelection
|
||||||
## The List view panel (left dock).
|
## The List view panel (left dock).
|
||||||
var list_view: ListView
|
var list_view: ListView
|
||||||
|
## The left dock: Cards (the card palette) | List (list_view).
|
||||||
|
var left_dock: LeftDock
|
||||||
## The phone layout, when it is on (MobileLayout.wanted).
|
## The phone layout, when it is on (MobileLayout.wanted).
|
||||||
var mobile: MobileLayout
|
var mobile: MobileLayout
|
||||||
## The Book panel (reusable results).
|
## The Book panel (reusable results).
|
||||||
|
|
|
||||||
|
|
@ -116,8 +116,7 @@ func _run_shell_cli(args: PackedStringArray) -> void:
|
||||||
if menu == "add":
|
if menu == "add":
|
||||||
# The Build tools were only just shown; let them lay out first.
|
# The Build tools were only just shown; let them lay out first.
|
||||||
await m.get_tree().process_frame
|
await m.get_tree().process_frame
|
||||||
await m.get_tree().process_frame
|
m.left_dock.show_tab(LeftDock.CARDS)
|
||||||
m.editing._add_menu.show_popup()
|
|
||||||
|
|
||||||
|
|
||||||
# ----- Logic-card screenshot flags -----
|
# ----- Logic-card screenshot flags -----
|
||||||
|
|
|
||||||
|
|
@ -9,90 +9,32 @@ var _link_from: Dictionary = {}
|
||||||
## Tests only: the card a link drop lands on, instead of the one under the mouse.
|
## Tests only: the card a link drop lands on, instead of the one under the mouse.
|
||||||
var _card_under_mouse_override: TableCard = null
|
var _card_under_mouse_override: TableCard = null
|
||||||
var _drop_card: TableCard
|
var _drop_card: TableCard
|
||||||
var _add_menu: MenuButton
|
|
||||||
var _sel_bar: PanelContainer
|
var _sel_bar: PanelContainer
|
||||||
var _sel_label: Label
|
var _sel_label: Label
|
||||||
|
|
||||||
## The "+ Card ▾" kinds: [label, kind, sub, default name].
|
|
||||||
const ADD_KINDS := [
|
|
||||||
["Roll table", RollTable.KIND_ROLL, "", "New table"],
|
|
||||||
["Check card: roll against a target", RollTable.KIND_CHECK, "", "Check"],
|
|
||||||
["Choice: which option", RollTable.KIND_CHOICE, "pick", "New choice"],
|
|
||||||
["Choice: how many", RollTable.KIND_CHOICE, "number", "How many?"],
|
|
||||||
["Choice: open ended", RollTable.KIND_CHOICE, "text", "What is it?"],
|
|
||||||
["Repeat", RollTable.KIND_LOOP, "times", "Repeat"],
|
|
||||||
["Branch: if / else if / otherwise", RollTable.KIND_ROUTER, "", "Branch"],
|
|
||||||
["Variable", RollTable.KIND_VARIABLE, "number", "New variable"],
|
|
||||||
["Ledger (Skills, Contacts…)", RollTable.KIND_VARIABLE, RollTable.VAR_COLLECTION, "Skills"],
|
|
||||||
["Scale (ordered steps)", RollTable.KIND_VARIABLE, RollTable.VAR_SCALE, "New scale"],
|
|
||||||
["Sheet", RollTable.KIND_SHEET, "", "Sheet"],
|
|
||||||
]
|
|
||||||
const MENU_FROM_TEMPLATE := 100
|
|
||||||
const MENU_GROUP := 101
|
|
||||||
## How close (screen pixels) a dragged thread must be to a card's input dot to drop on it.
|
## How close (screen pixels) a dragged thread must be to a card's input dot to drop on it.
|
||||||
const LINK_DROP_RADIUS := 24.0
|
const LINK_DROP_RADIUS := 24.0
|
||||||
const MENU_SAVE_SELECTION := 102
|
|
||||||
|
|
||||||
|
|
||||||
func _init(p_main: Main) -> void:
|
func _init(p_main: Main) -> void:
|
||||||
m = p_main
|
m = p_main
|
||||||
|
|
||||||
|
|
||||||
func _make_add_menu() -> MenuButton:
|
|
||||||
var mb := Style.menu_button("+ Card ▾", true)
|
|
||||||
mb.tooltip_text = "Add a roll table or a logic card"
|
|
||||||
var pm := mb.get_popup()
|
|
||||||
ModalCard.style_popup(pm)
|
|
||||||
for i in ADD_KINDS.size():
|
|
||||||
if i == 1:
|
|
||||||
pm.add_separator("Logic cards")
|
|
||||||
pm.add_item(str(ADD_KINDS[i][0]), i)
|
|
||||||
pm.add_separator("Groups and templates")
|
|
||||||
pm.add_item("From template…", MENU_FROM_TEMPLATE)
|
|
||||||
pm.add_item("Group the selection Ctrl+G", MENU_GROUP)
|
|
||||||
pm.add_item("Save selection as template…", MENU_SAVE_SELECTION)
|
|
||||||
pm.about_to_popup.connect(func() -> void:
|
|
||||||
pm.set_item_disabled(pm.get_item_index(MENU_GROUP), m.selection.is_empty() and m.selecting.groups.is_empty())
|
|
||||||
pm.set_item_disabled(pm.get_item_index(MENU_SAVE_SELECTION), m.selection.is_empty())
|
|
||||||
)
|
|
||||||
pm.id_pressed.connect(func(id: int) -> void:
|
|
||||||
match id:
|
|
||||||
MENU_FROM_TEMPLATE:
|
|
||||||
m.templating.open_template_picker()
|
|
||||||
MENU_GROUP:
|
|
||||||
m.grouping.group_selection()
|
|
||||||
MENU_SAVE_SELECTION:
|
|
||||||
m.templating.save_selection_as_template()
|
|
||||||
_:
|
|
||||||
var k: Array = ADD_KINDS[id]
|
|
||||||
add_table(str(k[1]), str(k[2]))
|
|
||||||
)
|
|
||||||
return mb
|
|
||||||
|
|
||||||
|
|
||||||
## Adds a card of any kind (RollTable.create) in the middle of the view, or
|
## Adds a card of any kind (RollTable.create) in the middle of the view, or
|
||||||
## with its top-left corner at `at` (world coordinates).
|
## with its top-left corner at `at` (world coordinates). `variant` gives it a
|
||||||
func add_table(kind: String = RollTable.KIND_ROLL, sub: String = "", at: Vector2 = Vector2.INF) -> RollTable:
|
## CardCatalog variant's start settings ("dice", "deck").
|
||||||
|
func add_table(kind: String = RollTable.KIND_ROLL, sub: String = "", at: Vector2 = Vector2.INF, variant: String = "") -> RollTable:
|
||||||
m.undo_redo._begin_edit()
|
m.undo_redo._begin_edit()
|
||||||
var center := m.board.screen_to_world(m.board.size / 2.0) if at == Vector2.INF else at + Vector2(128, 120)
|
var center := m.board.screen_to_world(m.board.size / 2.0) if at == Vector2.INF else at + Vector2(128, 120)
|
||||||
var name := "New table"
|
var item := CardCatalog.find(kind, sub, variant)
|
||||||
var found := false
|
var name := str(item.get("name", "New table"))
|
||||||
for k: Array in ADD_KINDS:
|
|
||||||
if k[1] == kind and k[2] == sub:
|
|
||||||
name = str(k[3])
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
if not found:
|
|
||||||
for k: Array in ADD_KINDS:
|
|
||||||
if k[1] == kind and (sub == "" or kind != RollTable.KIND_CHOICE) and k[2] != RollTable.VAR_COLLECTION:
|
|
||||||
name = str(k[3])
|
|
||||||
break
|
|
||||||
var t := RollTable.create(kind, TowerBoard.new_id("t"), name, sub)
|
var t := RollTable.create(kind, TowerBoard.new_id("t"), name, sub)
|
||||||
if kind == RollTable.KIND_ROLL or kind == RollTable.KIND_CHECK:
|
if kind == RollTable.KIND_ROLL or kind == RollTable.KIND_CHECK:
|
||||||
for e in t.entries:
|
for e in t.entries:
|
||||||
e.id = TowerBoard.new_id("e")
|
e.id = TowerBoard.new_id("e")
|
||||||
if kind == RollTable.KIND_VARIABLE:
|
if kind == RollTable.KIND_VARIABLE:
|
||||||
t.var_name = _free_var_name(t.var_name)
|
t.var_name = _free_var_name(t.var_name)
|
||||||
|
CardCatalog.apply_variant(t, variant)
|
||||||
t.position = Vector2(roundf(center.x - 128.0), roundf(center.y - 120.0))
|
t.position = Vector2(roundf(center.x - 128.0), roundf(center.y - 120.0))
|
||||||
m.data.tables.append(t)
|
m.data.tables.append(t)
|
||||||
var card := TableCard.new()
|
var card := TableCard.new()
|
||||||
|
|
|
||||||
|
|
@ -51,18 +51,17 @@ func _build_ui() -> void:
|
||||||
middle.add_theme_constant_override("separation", 0)
|
middle.add_theme_constant_override("separation", 0)
|
||||||
middle.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
middle.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||||
root.add_child(middle)
|
root.add_child(middle)
|
||||||
m.list_view = ListView.new()
|
m.left_dock = LeftDock.new()
|
||||||
m.list_view.setup(m)
|
m.left_dock.setup(m)
|
||||||
var lside := PanelSplitter.new(m, false, "list_width", ListView.WIDTH, ListView.MIN_WIDTH)
|
m.list_view = m.left_dock.list
|
||||||
|
var lside := PanelSplitter.new(m, false, "list_width", LeftDock.WIDTH, LeftDock.MIN_WIDTH)
|
||||||
lside.before = true
|
lside.before = true
|
||||||
lside.size_changed.connect(m.list_view.set_width)
|
lside.size_changed.connect(m.left_dock.set_width)
|
||||||
m.list_view.splitter = lside
|
m.left_dock.splitter = lside
|
||||||
m.list_view.set_width(lside.size_px)
|
m.left_dock.set_width(lside.size_px)
|
||||||
middle.add_child(m.list_view)
|
middle.add_child(m.left_dock)
|
||||||
middle.add_child(lside)
|
middle.add_child(lside)
|
||||||
var list_on := m.state != null and bool(m.state.get_setting(ListView.SETTING, false))
|
m.left_dock.restore()
|
||||||
m.list_view.visible = list_on
|
|
||||||
lside.visible = list_on
|
|
||||||
m.board = BoardView.new()
|
m.board = BoardView.new()
|
||||||
m.board.setup(m)
|
m.board.setup(m)
|
||||||
m.board.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
m.board.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
|
@ -157,7 +156,6 @@ func set_mode(new_mode: Main.Mode) -> void:
|
||||||
m.top_bar._hint.tooltip_text = Main.HINTS[new_mode]
|
m.top_bar._hint.tooltip_text = Main.HINTS[new_mode]
|
||||||
m.top_bar._hint.custom_minimum_size.x = 60.0 if new_mode == Main.Mode.PLAY else 0.0
|
m.top_bar._hint.custom_minimum_size.x = 60.0 if new_mode == Main.Mode.PLAY else 0.0
|
||||||
m.top_bar._build_tools.visible = new_mode == Main.Mode.BUILD
|
m.top_bar._build_tools.visible = new_mode == Main.Mode.BUILD
|
||||||
m.top_bar.play_add_button.visible = new_mode == Main.Mode.PLAY
|
|
||||||
m.board.pipes.hover_key = ""
|
m.board.pipes.hover_key = ""
|
||||||
m.clear_selection()
|
m.clear_selection()
|
||||||
SideTabs.sync(m)
|
SideTabs.sync(m)
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ func store_template(out: Dictionary) -> void:
|
||||||
if id == "":
|
if id == "":
|
||||||
m.toast("Couldn't save the template")
|
m.toast("Couldn't save the template")
|
||||||
else:
|
else:
|
||||||
m.toast("Saved template “%s”. Insert it from + Card ▾ → From template…" % out["name"])
|
m.toast("Saved template “%s”. Insert it from the Cards tab (Templates)" % out["name"])
|
||||||
|
|
||||||
|
|
||||||
## The selection as a template; groups whose cards are all selected come along.
|
## The selection as a template; groups whose cards are all selected come along.
|
||||||
|
|
@ -86,21 +86,24 @@ func open_template_picker() -> TemplatePicker:
|
||||||
|
|
||||||
|
|
||||||
## Asks for the template's parameters (if it has any), then inserts it.
|
## Asks for the template's parameters (if it has any), then inserts it.
|
||||||
func begin_template_insert(tpl: Dictionary) -> void:
|
## `at`: its top-left corner in world coordinates (INF = the view centre).
|
||||||
|
func begin_template_insert(tpl: Dictionary, at: Vector2 = Vector2.INF) -> void:
|
||||||
if (tpl.get("params", []) as Array).is_empty():
|
if (tpl.get("params", []) as Array).is_empty():
|
||||||
insert_template(tpl, {})
|
insert_template(tpl, {}, at)
|
||||||
return
|
return
|
||||||
m._add_modal(TemplateForms.params_dialog(tpl, func(values: Dictionary) -> void: insert_template(tpl, values)))
|
m._add_modal(TemplateForms.params_dialog(tpl, func(values: Dictionary) -> void: insert_template(tpl, values, at)))
|
||||||
|
|
||||||
|
|
||||||
## Inserts a template at the view centre: parameters substituted, fresh ids,
|
## Inserts a template, centred in the view or with its top-left corner at
|
||||||
## outside pipes relinked by name (or dropped and reported). Returns
|
## `at` (world coordinates): parameters substituted, fresh ids, outside pipes
|
||||||
## TemplateKit.instantiate's result.
|
## relinked by name (or dropped and reported). Returns TemplateKit.instantiate's result.
|
||||||
func insert_template(tpl: Dictionary, values: Dictionary) -> Dictionary:
|
func insert_template(tpl: Dictionary, values: Dictionary, at: Vector2 = Vector2.INF) -> Dictionary:
|
||||||
m.undo_redo._begin_edit()
|
m.undo_redo._begin_edit()
|
||||||
var ext := TemplateKit.extent(tpl)
|
var origin := at
|
||||||
var center := m.board.screen_to_world(m.board.size / 2.0)
|
if at == Vector2.INF:
|
||||||
var origin := (center - ext / 2.0).round()
|
var ext := TemplateKit.extent(tpl)
|
||||||
|
var center := m.board.screen_to_world(m.board.size / 2.0)
|
||||||
|
origin = (center - ext / 2.0).round()
|
||||||
var r := TemplateKit.insert(tpl, values, m.data, origin)
|
var r := TemplateKit.insert(tpl, values, m.data, origin)
|
||||||
for t: RollTable in r["tables"]:
|
for t: RollTable in r["tables"]:
|
||||||
if t.kind == RollTable.KIND_VARIABLE and t.var_name == "":
|
if t.kind == RollTable.KIND_VARIABLE and t.var_name == "":
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ var _toast_label: Label
|
||||||
var _toast_undo: Button
|
var _toast_undo: Button
|
||||||
## The toast button's own action (toast_action), or empty for Undo.
|
## The toast button's own action (toast_action), or empty for Undo.
|
||||||
var _toast_do := Callable()
|
var _toast_do := Callable()
|
||||||
## Play mode's greyed "+ Card" (BuildModeHint).
|
|
||||||
var play_add_button: Button
|
|
||||||
var _toast_timer: Timer
|
var _toast_timer: Timer
|
||||||
|
## Build only: opens or closes the card palette (lit while it shows).
|
||||||
|
var palette_button: Button
|
||||||
## The undo step the toast's Undo button undoes (EditHistory serial), or -1.
|
## The undo step the toast's Undo button undoes (EditHistory serial), or -1.
|
||||||
var _toast_serial := -1
|
var _toast_serial := -1
|
||||||
var _endless_chip: PanelContainer
|
var _endless_chip: PanelContainer
|
||||||
|
|
@ -117,9 +117,13 @@ func _build_top_bar() -> Control:
|
||||||
var tools := HBoxContainer.new()
|
var tools := HBoxContainer.new()
|
||||||
tools.add_theme_constant_override("separation", 6)
|
tools.add_theme_constant_override("separation", 6)
|
||||||
_build_tools = tools
|
_build_tools = tools
|
||||||
|
palette_button = Style.bar_button("Card palette")
|
||||||
|
palette_button.toggle_mode = true
|
||||||
|
palette_button.tooltip_text = "Show or hide the card palette: every kind of card and your templates"
|
||||||
|
palette_button.focus_mode = Control.FOCUS_NONE
|
||||||
|
palette_button.pressed.connect(func() -> void: m.left_dock.toggle_tab(LeftDock.CARDS))
|
||||||
|
tools.add_child(palette_button)
|
||||||
m.undo_redo._make_history_buttons(tools)
|
m.undo_redo._make_history_buttons(tools)
|
||||||
m.editing._add_menu = m.editing._make_add_menu()
|
|
||||||
tools.add_child(m.editing._add_menu)
|
|
||||||
_board_menu = IoMenu.new()
|
_board_menu = IoMenu.new()
|
||||||
_board_menu.setup(true, m.collections_enabled())
|
_board_menu.setup(true, m.collections_enabled())
|
||||||
_board_menu.reset_requested.connect(m.editing.reset_sample)
|
_board_menu.reset_requested.connect(m.editing.reset_sample)
|
||||||
|
|
@ -130,8 +134,6 @@ func _build_top_bar() -> Control:
|
||||||
tools.add_child(_board_menu)
|
tools.add_child(_board_menu)
|
||||||
tools.visible = false
|
tools.visible = false
|
||||||
h.add_child(tools)
|
h.add_child(tools)
|
||||||
play_add_button = BuildModeHint.make_button(m)
|
|
||||||
h.add_child(play_add_button)
|
|
||||||
|
|
||||||
_endless_chip = _make_endless_chip()
|
_endless_chip = _make_endless_chip()
|
||||||
h.add_child(_endless_chip)
|
h.add_child(_endless_chip)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
class_name MobileLayout
|
class_name MobileLayout
|
||||||
extends RefCounted
|
extends RefCounted
|
||||||
## The phone layout (Android, or --mobile on a desktop to try it): the List
|
## The phone layout (Android, or --mobile on a desktop to try it): the left
|
||||||
## fills the screen and a Spread/List button swaps it with the spread; the
|
## dock (List, or the card palette from "+") fills the screen and a Spread/List
|
||||||
|
## button swaps it with the spread; the
|
||||||
## top bar drops its hint and zoom control; everything scales to the screen's
|
## top bar drops its hint and zoom control; everything scales to the screen's
|
||||||
## density. Touch gestures come from TouchInput (added on every platform, so
|
## density. Touch gestures come from TouchInput (added on every platform, so
|
||||||
## touch screens on laptops work too).
|
## touch screens on laptops work too).
|
||||||
|
|
@ -9,6 +10,7 @@ extends RefCounted
|
||||||
var m: Main
|
var m: Main
|
||||||
var showing_list := true
|
var showing_list := true
|
||||||
var swap: Button
|
var swap: Button
|
||||||
|
var add_button: Button
|
||||||
|
|
||||||
|
|
||||||
func _init(p_main: Main) -> void:
|
func _init(p_main: Main) -> void:
|
||||||
|
|
@ -30,22 +32,36 @@ func apply() -> void:
|
||||||
c.visible = false
|
c.visible = false
|
||||||
m.tray.side_panel.visible = false
|
m.tray.side_panel.visible = false
|
||||||
m.tray.compact = true
|
m.tray.compact = true
|
||||||
m.list_view.close_button.visible = false
|
m.left_dock.close_button.visible = false
|
||||||
m.list_view.splitter.visible = false
|
m.left_dock.splitter.visible = false
|
||||||
m.list_view.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
m.left_dock.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
m.left_dock.show_tab(LeftDock.LIST)
|
||||||
m.board.minimap.visible = false
|
m.board.minimap.visible = false
|
||||||
swap = Style.bar_button("Spread")
|
swap = Style.bar_button("Spread")
|
||||||
swap.tooltip_text = "Swap between the list and the spread"
|
swap.tooltip_text = "Swap between the list and the spread"
|
||||||
swap.pressed.connect(func() -> void: show_list(not showing_list))
|
swap.pressed.connect(func() -> void: show_list(not showing_list))
|
||||||
bar.actions_menu.get_parent().add_child(swap)
|
bar.actions_menu.get_parent().add_child(swap)
|
||||||
bar.actions_menu.get_parent().move_child(swap, bar.actions_menu.get_index())
|
bar.actions_menu.get_parent().move_child(swap, bar.actions_menu.get_index())
|
||||||
|
# "+" opens the card palette full screen; picking a card goes back to the spread.
|
||||||
|
add_button = Style.bar_button("+")
|
||||||
|
add_button.tooltip_text = "Add a card"
|
||||||
|
add_button.custom_minimum_size = Vector2(44, 44)
|
||||||
|
add_button.pressed.connect(open_palette)
|
||||||
|
bar.actions_menu.get_parent().add_child(add_button)
|
||||||
|
bar.actions_menu.get_parent().move_child(add_button, swap.get_index())
|
||||||
show_list(true)
|
show_list(true)
|
||||||
|
|
||||||
|
|
||||||
## The list or the spread fills the screen.
|
## The list or the spread fills the screen.
|
||||||
func show_list(on: bool) -> void:
|
func show_list(on: bool) -> void:
|
||||||
showing_list = on
|
showing_list = on
|
||||||
m.list_view.visible = on
|
m.left_dock.visible = on
|
||||||
m.list_view._rev = -1
|
m.list_view._rev = -1
|
||||||
m.board.visible = not on
|
m.board.visible = not on
|
||||||
swap.text = "Spread" if on else "List"
|
swap.text = "Spread" if on else "List"
|
||||||
|
|
||||||
|
|
||||||
|
## The card palette fills the screen (the left dock's Cards tab).
|
||||||
|
func open_palette() -> void:
|
||||||
|
m.left_dock.show_tab(LeftDock.CARDS)
|
||||||
|
show_list(true)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ extends RefCounted
|
||||||
## In Build, the Inspector and the Lore Index share the right-hand dock as two
|
## 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
|
## 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).
|
## no inspector, so the Lore Index opens on its own (no tab row).
|
||||||
|
## tab_row is the shared tab style; LeftDock ("Cards | List") uses it too.
|
||||||
## The Lore Index is BookPanel in code (TowerBoard.book, BookPage).
|
## The Lore Index is BookPanel in code (TowerBoard.book, BookPage).
|
||||||
|
|
||||||
const INSPECTOR := "inspector"
|
const INSPECTOR := "inspector"
|
||||||
|
|
@ -11,11 +12,18 @@ const LORE := "lore"
|
||||||
|
|
||||||
## The tab row put at the top of both panels. `active` is the panel it sits on.
|
## 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:
|
static func make_row(m: Main, active: String) -> HBoxContainer:
|
||||||
|
return tab_row([[INSPECTOR, "Inspector"], [LORE, "Lore Index"]], active, func(which: String) -> void: show_tab(m, which))
|
||||||
|
|
||||||
|
|
||||||
|
## A row of dock tabs in the shared style (both docks use it). `tabs` holds
|
||||||
|
## [key, label] pairs; `on_pick` gets the key of the tab pressed.
|
||||||
|
static func tab_row(tabs: Array, active: String, on_pick: Callable) -> HBoxContainer:
|
||||||
var row := HBoxContainer.new()
|
var row := HBoxContainer.new()
|
||||||
row.add_theme_constant_override("separation", 4)
|
row.add_theme_constant_override("separation", 4)
|
||||||
for tab: Array in [[INSPECTOR, "Inspector"], [LORE, "Lore Index"]]:
|
for tab: Array in tabs:
|
||||||
var b := Button.new()
|
var b := Button.new()
|
||||||
b.text = tab[1]
|
b.text = tab[1]
|
||||||
|
b.name = str(tab[0])
|
||||||
b.toggle_mode = true
|
b.toggle_mode = true
|
||||||
b.button_pressed = tab[0] == active
|
b.button_pressed = tab[0] == active
|
||||||
b.focus_mode = Control.FOCUS_NONE
|
b.focus_mode = Control.FOCUS_NONE
|
||||||
|
|
@ -27,11 +35,17 @@ static func make_row(m: Main, active: String) -> HBoxContainer:
|
||||||
var on := Style.bordered(Style.box(Style.CARD, 6, [10, 5, 10, 5]), 2, Style.TRIM)
|
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)
|
Style.skin_button(b, normal, hover, on, Style.MUTED, Style.INK, Style.INK)
|
||||||
var which: String = tab[0]
|
var which: String = tab[0]
|
||||||
b.pressed.connect(func() -> void: show_tab(m, which))
|
b.pressed.connect(func() -> void: on_pick.call(which))
|
||||||
row.add_child(b)
|
row.add_child(b)
|
||||||
return row
|
return row
|
||||||
|
|
||||||
|
|
||||||
|
## Presses the tab named `which` in a row from tab_row (the others pop up).
|
||||||
|
static func press(row: HBoxContainer, which: String) -> void:
|
||||||
|
for b in row.get_children():
|
||||||
|
(b as Button).set_pressed_no_signal(b.name == which)
|
||||||
|
|
||||||
|
|
||||||
## Shows one tab. The Lore Index tab opens the Lore Index; the Inspector tab closes it.
|
## 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:
|
static func show_tab(m: Main, which: String) -> void:
|
||||||
if m.book:
|
if m.book:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class_name TemplatePicker
|
class_name TemplatePicker
|
||||||
extends ModalCard
|
extends ModalCard
|
||||||
## "+ Card ▾ → From template…": the template list with search, each row
|
## "All templates…" in the card palette: the template list with search, each row
|
||||||
## showing its name, description and a small preview. The user's own
|
## showing its name, description and a small preview. The user's own
|
||||||
## templates can be renamed, exported and deleted here; built-in ones are
|
## templates can be renamed, exported and deleted here; built-in ones are
|
||||||
## read-only. Import… adds a template file. Insert asks for parameters (if
|
## read-only. Import… adds a template file. Insert asks for parameters (if
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ const ID_BOOK := 7
|
||||||
const ID_SOUND := 8
|
const ID_SOUND := 8
|
||||||
const ID_CONFIRM_DELETE := 9
|
const ID_CONFIRM_DELETE := 9
|
||||||
const ID_SKIP_ANIM := 10
|
const ID_SKIP_ANIM := 10
|
||||||
|
const ID_CARDS := 11
|
||||||
|
|
||||||
var m: Main
|
var m: Main
|
||||||
|
|
||||||
|
|
@ -35,6 +36,8 @@ func setup(p_main: Main) -> void:
|
||||||
pm.add_separator("Show")
|
pm.add_separator("Show")
|
||||||
pm.add_check_item("Striped rows", ID_STRIPES)
|
pm.add_check_item("Striped rows", ID_STRIPES)
|
||||||
pm.add_check_item("Minimap (M)", ID_MINIMAP)
|
pm.add_check_item("Minimap (M)", ID_MINIMAP)
|
||||||
|
pm.add_check_item("Card palette", ID_CARDS)
|
||||||
|
pm.set_item_tooltip(pm.get_item_index(ID_CARDS), "Every kind of card and your templates, to click or drag onto the spread")
|
||||||
pm.add_check_item("List view", ID_LIST)
|
pm.add_check_item("List view", ID_LIST)
|
||||||
pm.add_check_item("Lore Index", ID_BOOK)
|
pm.add_check_item("Lore Index", ID_BOOK)
|
||||||
pm.add_check_item("Ask before deleting", ID_CONFIRM_DELETE)
|
pm.add_check_item("Ask before deleting", ID_CONFIRM_DELETE)
|
||||||
|
|
@ -60,7 +63,8 @@ func sync() -> void:
|
||||||
pm.set_item_text(pm.get_item_index(ID_COLLAPSE), collapse_label())
|
pm.set_item_text(pm.get_item_index(ID_COLLAPSE), collapse_label())
|
||||||
pm.set_item_checked(pm.get_item_index(ID_STRIPES), m.local_state.striped_rows())
|
pm.set_item_checked(pm.get_item_index(ID_STRIPES), m.local_state.striped_rows())
|
||||||
pm.set_item_checked(pm.get_item_index(ID_MINIMAP), m.board.minimap.visible)
|
pm.set_item_checked(pm.get_item_index(ID_MINIMAP), m.board.minimap.visible)
|
||||||
pm.set_item_checked(pm.get_item_index(ID_LIST), m.list_view.visible)
|
pm.set_item_checked(pm.get_item_index(ID_CARDS), m.left_dock.showing(LeftDock.CARDS))
|
||||||
|
pm.set_item_checked(pm.get_item_index(ID_LIST), m.list_view.shown())
|
||||||
pm.set_item_checked(pm.get_item_index(ID_BOOK), m.book.visible)
|
pm.set_item_checked(pm.get_item_index(ID_BOOK), m.book.visible)
|
||||||
pm.set_item_checked(pm.get_item_index(ID_CONFIRM_DELETE), DeleteKey.asks(m))
|
pm.set_item_checked(pm.get_item_index(ID_CONFIRM_DELETE), DeleteKey.asks(m))
|
||||||
pm.set_item_checked(pm.get_item_index(ID_SKIP_ANIM), SkipAnimations.on(m))
|
pm.set_item_checked(pm.get_item_index(ID_SKIP_ANIM), SkipAnimations.on(m))
|
||||||
|
|
@ -82,6 +86,8 @@ func activate(id: int) -> void:
|
||||||
m.local_state.set_striped_rows(not m.local_state.striped_rows())
|
m.local_state.set_striped_rows(not m.local_state.striped_rows())
|
||||||
ID_MINIMAP:
|
ID_MINIMAP:
|
||||||
m.nav.set_minimap_visible(not m.board.minimap.visible, true)
|
m.nav.set_minimap_visible(not m.board.minimap.visible, true)
|
||||||
|
ID_CARDS:
|
||||||
|
m.left_dock.toggle_tab(LeftDock.CARDS)
|
||||||
ID_LIST:
|
ID_LIST:
|
||||||
m.list_view.toggle()
|
m.list_view.toggle()
|
||||||
ID_BOOK:
|
ID_BOOK:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue