Groups and templates: docs, export filter and screenshot flags
Ship templates/*.json in exports, document groups and templates in the README and design doc, and add --group-menu, --drag-demo, --insert-form, --save-group-template and --clear-result for screenshots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9fdf65c00b
commit
9cd1f1ea95
5 changed files with 75 additions and 6 deletions
22
README.md
22
README.md
|
|
@ -42,6 +42,21 @@ godot --path .
|
||||||
chance. Each range takes one pipe; laying a new one replaces the old.
|
chance. Each range takes one pipe; laying a new one replaces the old.
|
||||||
- **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. **Collapse all / Expand all** in the top bar does every table at once.
|
||||||
|
- **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 **+ Table ▾**). A group is a
|
||||||
|
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
|
||||||
|
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
|
||||||
|
group and its cards (with undo). **Collapse all** and **Fit** include groups.
|
||||||
|
- **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
|
||||||
|
save dialog finds them and asks for a label and default. **+ Table ▾ → From template…**
|
||||||
|
lists your templates and the built-in ones (2D skill check, ask-and-repeat, pick menu,
|
||||||
|
counter, simple sheet), asks for the parameters and drops fresh copies at the view
|
||||||
|
centre. Pipes to cards outside the template relink by name, or are listed if they can't.
|
||||||
|
Templates live in `user://templates/` and are shared by every collection; the list can
|
||||||
|
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.
|
Ctrl+wheel or pinch to zoom, and **Fit** to see every table.
|
||||||
|
|
||||||
|
|
@ -57,6 +72,7 @@ core/ data model, roller, dice, decks, text references, storage (no UI; testa
|
||||||
io/ import and export converters
|
io/ import and export converters
|
||||||
ui/ main scene, board view, cards, pipes, ports, result tray, styles
|
ui/ main scene, board view, cards, pipes, ports, result tray, styles
|
||||||
assets/ fonts (Rokkitt and Atkinson Hyperlegible, both SIL OFL)
|
assets/ fonts (Rokkitt and Atkinson Hyperlegible, both SIL OFL)
|
||||||
|
templates/ built-in templates (read-only, listed beside the user's)
|
||||||
tests/ headless checks
|
tests/ headless checks
|
||||||
docs/ design document
|
docs/ design document
|
||||||
```
|
```
|
||||||
|
|
@ -79,6 +95,12 @@ the first questions and leaves the next pop-up open; `--menu=add`, `--open-setti
|
||||||
`--edit-effects=<id>`, `--demo-long=<n>` (a chain of n steps) and `--confirm-reset` show the
|
`--edit-effects=<id>`, `--demo-long=<n>` (a chain of n steps) and `--confirm-reset` show the
|
||||||
rest.
|
rest.
|
||||||
|
|
||||||
|
Groups and templates: `--select=<id>,<id>`, `--group-selected[=<name>]`, `--collapse-groups`,
|
||||||
|
`--expand-groups`, `--toggle-group=<id>`, `--group-menu`, `--drag-demo`, `--templates[=<search>]`,
|
||||||
|
`--insert-form=builtin:2d-check`, `--insert-template=<id> --template-values=skill=pilot|target=8`,
|
||||||
|
`--save-template=<table>`, `--save-group-template=first`, `--view=<x>,<y>[,<zoom>]`, `--fit` and
|
||||||
|
`--clear-result`.
|
||||||
|
|
||||||
This uses the sample board and doesn't save anything. `tools/test_window.sh` runs the game
|
This uses the sample board and doesn't save anything. `tools/test_window.sh` runs the game
|
||||||
under the window class "TableTower Test" (via a temporary `override.cfg`), which a KWin
|
under the window class "TableTower Test" (via a temporary `override.cfg`), which a KWin
|
||||||
window rule keeps in the background without focus.
|
window rule keeps in the background without focus.
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,22 @@ The only extra data is where each table sits on screen, saved in the optional `g
|
||||||
- **The roller ignores it,** so a bad or missing position never affects a roll.
|
- **The roller ignores it,** so a bad or missing position never affects a roll.
|
||||||
- **Small git changes:** positions snap to a grid, and the section is kept at the end of the file. This keeps changes from moving nodes small and separate from table edits.
|
- **Small git changes:** positions snap to a grid, and the section is kept at the end of the file. This keeps changes from moving nodes small and separate from table edits.
|
||||||
|
|
||||||
|
### Groups and templates
|
||||||
|
- **Groups** (optional `groups` list on a collection): `{id, name, x, y, w, h, collapsed,
|
||||||
|
members: [table ids], details?}`. A table is in at most one group; groups don't nest.
|
||||||
|
They are presentation only: the roller never reads them. Files without groups load and
|
||||||
|
save unchanged (no `groups` key is written when there are none). Import maps members
|
||||||
|
to renamed tables (or by name) and drops unknown ones with a warning.
|
||||||
|
- **Templates** (`user://templates/<slug>.json`, plus read-only built-ins in
|
||||||
|
`res://templates/`): `{format_version: 1, name, description, kind: card|group|selection,
|
||||||
|
params: [{name, label, default}], tables, groups}`. Positions are relative to the
|
||||||
|
template's top-left corner. Pipes between the template's tables keep their ids; a pipe to
|
||||||
|
any other table is stored as `{"table": "<that table's name>", "outside": true}` and is
|
||||||
|
relinked by name on insert (or dropped and reported). `{$name}` placeholders in any
|
||||||
|
string are filled in on insert, and every table, entry and group gets a fresh id.
|
||||||
|
Code: `TableGroup`, `TemplateKit`, `TemplateLibrary` (core), `GroupCard`, `GroupLayer`,
|
||||||
|
`TemplatePicker`, `TemplateForms` (ui).
|
||||||
|
|
||||||
## 6. Import and export
|
## 6. Import and export
|
||||||
|
|
||||||
### TableTower JSON
|
### TableTower JSON
|
||||||
|
|
|
||||||
|
|
@ -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=""
|
include_filter="templates/*.json"
|
||||||
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=""
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ var main: Main
|
||||||
var group: TableGroup
|
var group: TableGroup
|
||||||
## "tid:eid" -> row, for the lit results a collapsed group lists.
|
## "tid:eid" -> row, for the lit results a collapsed group lists.
|
||||||
var lit_rows: Dictionary = {}
|
var lit_rows: Dictionary = {}
|
||||||
|
## The Build-mode ⋯ menu, or null.
|
||||||
|
var menu_button: MenuButton
|
||||||
|
|
||||||
var _card: PanelContainer
|
var _card: PanelContainer
|
||||||
var _header: Control
|
var _header: Control
|
||||||
|
|
@ -74,6 +76,7 @@ func rebuild() -> void:
|
||||||
remove_child(c)
|
remove_child(c)
|
||||||
c.queue_free()
|
c.queue_free()
|
||||||
lit_rows.clear()
|
lit_rows.clear()
|
||||||
|
menu_button = null
|
||||||
_card = null
|
_card = null
|
||||||
_header = null
|
_header = null
|
||||||
position = group.position
|
position = group.position
|
||||||
|
|
@ -394,6 +397,7 @@ func _menu_button(on_felt: bool) -> MenuButton:
|
||||||
for c in ["font_color", "font_hover_color", "font_focus_color", "font_pressed_color", "font_hover_pressed_color"]:
|
for c in ["font_color", "font_hover_color", "font_focus_color", "font_pressed_color", "font_hover_pressed_color"]:
|
||||||
mb.add_theme_color_override(c, fg)
|
mb.add_theme_color_override(c, fg)
|
||||||
mb.mouse_default_cursor_shape = CURSOR_POINTING_HAND
|
mb.mouse_default_cursor_shape = CURSOR_POINTING_HAND
|
||||||
|
menu_button = mb
|
||||||
var pm := mb.get_popup()
|
var pm := mb.get_popup()
|
||||||
ModalCard.style_popup(pm)
|
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)
|
||||||
|
|
|
||||||
37
ui/main.gd
37
ui/main.gd
|
|
@ -1930,8 +1930,12 @@ func _run_logic_cli(args: PackedStringArray) -> void:
|
||||||
# --templates[=<search>] open the template list
|
# --templates[=<search>] open the template list
|
||||||
# --insert-template=<id> insert a template (builtin:<file> or a user id)
|
# --insert-template=<id> insert a template (builtin:<file> or a user id)
|
||||||
# [--template-values=<name>=<value>|…]
|
# [--template-values=<name>=<value>|…]
|
||||||
# --save-template=<table id> open the save dialog for one card
|
# --insert-form=<id> open a template's parameter form
|
||||||
# --save-group-template=<group id>
|
# --save-template=<table id or name> open the save dialog for one card
|
||||||
|
# --save-group-template=<group id|first|last>
|
||||||
|
# --group-menu open the first group's ⋯ menu (Build)
|
||||||
|
# --drag-demo hold a card over the first group's frame (Build)
|
||||||
|
# --clear-result empty the tray (the board stays lit)
|
||||||
# --view=<x>,<y>[,<zoom>] centre the view on a world point (after Fit)
|
# --view=<x>,<y>[,<zoom>] centre the view on a world point (after Fit)
|
||||||
|
|
||||||
func _run_group_cli(args: PackedStringArray) -> void:
|
func _run_group_cli(args: PackedStringArray) -> void:
|
||||||
|
|
@ -1962,12 +1966,20 @@ func _run_group_cli(args: PackedStringArray) -> void:
|
||||||
push_warning("No template %s" % ins)
|
push_warning("No template %s" % ins)
|
||||||
else:
|
else:
|
||||||
insert_template(tpl, values)
|
insert_template(tpl, values)
|
||||||
|
var form := _arg_value(args, "--insert-form")
|
||||||
|
if form != "" and not templates().get_template(form).is_empty():
|
||||||
|
begin_template_insert(templates().get_template(form))
|
||||||
var st := _arg_value(args, "--save-template")
|
var st := _arg_value(args, "--save-template")
|
||||||
if st != "":
|
if st != "":
|
||||||
save_template_from([st], "card")
|
save_template_from([Roller.resolve(data, st)], "card")
|
||||||
var sg := _arg_value(args, "--save-group-template")
|
var sg := _arg_value(args, "--save-group-template")
|
||||||
if sg != "":
|
if sg != "" and not data.groups.is_empty():
|
||||||
save_template_from([], "group", [sg])
|
var gid: String = sg
|
||||||
|
if sg == "first":
|
||||||
|
gid = data.groups[0].id
|
||||||
|
elif sg == "last":
|
||||||
|
gid = data.groups[data.groups.size() - 1].id
|
||||||
|
save_template_from([], "group", [gid])
|
||||||
for a in args:
|
for a in args:
|
||||||
if a == "--templates" or a.begins_with("--templates="):
|
if a == "--templates" or a.begins_with("--templates="):
|
||||||
var p := open_template_picker()
|
var p := open_template_picker()
|
||||||
|
|
@ -1981,6 +1993,21 @@ func _run_group_cli(args: PackedStringArray) -> void:
|
||||||
# Let new cards and frames lay out.
|
# Let new cards and frames lay out.
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
|
if args.has("--group-menu") and not data.groups.is_empty():
|
||||||
|
await get_tree().process_frame
|
||||||
|
var gn := group_node(data.groups[0].id)
|
||||||
|
if gn and gn.menu_button:
|
||||||
|
gn.menu_button.show_popup()
|
||||||
|
if args.has("--drag-demo") and not data.groups.is_empty():
|
||||||
|
# A card held over the first group's frame, to show the drop highlight.
|
||||||
|
var g := data.groups[0]
|
||||||
|
for t in data.tables:
|
||||||
|
if not g.has(t.id) and card_for(t.id).visible:
|
||||||
|
var c := card_for(t.id)
|
||||||
|
c.get_parent().move_child(c, -1)
|
||||||
|
begin_card_drag(c)
|
||||||
|
drag_card(c, g.position + Vector2(g.size.x * 0.5, TableGroup.TITLE_H + 40))
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
func _apply_view_flag(args: PackedStringArray) -> void:
|
func _apply_view_flag(args: PackedStringArray) -> void:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue