UI pass: striped rows, View/Help menus, zoom control, card ⋯ menu, fuller sample
- Striped result rows (parchment tint, on by default, `striped_rows` setting). - Top bar: View ▾ (Plain words / Rule text, Collapse/Expand all, Striped rows, Minimap) and a "− 90% ▾ +" zoom control replace the Plain|Text switch, Collapse all, −/Fit/+ and Map. Arrange ▾ folds into Board ▾; Search is an icon. - Help ▾ and F1 open a Help window; the 17 topics live in help/topics.txt. - Build cards get a ⋯ menu (settings, template, collapse, delete) instead of the gear and footer Delete, sharing Style.overflow_button with group cards. Row × buttons show only on hover, focus or selection. - Sample: Luck value card, Make Camp (pick card) and Search the Ruins (1d6 + Luck, with results only a modifier reaches). - New test suite test_top_bar; Canvas/GraphML round-trip tests compare plain tables only, since logic keys are JSON-only. - DESIGN.md: open items, including the Card Mode UI redesign. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
540f995e2b
commit
8f16d337cf
36 changed files with 1020 additions and 218 deletions
28
README.md
28
README.md
|
|
@ -22,15 +22,21 @@ godot --path .
|
||||||
- **Build mode** is for setting up tables. Edit names, results, weights and details in place,
|
- **Build mode** is for setting up tables. Edit names, results, weights and details in place,
|
||||||
add or delete results and tables, and drag a card by its header. Drag from a result's ●
|
add or delete results and tables, and drag a card by its header. Drag from a result's ●
|
||||||
onto another table to lay a pipe. The **inspector** docked on the right edits whatever is
|
onto another table to lay a pipe. The **inspector** docked on the right edits whatever is
|
||||||
selected: click a card's title (or its ⚙) for the card, a result's text for the result, or
|
selected: click a card's title for the card, a result's text for the result, or
|
||||||
a pipe for the pipe. Results get fill-in rows for their changes ("Subtract [1] from
|
a pipe for the pipe. Results get fill-in rows for their changes ("Subtract [1] from
|
||||||
[Luck ▾]") and a box per pipe with its inputs, **Only if** conditions ("[Luck ▾] [is at
|
[Luck ▾]") and a box per pipe with its inputs, **Only if** conditions ("[Luck ▾] [is at
|
||||||
least ▾] [2]"), **Otherwise**, count and "saves as". Cards get their kind's fields (check
|
least ▾] [2]"), **Otherwise**, count and "saves as". Cards get their kind's fields (check
|
||||||
dice, modifier and target; choice options; loop rules; router cases; collection members;
|
dice, modifier and target; choice options; loop rules; router cases; collection members;
|
||||||
inputs). Value dropdowns list the board's values with search and **+ New value…**. "Edit
|
inputs). Value dropdowns list the board's values with search and **+ New value…**. "Edit
|
||||||
as text" switches any builder to the rule text. **More settings…** opens the card's full
|
as text" switches any builder to the rule text. **More settings…** opens the card's full
|
||||||
settings (Card mode and the rest). The top bar's **Plain / Text** switch shows rules in
|
settings (Card mode and the rest). **View ▾ → Rules** shows rules in plain words or as
|
||||||
plain words or as rule text. » hides the inspector.
|
rule text. » hides the inspector. Each card's **⋯** menu has Table settings…, Save as
|
||||||
|
template…, Collapse and Delete table, and a result's **×** shows when you hover the row.
|
||||||
|
- **View ▾** (top bar): rules as Plain words or Rule text, Collapse or Expand all tables,
|
||||||
|
**Striped rows** (every second result row tinted, on by default) and the minimap.
|
||||||
|
- **Help ▾** (top bar, or **F1**) opens the Help window at any of its topics: getting
|
||||||
|
started, rolling, building, pipes, roll modifiers, card mode, choices, values, logic cards,
|
||||||
|
text, groups and templates, collections, testing, finding your way and shortcuts.
|
||||||
- **Undo and redo:** every change to the board can be undone: typing, weights, effects,
|
- **Undo and redo:** every change to the board can be undone: typing, weights, effects,
|
||||||
details and settings, adding and deleting results, cards and pipes, pipe options, moves,
|
details and settings, adding and deleting results, cards and pipes, pipe options, moves,
|
||||||
groups, templates, Pack and Reset sample. **Ctrl+Z** undoes and **Ctrl+Shift+Z** or
|
groups, templates, Pack and Reset sample. **Ctrl+Z** undoes and **Ctrl+Shift+Z** or
|
||||||
|
|
@ -77,15 +83,15 @@ godot --path .
|
||||||
- **Resizing:** drag the top edge of the result tray or the left edge of the inspector.
|
- **Resizing:** drag the top edge of the result tray or the left edge of the inspector.
|
||||||
Double-click the edge to go back to the default size.
|
Double-click the edge to go back to the default size.
|
||||||
- **Collapsing:** the arrow beside a table's name collapses it. A collapsed table still shows
|
- **Collapsing:** the arrow beside a table's name collapses it. A collapsed table still shows
|
||||||
its last result. **Collapse all / Expand all** in the top bar does every table at once.
|
its last result. **View ▾ → Collapse all tables / Expand all tables** does every table at once.
|
||||||
- **Groups:** in Build mode, Ctrl- or Shift-click card headers (or Ctrl-drag on the felt) to
|
- **Groups:** in Build mode, Ctrl- or Shift-click card headers (or Ctrl-drag on the felt) to
|
||||||
select cards, then **Group** (Ctrl+G, the selection bar, or **+ Card ▾**). A group is a
|
select cards, then **Group** (Ctrl+G, the selection bar, or **+ Card ▾**). A group is a
|
||||||
frame behind its cards; drag its title bar to move them all, drop a card into a frame to
|
frame behind its cards; drag its title bar to move them all, drop a card into a frame to
|
||||||
add it, drag it out to take it out. The chevron collapses the group into one compact
|
add it, drag it out to take it out. The chevron collapses the group into one compact
|
||||||
card that still shows its cards' last results, with pipes attached to its edges. The
|
card that still shows its cards' last results, with pipes attached to its edges. The
|
||||||
title bar's ⋯ menu renames, edits details, ungroups (keeping the cards) or deletes the
|
title bar's ⋯ menu renames, edits details, ungroups (keeping the cards) or deletes the
|
||||||
group and its cards (with undo). **Collapse all** and **Fit** include groups.
|
group and its cards (with undo). Collapse all and Fit board include groups.
|
||||||
- **Templates:** save a card (⚙ → Save as template…), a group (⋯ → Save as template…) or a
|
- **Templates:** save a card (⋯ → Save as template…), a group (⋯ → Save as template…) or a
|
||||||
selection as a reusable template. Write `{$name}` in any text to make a parameter; the
|
selection as a reusable template. Write `{$name}` in any text to make a parameter; the
|
||||||
save dialog finds them and asks for a label and default. **+ Card ▾ → From template…**
|
save dialog finds them and asks for a label and default. **+ Card ▾ → From template…**
|
||||||
lists your templates and the built-in ones (skill check, ask-and-repeat, pick menu,
|
lists your templates and the built-in ones (skill check, ask-and-repeat, pick menu,
|
||||||
|
|
@ -94,7 +100,8 @@ godot --path .
|
||||||
Templates live in `user://templates/` and are shared by every collection; the list can
|
Templates live in `user://templates/` and are shared by every collection; the list can
|
||||||
rename, delete, export and import them.
|
rename, delete, export and import them.
|
||||||
- **Moving around:** drag the felt to pan, use the mouse wheel to scroll (Shift for sideways),
|
- **Moving around:** drag the felt to pan, use the mouse wheel to scroll (Shift for sideways),
|
||||||
Ctrl+wheel or pinch to zoom, and **Fit** to see every table. Zoom goes out far enough
|
Ctrl+wheel or pinch to zoom. The zoom control (**− 90% ▾ +**) steps the zoom, and its
|
||||||
|
percentage opens **Fit board** (every table), **Zoom to 100%** and the minimap. Zoom goes out far enough
|
||||||
(8%) to fit a board of several hundred cards; that far out, cards show as plain cards with
|
(8%) to fit a board of several hundred cards; that far out, cards show as plain cards with
|
||||||
their title line and group names are written large.
|
their title line and group names are written large.
|
||||||
- **Search** (top bar, or **Ctrl+F**) finds cards by name, result text, details, choice
|
- **Search** (top bar, or **Ctrl+F**) finds cards by name, result text, details, choice
|
||||||
|
|
@ -102,10 +109,10 @@ godot --path .
|
||||||
result, Enter or a click jumps to it, Esc closes. Jumping opens the card's group if it's
|
result, Enter or a click jumps to it, Esc closes. Jumping opens the card's group if it's
|
||||||
collapsed (and says so), scrolls a long list to the result, centres the card at a readable
|
collapsed (and says so), scrolls a long list to the result, centres the card at a readable
|
||||||
zoom and flashes a ring around it.
|
zoom and flashes a ring around it.
|
||||||
- **Map** (beside Fit, or **M**) shows an overview in the corner: groups, cards, lit cards in
|
- **The minimap** (View ▾, the zoom menu, or **M**) shows an overview in the corner: groups, cards, lit cards in
|
||||||
brass and the part in view. Click or drag on it to move there. It starts off in Play and
|
brass and the part in view. Click or drag on it to move there. It starts off in Play and
|
||||||
on in Build; the choice is remembered for each mode.
|
on in Build; the choice is remembered for each mode.
|
||||||
- **Arrange ▾ → Pack collapsed groups** (Build) moves collapsed groups, and the cards and
|
- **Board ▾ → Pack collapsed groups** (Build) moves collapsed groups, and the cards and
|
||||||
open groups between them, together to close the gaps collapsed blocks leave, keeping
|
open groups between them, together to close the gaps collapsed blocks leave, keeping
|
||||||
their order left to right and top to bottom (undo from the toast). Expanding a group
|
their order left to right and top to bottom (undo from the toast). Expanding a group
|
||||||
whose frame would now cover its neighbours shifts the blocks to its right further right
|
whose frame would now cover its neighbours shifts the blocks to its right further right
|
||||||
|
|
@ -160,7 +167,8 @@ tools/test_window.sh -- --screenshot=/tmp/board.png [--build] [--expand-all] [--
|
||||||
```
|
```
|
||||||
|
|
||||||
Logic-card views: `--board=examples/logic_demo.json --roll=start "--answers=Brin|3"` answers
|
Logic-card views: `--board=examples/logic_demo.json --roll=start "--answers=Brin|3"` answers
|
||||||
the first questions and leaves the next pop-up open; `--menu=add`, `--open-settings=<id>`,
|
the first questions and leaves the next pop-up open; `--menu=add|board|collections|view|help|zoom|card`
|
||||||
|
(card: the first card's ⋯ menu, with `--build`), `--help[=<topic>]`, `--open-settings=<id>`,
|
||||||
`--demo-long=<n>` (a chain of n steps) and `--confirm-reset` show the
|
`--demo-long=<n>` (a chain of n steps) and `--confirm-reset` show the
|
||||||
rest.
|
rest.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
class_name SampleBoard
|
class_name SampleBoard
|
||||||
extends RefCounted
|
extends RefCounted
|
||||||
## The example board: road encounters, loot chains, a d100 ranged travel table
|
## The example board: road encounters, loot chains, a d100 ranged travel table,
|
||||||
## and a d100 table of 100 unique trinkets.
|
## a d100 table of 100 unique trinkets, a card-mode deck (Party Roles), and a
|
||||||
|
## camp corner showing a pick choice (Make Camp), a value card (Luck) and a
|
||||||
|
## table whose end results only a roll modifier reaches (Search the Ruins).
|
||||||
|
|
||||||
const TRINKETS := [
|
const TRINKETS := [
|
||||||
"A brass key that's warm to the touch", "A glass eye that follows movement", "A tin whistle only dogs can hear", "A pressed flower that never wilts",
|
"A brass key that's warm to the touch", "A glass eye that follows movement", "A tin whistle only dogs can hear", "A pressed flower that never wilts",
|
||||||
|
|
@ -107,4 +109,54 @@ static func create() -> TowerBoard:
|
||||||
e.weight = int(row[3].get("weight", 1))
|
e.weight = int(row[3].get("weight", 1))
|
||||||
t.entries.append(e)
|
t.entries.append(e)
|
||||||
board.tables.append(t)
|
board.tables.append(t)
|
||||||
|
_add_camp(board)
|
||||||
return board
|
return board
|
||||||
|
|
||||||
|
|
||||||
|
## Make Camp (a pick choice that changes Luck or goes searching), the Luck value
|
||||||
|
## card, and Search the Ruins: 1d6 + Luck, whose first and last results the
|
||||||
|
## dice alone can't reach.
|
||||||
|
static func _add_camp(board: TowerBoard) -> void:
|
||||||
|
var luck := RollTable.create(RollTable.KIND_VARIABLE, "luck", "Luck")
|
||||||
|
luck.position = Vector2(1090, 800)
|
||||||
|
luck.details = "The party's luck. Make Camp raises or lowers it, and Search the Ruins adds it to the roll."
|
||||||
|
board.tables.append(luck)
|
||||||
|
|
||||||
|
var camp := RollTable.create(RollTable.KIND_CHOICE, "make_camp", "Make Camp", "pick")
|
||||||
|
camp.position = Vector2(1440, 800)
|
||||||
|
camp.prompt = "Night falls. Your Luck is {@luck}. How does the party spend the evening?"
|
||||||
|
camp.details = "A [b]pick[/b] card: the roll stops and asks which option, or picks one at Random."
|
||||||
|
camp.entries.clear()
|
||||||
|
for row in [
|
||||||
|
["Pray at the roadside shrine", "@luck += 1", ""],
|
||||||
|
["Gamble with the caravan guards", "@luck -= 1", ""],
|
||||||
|
["Search the old ruins", "", "ruins"],
|
||||||
|
["Keep watch and rest", "", ""],
|
||||||
|
]:
|
||||||
|
var e := TableEntry.new(TowerBoard.new_id("e"), row[0])
|
||||||
|
e.effects = row[1]
|
||||||
|
if row[2] != "":
|
||||||
|
e.add_pipe(row[2])
|
||||||
|
camp.entries.append(e)
|
||||||
|
board.tables.append(camp)
|
||||||
|
|
||||||
|
var ruins := RollTable.new("ruins", "Search the Ruins")
|
||||||
|
ruins.position = Vector2(1790, 800)
|
||||||
|
ruins.dice = "1d6"
|
||||||
|
ruins.dice_mod = "@luck"
|
||||||
|
ruins.details = "Roll [b]1d6 + Luck[/b]. Only bad luck reaches the cave-in, and only good luck finds the vault."
|
||||||
|
# Inline [[references]] rather than pipes: Loot and the trinkets are far
|
||||||
|
# away on the board.
|
||||||
|
for row in [
|
||||||
|
["A tunnel caves in behind you", -1, 0],
|
||||||
|
["Dust and old bones", 1, 2],
|
||||||
|
["A few tarnished coins", 3, 4],
|
||||||
|
["Something glints in the rubble: [[Loot]]", 5, 6],
|
||||||
|
["A hidden vault holding [[Curious Trinkets]]", 7, 8],
|
||||||
|
]:
|
||||||
|
var e := TableEntry.new(TowerBoard.new_id("e"), row[0])
|
||||||
|
e.has_range = true
|
||||||
|
e.range_lo = row[1]
|
||||||
|
e.range_hi = row[2]
|
||||||
|
ruins.entries.append(e)
|
||||||
|
board.tables.append(ruins)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# TableTower — Design and Status
|
# TableTower — Design and Status
|
||||||
|
|
||||||
**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-09 (roll modifiers, resizable tray and inspector; see §10)
|
**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-09 (UI pass: striped rows, View/Help menus, card ⋯ menu, a fuller sample; see §10)
|
||||||
|
|
||||||
This is the starting point for anyone picking the project up, including a new Claude
|
This is the starting point for anyone picking the project up, including a new Claude
|
||||||
session. It records what TableTower is, how it's built, how to work on it, where things
|
session. It records what TableTower is, how it's built, how to work on it, where things
|
||||||
|
|
@ -21,12 +21,30 @@ stand, and what's next.
|
||||||
- **Needed from the user:** that exact username, plus an API token (repository read/write
|
- **Needed from the user:** that exact username, plus an API token (repository read/write
|
||||||
and user read, passed as `FORGEJO_TOKEN`), or they do it in the web UI themselves.
|
and user read, passed as `FORGEJO_TOKEN`), or they do it in the web UI themselves.
|
||||||
- Don't go looking for stored credentials.
|
- Don't go looking for stored credentials.
|
||||||
- **Hands-on playtest, then fix what feels wrong.** On `main` and not yet tried by hand:
|
- **Card Mode needs a UI redesign (user request, 2026-11-09).** Card mode works, but its
|
||||||
- Roll modifiers: build a 1d20 + Luck table from −3 to 24 in the inspector, check that the
|
controls need rethinking when we get to it:
|
||||||
chances move as Luck changes, roll it, and read Why this?.
|
- It's switched on deep in Table settings… (an Off/On switch plus "When the deck runs out").
|
||||||
- The resizable tray and inspector: drag both edges, double-click to reset, restart the app to
|
- The deck state is a small "4 / 6 left · ↻ Reshuffle" line under the card's name.
|
||||||
check the sizes are kept, and fill Earlier with long rolls to check it scrolls.
|
Start with a mockup, as for the UI pass, before changing code. The sample's Party Roles is
|
||||||
- The terminology pass (the file splits had a first look: "looking fine so far").
|
the card-mode example. Undecided: where the switch lives, how a dealt result looks on the card,
|
||||||
|
and how "deck empty" shows.
|
||||||
|
- **Hands-on playtest, then fix what feels wrong.** On `main`:
|
||||||
|
- The UI pass had a first look from the user ("looks fine for now"), but not every part was
|
||||||
|
tried: striped rows, View ▾ (Plain/Text moved here), the zoom control, Help ▾ / F1, the card
|
||||||
|
⋯ menu and the row × that shows on hover. In the sample, pray at Make Camp's shrine and search
|
||||||
|
the ruins until the vault turns up. An existing Fantasy Loot collection only gets the new
|
||||||
|
cards after Board ▾ → Reset sample.
|
||||||
|
- Not yet tried by hand:
|
||||||
|
- Roll modifiers: build a 1d20 + Luck table from −3 to 24 in the inspector, check that the
|
||||||
|
chances move as Luck changes, roll it, and read Why this?.
|
||||||
|
- The resizable tray and inspector: drag both edges, double-click to reset, restart the app to
|
||||||
|
check the sizes are kept, and fill Earlier with long rolls to check it scrolls.
|
||||||
|
- The terminology pass (the file splits had a first look: "looking fine so far").
|
||||||
|
- **Suggested test audit: script errors can still pass.** A suite whose test function crashes
|
||||||
|
(SCRIPT ERROR) skips the rest of that function but can still print `PASS: 0 failure(s)`.
|
||||||
|
test_groups and test_navigation did this during the UI pass. Fix: treat any SCRIPT ERROR in
|
||||||
|
a suite's output as a failure, for example in a small `tools/run_tests.sh` that runs the suites
|
||||||
|
in parallel (about 15 s) and checks both.
|
||||||
- **Suggested next: a size audit of `core/describe.gd`** (731 lines, now the largest file). Split
|
- **Suggested next: a size audit of `core/describe.gd`** (731 lines, now the largest file). Split
|
||||||
it by area (labels, effects/conditions, cards, why) with one-line delegators, as for main.gd.
|
it by area (labels, effects/conditions, cards, why) with one-line delegators, as for main.gd.
|
||||||
The other files over ~530 lines are listed in §3 under "Keep files small".
|
The other files over ~530 lines are listed in §3 under "Keep files small".
|
||||||
|
|
@ -62,7 +80,15 @@ character, can run as one chain.
|
||||||
- **Cards and pipes.** Cards show their numbered results and a die button. Drag from a
|
- **Cards and pipes.** Cards show their numbered results and a die button. Drag from a
|
||||||
result's ● onto another card to lay a pipe.
|
result's ● onto another card to lay a pipe.
|
||||||
- **Rolling.** Results flicker and land, and a bead travels each pipe. **Shift-click** fast-rolls with no animation.
|
- **Rolling.** Results flicker and land, and a bead travels each pipe. **Shift-click** fast-rolls with no animation.
|
||||||
- **Play / Build modes.** Collapse a card or **Collapse all**. Pan, zoom (8%–150%), **Fit** and a minimap (**Map**).
|
- **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).
|
||||||
|
- **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 ▾
|
||||||
|
and Board ▾ (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
|
||||||
|
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,
|
||||||
|
see `HelpDialog`), included in exports via the preset's include filter.
|
||||||
- **Table types.** Weighted plain tables, ranged dice tables (`1d100`, `2d6`, any
|
- **Table types.** Weighted plain tables, ranged dice tables (`1d100`, `2d6`, any
|
||||||
expression such as `2d6 + dm(@str)`), and card mode (a deck with no repeats, with Reshuffle).
|
expression such as `2d6 + dm(@str)`), and card mode (a deck with no repeats, with Reshuffle).
|
||||||
- **Roll modifiers** (`dice_mod`, LOGIC.md §3c). A ranged table adds a modifier such as `@luck` to
|
- **Roll modifiers** (`dice_mod`, LOGIC.md §3c). A ranged table adds a modifier such as `@luck` to
|
||||||
|
|
@ -100,13 +126,15 @@ character, can run as one chain.
|
||||||
- kind-specific card fields
|
- kind-specific card fields
|
||||||
- a value picker with "+ New value…"
|
- a value picker with "+ New value…"
|
||||||
- "Edit as text" everywhere
|
- "Edit as text" everywhere
|
||||||
- **Plain / Text switch** in the top bar.
|
- **Plain / Text** in View ▾ → Rules.
|
||||||
|
- **Card ⋯ menu** (Build): Table settings…, Save as template…, Collapse, Delete table. A row's ×
|
||||||
|
shows only on hover, keyboard focus or when the row is selected.
|
||||||
- **Undo/redo** (Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y, or ↶ ↷) for every board edit. Typing and dragging merge into one step.
|
- **Undo/redo** (Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y, or ↶ ↷) for every board edit. Typing and dragging merge into one step.
|
||||||
- Collapse/expand isn't undoable.
|
- Collapse/expand isn't undoable.
|
||||||
- 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. Arrange ▾ → Pack collapsed groups.
|
select, Ctrl+G to group, then drag cards in or out, rename, ungroup or delete. Board ▾ → 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/`:
|
"+ Card ▾ → From template…". 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
|
||||||
|
|
@ -148,8 +176,9 @@ ui/ main.gd: the app shell (shared fields, _ready, cards, collapse, inpu
|
||||||
delegators to RefCounted helpers that hold `m: Main`:
|
delegators to RefCounted helpers that hold `m: Main`:
|
||||||
main_cli (every CLI/screenshot flag), main_rolling, main_editing, main_groups,
|
main_cli (every CLI/screenshot flag), main_rolling, main_editing, main_groups,
|
||||||
main_history (undo), main_navigation (search/focus/minimap/arrange),
|
main_history (undo), main_navigation (search/focus/minimap/arrange),
|
||||||
main_top_bar (bar, toast, rules switch), main_state (decks, variables),
|
main_top_bar (bar, toast, endless-loop chip), main_state (decks, variables),
|
||||||
main_collections, main_templates, main_inspector
|
main_collections, main_templates, main_inspector
|
||||||
|
top bar parts: view_menu (View ▾), zoom_control, help_menu + help_dialog
|
||||||
table_card.gd + table_card_{header,rows,editing,value,text}.gd
|
table_card.gd + table_card_{header,rows,editing,value,text}.gd
|
||||||
result_tray.gd + tray_chips, tray_text, earlier_rolls
|
result_tray.gd + tray_chips, tray_text, earlier_rolls
|
||||||
table_settings_dialog.gd + table_settings_rules (validation/apply), settings_kind_fields
|
table_settings_dialog.gd + table_settings_rules (validation/apply), settings_kind_fields
|
||||||
|
|
@ -159,8 +188,9 @@ ui/ main.gd: the app shell (shared fields, _ready, cards, collapse, inpu
|
||||||
why_popover, choice_dialog, table_preview, details_popup, inspector*, value_picker,
|
why_popover, choice_dialog, table_preview, details_popup, inspector*, value_picker,
|
||||||
rules_view, search_panel, board_search, board_layout, edit_history, test_board_dialog,
|
rules_view, search_panel, board_search, board_layout, edit_history, test_board_dialog,
|
||||||
template_*, io_menu, collection_switcher, variables_panel, modal_card, rich_text, style
|
template_*, io_menu, collection_switcher, variables_panel, modal_card, rich_text, style
|
||||||
|
help/ topics.txt: the Help window's text (# Title per topic)
|
||||||
tools/ simulate_board.gd (headless simulator CLI), test_window.sh (background test windows)
|
tools/ simulate_board.gd (headless simulator CLI), test_window.sh (background test windows)
|
||||||
tests/ test_*.gd: 26 headless suites
|
tests/ test_*.gd: 27 headless suites
|
||||||
templates/ built-in templates · examples/logic_demo.json (original demo board) · assets/fonts (OFL)
|
templates/ built-in templates · examples/logic_demo.json (original demo board) · assets/fonts (OFL)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -185,7 +215,7 @@ templates/ built-in templates · examples/logic_demo.json (original demo board)
|
||||||
name, tables, groups?}`). On Linux that's `~/.local/share/godot/app_userdata/TableTower/`.
|
name, tables, groups?}`). On Linux that's `~/.local/share/godot/app_userdata/TableTower/`.
|
||||||
- **Local state** (never exported): `user://state/state.json` holds decks, board
|
- **Local state** (never exported): `user://state/state.json` holds decks, board
|
||||||
variables, history (cap 50) and settings (`last_collection`, minimap, inspector collapsed,
|
variables, history (cap 50) and settings (`last_collection`, minimap, inspector collapsed,
|
||||||
`rules_view`). Templates live in `user://templates/`.
|
`rules_view`, `striped_rows`). Templates live in `user://templates/`.
|
||||||
- **Installed collections today:** `my-tables` (migrated from the old `board.json`, backed
|
- **Installed collections today:** `my-tables` (migrated from the old `board.json`, backed
|
||||||
up as `board.json.bak`) and `traveller-chargen`. Backups of earlier Traveller boards are
|
up as `board.json.bak`) and `traveller-chargen`. Backups of earlier Traveller boards are
|
||||||
`traveller-chargen.before-*.json.bak` in the app data folder.
|
`traveller-chargen.before-*.json.bak` in the app data folder.
|
||||||
|
|
@ -249,6 +279,12 @@ templates/ built-in templates · examples/logic_demo.json (original demo board)
|
||||||
- **Panel resizing** uses a small drag handle (`PanelSplitter`) rather than Godot's
|
- **Panel resizing** uses a small drag handle (`PanelSplitter`) rather than Godot's
|
||||||
`SplitContainer`. The tray used to size itself to its content and the inspector collapses to a
|
`SplitContainer`. The tray used to size itself to its content and the inspector collapses to a
|
||||||
strip, and a handle that sets the panel's size fits both without changing the layout.
|
strip, and a handle that sets the panel's size fits both without changing the layout.
|
||||||
|
- **UI pass (2026-11-09).** View preferences (rules view, collapse all, stripes, minimap) live in
|
||||||
|
View ▾ rather than on the bar; Plain/Text is one click further away, which the user accepted.
|
||||||
|
The card ⋯ menu shares `Style.overflow_button` with the group card's ⋯. Stripes use the
|
||||||
|
"parchment" tint picked from a mockup (felt tint and hairline were the other options). The
|
||||||
|
sample's Search the Ruins uses `[[refs]]` rather than pipes, because Loot and the trinkets are
|
||||||
|
far across the board. Card mode already existed (Party Roles) and needed no new work.
|
||||||
- **Terminology (2026-11-09).** UI text uses these words; code and JSON keys keep their old names.
|
- **Terminology (2026-11-09).** UI text uses these words; code and JSON keys keep their old names.
|
||||||
- **Card:** anything on the felt. "Roll table" means only the `roll` kind.
|
- **Card:** anything on the felt. "Roll table" means only the `roll` kind.
|
||||||
- **Result**, never "entry" or "row" (code: `TableEntry`, `entries`).
|
- **Result**, never "entry" or "row" (code: `TableEntry`, `entries`).
|
||||||
|
|
@ -382,3 +418,11 @@ templates/ built-in templates · examples/logic_demo.json (original demo board)
|
||||||
cards. The demo's Room check uses 2d6 + Luck and has a vault only luck reaches.
|
cards. The demo's Room check uses 2d6 + Luck and has a vault only luck reaches.
|
||||||
12. Resizable tray (top edge) and inspector (left edge). The Earlier tab scrolls, and the tray no
|
12. Resizable tray (top edge) and inspector (left edge). The Earlier tab scrolls, and the tray no
|
||||||
longer grows with long Earlier rolls, sheets or chains.
|
longer grows with long Earlier rolls, sheets or chains.
|
||||||
|
|
||||||
|
**2026-11-09: UI pass** (merged to `main`)
|
||||||
|
13. From an HTML mockup: striped result rows; View ▾ (Plain/Text, Collapse all, Striped rows,
|
||||||
|
Minimap) and the zoom control replace the Plain|Text switch, Collapse all, −/Fit/+ and Map;
|
||||||
|
Arrange ▾ folded into Board ▾; Search is an icon. Help ▾ and F1 open a Help window with
|
||||||
|
17 topics. Build cards get a ⋯ menu instead of the gear and footer Delete, and row × buttons
|
||||||
|
show on hover. The sample gained Luck, Make Camp (a pick card) and Search the Ruins (1d6 + Luck,
|
||||||
|
with a cave-in and a vault only a modifier reaches). New suite: test_top_bar.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ runnable=true
|
||||||
dedicated_server=false
|
dedicated_server=false
|
||||||
custom_features=""
|
custom_features=""
|
||||||
export_filter="all_resources"
|
export_filter="all_resources"
|
||||||
include_filter="templates/*.json"
|
include_filter="templates/*.json, help/*.txt"
|
||||||
exclude_filter="tests/*"
|
exclude_filter="tests/*"
|
||||||
export_path="build/linux/TableTower.x86_64"
|
export_path="build/linux/TableTower.x86_64"
|
||||||
encryption_include_filters=""
|
encryption_include_filters=""
|
||||||
|
|
|
||||||
192
help/topics.txt
Normal file
192
help/topics.txt
Normal file
|
|
@ -0,0 +1,192 @@
|
||||||
|
# Getting started
|
||||||
|
TableTower holds [b]random tables[/b] for tabletop games. Each table is a card on the felt. Cards are joined by copper [b]pipes[/b], so one roll can lead on to the next: a travel roll finds a stranger, and the stranger gets a name.
|
||||||
|
|
||||||
|
## Two modes
|
||||||
|
- [b]Play[/b] is for the game table. Click a die to roll, and read the result in the tray at the bottom.
|
||||||
|
- [b]Build[/b] is for making and changing tables. Click a card, a result or a pipe to edit it in the inspector on the right.
|
||||||
|
|
||||||
|
Switch between them with [b]Play | Build[/b] at the top left. Everything you build is saved as you go.
|
||||||
|
|
||||||
|
## Try the sample
|
||||||
|
The Fantasy Loot collection shows most features:
|
||||||
|
- [b]Wilderness Travel[/b] is a d100 table whose results pipe into other tables.
|
||||||
|
- [b]Party Roles[/b] deals each role once until the deck is reshuffled ([topic]Card mode[/topic]).
|
||||||
|
- [b]Make Camp[/b] asks you to pick what the party does ([topic]Choice cards[/topic]).
|
||||||
|
- [b]Search the Ruins[/b] adds your [b]Luck[/b] to the roll, and two of its results can only be reached with good or bad luck ([topic]Roll modifiers[/topic]).
|
||||||
|
|
||||||
|
# Rolling
|
||||||
|
Click the die button on a card to roll it. The results flicker, one lands and lights up in brass, and the roll follows any pipes from that result to other cards.
|
||||||
|
- [b]Shift-click[/b] the die to skip the animation.
|
||||||
|
- Hover a result to read its details. A small ⓘ after a card's name means the card has details too.
|
||||||
|
- On a ranged card, the percentage beside each result is its chance right now.
|
||||||
|
|
||||||
|
Some cards stop and ask you something before the roll goes on. See [topic]Choice cards[/topic].
|
||||||
|
|
||||||
|
# The result tray
|
||||||
|
The tray at the bottom of the window shows the last roll as a row of steps, one per card the roll passed through.
|
||||||
|
- [b]Why this?[/b] on a step explains it in plain words: what was rolled, any modifier, and why the roll went where it did.
|
||||||
|
- [b]Roll again[/b] repeats the last roll.
|
||||||
|
- [b]Copy ▾[/b] copies the result as plain text, as BBCode for forums, or with the details of each step.
|
||||||
|
- [b]Earlier[/b] lists your recent rolls. [b]Variables[/b] lists the values the board remembers between rolls, such as Luck.
|
||||||
|
|
||||||
|
Drag the tray's top edge to make it taller or shorter. Double-click the edge to reset it.
|
||||||
|
|
||||||
|
# Building tables
|
||||||
|
Switch to [b]Build[/b] to edit.
|
||||||
|
- [b]+ Card ▾[/b] adds a new roll table or one of the logic cards.
|
||||||
|
- 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.
|
||||||
|
- Hover a row to show its [b]×[/b] delete button.
|
||||||
|
- The card's [b]⋯[/b] menu has Table settings, Save as template, Collapse and Delete table.
|
||||||
|
- Click a card's title, a result's text or a pipe to edit it in the [b]inspector[/b] on the right. Drag the inspector's left edge to resize it.
|
||||||
|
|
||||||
|
Every edit can be undone with [b]Ctrl+Z[/b] or the ↶ button, and redone with [b]Ctrl+Shift+Z[/b], [b]Ctrl+Y[/b] or ↷.
|
||||||
|
|
||||||
|
## Table settings
|
||||||
|
[b]Table settings…[/b] in the ⋯ menu sets the card's type, dice, details and tags, and turns on [topic]Card mode[/topic].
|
||||||
|
|
||||||
|
# Ranged tables and dice
|
||||||
|
A [b]ranged table[/b] gives each result a range of numbers instead of a weight, the way printed tables do: 01–30 Travelers on the road, 31–50 Beasts on the hunt, and so on.
|
||||||
|
- Set the dice in Table settings: `1d100`, `2d6`, `d20` or any expression.
|
||||||
|
- In Build mode each row has a from and a to box for its range.
|
||||||
|
- [b]Weather[/b] in the sample rolls `2d6`, so the middle results come up most often. The card shows each chance.
|
||||||
|
|
||||||
|
Dice can be written `2d6`, `d20`, `3D` or `D3`. A missing count means 1 and missing sides mean 6, so `2D` is 2d6. To add a value to the dice, use a [topic]Roll modifiers[/topic] modifier.
|
||||||
|
|
||||||
|
# Pipes
|
||||||
|
A pipe carries the roll from a result to another card.
|
||||||
|
- In Build mode, drag from the ● at the right of a result onto another card to lay a pipe.
|
||||||
|
- When that result is rolled, the card at the other end is rolled too. The pipes of a roll light up in brass.
|
||||||
|
- Click a pipe on the felt to edit it in the inspector.
|
||||||
|
|
||||||
|
## Pipe options
|
||||||
|
- [b]Count[/b] rolls the next card more than once. It can be a number or an expression such as `1d3`.
|
||||||
|
- [b]Save as[/b] keeps the next card's result under a name, so later text can show it as `{name}`.
|
||||||
|
- [b]Only if[/b] runs the pipe only when a condition is true, such as `@gold >= 10`.
|
||||||
|
- [b]Otherwise[/b] runs the pipe only when none of the result's Only if pipes ran.
|
||||||
|
- [b]Inputs[/b] pass values to a card that declares them.
|
||||||
|
|
||||||
|
# Roll modifiers
|
||||||
|
A ranged table can add a [b]modifier[/b] to its dice, for rules like "roll 1d20 and add your Luck".
|
||||||
|
- In Build mode, select the card and set the modifier in the inspector: [b]Add[/b] a value, [b]Subtract[/b] one, or write your own.
|
||||||
|
- [b]Ranges can go past the dice.[/b] A 1d6 table can have results for 0 or less and for 7 and up. Only a modifier reaches them, and their number's tooltip says so.
|
||||||
|
- Totals past either end count as the end result, so the top result also catches every higher total.
|
||||||
|
- The chances on the card follow the modifier's value as it is now.
|
||||||
|
|
||||||
|
## In the sample
|
||||||
|
[b]Search the Ruins[/b] rolls 1d6 + Luck. With no Luck you can't reach "A tunnel caves in" or "A hidden vault". Pray at the shrine in [b]Make Camp[/b] to raise your Luck, gamble with the guards to lower it, then search again and watch the chances move. Why this? on the step names the modifier: "+1 for Luck".
|
||||||
|
|
||||||
|
Card mode decks ignore the modifier.
|
||||||
|
|
||||||
|
# Card mode
|
||||||
|
[b]Card mode[/b] turns a table into a deck of cards. Each result is dealt once, with no repeats, until the deck runs out.
|
||||||
|
- Turn it on in [b]Table settings… → Card mode[/b].
|
||||||
|
- The card shows how many are left, for example [b]4 / 6 left[/b].
|
||||||
|
- [b]↻ Reshuffle[/b] under the card's name puts every card back.
|
||||||
|
- [b]When the deck runs out[/b] can reshuffle by itself or stop until you reshuffle.
|
||||||
|
|
||||||
|
[b]Party Roles[/b] in the sample is a deck: hand one role to each player, and nobody gets the same role twice until you reshuffle.
|
||||||
|
|
||||||
|
# Choice cards
|
||||||
|
A choice card stops the roll and asks the player. Add one from [b]+ Card ▾[/b].
|
||||||
|
- [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 pipes follow.
|
||||||
|
- [b]How many[/b] asks for a number between a lowest and highest value.
|
||||||
|
- [b]Open ended[/b] asks for any text.
|
||||||
|
|
||||||
|
The question can show values, such as "Your Luck is {@luck}. What now?". Answers can be saved under a name for later. [b]Cancel[/b] in the pop-up stops the whole roll, and the pop-up can be minimized to look at the board first.
|
||||||
|
|
||||||
|
## Options that come and go
|
||||||
|
An option can have [b]Show only if[/b], so it's offered only when a condition is true, such as `@gold >= 10`. A Which option card can also build its options from a collection of values, such as every skill the character has.
|
||||||
|
|
||||||
|
[b]Make Camp[/b] in the sample is a Which option card.
|
||||||
|
|
||||||
|
# Values and changes
|
||||||
|
A board can remember [b]values[/b] between rolls, such as Luck, Gold or the current town. In rules a value is written with @: `@luck`.
|
||||||
|
- Any result can have [b]changes[/b] that happen when it comes up: [b]Add 1 to Luck[/b], [b]Subtract 3 from Gold[/b], [b]Set Town to …[/b]. Edit them in the inspector as rows, or with Edit as text.
|
||||||
|
- A [b]Variable[/b] card gives a value a name, a type and a starting value, and shows what it is now. The sample's [b]Luck[/b] card starts at 0.
|
||||||
|
- A [b]Collection[/b] card groups related values, such as Skills, so they can be listed and picked from together.
|
||||||
|
- The tray's [b]Variables[/b] tab shows every value, and lets you clear or reset them. [b]Reset all…[/b] puts every value back to its start.
|
||||||
|
|
||||||
|
## Writing changes as text
|
||||||
|
- `@luck += 1` adds, `@luck -= 1` subtracts and `@gold = 2d6` sets.
|
||||||
|
- `reset @luck` goes back to the starting value. `reset @skill_*` resets every value starting with skill_.
|
||||||
|
- Text values work as lists: `@traits += "Brave"` adds an item.
|
||||||
|
|
||||||
|
## Conditions
|
||||||
|
Conditions are used by Only if pipes, routers, loops and Show only if. In plain words they read "Luck is at least 2". As text: `@luck >= 2`, `@town = "Saltmere"`, `@gold > 0 and @luck < 3`.
|
||||||
|
|
||||||
|
# Logic cards
|
||||||
|
Besides roll tables and choices, [b]+ Card ▾[/b] 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]Loop[/b]: repeats its Each time result a number of times, or while or until a condition holds, then runs Afterwards once.
|
||||||
|
- [b]Router[/b]: checks its cases from top to bottom (if, else if, otherwise) and follows the first one that's true.
|
||||||
|
- [b]Sheet[/b]: a page of text, such as a character sheet, that always shows the current values. A roll that reaches it prints it in the tray.
|
||||||
|
- [b]Variable[/b] and [b]Collection[/b]: see [topic]Values and changes[/topic].
|
||||||
|
|
||||||
|
Use [b]Test board[/b] to check that a board of logic cards works. See [topic]Testing a board[/topic].
|
||||||
|
|
||||||
|
# Text in results
|
||||||
|
Result text can do more than plain words:
|
||||||
|
- `[[Traveler Names]]` rolls that table and puts its result in the text.
|
||||||
|
- `[[Traveler Names -> patron]]` also saves it as patron, so later text can say `{patron}`.
|
||||||
|
- `{@town}` shows a value. `{@town|Towns}` shows it, or rolls Towns once and remembers the answer if it isn't set yet.
|
||||||
|
- `{= @gold * 2}` shows a worked-out number.
|
||||||
|
- Formatting: `[b]bold[/b]` and `[i]italic[/i]`.
|
||||||
|
|
||||||
|
[b]Quest Hooks[/b] in the sample uses all of these.
|
||||||
|
|
||||||
|
# Groups and templates
|
||||||
|
## Groups
|
||||||
|
- Ctrl-click or Shift-click cards to select several, or Ctrl-drag a box around them.
|
||||||
|
- Press [b]Ctrl+G[/b] to put them in a group: a frame that moves and collapses as one.
|
||||||
|
- Drag cards into or out of a group. The group's ⋯ menu renames, saves as a template, ungroups or deletes it.
|
||||||
|
- [b]Board ▾ → Pack collapsed groups[/b] moves collapsed groups together to close the gaps.
|
||||||
|
|
||||||
|
## Templates
|
||||||
|
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.
|
||||||
|
- Insert one from [b]+ Card ▾ → From template…[/b].
|
||||||
|
- Built-in templates include a skill check, ask-and-repeat, a pick menu, a counter and a simple sheet.
|
||||||
|
|
||||||
|
# Collections, import and export
|
||||||
|
A [b]collection[/b] is one board of tables. Use the switcher beside Play | Build (it shows the collection's name) to switch, or to make a new collection, rename, duplicate or delete one.
|
||||||
|
|
||||||
|
In Build mode, [b]Board ▾[/b] has:
|
||||||
|
- [b]Import as new collection…[/b] for TableTower JSON, JSON Canvas and GraphML files.
|
||||||
|
- [b]Export as…[/b] TableTower JSON, JSON Canvas, GraphML, a Mermaid diagram or Graphviz DOT.
|
||||||
|
|
||||||
|
Exports hold the tables only. Your roll history, decks and remembered values stay on this computer.
|
||||||
|
|
||||||
|
# Testing a board
|
||||||
|
[b]Board ▾ → Test board…[/b] rolls a card hundreds of times, answering every question at random, and reports:
|
||||||
|
- errors, such as a rule that can't be worked out
|
||||||
|
- dead ends, where a roll stops unexpectedly
|
||||||
|
- cards and results that never came up
|
||||||
|
- tips, such as an option that can never be offered
|
||||||
|
|
||||||
|
Click any item in the report to jump to that card. A board that can loop forever shows a warning in the top bar while you build.
|
||||||
|
|
||||||
|
# Finding your way
|
||||||
|
- [b]Search[/b] (the magnifier, or [b]Ctrl+F[/b]) finds cards by name, result, question, value or group, opens closed groups and flashes the card.
|
||||||
|
- Drag the felt to move around. The mouse wheel scrolls up and down, [b]Shift+wheel[/b] scrolls sideways and [b]Ctrl+wheel[/b] zooms.
|
||||||
|
- The zoom control at the top right shows the zoom. − and + step it, and the percentage opens [b]Fit board[/b], [b]Zoom to 100%[/b] and the minimap.
|
||||||
|
- The [b]minimap[/b] (press [b]M[/b]) shows the whole board in the corner. Click or drag on it to move there.
|
||||||
|
|
||||||
|
## The View menu
|
||||||
|
- [b]Rules[/b]: show rules in [b]Plain words[/b] ("Subtract 1 from Luck") or as [b]Rule text[/b] (`@luck -= 1`).
|
||||||
|
- [b]Collapse all tables[/b] or [b]Expand all tables[/b].
|
||||||
|
- [b]Striped rows[/b] shades every second result row, so long tables are easier to read across.
|
||||||
|
- [b]Minimap[/b].
|
||||||
|
|
||||||
|
# Keyboard shortcuts
|
||||||
|
- [b]F1[/b]: this help
|
||||||
|
- [b]Shift-click[/b] a die: roll without the animation
|
||||||
|
- [b]Ctrl+F[/b]: search
|
||||||
|
- [b]M[/b]: show or hide the minimap
|
||||||
|
- [b]Ctrl+wheel[/b]: zoom. [b]Shift+wheel[/b]: scroll sideways
|
||||||
|
- [b]Ctrl+Z[/b]: undo
|
||||||
|
- [b]Ctrl+Shift+Z[/b] or [b]Ctrl+Y[/b]: redo
|
||||||
|
- [b]Ctrl+G[/b]: group the selected cards
|
||||||
|
- [b]Ctrl-click[/b], [b]Shift-click[/b] or [b]Ctrl-drag[/b]: select several cards
|
||||||
|
- [b]Esc[/b]: clear the selection, or close a window
|
||||||
|
- Double-click the tray's or the inspector's edge: reset its size
|
||||||
|
|
@ -297,7 +297,7 @@ func _test_collapse_all_and_fit() -> void:
|
||||||
main.set_all_collapsed(true)
|
main.set_all_collapsed(true)
|
||||||
await process_frame
|
await process_frame
|
||||||
_check(g.collapsed and not _shown("a"), "Collapse all collapses groups too")
|
_check(g.collapsed and not _shown("a"), "Collapse all collapses groups too")
|
||||||
_check(main.top_bar._collapse_all.text == "Expand all", "the button then offers Expand all")
|
_check(main.top_bar.view_menu.collapse_label() == "Expand all tables", "View ▾ then offers Expand all tables")
|
||||||
# Fit ignores hidden members: move one far away; the bounds don't reach it.
|
# Fit ignores hidden members: move one far away; the bounds don't reach it.
|
||||||
main.data.get_table("a").position = Vector2(30000, 30000)
|
main.data.get_table("a").position = Vector2(30000, 30000)
|
||||||
var bounds := main.board.content_bounds()
|
var bounds := main.board.content_bounds()
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ func _test_selection() -> void:
|
||||||
main.open_pipe_options("beyond:e2>curios", Vector2(10, 10))
|
main.open_pipe_options("beyond:e2>curios", Vector2(10, 10))
|
||||||
_eq(insp.selection.get("to"), "curios", "clicking a pipe in Build selects it in the inspector")
|
_eq(insp.selection.get("to"), "curios", "clicking a pipe in Build selects it in the inspector")
|
||||||
main.request_table_settings("loot")
|
main.request_table_settings("loot")
|
||||||
_eq(insp.selection, {"kind": "card", "tid": "loot"}, "the card's ⚙ selects the card")
|
_eq(insp.selection, {"kind": "card", "tid": "loot"}, "Table settings… selects the card")
|
||||||
main.select_result("beyond", "nope")
|
main.select_result("beyond", "nope")
|
||||||
_eq(insp.selection.get("tid"), "loot", "a missing result isn't selected")
|
_eq(insp.selection.get("tid"), "loot", "a missing result isn't selected")
|
||||||
main.set_mode(Main.Mode.PLAY)
|
main.set_mode(Main.Mode.PLAY)
|
||||||
|
|
@ -453,8 +453,8 @@ func _test_rules_view() -> void:
|
||||||
_eq(got.size(), 1, "setting the same view again doesn't fire")
|
_eq(got.size(), 1, "setting the same view again doesn't fire")
|
||||||
main.set_rules_view("bogus")
|
main.set_rules_view("bogus")
|
||||||
_eq(main.rules_view(), "text", "unknown views are ignored")
|
_eq(main.rules_view(), "text", "unknown views are ignored")
|
||||||
main.top_bar._rules_buttons[0].pressed.emit()
|
main.top_bar.view_menu.activate(ViewMenu.ID_PLAIN)
|
||||||
_eq(main.rules_view(), "plain", "the top-bar switch sets it")
|
_eq(main.rules_view(), "plain", "View ▾ → Plain words sets it")
|
||||||
_check(not insp.effects.text_mode, "builders are back")
|
_check(not insp.effects.text_mode, "builders are back")
|
||||||
await _frames()
|
await _frames()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,8 @@ func _test_canvas() -> void:
|
||||||
|
|
||||||
var sample := SampleBoard.create().to_dict()
|
var sample := SampleBoard.create().to_dict()
|
||||||
var big := CanvasIO.import_canvas(CanvasIO.export_canvas(sample))
|
var big := CanvasIO.import_canvas(CanvasIO.export_canvas(sample))
|
||||||
_check(big["ok"] and big["collection"]["tables"] == JsonIO.canonical(sample)["tables"], "sample board survives a canvas round trip")
|
_check(big["ok"] and _plain_tables(big["collection"]["tables"], sample) == _plain_tables(JsonIO.canonical(sample)["tables"], sample),
|
||||||
|
"sample board's roll tables survive a canvas round trip (logic keys are JSON-only)")
|
||||||
|
|
||||||
|
|
||||||
func _test_canvas_stripped() -> void:
|
func _test_canvas_stripped() -> void:
|
||||||
|
|
@ -243,7 +244,8 @@ func _test_graphml() -> void:
|
||||||
_check(res["collection"] == JsonIO.canonical(small), "graphml round trip keeps everything")
|
_check(res["collection"] == JsonIO.canonical(small), "graphml round trip keeps everything")
|
||||||
var sample := SampleBoard.create().to_dict()
|
var sample := SampleBoard.create().to_dict()
|
||||||
var big := GraphMLIO.import_graphml(GraphMLIO.export_graphml(sample))
|
var big := GraphMLIO.import_graphml(GraphMLIO.export_graphml(sample))
|
||||||
_check(big["ok"] and big["collection"]["tables"] == JsonIO.canonical(sample)["tables"], "sample board survives a graphml round trip")
|
_check(big["ok"] and _plain_tables(big["collection"]["tables"], sample) == _plain_tables(JsonIO.canonical(sample)["tables"], sample),
|
||||||
|
"sample board's roll tables survive a graphml round trip (logic keys are JSON-only)")
|
||||||
|
|
||||||
# Foreign GraphML: nodes become tables, edges entries.
|
# Foreign GraphML: nodes become tables, edges entries.
|
||||||
var foreign := '<?xml version="1.0"?><graphml xmlns="http://graphml.graphdrawing.org/xmlns"><key id="d0" for="node" attr.name="name" attr.type="string"/><graph edgedefault="directed"><node id="a"><data key="d0">Alpha</data></node><node id="b"><data key="d0">Beta</data></node><edge source="a" target="b"/></graph></graphml>'
|
var foreign := '<?xml version="1.0"?><graphml xmlns="http://graphml.graphdrawing.org/xmlns"><key id="d0" for="node" attr.name="name" attr.type="string"/><graph edgedefault="directed"><node id="a"><data key="d0">Alpha</data></node><node id="b"><data key="d0">Beta</data></node><edge source="a" target="b"/></graph></graphml>'
|
||||||
|
|
@ -268,6 +270,19 @@ func _cleanup() -> void:
|
||||||
DirAccess.remove_absolute(TMP_DIR)
|
DirAccess.remove_absolute(TMP_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
## The tables of `tables` that are plain roll tables in `sample` (no kind,
|
||||||
|
## modifier or changes), since only TableTower JSON keeps logic keys.
|
||||||
|
func _plain_tables(tables: Array, sample: Dictionary) -> Array:
|
||||||
|
var plain := {}
|
||||||
|
for t: Dictionary in JsonIO.canonical(sample)["tables"]:
|
||||||
|
var logic := t.has("kind") or t.has("dice_mod")
|
||||||
|
for e: Dictionary in t["entries"]:
|
||||||
|
logic = logic or e.has("effects")
|
||||||
|
if not logic:
|
||||||
|
plain[t["id"]] = true
|
||||||
|
return tables.filter(func(t: Dictionary) -> bool: return plain.has(t["id"]))
|
||||||
|
|
||||||
|
|
||||||
func _check(ok: bool, what: String) -> void:
|
func _check(ok: bool, what: String) -> void:
|
||||||
if not ok:
|
if not ok:
|
||||||
_failures += 1
|
_failures += 1
|
||||||
|
|
|
||||||
|
|
@ -366,6 +366,15 @@ func _test_sample() -> void:
|
||||||
_check(w.dice == "2d6" and w.position == Vector2(1790, 380) and w.range_problems() == "", "Weather is a clean 2d6 table")
|
_check(w.dice == "2d6" and w.position == Vector2(1790, 380) and w.range_problems() == "", "Weather is a clean 2d6 table")
|
||||||
_check(s.get_table("monsters").entries[0].details != "" and s.get_table("wilderness").details != "", "sample has details")
|
_check(s.get_table("monsters").entries[0].details != "" and s.get_table("wilderness").details != "", "sample has details")
|
||||||
_check(s.get_table("wilderness").position == Vector2(40, 180) and s.get_table("quality").position == Vector2(1790, 130), "existing positions kept")
|
_check(s.get_table("wilderness").position == Vector2(40, 180) and s.get_table("quality").position == Vector2(1790, 130), "existing positions kept")
|
||||||
|
var camp := s.get_table("make_camp")
|
||||||
|
_check(camp.kind == RollTable.KIND_CHOICE and camp.choice == "pick" and camp.entries.size() == 4, "Make Camp is a 4-option pick card")
|
||||||
|
_check(camp.entries[0].effects == "@luck += 1" and camp.entries[2].pipes == ["ruins"], "its options change Luck or go searching")
|
||||||
|
var luck := s.get_table("luck")
|
||||||
|
_check(luck.kind == RollTable.KIND_VARIABLE and luck.var_name == "luck" and luck.initial == "0", "Luck is a value card starting at 0")
|
||||||
|
var ruins := s.get_table("ruins")
|
||||||
|
_check(ruins.dice_mod == "@luck" and ruins.range_problems() == "", "Search the Ruins is 1d6 + Luck with clean ranges")
|
||||||
|
var reach: Array = ruins.entries.map(func(e: TableEntry) -> bool: return RollRange.natural_reach(ruins, e))
|
||||||
|
_check(reach == [false, true, true, true, false], "only a modifier reaches its first and last results: %s" % str(reach))
|
||||||
|
|
||||||
|
|
||||||
func _check(ok: bool, what: String) -> void:
|
func _check(ok: bool, what: String) -> void:
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,9 @@ func _test_minimap() -> void:
|
||||||
var mm := main.board.minimap
|
var mm := main.board.minimap
|
||||||
main.nav.set_minimap_visible(true)
|
main.nav.set_minimap_visible(true)
|
||||||
await process_frame
|
await process_frame
|
||||||
_check(mm.visible and main.nav._map_toggle.button_pressed, "the minimap shows, and its toggle is on")
|
main.top_bar.view_menu.sync()
|
||||||
|
var view_pm := main.top_bar.view_menu.get_popup()
|
||||||
|
_check(mm.visible and view_pm.is_item_checked(view_pm.get_item_index(ViewMenu.ID_MINIMAP)), "the minimap shows, and View ▾ has it checked")
|
||||||
_check(mm.position.x + mm.size.x <= main.board.size.x and mm.position.y + mm.size.y <= main.board.size.y, "in the board's bottom-right corner")
|
_check(mm.position.x + mm.size.x <= main.board.size.x and mm.position.y + mm.size.y <= main.board.size.y, "in the board's bottom-right corner")
|
||||||
mm.set_world(Rect2(-100, -100, 4000, 2000))
|
mm.set_world(Rect2(-100, -100, 4000, 2000))
|
||||||
var p := Vector2(1234, 567)
|
var p := Vector2(1234, 567)
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,7 @@ func _test_app() -> void:
|
||||||
has_btn = true
|
has_btn = true
|
||||||
_press(sd, "Save as template…")
|
_press(sd, "Save as template…")
|
||||||
await process_frame
|
await process_frame
|
||||||
_check(has_btn and _top_modal() != null and _top_modal().title_label.text == "Save as template", "⚙ settings → Save as template opens the save dialog")
|
_check(has_btn and _top_modal() != null and _top_modal().title_label.text == "Save as template", "settings → Save as template opens the save dialog")
|
||||||
main.set_mode(Main.Mode.PLAY)
|
main.set_mode(Main.Mode.PLAY)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
166
tests/test_top_bar.gd
Normal file
166
tests/test_top_bar.gd
Normal file
|
|
@ -0,0 +1,166 @@
|
||||||
|
extends SceneTree
|
||||||
|
## The top bar's menus (View ▾, the zoom control, Board ▾ with Pack, Help ▾),
|
||||||
|
## 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.
|
||||||
|
## Run: godot --headless --path . -s res://tests/test_top_bar.gd -- --sample
|
||||||
|
|
||||||
|
var _failures := 0
|
||||||
|
var main: Main
|
||||||
|
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
if not OS.get_cmdline_user_args().has("--sample"):
|
||||||
|
print("Run with -- --sample so the test can't touch saved data.")
|
||||||
|
quit(2)
|
||||||
|
return
|
||||||
|
main = load("res://ui/main.tscn").instantiate()
|
||||||
|
root.add_child(main)
|
||||||
|
await _frames(5)
|
||||||
|
if main._saving_enabled:
|
||||||
|
print("Saving is enabled; refusing to run.")
|
||||||
|
quit(2)
|
||||||
|
return
|
||||||
|
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
|
||||||
|
main.size = Vector2(1440, 900)
|
||||||
|
_test_bar()
|
||||||
|
await _test_zoom()
|
||||||
|
await _test_view_menu()
|
||||||
|
await _test_stripes()
|
||||||
|
await _test_card_menu()
|
||||||
|
await _test_help()
|
||||||
|
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
|
||||||
|
quit(1 if _failures else 0)
|
||||||
|
|
||||||
|
|
||||||
|
func _test_bar() -> void:
|
||||||
|
var bar := main.top_bar
|
||||||
|
_check(bar.view_menu != null and bar.help_menu != null and bar.zoom != null, "View ▾, Help ▾ and the zoom control are on the bar")
|
||||||
|
var texts: Array[String] = []
|
||||||
|
for n in bar._build_tools.find_children("*", "Button", true, false):
|
||||||
|
texts.append((n as Button).text)
|
||||||
|
_check(not texts.has("Arrange ▾"), "Arrange ▾ is gone from the Build tools: %s" % str(texts))
|
||||||
|
var pm := bar._board_menu.get_popup()
|
||||||
|
_check(pm.get_item_index(IoMenu.ID_PACK) >= 0, "Board ▾ has Pack collapsed groups")
|
||||||
|
_check(main.nav._search_button.text == "", "Search is an icon button")
|
||||||
|
|
||||||
|
|
||||||
|
func _test_zoom() -> void:
|
||||||
|
var z := main.top_bar.zoom
|
||||||
|
z.activate(ZoomControl.ID_ACTUAL)
|
||||||
|
await _frames()
|
||||||
|
_eq(main.board.zoom, 1.0, "Zoom to 100% sets the zoom")
|
||||||
|
_eq(z.menu.text, "100% ▾", "the percentage follows")
|
||||||
|
main.board.set_zoom(0.5)
|
||||||
|
await _frames()
|
||||||
|
_eq(z.menu.text, "50% ▾", "and follows zoom changes from elsewhere")
|
||||||
|
z.activate(ZoomControl.ID_FIT)
|
||||||
|
_check(main.board.zoom != 0.5, "Fit board changes the zoom")
|
||||||
|
|
||||||
|
|
||||||
|
func _test_view_menu() -> void:
|
||||||
|
var v := main.top_bar.view_menu
|
||||||
|
v.activate(ViewMenu.ID_TEXT)
|
||||||
|
_eq(main.rules_view(), "text", "Rule text")
|
||||||
|
v.activate(ViewMenu.ID_PLAIN)
|
||||||
|
_eq(main.rules_view(), "plain", "Plain words")
|
||||||
|
var was := main.board.minimap.visible
|
||||||
|
v.activate(ViewMenu.ID_MINIMAP)
|
||||||
|
_check(main.board.minimap.visible != was, "Minimap toggles")
|
||||||
|
v.activate(ViewMenu.ID_MINIMAP)
|
||||||
|
v.activate(ViewMenu.ID_COLLAPSE)
|
||||||
|
await _frames()
|
||||||
|
_eq(v.collapse_label(), "Expand all tables", "after Collapse all the menu offers Expand")
|
||||||
|
v.activate(ViewMenu.ID_COLLAPSE)
|
||||||
|
await _frames()
|
||||||
|
_eq(v.collapse_label(), "Collapse all tables", "and Expand all puts it back")
|
||||||
|
v.sync()
|
||||||
|
var pm := v.get_popup()
|
||||||
|
_check(pm.is_item_checked(pm.get_item_index(ViewMenu.ID_PLAIN)) and pm.is_item_checked(pm.get_item_index(ViewMenu.ID_STRIPES)),
|
||||||
|
"the menu checks Plain words and Striped rows")
|
||||||
|
|
||||||
|
|
||||||
|
func _row_bg(card: TableCard, index: int) -> Color:
|
||||||
|
var e := card.table.entries[index]
|
||||||
|
return ((card.rows[e.id] as PanelContainer).get_theme_stylebox("panel") as StyleBoxFlat).bg_color
|
||||||
|
|
||||||
|
|
||||||
|
func _test_stripes() -> void:
|
||||||
|
var card := main.card_for("loot")
|
||||||
|
_check(main.local_state.striped_rows(), "stripes are on by default")
|
||||||
|
_eq(_row_bg(card, 0), Color(0, 0, 0, 0), "the first row is clear")
|
||||||
|
_eq(_row_bg(card, 1), Style.STRIPE, "the second row is striped")
|
||||||
|
_eq(_row_bg(card, 2), Color(0, 0, 0, 0), "the third row is clear")
|
||||||
|
card.rows_ui.set_row_state(card.table.entries[1].id, TableCardRows.RowState.LIT)
|
||||||
|
_eq(_row_bg(card, 1), Style.LIT, "a lit row shows lit, not striped")
|
||||||
|
card.rows_ui.restate(card.table.entries[1].id)
|
||||||
|
main.top_bar.view_menu.activate(ViewMenu.ID_STRIPES)
|
||||||
|
_eq(_row_bg(card, 1), Color(0, 0, 0, 0), "turning stripes off clears them")
|
||||||
|
main.top_bar.view_menu.activate(ViewMenu.ID_STRIPES)
|
||||||
|
_eq(_row_bg(card, 1), Style.STRIPE, "and back on")
|
||||||
|
await _frames()
|
||||||
|
|
||||||
|
|
||||||
|
func _test_card_menu() -> void:
|
||||||
|
main.set_mode(Main.Mode.BUILD)
|
||||||
|
await _frames()
|
||||||
|
var card := main.card_for("loot")
|
||||||
|
var menus := card.find_children("*", "MenuButton", true, false)
|
||||||
|
_check(menus.size() == 1 and (menus[0] as MenuButton).tooltip_text == "Table actions", "the card has one ⋯ menu")
|
||||||
|
var texts: Array[String] = []
|
||||||
|
for n in card.find_children("*", "Button", true, false):
|
||||||
|
texts.append((n as Button).text)
|
||||||
|
_check(not texts.has("⚙") and not texts.has("Delete"), "no gear and no footer Delete: %s" % str(texts))
|
||||||
|
|
||||||
|
var eid := card.table.entries[2].id
|
||||||
|
var del: Button = card.rows_ui.parts[eid]["delete"]
|
||||||
|
_eq(del.modulate.a, 0.0, "a row's × is hidden until hovered")
|
||||||
|
card.select_entry(eid)
|
||||||
|
_eq(del.modulate.a, 1.0, "the selected row shows its ×")
|
||||||
|
card.select_entry("")
|
||||||
|
_eq(del.modulate.a, 0.0, "and hides it again when deselected")
|
||||||
|
|
||||||
|
var pm := (menus[0] as MenuButton).get_popup()
|
||||||
|
pm.id_pressed.emit(TableCardEditing.MENU_DELETE)
|
||||||
|
await _frames()
|
||||||
|
_check(main.data.get_table("loot") == null, "⋯ → Delete table deletes it")
|
||||||
|
main.undo_redo.undo()
|
||||||
|
await _frames()
|
||||||
|
_check(main.data.get_table("loot") != null, "and undo brings it back")
|
||||||
|
main.set_mode(Main.Mode.PLAY)
|
||||||
|
await _frames()
|
||||||
|
|
||||||
|
|
||||||
|
func _test_help() -> void:
|
||||||
|
var titles := HelpDialog.titles()
|
||||||
|
_check(titles.size() >= 10 and titles.has("Card mode") and titles.has("Roll modifiers"), "help has its topics: %s" % str(titles))
|
||||||
|
var src := FileAccess.get_file_as_string(HelpDialog.PATH)
|
||||||
|
var re := RegEx.create_from_string("\\[topic\\](.+?)\\[/topic\\]")
|
||||||
|
for m in re.search_all(src):
|
||||||
|
_check(titles.has(m.get_string(1)), "the link to “%s” has a topic" % m.get_string(1))
|
||||||
|
for t: Dictionary in HelpDialog.topics():
|
||||||
|
_check(str(t["body"]).length() > 80, "“%s” has text" % t["title"])
|
||||||
|
_check(HelpDialog._inline("`[[Loot]]`").contains("[lb][lb]Loot[rb][rb]"), "code spans keep their brackets")
|
||||||
|
|
||||||
|
var d := main.top_bar.help_menu.open("card MODE")
|
||||||
|
await _frames()
|
||||||
|
_eq(d.current, "Card mode", "Help opens at the asked topic, any case")
|
||||||
|
d._on_meta("topic:Roll modifiers")
|
||||||
|
_eq(d.current, "Roll modifiers", "a topic link switches topics")
|
||||||
|
_check(d.text.get_parsed_text().contains("Luck"), "and shows its text")
|
||||||
|
d.close()
|
||||||
|
await _frames()
|
||||||
|
|
||||||
|
|
||||||
|
func _frames(n: int = 2) -> void:
|
||||||
|
for i in n:
|
||||||
|
await process_frame
|
||||||
|
|
||||||
|
|
||||||
|
func _check(ok: bool, what: String) -> void:
|
||||||
|
if not ok:
|
||||||
|
_failures += 1
|
||||||
|
print("FAIL ", what)
|
||||||
|
|
||||||
|
|
||||||
|
func _eq(got: Variant, want: Variant, what: String) -> void:
|
||||||
|
_check(got == want, "%s: got %s, want %s" % [what, str(got), str(want)])
|
||||||
1
tests/test_top_bar.gd.uid
Normal file
1
tests/test_top_bar.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://hfon565hmp38
|
||||||
|
|
@ -366,25 +366,9 @@ func _name_edit(on_felt: bool) -> LineEdit:
|
||||||
|
|
||||||
|
|
||||||
func _menu_button(on_felt: bool) -> MenuButton:
|
func _menu_button(on_felt: bool) -> MenuButton:
|
||||||
var mb := MenuButton.new()
|
var mb := Style.overflow_button("Group options", on_felt)
|
||||||
mb.text = "⋯"
|
|
||||||
mb.flat = false
|
|
||||||
mb.tooltip_text = "Group options"
|
|
||||||
mb.custom_minimum_size = Vector2(30, 26)
|
|
||||||
mb.size_flags_vertical = SIZE_SHRINK_CENTER
|
|
||||||
mb.add_theme_font_override("font", Style.body_bold(true))
|
|
||||||
mb.add_theme_font_size_override("font_size", 16)
|
|
||||||
var hover := Style.box(Color(1, 1, 1, 0.1) if on_felt else Color("#e6dfcd"), 6)
|
|
||||||
for n in ["normal", "disabled", "focus"]:
|
|
||||||
mb.add_theme_stylebox_override(n, Style.box(Color(0, 0, 0, 0), 6))
|
|
||||||
for n in ["hover", "pressed", "hover_pressed"]:
|
|
||||||
mb.add_theme_stylebox_override(n, hover)
|
|
||||||
var fg := Style.ON_FELT if on_felt else Style.MUTED
|
|
||||||
Style.font_colors(mb, fg)
|
|
||||||
mb.mouse_default_cursor_shape = CURSOR_POINTING_HAND
|
|
||||||
menu_button = mb
|
menu_button = mb
|
||||||
var pm := mb.get_popup()
|
var pm := mb.get_popup()
|
||||||
ModalCard.style_popup(pm)
|
|
||||||
pm.add_item("Expand" if group.collapsed else "Collapse", MENU_TOGGLE)
|
pm.add_item("Expand" if group.collapsed else "Collapse", MENU_TOGGLE)
|
||||||
pm.add_item("Details…", MENU_DETAILS)
|
pm.add_item("Details…", MENU_DETAILS)
|
||||||
pm.add_item("Save as template…", MENU_TEMPLATE)
|
pm.add_item("Save as template…", MENU_TEMPLATE)
|
||||||
|
|
|
||||||
144
ui/help_dialog.gd
Normal file
144
ui/help_dialog.gd
Normal file
|
|
@ -0,0 +1,144 @@
|
||||||
|
class_name HelpDialog
|
||||||
|
extends ModalCard
|
||||||
|
## The Help window: topics down the left, the chosen topic on the right.
|
||||||
|
##
|
||||||
|
## The text lives in res://help/topics.txt, written in a small markup:
|
||||||
|
## # Title starts a topic
|
||||||
|
## ## Heading a heading inside a topic
|
||||||
|
## - item a bullet
|
||||||
|
## `code` rule text, shown as typed (brackets are safe inside)
|
||||||
|
## [topic]Title[/topic] a link to another topic
|
||||||
|
## Everything else is BBCode ([b], [i]) and blank lines split paragraphs.
|
||||||
|
|
||||||
|
const PATH := "res://help/topics.txt"
|
||||||
|
const LINK_COLOR := "#4f2b12"
|
||||||
|
const CODE_COLOR := "#8a4a1c"
|
||||||
|
|
||||||
|
static var _cache: Array = []
|
||||||
|
|
||||||
|
var current := ""
|
||||||
|
var text: RichTextLabel
|
||||||
|
var _buttons: Dictionary = {} # title -> Button
|
||||||
|
|
||||||
|
|
||||||
|
func _init(start: String = "") -> void:
|
||||||
|
super._init("Help", 920.0)
|
||||||
|
var row := HBoxContainer.new()
|
||||||
|
row.add_theme_constant_override("separation", 24)
|
||||||
|
body.add_child(row)
|
||||||
|
var list := VBoxContainer.new()
|
||||||
|
list.add_theme_constant_override("separation", 2)
|
||||||
|
list.custom_minimum_size.x = 220
|
||||||
|
row.add_child(list)
|
||||||
|
var group := ButtonGroup.new()
|
||||||
|
for t: Dictionary in topics():
|
||||||
|
var b := _topic_button(str(t["title"]), group)
|
||||||
|
list.add_child(b)
|
||||||
|
_buttons[t["title"]] = b
|
||||||
|
text = RichTextLabel.new()
|
||||||
|
text.bbcode_enabled = true
|
||||||
|
text.fit_content = true
|
||||||
|
text.selection_enabled = true
|
||||||
|
text.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||||
|
text.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||||
|
text.add_theme_constant_override("line_separation", 3)
|
||||||
|
text.meta_clicked.connect(_on_meta)
|
||||||
|
row.add_child(text)
|
||||||
|
add_button("Close", "primary", close)
|
||||||
|
show_topic(start)
|
||||||
|
|
||||||
|
|
||||||
|
## Every topic, in file order: [{title, body}] with the body already turned
|
||||||
|
## into BBCode. Read once and cached.
|
||||||
|
static func topics() -> Array:
|
||||||
|
if _cache.is_empty():
|
||||||
|
_cache = parse(FileAccess.get_file_as_string(PATH))
|
||||||
|
if _cache.is_empty():
|
||||||
|
_cache = [{"title": "Help", "body": "The help text is missing (%s)." % PATH}]
|
||||||
|
return _cache
|
||||||
|
|
||||||
|
|
||||||
|
static func titles() -> Array[String]:
|
||||||
|
var out: Array[String] = []
|
||||||
|
for t: Dictionary in topics():
|
||||||
|
out.append(str(t["title"]))
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
static func parse(source: String) -> Array:
|
||||||
|
var out: Array = []
|
||||||
|
var cur: Dictionary = {}
|
||||||
|
for line in source.split("\n"):
|
||||||
|
if line.begins_with("# "):
|
||||||
|
cur = {"title": line.substr(2).strip_edges(), "body": ""}
|
||||||
|
out.append(cur)
|
||||||
|
elif not cur.is_empty():
|
||||||
|
cur["body"] += _line(line) + "\n"
|
||||||
|
for t: Dictionary in out:
|
||||||
|
t["body"] = str(t["body"]).strip_edges()
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
static func _line(line: String) -> String:
|
||||||
|
if line.begins_with("## "):
|
||||||
|
return "[font_size=19][b]%s[/b][/font_size]" % _inline(line.substr(3).strip_edges())
|
||||||
|
if line.begins_with("- "):
|
||||||
|
return "[indent]• %s[/indent]" % _inline(line.substr(2))
|
||||||
|
return _inline(line)
|
||||||
|
|
||||||
|
|
||||||
|
## `code` spans (brackets escaped) and [topic] links.
|
||||||
|
static func _inline(s: String) -> String:
|
||||||
|
var out := ""
|
||||||
|
var parts := s.split("`")
|
||||||
|
for i in parts.size():
|
||||||
|
if i % 2 == 1:
|
||||||
|
var code := ""
|
||||||
|
for ch in parts[i]:
|
||||||
|
code += "[lb]" if ch == "[" else ("[rb]" if ch == "]" else ch)
|
||||||
|
out += "[color=%s][b]%s[/b][/color]" % [CODE_COLOR, code]
|
||||||
|
else:
|
||||||
|
out += parts[i]
|
||||||
|
var re := RegEx.create_from_string("\\[topic\\](.+?)\\[/topic\\]")
|
||||||
|
return re.sub(out, "[url=topic:$1][color=%s][u]$1[/u][/color][/url]" % LINK_COLOR, true)
|
||||||
|
|
||||||
|
|
||||||
|
func show_topic(title: String) -> void:
|
||||||
|
var all := topics()
|
||||||
|
var found: Dictionary = all[0]
|
||||||
|
for t: Dictionary in all:
|
||||||
|
if str(t["title"]).to_lower() == title.to_lower():
|
||||||
|
found = t
|
||||||
|
current = str(found["title"])
|
||||||
|
title_label.text = current
|
||||||
|
text.text = str(found["body"])
|
||||||
|
if _buttons.has(current):
|
||||||
|
(_buttons[current] as Button).set_pressed_no_signal(true)
|
||||||
|
_scroll.scroll_vertical = 0
|
||||||
|
|
||||||
|
|
||||||
|
func _on_meta(meta: Variant) -> void:
|
||||||
|
var s := str(meta)
|
||||||
|
if s.begins_with("topic:"):
|
||||||
|
show_topic(s.substr(6))
|
||||||
|
|
||||||
|
|
||||||
|
## The window keeps one height while you move between topics.
|
||||||
|
func _fit() -> void:
|
||||||
|
card.custom_minimum_size.x = minf(_width, maxf(240.0, size.x - 32.0))
|
||||||
|
_scroll.custom_minimum_size.y = clampf(size.y - 200.0, 160.0, 640.0)
|
||||||
|
|
||||||
|
|
||||||
|
func _topic_button(title: String, group: ButtonGroup) -> Button:
|
||||||
|
var b := Button.new()
|
||||||
|
b.text = title
|
||||||
|
b.toggle_mode = true
|
||||||
|
b.button_group = group
|
||||||
|
b.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||||
|
b.add_theme_font_size_override("font_size", 15)
|
||||||
|
var m := [10, 5, 10, 5]
|
||||||
|
var on := Style.box(Color(Style.BRASS, 0.3), 6, m)
|
||||||
|
Style.skin_button(b, Style.box(Color(0, 0, 0, 0), 6, m), Style.box(Style.HOVER_ROW, 6, m), on, Style.INK)
|
||||||
|
b.add_theme_stylebox_override("hover_pressed", on)
|
||||||
|
b.pressed.connect(func() -> void: show_topic(title))
|
||||||
|
return b
|
||||||
1
ui/help_dialog.gd.uid
Normal file
1
ui/help_dialog.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://d254cgn60towv
|
||||||
25
ui/help_menu.gd
Normal file
25
ui/help_menu.gd
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
class_name HelpMenu
|
||||||
|
extends MenuButton
|
||||||
|
## The top bar's "Help ▾" menu: one item per help topic, each opening the
|
||||||
|
## Help window at that topic. F1 opens it at the first topic.
|
||||||
|
|
||||||
|
var m: Main
|
||||||
|
|
||||||
|
|
||||||
|
func setup(p_main: Main) -> void:
|
||||||
|
m = p_main
|
||||||
|
Style.menu_button("Help ▾", false, self)
|
||||||
|
tooltip_text = "How to use TableTower (F1)"
|
||||||
|
var pm := get_popup()
|
||||||
|
ModalCard.style_popup(pm)
|
||||||
|
var titles := HelpDialog.titles()
|
||||||
|
for i in titles.size():
|
||||||
|
pm.add_item(titles[i], i)
|
||||||
|
pm.id_pressed.connect(func(id: int) -> void: open(titles[id]))
|
||||||
|
|
||||||
|
|
||||||
|
## Opens the Help window at `topic` (the first topic when blank) and returns it.
|
||||||
|
func open(topic: String = "") -> HelpDialog:
|
||||||
|
var d := HelpDialog.new(topic)
|
||||||
|
m._add_modal(d)
|
||||||
|
return d
|
||||||
1
ui/help_menu.gd.uid
Normal file
1
ui/help_menu.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dmgtusvuudrhf
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
class_name IoMenu
|
class_name IoMenu
|
||||||
extends MenuButton
|
extends MenuButton
|
||||||
## The Build-mode "Board ▾" menu (reset, import, export) plus the import and
|
## The Build-mode "Board ▾" 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
|
||||||
const ID_IMPORT := 2
|
const ID_IMPORT := 2
|
||||||
const ID_TEST := 3
|
const ID_TEST := 3
|
||||||
|
const ID_PACK := 4
|
||||||
const ID_EXPORT := 100
|
const ID_EXPORT := 100
|
||||||
|
|
||||||
## Export formats: label, file extension, FileDialog filter.
|
## Export formats: label, file extension, FileDialog filter.
|
||||||
|
|
@ -29,15 +30,19 @@ signal reset_requested
|
||||||
signal import_requested
|
signal import_requested
|
||||||
signal export_requested(format: Dictionary)
|
signal export_requested(format: Dictionary)
|
||||||
signal test_requested
|
signal test_requested
|
||||||
|
signal pack_requested
|
||||||
|
|
||||||
|
|
||||||
func setup(can_reset: bool, can_import: bool) -> void:
|
func setup(can_reset: bool, can_import: bool) -> void:
|
||||||
Style.menu_button("Board ▾", false, self)
|
Style.menu_button("Board ▾", false, self)
|
||||||
tooltip_text = "Reset, import and export"
|
tooltip_text = "Test, arrange, import and export the board"
|
||||||
var pm := get_popup()
|
var pm := get_popup()
|
||||||
ModalCard.style_popup(pm)
|
ModalCard.style_popup(pm)
|
||||||
pm.add_item("Reset sample", ID_RESET)
|
|
||||||
pm.add_item("Test board…", ID_TEST)
|
pm.add_item("Test board…", ID_TEST)
|
||||||
|
pm.add_item("Reset sample", ID_RESET)
|
||||||
|
pm.add_separator("Arrange")
|
||||||
|
pm.add_item("Pack collapsed groups", ID_PACK)
|
||||||
|
pm.set_item_tooltip(pm.get_item_index(ID_PACK), "Move collapsed groups and the cards between them together, closing the gaps, in reading order")
|
||||||
pm.add_separator("Import")
|
pm.add_separator("Import")
|
||||||
pm.add_item("Import as new collection…", ID_IMPORT)
|
pm.add_item("Import as new collection…", ID_IMPORT)
|
||||||
pm.set_item_disabled(pm.get_item_index(ID_IMPORT), not can_import)
|
pm.set_item_disabled(pm.get_item_index(ID_IMPORT), not can_import)
|
||||||
|
|
@ -49,6 +54,8 @@ func setup(can_reset: bool, can_import: bool) -> void:
|
||||||
reset_requested.emit()
|
reset_requested.emit()
|
||||||
elif id == ID_TEST:
|
elif id == ID_TEST:
|
||||||
test_requested.emit()
|
test_requested.emit()
|
||||||
|
elif id == ID_PACK:
|
||||||
|
pack_requested.emit()
|
||||||
elif id == ID_IMPORT:
|
elif id == ID_IMPORT:
|
||||||
import_requested.emit()
|
import_requested.emit()
|
||||||
elif id >= ID_EXPORT and id < ID_EXPORT + EXPORTS.size():
|
elif id >= ID_EXPORT and id < ID_EXPORT + EXPORTS.size():
|
||||||
|
|
|
||||||
15
ui/main.gd
15
ui/main.gd
|
|
@ -104,7 +104,6 @@ func _ready() -> void:
|
||||||
_build_ui()
|
_build_ui()
|
||||||
_rebuild_cards()
|
_rebuild_cards()
|
||||||
rolling._seed_session()
|
rolling._seed_session()
|
||||||
_update_collapse_all()
|
|
||||||
# Let the cards lay out before fitting them to the window.
|
# Let the cards lay out before fitting them to the window.
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
|
|
@ -219,7 +218,6 @@ func _rebuild_cards() -> void:
|
||||||
selection.clear()
|
selection.clear()
|
||||||
grouping._rebuild_groups()
|
grouping._rebuild_groups()
|
||||||
editing._update_selection_bar()
|
editing._update_selection_bar()
|
||||||
_update_collapse_all()
|
|
||||||
# A board loaded or replaced starts with nothing in the inspector; an
|
# A board loaded or replaced starts with nothing in the inspector; an
|
||||||
# undo keeps the selection (the inspector follows the board).
|
# undo keeps the selection (the inspector follows the board).
|
||||||
if inspector and not undo_redo._keep_history:
|
if inspector and not undo_redo._keep_history:
|
||||||
|
|
@ -250,8 +248,6 @@ func set_mode(m: Mode) -> void:
|
||||||
top_bar._hint.text = HINTS[m] if m == Mode.PLAY else ""
|
top_bar._hint.text = HINTS[m] if m == Mode.PLAY else ""
|
||||||
top_bar._hint.tooltip_text = HINTS[m]
|
top_bar._hint.tooltip_text = HINTS[m]
|
||||||
top_bar._hint.custom_minimum_size.x = 60.0 if m == Mode.PLAY else 0.0
|
top_bar._hint.custom_minimum_size.x = 60.0 if m == Mode.PLAY else 0.0
|
||||||
# Build's bar has no room for Collapse all; it's in Arrange ▾ there.
|
|
||||||
top_bar._collapse_all.visible = m != Mode.BUILD
|
|
||||||
top_bar._build_tools.visible = m == Mode.BUILD
|
top_bar._build_tools.visible = m == Mode.BUILD
|
||||||
board.pipes.hover_key = ""
|
board.pipes.hover_key = ""
|
||||||
clear_selection()
|
clear_selection()
|
||||||
|
|
@ -273,7 +269,6 @@ func _board_changed() -> void:
|
||||||
local_state._ref_cache.clear()
|
local_state._ref_cache.clear()
|
||||||
view_rev += 1
|
view_rev += 1
|
||||||
edit_rev += 1
|
edit_rev += 1
|
||||||
_update_collapse_all()
|
|
||||||
top_bar._schedule_endless_check()
|
top_bar._schedule_endless_check()
|
||||||
if mode == Mode.BUILD:
|
if mode == Mode.BUILD:
|
||||||
refresh_live()
|
refresh_live()
|
||||||
|
|
@ -294,11 +289,6 @@ func _any_expanded() -> bool:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
||||||
func _update_collapse_all() -> void:
|
|
||||||
if top_bar._collapse_all:
|
|
||||||
top_bar._collapse_all.text = "Collapse all" if _any_expanded() else "Expand all"
|
|
||||||
|
|
||||||
|
|
||||||
# ---------- Collapsing ----------
|
# ---------- Collapsing ----------
|
||||||
|
|
||||||
func toggle_collapse(tid: String) -> void:
|
func toggle_collapse(tid: String) -> void:
|
||||||
|
|
@ -395,6 +385,9 @@ func _shortcut_input(ev: InputEvent) -> void:
|
||||||
return
|
return
|
||||||
nav.set_minimap_visible(not board.minimap.visible, true)
|
nav.set_minimap_visible(not board.minimap.visible, true)
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
|
elif k.keycode == KEY_F1:
|
||||||
|
top_bar.help_menu.open()
|
||||||
|
get_viewport().set_input_as_handled()
|
||||||
|
|
||||||
|
|
||||||
func _unhandled_input(ev: InputEvent) -> void:
|
func _unhandled_input(ev: InputEvent) -> void:
|
||||||
|
|
@ -430,13 +423,11 @@ func set_rules_view(v: String) -> void:
|
||||||
if v != "plain" and v != "text":
|
if v != "plain" and v != "text":
|
||||||
return
|
return
|
||||||
if v == rules_view():
|
if v == rules_view():
|
||||||
top_bar._sync_rules_switch()
|
|
||||||
return
|
return
|
||||||
if state:
|
if state:
|
||||||
state.set_rules_view(v)
|
state.set_rules_view(v)
|
||||||
state.save()
|
state.save()
|
||||||
_rules_view_mem = v
|
_rules_view_mem = v
|
||||||
top_bar._sync_rules_switch()
|
|
||||||
if inspector:
|
if inspector:
|
||||||
inspector.rebuild()
|
inspector.rebuild()
|
||||||
rules_view_changed.emit(v)
|
rules_view_changed.emit(v)
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,9 @@ func _run_cli(args: PackedStringArray) -> void:
|
||||||
# --open-settings=<table id> open the settings dialog
|
# --open-settings=<table id> open the settings dialog
|
||||||
# --demo-import=<file> show the import report for a file (nothing is saved)
|
# --demo-import=<file> show the import report for a file (nothing is saved)
|
||||||
# --demo-endless pipe the first two tables into each other
|
# --demo-endless pipe the first two tables into each other
|
||||||
# --menu=board|collections pop up a top-bar menu
|
# --menu=board|collections|view|help|zoom|add|card pop up a menu (card: the
|
||||||
|
# first card's ⋯ menu, in Build)
|
||||||
|
# --help[=<topic>] open the Help window
|
||||||
|
|
||||||
func _run_shell_cli(args: PackedStringArray) -> void:
|
func _run_shell_cli(args: PackedStringArray) -> void:
|
||||||
var tid := _arg_value(args, "--open-settings")
|
var tid := _arg_value(args, "--open-settings")
|
||||||
|
|
@ -88,7 +90,22 @@ func _run_shell_cli(args: PackedStringArray) -> void:
|
||||||
m.top_bar._board_menu.show_popup()
|
m.top_bar._board_menu.show_popup()
|
||||||
elif menu == "collections":
|
elif menu == "collections":
|
||||||
m.top_bar._switcher.show_popup()
|
m.top_bar._switcher.show_popup()
|
||||||
elif menu == "add":
|
elif menu == "view":
|
||||||
|
m.top_bar.view_menu.show_popup()
|
||||||
|
elif menu == "help":
|
||||||
|
m.top_bar.help_menu.show_popup()
|
||||||
|
elif menu == "zoom":
|
||||||
|
m.top_bar.zoom.menu.show_popup()
|
||||||
|
elif menu == "card":
|
||||||
|
# The first card's ⋯ menu (Build mode).
|
||||||
|
await m.get_tree().process_frame
|
||||||
|
var card := m.card_for(m.data.tables[0].id)
|
||||||
|
var more := card.find_children("*", "MenuButton", true, false) if card else []
|
||||||
|
if not more.is_empty():
|
||||||
|
(more[0] as MenuButton).show_popup()
|
||||||
|
if args.has("--help") or _arg_value(args, "--help") != "":
|
||||||
|
m.top_bar.help_menu.open(_arg_value(args, "--help"))
|
||||||
|
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
|
await m.get_tree().process_frame
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ func _rebuild_groups() -> void:
|
||||||
## rest in step.
|
## rest in step.
|
||||||
func _groups_changed() -> void:
|
func _groups_changed() -> void:
|
||||||
_rebuild_groups()
|
_rebuild_groups()
|
||||||
m._update_collapse_all()
|
|
||||||
|
|
||||||
|
|
||||||
## Builds the cards that are on show and frees the ones hidden in collapsed
|
## Builds the cards that are on show and frees the ones hidden in collapsed
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,6 @@ func _refresh_patched(p: Dictionary, d: Dictionary) -> void:
|
||||||
c.position = c.table.position
|
c.position = c.table.position
|
||||||
if all or (d["changed"] as Array).has(tid):
|
if all or (d["changed"] as Array).has(tid):
|
||||||
c.rebuild()
|
c.rebuild()
|
||||||
m._update_collapse_all()
|
|
||||||
|
|
||||||
|
|
||||||
## Rings the cards an undo or redo changed, once they have laid out. One
|
## Rings the cards an undo or redo changed, once they have laid out. One
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ extends RefCounted
|
||||||
## the selected card, result or pipe. The display side calls select_card /
|
## the selected card, result or pipe. The display side calls select_card /
|
||||||
## select_result / select_pipe / clear_inspector; Main also selects from the
|
## select_result / select_pipe / clear_inspector; Main also selects from the
|
||||||
## board: a card's title (drag start), focus entering a result's field on a
|
## board: a card's title (drag start), focus entering a result's field on a
|
||||||
## card, a clicked pipe, the ⚙.
|
## card, a clicked pipe, the card ⋯ menu's Table settings….
|
||||||
|
|
||||||
var m: Main
|
var m: Main
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ func open_pipe_options(key: String, at: Vector2) -> void:
|
||||||
_pipe_popover.open(key, at)
|
_pipe_popover.open(key, at)
|
||||||
|
|
||||||
|
|
||||||
## The card's ⚙ button. Main.open_table_settings comes from the app-shell work;
|
## The card ⋯ menu's Table settings…. Main.open_table_settings comes from the app-shell work;
|
||||||
## until it exists this only says so.
|
## until it exists this only says so.
|
||||||
func request_table_settings(tid: String) -> void:
|
func request_table_settings(tid: String) -> void:
|
||||||
if m.mode == Main.Mode.BUILD and m.inspector != null:
|
if m.mode == Main.Mode.BUILD and m.inspector != null:
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,11 @@ const READABLE_ZOOM := 0.85
|
||||||
## ...but zooms out as far as this to fit a tall card.
|
## ...but zooms out as far as this to fit a tall card.
|
||||||
const MIN_FOCUS_ZOOM := 0.7
|
const MIN_FOCUS_ZOOM := 0.7
|
||||||
const PACK_GAP := 60.0
|
const PACK_GAP := 60.0
|
||||||
const ARRANGE_PACK := 0
|
|
||||||
const ARRANGE_COLLAPSE := 1
|
|
||||||
|
|
||||||
var m: Main
|
var m: Main
|
||||||
|
|
||||||
var _search_button: Button
|
var _search_button: Button
|
||||||
var _search_panel: SearchPanel
|
var _search_panel: SearchPanel
|
||||||
var _map_toggle: Button
|
|
||||||
|
|
||||||
|
|
||||||
func _init(p_main: Main) -> void:
|
func _init(p_main: Main) -> void:
|
||||||
|
|
@ -158,29 +155,11 @@ func _expand_group(g: TableGroup) -> Dictionary:
|
||||||
|
|
||||||
# ----- Minimap -----
|
# ----- Minimap -----
|
||||||
|
|
||||||
func _make_map_toggle() -> Button:
|
|
||||||
var b := Style.bar_button("Map")
|
|
||||||
b.toggle_mode = true
|
|
||||||
b.tooltip_text = "Show an overview of the board in the corner (M)"
|
|
||||||
var on := Style.bordered(Style.box(Color(Style.BRASS, 0.16), 8, [12, 6, 12, 6]), 1, Style.BRASS)
|
|
||||||
b.add_theme_stylebox_override("pressed", on)
|
|
||||||
b.add_theme_stylebox_override("hover_pressed", on)
|
|
||||||
m.top_bar._bar_icon(b, func(c: Control) -> void:
|
|
||||||
c.draw_rect(Rect2(1, 2, 14, 12), Style.ON_FELT, false, 1.5)
|
|
||||||
c.draw_rect(Rect2(4, 5, 4, 3), Style.ON_FELT)
|
|
||||||
c.draw_rect(Rect2(9, 8, 3, 3), Style.BRASS))
|
|
||||||
b.toggled.connect(func(pressed: bool) -> void: set_minimap_visible(pressed, true))
|
|
||||||
_nav_mode_changed.call_deferred()
|
|
||||||
return b
|
|
||||||
|
|
||||||
|
|
||||||
## Shows or hides the minimap; `remember` saves the choice for this mode.
|
## Shows or hides the minimap; `remember` saves the choice for this mode.
|
||||||
func set_minimap_visible(on: bool, remember: bool = false) -> void:
|
func set_minimap_visible(on: bool, remember: bool = false) -> void:
|
||||||
if m.board == null:
|
if m.board == null:
|
||||||
return
|
return
|
||||||
m.board.minimap.visible = on
|
m.board.minimap.visible = on
|
||||||
if _map_toggle:
|
|
||||||
_map_toggle.set_pressed_no_signal(on)
|
|
||||||
if remember and m.state:
|
if remember and m.state:
|
||||||
m.state.set_setting(_minimap_key(), on)
|
m.state.set_setting(_minimap_key(), on)
|
||||||
m.state.save()
|
m.state.save()
|
||||||
|
|
@ -204,25 +183,6 @@ func _nav_mode_changed() -> void:
|
||||||
|
|
||||||
# ----- Arrange: pack collapsed groups -----
|
# ----- Arrange: pack collapsed groups -----
|
||||||
|
|
||||||
func _make_arrange_menu() -> MenuButton:
|
|
||||||
var mb := Style.menu_button("Arrange ▾")
|
|
||||||
mb.tooltip_text = "Tidy the layout of the board"
|
|
||||||
var pm := mb.get_popup()
|
|
||||||
ModalCard.style_popup(pm)
|
|
||||||
pm.add_item("Pack collapsed groups", ARRANGE_PACK)
|
|
||||||
pm.set_item_tooltip(0, "Move collapsed groups and the cards between them together, closing the gaps, in reading order")
|
|
||||||
# Build mode's bar has no room for the Collapse all button, so it lives here.
|
|
||||||
pm.add_item("Collapse all", ARRANGE_COLLAPSE)
|
|
||||||
pm.about_to_popup.connect(func() -> void:
|
|
||||||
pm.set_item_text(pm.get_item_index(ARRANGE_COLLAPSE), "Collapse all" if m._any_expanded() else "Expand all"))
|
|
||||||
pm.id_pressed.connect(func(id: int) -> void:
|
|
||||||
if id == ARRANGE_PACK:
|
|
||||||
pack_collapsed_groups()
|
|
||||||
elif id == ARRANGE_COLLAPSE:
|
|
||||||
m.set_all_collapsed(m._any_expanded()))
|
|
||||||
return mb
|
|
||||||
|
|
||||||
|
|
||||||
## The blocks Pack and make-room move: every group (its compact card when
|
## The blocks Pack and make-room move: every group (its compact card when
|
||||||
## collapsed, its frame when expanded) and every card in no group, as
|
## collapsed, its frame when expanded) and every card in no group, as
|
||||||
## [{rect, group, table}] with one of group / table set. `skip` is a group id
|
## [{rect, group, table}] with one of group / table set. `skip` is a group id
|
||||||
|
|
|
||||||
|
|
@ -253,3 +253,27 @@ func set_collection_member(t: RollTable, item: String, value: String) -> void:
|
||||||
func remove_collection_member(t: RollTable, item: String) -> void:
|
func remove_collection_member(t: RollTable, item: String) -> void:
|
||||||
if m.persistent_vars.erase("%s_%s" % [t.var_name, item]):
|
if m.persistent_vars.erase("%s_%s" % [t.var_name, item]):
|
||||||
_variables_changed()
|
_variables_changed()
|
||||||
|
|
||||||
|
|
||||||
|
# ---------- Striped rows ----------
|
||||||
|
|
||||||
|
const STRIPED_ROWS := "striped_rows"
|
||||||
|
## Used when saving is off (--sample / --screenshot) and `state` is null.
|
||||||
|
var _striped_mem := true
|
||||||
|
|
||||||
|
|
||||||
|
## True when every second result row on a card is tinted (on by default).
|
||||||
|
func striped_rows() -> bool:
|
||||||
|
return bool(m.state.get_setting(STRIPED_ROWS, true)) if m.state else _striped_mem
|
||||||
|
|
||||||
|
|
||||||
|
## Turns the stripes on or off, saves the choice and restyles every row.
|
||||||
|
func set_striped_rows(on: bool) -> void:
|
||||||
|
_striped_mem = on
|
||||||
|
if m.state:
|
||||||
|
m.state.set_setting(STRIPED_ROWS, on)
|
||||||
|
m.state.save()
|
||||||
|
for c: Variant in m.cards.values():
|
||||||
|
var card := c as TableCard
|
||||||
|
for eid: String in card.rows:
|
||||||
|
card.rows_ui.restate(eid)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
class_name MainTopBar
|
class_name MainTopBar
|
||||||
extends RefCounted
|
extends RefCounted
|
||||||
## Main's top bar (brand, Play/Build, collections, Build tools, rules switch,
|
## Main's top bar (brand, Play/Build, collections, Build tools, search,
|
||||||
## search, zoom), the toast at the bottom and the endless-loop warning chip.
|
## View ▾, Help ▾ and the zoom control), the toast at the bottom and the
|
||||||
|
## endless-loop warning chip.
|
||||||
|
|
||||||
var m: Main
|
var m: Main
|
||||||
|
|
||||||
|
|
@ -9,9 +10,11 @@ var _hint: Label
|
||||||
var _play_button: Button
|
var _play_button: Button
|
||||||
var _build_button: Button
|
var _build_button: Button
|
||||||
var _build_tools: Control
|
var _build_tools: Control
|
||||||
var _collapse_all: Button
|
|
||||||
var _switcher: CollectionSwitcher
|
var _switcher: CollectionSwitcher
|
||||||
var _board_menu: IoMenu
|
var _board_menu: IoMenu
|
||||||
|
var view_menu: ViewMenu
|
||||||
|
var help_menu: HelpMenu
|
||||||
|
var zoom: ZoomControl
|
||||||
var _toast: PanelContainer
|
var _toast: PanelContainer
|
||||||
var _toast_label: Label
|
var _toast_label: Label
|
||||||
var _toast_undo: Button
|
var _toast_undo: Button
|
||||||
|
|
@ -21,7 +24,6 @@ var _toast_serial := -1
|
||||||
var _endless_chip: PanelContainer
|
var _endless_chip: PanelContainer
|
||||||
var _endless_label: Label
|
var _endless_label: Label
|
||||||
var _endless_timer: Timer
|
var _endless_timer: Timer
|
||||||
var _rules_buttons: Array[Button] = []
|
|
||||||
|
|
||||||
|
|
||||||
func _init(p_main: Main) -> void:
|
func _init(p_main: Main) -> void:
|
||||||
|
|
@ -90,43 +92,28 @@ func _build_top_bar() -> Control:
|
||||||
_board_menu.import_requested.connect(m.collections.import_collection)
|
_board_menu.import_requested.connect(m.collections.import_collection)
|
||||||
_board_menu.test_requested.connect(m.collections.open_test_board)
|
_board_menu.test_requested.connect(m.collections.open_test_board)
|
||||||
_board_menu.export_requested.connect(m.collections.export_collection)
|
_board_menu.export_requested.connect(m.collections.export_collection)
|
||||||
|
_board_menu.pack_requested.connect(m.nav.pack_collapsed_groups)
|
||||||
tools.add_child(_board_menu)
|
tools.add_child(_board_menu)
|
||||||
# Test board… lives in the Board ▾ menu to keep the Build bar from overflowing.
|
|
||||||
tools.add_child(m.nav._make_arrange_menu())
|
|
||||||
tools.visible = false
|
tools.visible = false
|
||||||
h.add_child(tools)
|
h.add_child(tools)
|
||||||
|
|
||||||
_endless_chip = _make_endless_chip()
|
_endless_chip = _make_endless_chip()
|
||||||
h.add_child(_endless_chip)
|
h.add_child(_endless_chip)
|
||||||
|
|
||||||
h.add_child(_make_rules_switch())
|
|
||||||
|
|
||||||
m.nav._search_button = _make_search_button()
|
m.nav._search_button = _make_search_button()
|
||||||
h.add_child(m.nav._search_button)
|
h.add_child(m.nav._search_button)
|
||||||
|
|
||||||
_collapse_all = Style.bar_button("Collapse all")
|
view_menu = ViewMenu.new()
|
||||||
_collapse_all.tooltip_text = "Collapse or expand every table at once"
|
view_menu.setup(m)
|
||||||
_collapse_all.pressed.connect(func() -> void: m.set_all_collapsed(m._any_expanded()))
|
h.add_child(view_menu)
|
||||||
h.add_child(_collapse_all)
|
help_menu = HelpMenu.new()
|
||||||
|
help_menu.setup(m)
|
||||||
var zoom := HBoxContainer.new()
|
h.add_child(help_menu)
|
||||||
zoom.add_theme_constant_override("separation", 6)
|
zoom = ZoomControl.new()
|
||||||
var zout := Style.bar_button("−")
|
zoom.setup(m)
|
||||||
zout.tooltip_text = "Zoom out"
|
|
||||||
zout.custom_minimum_size = Vector2(34, 0)
|
|
||||||
zout.pressed.connect(func() -> void: m.board.set_zoom(m.board.zoom / 1.15))
|
|
||||||
var zfit := Style.bar_button("Fit")
|
|
||||||
zfit.tooltip_text = "Show every table"
|
|
||||||
zfit.pressed.connect(func() -> void: m.board.fit())
|
|
||||||
var zin := Style.bar_button("+")
|
|
||||||
zin.tooltip_text = "Zoom in"
|
|
||||||
zin.custom_minimum_size = Vector2(34, 0)
|
|
||||||
zin.pressed.connect(func() -> void: m.board.set_zoom(m.board.zoom * 1.15))
|
|
||||||
for b in [zout, zfit, zin]:
|
|
||||||
zoom.add_child(b)
|
|
||||||
m.nav._map_toggle = m.nav._make_map_toggle()
|
|
||||||
zoom.add_child(m.nav._map_toggle)
|
|
||||||
h.add_child(zoom)
|
h.add_child(zoom)
|
||||||
|
# Show or hide the minimap as remembered for the starting mode.
|
||||||
|
m.nav._nav_mode_changed.call_deferred()
|
||||||
return bar
|
return bar
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -145,7 +132,8 @@ func _seg_button(text: String, group: ButtonGroup) -> Button:
|
||||||
|
|
||||||
|
|
||||||
func _make_search_button() -> Button:
|
func _make_search_button() -> Button:
|
||||||
var b := Style.bar_button("Search")
|
var b := Style.bar_button("")
|
||||||
|
b.custom_minimum_size = Vector2(38, 0)
|
||||||
b.tooltip_text = "Find a card by its name, results, prompt, variables or group (Ctrl+F)"
|
b.tooltip_text = "Find a card by its name, results, prompt, variables or group (Ctrl+F)"
|
||||||
_bar_icon(b, func(c: Control) -> void:
|
_bar_icon(b, func(c: Control) -> void:
|
||||||
c.draw_arc(Vector2(6.5, 6.5), 5.0, 0.0, TAU, 24, Style.ON_FELT, 1.8, true)
|
c.draw_arc(Vector2(6.5, 6.5), 5.0, 0.0, TAU, 24, Style.ON_FELT, 1.8, true)
|
||||||
|
|
@ -154,55 +142,22 @@ func _make_search_button() -> Button:
|
||||||
return b
|
return b
|
||||||
|
|
||||||
|
|
||||||
## Puts a 16 px drawn icon at the left of a top-bar button.
|
## Puts a 16 px drawn icon on a top-bar button: at the left of its text, or
|
||||||
|
## centred when the button has no text.
|
||||||
func _bar_icon(b: Button, paint: Callable) -> void:
|
func _bar_icon(b: Button, paint: Callable) -> void:
|
||||||
|
var icon_only := b.text == ""
|
||||||
for n in ["normal", "hover", "pressed", "hover_pressed", "disabled"]:
|
for n in ["normal", "hover", "pressed", "hover_pressed", "disabled"]:
|
||||||
var sb := b.get_theme_stylebox(n) as StyleBoxFlat
|
var sb := b.get_theme_stylebox(n) as StyleBoxFlat
|
||||||
if sb:
|
if sb and not icon_only:
|
||||||
sb.content_margin_left = 32
|
sb.content_margin_left = 32
|
||||||
var icon := Control.new()
|
var icon := Control.new()
|
||||||
icon.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
icon.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
icon.size = Vector2(16, 16)
|
icon.size = Vector2(16, 16)
|
||||||
icon.draw.connect(paint.bind(icon))
|
icon.draw.connect(paint.bind(icon))
|
||||||
b.add_child(icon)
|
b.add_child(icon)
|
||||||
b.resized.connect(func() -> void: icon.position = Vector2(11, roundf((b.size.y - 16.0) / 2.0)))
|
b.resized.connect(func() -> void:
|
||||||
|
var x := roundf((b.size.x - 16.0) / 2.0) if icon_only else 11.0
|
||||||
|
icon.position = Vector2(x, roundf((b.size.y - 16.0) / 2.0)))
|
||||||
func _sync_rules_switch() -> void:
|
|
||||||
if _rules_buttons.size() == 2:
|
|
||||||
_rules_buttons[0].set_pressed_no_signal(m.rules_plain())
|
|
||||||
_rules_buttons[1].set_pressed_no_signal(not m.rules_plain())
|
|
||||||
|
|
||||||
|
|
||||||
## The top bar's compact "Plain | Text" rules switch.
|
|
||||||
func _make_rules_switch() -> Control:
|
|
||||||
var seg := PanelContainer.new()
|
|
||||||
seg.add_theme_stylebox_override("panel", Style.box(Color(0, 0, 0, 0.28), 9, [3, 3, 3, 3]))
|
|
||||||
seg.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
|
||||||
seg.tooltip_text = "Show rules in plain words, or as the rule text they're stored as"
|
|
||||||
var row := HBoxContainer.new()
|
|
||||||
row.add_theme_constant_override("separation", 0)
|
|
||||||
seg.add_child(row)
|
|
||||||
var group := ButtonGroup.new()
|
|
||||||
_rules_buttons.clear()
|
|
||||||
for pair in [["Plain", "plain"], ["Text", "text"]]:
|
|
||||||
var b := _seg_button(str(pair[0]), group)
|
|
||||||
b.add_theme_font_size_override("font_size", 14)
|
|
||||||
for n in ["normal", "hover", "pressed", "hover_pressed"]:
|
|
||||||
var sb := b.get_theme_stylebox(n) as StyleBoxFlat
|
|
||||||
if sb:
|
|
||||||
sb.content_margin_left = 10
|
|
||||||
sb.content_margin_right = 10
|
|
||||||
sb.content_margin_top = 4
|
|
||||||
sb.content_margin_bottom = 4
|
|
||||||
b.tooltip_text = "Rules: show them in plain words" if pair[1] == "plain" else "Rules: show them as rule text (@luck -= 1)"
|
|
||||||
b.focus_mode = Control.FOCUS_NONE
|
|
||||||
var v: String = pair[1]
|
|
||||||
b.pressed.connect(func() -> void: m.set_rules_view(v))
|
|
||||||
row.add_child(b)
|
|
||||||
_rules_buttons.append(b)
|
|
||||||
_sync_rules_switch()
|
|
||||||
return seg
|
|
||||||
|
|
||||||
|
|
||||||
# ----- Toast -----
|
# ----- Toast -----
|
||||||
|
|
|
||||||
24
ui/style.gd
24
ui/style.gd
|
|
@ -16,6 +16,8 @@ const BRASS_DARK := Color("#6e5410")
|
||||||
const LIT := Color("#f8e4a2")
|
const LIT := Color("#f8e4a2")
|
||||||
const FLICK := Color(0.953, 0.769, 0.314, 0.35)
|
const FLICK := Color(0.953, 0.769, 0.314, 0.35)
|
||||||
const HOVER_ROW := Color("#e9e4d6")
|
const HOVER_ROW := Color("#e9e4d6")
|
||||||
|
## Every second result row on a card ("parchment" zebra stripe).
|
||||||
|
const STRIPE := Color(0.11, 0.145, 0.125, 0.055)
|
||||||
const ON_FELT := Color("#e9efe9")
|
const ON_FELT := Color("#e9efe9")
|
||||||
const ON_FELT_MUTED := Color("#a8bdb1")
|
const ON_FELT_MUTED := Color("#a8bdb1")
|
||||||
const DANGER := Color("#e0574a")
|
const DANGER := Color("#e0574a")
|
||||||
|
|
@ -179,6 +181,28 @@ static func menu_button(text: String, primary: bool = false, onto: MenuButton =
|
||||||
return mb
|
return mb
|
||||||
|
|
||||||
|
|
||||||
|
## A "⋯" overflow menu button (group cards and Build-mode table cards), with
|
||||||
|
## its popup styled. `on_felt` picks the light-on-felt look.
|
||||||
|
static func overflow_button(tooltip: String, on_felt: bool = false) -> MenuButton:
|
||||||
|
var mb := MenuButton.new()
|
||||||
|
mb.text = "⋯"
|
||||||
|
mb.flat = false
|
||||||
|
mb.tooltip_text = tooltip
|
||||||
|
mb.custom_minimum_size = Vector2(30, 26)
|
||||||
|
mb.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||||
|
mb.add_theme_font_override("font", body_bold(true))
|
||||||
|
mb.add_theme_font_size_override("font_size", 16)
|
||||||
|
var hover := box(Color(1, 1, 1, 0.1) if on_felt else Color("#e6dfcd"), 6)
|
||||||
|
for n in ["normal", "disabled", "focus"]:
|
||||||
|
mb.add_theme_stylebox_override(n, box(Color(0, 0, 0, 0), 6))
|
||||||
|
for n in ["hover", "pressed", "hover_pressed"]:
|
||||||
|
mb.add_theme_stylebox_override(n, hover)
|
||||||
|
font_colors(mb, ON_FELT if on_felt else MUTED)
|
||||||
|
mb.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||||
|
ModalCard.style_popup(mb.get_popup())
|
||||||
|
return mb
|
||||||
|
|
||||||
|
|
||||||
const BUTTON_FONT_COLORS: Array[String] = ["font_color", "font_hover_color", "font_focus_color",
|
const BUTTON_FONT_COLORS: Array[String] = ["font_color", "font_hover_color", "font_focus_color",
|
||||||
"font_pressed_color", "font_hover_pressed_color"]
|
"font_pressed_color", "font_hover_pressed_color"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,16 @@
|
||||||
class_name TableCardEditing
|
class_name TableCardEditing
|
||||||
extends RefCounted
|
extends RefCounted
|
||||||
## A TableCard's Build-mode controls: the inline result-text, weight and range
|
## A TableCard's Build-mode controls: the inline result-text, weight and range
|
||||||
## fields, router case rows with move and delete, and the footer (add a
|
## fields, router case rows with move and delete, the footer (add a result,
|
||||||
## result, option or case; delete the table). Everything else is edited in
|
## option or case), the card's ⋯ menu (settings, template, collapse, delete)
|
||||||
## Main's inspector.
|
## and the row × that shows only on hover or selection. Everything else is
|
||||||
|
## edited in Main's inspector.
|
||||||
|
|
||||||
|
## The card's ⋯ menu items.
|
||||||
|
const MENU_SETTINGS := 0
|
||||||
|
const MENU_TEMPLATE := 1
|
||||||
|
const MENU_COLLAPSE := 2
|
||||||
|
const MENU_DELETE := 3
|
||||||
|
|
||||||
var card: TableCard
|
var card: TableCard
|
||||||
|
|
||||||
|
|
@ -84,12 +91,14 @@ func make_case_row(e: TableEntry, index: int, numw: float) -> Control:
|
||||||
top.add_child(cond)
|
top.add_child(cond)
|
||||||
top.add_child(mini_button("↑", "Move this case up", index > 0, func() -> void: _move_case(index, -1)))
|
top.add_child(mini_button("↑", "Move this case up", index > 0, func() -> void: _move_case(index, -1)))
|
||||||
top.add_child(mini_button("↓", "Move this case down", index < table.entries.size() - 1, func() -> void: _move_case(index, 1)))
|
top.add_child(mini_button("↓", "Move this case down", index < table.entries.size() - 1, func() -> void: _move_case(index, 1)))
|
||||||
top.add_child(mini_button("×", "Delete this case", true, func() -> void: main.delete_entry(table.id, e.id)))
|
var del := mini_button("×", "Delete this case", true, func() -> void: main.delete_entry(table.id, e.id))
|
||||||
|
top.add_child(del)
|
||||||
|
|
||||||
v.add_child(text_edit(e, index, false))
|
v.add_child(text_edit(e, index, false))
|
||||||
card.rows_ui.add_rule_chips(v, e)
|
card.rows_ui.add_rule_chips(v, e)
|
||||||
hook_select(row, e.id)
|
hook_select(row, e.id)
|
||||||
card.rows_ui.register(e, row, num, null, index)
|
card.rows_ui.register(e, row, num, null, index)
|
||||||
|
reveal_on_hover(e.id, row, del)
|
||||||
return row
|
return row
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -220,14 +229,7 @@ func make_footer(ranged: bool) -> Control:
|
||||||
addc.tooltip_text = "Add a case before Otherwise"
|
addc.tooltip_text = "Add a case before Otherwise"
|
||||||
addc.pressed.connect(add_case)
|
addc.pressed.connect(add_case)
|
||||||
h.add_child(addc)
|
h.add_child(addc)
|
||||||
var spacer := Control.new()
|
# Deleting the table lives in the card's ⋯ menu.
|
||||||
spacer.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
||||||
spacer.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
||||||
h.add_child(spacer)
|
|
||||||
var del := footer_button("Delete", Style.DANGER_INK)
|
|
||||||
del.tooltip_text = "Delete this table"
|
|
||||||
del.pressed.connect(func() -> void: main.delete_table(table.id))
|
|
||||||
h.add_child(del)
|
|
||||||
return wrap
|
return wrap
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -239,3 +241,56 @@ static func footer_button(text: String, hover_color: Color) -> Button:
|
||||||
var hover := Style.bordered(Style.box(Color(0, 0, 0, 0), 6, [10, 4, 10, 4]), 1, hover_color if hover_color != Style.INK else Style.MUTED)
|
var hover := Style.bordered(Style.box(Color(0, 0, 0, 0), 6, [10, 4, 10, 4]), 1, hover_color if hover_color != Style.INK else Style.MUTED)
|
||||||
Style.skin_button(b, normal, hover, hover, Style.MUTED, hover_color)
|
Style.skin_button(b, normal, hover, hover, Style.MUTED, hover_color)
|
||||||
return b
|
return b
|
||||||
|
|
||||||
|
|
||||||
|
## Build mode's "⋯" menu on the card: settings, save as template, collapse
|
||||||
|
## and delete (the same pattern as a group card's ⋯ menu).
|
||||||
|
func make_card_menu() -> MenuButton:
|
||||||
|
var table := card.table
|
||||||
|
var main := card.main
|
||||||
|
var mb := Style.overflow_button("Table actions")
|
||||||
|
var pm := mb.get_popup()
|
||||||
|
pm.add_item("Table settings…", MENU_SETTINGS)
|
||||||
|
pm.add_item("Save as template…", MENU_TEMPLATE)
|
||||||
|
if card.can_collapse():
|
||||||
|
pm.add_item("Expand" if table.collapsed else "Collapse", MENU_COLLAPSE)
|
||||||
|
pm.add_separator()
|
||||||
|
pm.add_item("Delete table", MENU_DELETE)
|
||||||
|
pm.id_pressed.connect(func(id: int) -> void:
|
||||||
|
match id:
|
||||||
|
MENU_SETTINGS:
|
||||||
|
main.request_table_settings(table.id)
|
||||||
|
MENU_TEMPLATE:
|
||||||
|
main.save_template_from([table.id], "card")
|
||||||
|
MENU_COLLAPSE:
|
||||||
|
main.toggle_collapse(table.id)
|
||||||
|
MENU_DELETE:
|
||||||
|
main.delete_table(table.id)
|
||||||
|
)
|
||||||
|
return mb
|
||||||
|
|
||||||
|
|
||||||
|
## Build mode: a row's delete × shows only while the row is hovered, the ×
|
||||||
|
## has keyboard focus, or the row is the inspector's selected result.
|
||||||
|
func reveal_on_hover(eid: String, row: Control, button: Button) -> void:
|
||||||
|
card.rows_ui.parts[eid]["delete"] = button
|
||||||
|
row.mouse_entered.connect(func() -> void:
|
||||||
|
row.set_meta("hovered", true)
|
||||||
|
sync_delete(eid))
|
||||||
|
row.mouse_exited.connect(func() -> void:
|
||||||
|
# Moving onto a child control still counts as inside the row.
|
||||||
|
row.set_meta("hovered", row.get_global_rect().has_point(row.get_global_mouse_position()))
|
||||||
|
sync_delete(eid))
|
||||||
|
button.focus_entered.connect(sync_delete.bind(eid))
|
||||||
|
button.focus_exited.connect(sync_delete.bind(eid))
|
||||||
|
sync_delete(eid)
|
||||||
|
|
||||||
|
|
||||||
|
## Shows or hides a row's ×; TableCardRows.set_row_state calls it too.
|
||||||
|
func sync_delete(eid: String) -> void:
|
||||||
|
var b: Button = card.rows_ui.parts.get(eid, {}).get("delete")
|
||||||
|
if b == null or not is_instance_valid(b):
|
||||||
|
return
|
||||||
|
var row: Control = card.rows.get(eid)
|
||||||
|
var hovered := row != null and bool(row.get_meta("hovered", false))
|
||||||
|
b.modulate.a = 1.0 if hovered or b.has_focus() or eid == card.selected_entry() else 0.0
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
class_name TableCardHeader
|
class_name TableCardHeader
|
||||||
extends RefCounted
|
extends RefCounted
|
||||||
## The top of a TableCard: collapse chevron, name (or its inline editor and
|
## The top of a TableCard: collapse chevron, name (or its inline editor and
|
||||||
## settings gear in Build), the go button, the card-mode deck row and the
|
## ⋯ menu in Build), the go button, the card-mode deck row and the
|
||||||
## kind-specific lines under the title, plus the dashed inputs box. Owns the
|
## kind-specific lines under the title, plus the dashed inputs box. Owns the
|
||||||
## live labels refresh_live() updates (a choice's question, "3 available now").
|
## live labels refresh_live() updates (a choice's question, "3 available now").
|
||||||
|
|
||||||
|
|
@ -68,15 +68,7 @@ func make(build: bool, ranged: bool) -> Control:
|
||||||
main.mark_dirty()
|
main.mark_dirty()
|
||||||
)
|
)
|
||||||
row.add_child(name_edit)
|
row.add_child(name_edit)
|
||||||
var gear := Button.new()
|
row.add_child(card.edit_ui.make_card_menu())
|
||||||
gear.text = "⚙"
|
|
||||||
gear.tooltip_text = "Table settings"
|
|
||||||
gear.custom_minimum_size = Vector2(26, 26)
|
|
||||||
gear.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
|
||||||
gear.add_theme_font_size_override("font_size", 16)
|
|
||||||
Style.skin_button(gear, Style.box(Color(0, 0, 0, 0), 6), Style.box(Color("#e6dfcd"), 6), Style.box(Color("#e6dfcd"), 6), Style.MUTED, Style.INK)
|
|
||||||
gear.pressed.connect(func() -> void: main.request_table_settings(table.id))
|
|
||||||
row.add_child(gear)
|
|
||||||
else:
|
else:
|
||||||
var titles := TableCard.vbox(3)
|
var titles := TableCard.vbox(3)
|
||||||
titles.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
titles.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ var parts: Dictionary = {}
|
||||||
var more_label: Label
|
var more_label: Label
|
||||||
var sheet_label: RichTextLabel
|
var sheet_label: RichTextLabel
|
||||||
|
|
||||||
|
## Row styles by state, then +3 for the inspector's selected result, then +6
|
||||||
|
## for a striped (every second) row.
|
||||||
var _row_styles: Array[StyleBoxFlat] = []
|
var _row_styles: Array[StyleBoxFlat] = []
|
||||||
var _flick_id := ""
|
var _flick_id := ""
|
||||||
## Chance labels by entry id (ranged rows in Play mode), kept current by
|
## Chance labels by entry id (ranged rows in Play mode), kept current by
|
||||||
|
|
@ -28,15 +30,18 @@ var _odds: Dictionary = {}
|
||||||
|
|
||||||
func _init(p_card: TableCard) -> void:
|
func _init(p_card: TableCard) -> void:
|
||||||
card = p_card
|
card = p_card
|
||||||
for c in [Color(0, 0, 0, 0), Style.FLICK, Style.LIT]:
|
# Normal, flicker and lit; then the same with the copper bar of the
|
||||||
_row_styles.append(Style.box(c, 0, [12, 6, 22, 6]))
|
# inspector's selected result. Striped rows tint only the normal state, so
|
||||||
# The same, with the copper bar of the inspector's selected result.
|
# the flicker and the lit result always read over the stripe.
|
||||||
for c in [Color(0, 0, 0, 0), Style.FLICK, Style.LIT]:
|
for striped in [false, true]:
|
||||||
var sel := Style.box(c, 0, [12, 6, 22, 6])
|
for selected in [false, true]:
|
||||||
sel.border_width_left = 3
|
for c in [Style.STRIPE if striped else Color(0, 0, 0, 0), Style.FLICK, Style.LIT]:
|
||||||
sel.border_color = Style.COPPER
|
var sb := Style.box(c, 0, [12, 6, 22, 6])
|
||||||
sel.anti_aliasing = false
|
if selected:
|
||||||
_row_styles.append(sel)
|
sb.border_width_left = 3
|
||||||
|
sb.border_color = Style.COPPER
|
||||||
|
sb.anti_aliasing = false
|
||||||
|
_row_styles.append(sb)
|
||||||
|
|
||||||
|
|
||||||
## Forgets the previous build's rows.
|
## Forgets the previous build's rows.
|
||||||
|
|
@ -100,6 +105,7 @@ func make_row(e: TableEntry, index: int, build: bool, ranged: bool, numw: float)
|
||||||
h.add_child(num)
|
h.add_child(num)
|
||||||
|
|
||||||
var text: RichTextLabel = null
|
var text: RichTextLabel = null
|
||||||
|
var delete_button: Button = null
|
||||||
if build:
|
if build:
|
||||||
h.add_theme_constant_override("separation", 4)
|
h.add_theme_constant_override("separation", 4)
|
||||||
var col := TableCard.vbox(2)
|
var col := TableCard.vbox(2)
|
||||||
|
|
@ -125,7 +131,8 @@ func make_row(e: TableEntry, index: int, build: bool, ranged: bool, numw: float)
|
||||||
if not ranged and not fixed:
|
if not ranged and not fixed:
|
||||||
h.add_child(edit.weight_edit(e))
|
h.add_child(edit.weight_edit(e))
|
||||||
if not fixed and not chosen:
|
if not fixed and not chosen:
|
||||||
h.add_child(TableCardEditing.mini_button("×", "Delete this result", true, func() -> void: main.delete_entry(table.id, e.id)))
|
delete_button = TableCardEditing.mini_button("×", "Delete this result", true, func() -> void: main.delete_entry(table.id, e.id))
|
||||||
|
h.add_child(delete_button)
|
||||||
edit.hook_select(row, e.id)
|
edit.hook_select(row, e.id)
|
||||||
else:
|
else:
|
||||||
var col := TableCard.vbox(3)
|
var col := TableCard.vbox(3)
|
||||||
|
|
@ -151,6 +158,8 @@ func make_row(e: TableEntry, index: int, build: bool, ranged: bool, numw: float)
|
||||||
num.mouse_filter = Control.MOUSE_FILTER_PASS
|
num.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||||
|
|
||||||
register(e, row, num, text, index)
|
register(e, row, num, text, index)
|
||||||
|
if delete_button:
|
||||||
|
edit.reveal_on_hover(e.id, row, delete_button)
|
||||||
return row
|
return row
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -421,9 +430,12 @@ func more_text() -> String:
|
||||||
func set_row_state(eid: String, state: RowState) -> void:
|
func set_row_state(eid: String, state: RowState) -> void:
|
||||||
if not card.rows.has(eid):
|
if not card.rows.has(eid):
|
||||||
return
|
return
|
||||||
var k := int(state) + (3 if eid == card.selected_entry() else 0)
|
|
||||||
(card.rows[eid] as PanelContainer).add_theme_stylebox_override("panel", _row_styles[k])
|
|
||||||
var p: Dictionary = parts[eid]
|
var p: Dictionary = parts[eid]
|
||||||
|
var k := int(state) + (3 if eid == card.selected_entry() else 0)
|
||||||
|
if int(p["index"]) % 2 == 1 and card.main.local_state.striped_rows():
|
||||||
|
k += 6
|
||||||
|
(card.rows[eid] as PanelContainer).add_theme_stylebox_override("panel", _row_styles[k])
|
||||||
|
card.edit_ui.sync_delete(eid)
|
||||||
var num: Label = p["num"]
|
var num: Label = p["num"]
|
||||||
if num:
|
if num:
|
||||||
num.add_theme_color_override("font_color", Style.INK if state == RowState.LIT else Style.MUTED)
|
num.add_theme_color_override("font_color", Style.INK if state == RowState.LIT else Style.MUTED)
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ func refresh() -> void:
|
||||||
any = true
|
any = true
|
||||||
_list.add_child(_row(r))
|
_list.add_child(_row(r))
|
||||||
if not any:
|
if not any:
|
||||||
_list.add_child(ModalCard.note("No templates match." if q != "" else "No templates yet. Save one from a card's ⚙, a group's ⋯ menu or a selection."))
|
_list.add_child(ModalCard.note("No templates match." if q != "" else "No templates yet. Save one from a card's or a group's ⋯ menu, or from a selection."))
|
||||||
if not _rows.has(_selected):
|
if not _rows.has(_selected):
|
||||||
_selected = ""
|
_selected = ""
|
||||||
_insert.disabled = _selected == ""
|
_insert.disabled = _selected == ""
|
||||||
|
|
|
||||||
61
ui/view_menu.gd
Normal file
61
ui/view_menu.gd
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
class_name ViewMenu
|
||||||
|
extends MenuButton
|
||||||
|
## The top bar's "View ▾" menu: how rules read (plain words or rule text),
|
||||||
|
## collapsing or expanding every table, striped result rows and the minimap.
|
||||||
|
## These are view preferences, so they live in one menu instead of the bar.
|
||||||
|
|
||||||
|
const ID_PLAIN := 0
|
||||||
|
const ID_TEXT := 1
|
||||||
|
const ID_COLLAPSE := 2
|
||||||
|
const ID_STRIPES := 3
|
||||||
|
const ID_MINIMAP := 4
|
||||||
|
|
||||||
|
var m: Main
|
||||||
|
|
||||||
|
|
||||||
|
func setup(p_main: Main) -> void:
|
||||||
|
m = p_main
|
||||||
|
Style.menu_button("View ▾", false, self)
|
||||||
|
tooltip_text = "How rules read, collapsing tables, striped rows and the minimap"
|
||||||
|
var pm := get_popup()
|
||||||
|
ModalCard.style_popup(pm)
|
||||||
|
pm.add_separator("Rules")
|
||||||
|
pm.add_radio_check_item("Plain words", ID_PLAIN)
|
||||||
|
pm.set_item_tooltip(pm.get_item_index(ID_PLAIN), "Show rules in plain words: “Subtract 1 from Luck”")
|
||||||
|
pm.add_radio_check_item("Rule text", ID_TEXT)
|
||||||
|
pm.set_item_tooltip(pm.get_item_index(ID_TEXT), "Show rules as the text they're stored as: @luck -= 1")
|
||||||
|
pm.add_separator("Tables")
|
||||||
|
pm.add_item("Collapse all tables", ID_COLLAPSE)
|
||||||
|
pm.add_separator("Show")
|
||||||
|
pm.add_check_item("Striped rows", ID_STRIPES)
|
||||||
|
pm.add_check_item("Minimap (M)", ID_MINIMAP)
|
||||||
|
pm.about_to_popup.connect(sync)
|
||||||
|
pm.id_pressed.connect(activate)
|
||||||
|
|
||||||
|
|
||||||
|
## Brings the checks and the Collapse/Expand label up to date.
|
||||||
|
func sync() -> void:
|
||||||
|
var pm := get_popup()
|
||||||
|
pm.set_item_checked(pm.get_item_index(ID_PLAIN), m.rules_plain())
|
||||||
|
pm.set_item_checked(pm.get_item_index(ID_TEXT), not m.rules_plain())
|
||||||
|
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_MINIMAP), m.board.minimap.visible)
|
||||||
|
|
||||||
|
|
||||||
|
func collapse_label() -> String:
|
||||||
|
return "Collapse all tables" if m._any_expanded() else "Expand all tables"
|
||||||
|
|
||||||
|
|
||||||
|
func activate(id: int) -> void:
|
||||||
|
match id:
|
||||||
|
ID_PLAIN:
|
||||||
|
m.set_rules_view("plain")
|
||||||
|
ID_TEXT:
|
||||||
|
m.set_rules_view("text")
|
||||||
|
ID_COLLAPSE:
|
||||||
|
m.set_all_collapsed(m._any_expanded())
|
||||||
|
ID_STRIPES:
|
||||||
|
m.local_state.set_striped_rows(not m.local_state.striped_rows())
|
||||||
|
ID_MINIMAP:
|
||||||
|
m.nav.set_minimap_visible(not m.board.minimap.visible, true)
|
||||||
1
ui/view_menu.gd.uid
Normal file
1
ui/view_menu.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cxkptc6vkgcmc
|
||||||
60
ui/zoom_control.gd
Normal file
60
ui/zoom_control.gd
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
class_name ZoomControl
|
||||||
|
extends HBoxContainer
|
||||||
|
## The top bar's zoom: − and + around a "90% ▾" menu that offers Fit board,
|
||||||
|
## Zoom to 100% and the minimap. The percentage follows the board's zoom,
|
||||||
|
## however it changed (buttons, wheel, Fit or a pan-and-zoom animation).
|
||||||
|
|
||||||
|
const ID_FIT := 0
|
||||||
|
const ID_ACTUAL := 1
|
||||||
|
const ID_MINIMAP := 2
|
||||||
|
const STEP := 1.15
|
||||||
|
|
||||||
|
var m: Main
|
||||||
|
var menu: MenuButton
|
||||||
|
var _shown := -1.0
|
||||||
|
|
||||||
|
|
||||||
|
func setup(p_main: Main) -> void:
|
||||||
|
m = p_main
|
||||||
|
add_theme_constant_override("separation", 4)
|
||||||
|
var zout := _step_button("−", "Zoom out", 1.0 / STEP)
|
||||||
|
add_child(zout)
|
||||||
|
menu = ModalCard.bar_menu_button("100% ▾")
|
||||||
|
menu.tooltip_text = "Zoom: fit the board, 100% or the minimap"
|
||||||
|
menu.custom_minimum_size.x = 86
|
||||||
|
var pm := menu.get_popup()
|
||||||
|
pm.add_item("Fit board", ID_FIT)
|
||||||
|
pm.set_item_tooltip(pm.get_item_index(ID_FIT), "Show every table")
|
||||||
|
pm.add_item("Zoom to 100%", ID_ACTUAL)
|
||||||
|
pm.add_separator()
|
||||||
|
pm.add_check_item("Minimap (M)", ID_MINIMAP)
|
||||||
|
pm.about_to_popup.connect(func() -> void:
|
||||||
|
pm.set_item_checked(pm.get_item_index(ID_MINIMAP), m.board.minimap.visible))
|
||||||
|
pm.id_pressed.connect(activate)
|
||||||
|
add_child(menu)
|
||||||
|
add_child(_step_button("+", "Zoom in", STEP))
|
||||||
|
|
||||||
|
|
||||||
|
func _step_button(text: String, tip: String, factor: float) -> Button:
|
||||||
|
var b := Style.bar_button(text)
|
||||||
|
b.tooltip_text = tip
|
||||||
|
b.custom_minimum_size = Vector2(34, 0)
|
||||||
|
b.pressed.connect(func() -> void: m.board.set_zoom(m.board.zoom * factor))
|
||||||
|
return b
|
||||||
|
|
||||||
|
|
||||||
|
func activate(id: int) -> void:
|
||||||
|
match id:
|
||||||
|
ID_FIT:
|
||||||
|
m.board.fit()
|
||||||
|
ID_ACTUAL:
|
||||||
|
m.board.set_zoom(1.0)
|
||||||
|
ID_MINIMAP:
|
||||||
|
m.nav.set_minimap_visible(not m.board.minimap.visible, true)
|
||||||
|
|
||||||
|
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
|
if m == null or m.board == null or is_equal_approx(m.board.zoom, _shown):
|
||||||
|
return
|
||||||
|
_shown = m.board.zoom
|
||||||
|
menu.text = "%d%% ▾" % roundi(_shown * 100.0)
|
||||||
1
ui/zoom_control.gd.uid
Normal file
1
ui/zoom_control.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bnhk6o64rtlhs
|
||||||
Loading…
Reference in a new issue