diff --git a/README.md b/README.md index b0ebb9d..183e9fd 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,21 @@ godot --path . 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 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), 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 ui/ main scene, board view, cards, pipes, ports, result tray, styles assets/ fonts (Rokkitt and Atkinson Hyperlegible, both SIL OFL) +templates/ built-in templates (read-only, listed beside the user's) tests/ headless checks docs/ design document ``` @@ -79,6 +95,12 @@ the first questions and leaves the next pop-up open; `--menu=add`, `--open-setti `--edit-effects=`, `--demo-long=` (a chain of n steps) and `--confirm-reset` show the rest. +Groups and templates: `--select=,`, `--group-selected[=]`, `--collapse-groups`, +`--expand-groups`, `--toggle-group=`, `--group-menu`, `--drag-demo`, `--templates[=]`, +`--insert-form=builtin:2d-check`, `--insert-template= --template-values=skill=pilot|target=8`, +`--save-template=`, `--save-group-template=first`, `--view=,[,]`, `--fit` and +`--clear-result`. + 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 window rule keeps in the background without focus. diff --git a/docs/DESIGN.md b/docs/DESIGN.md index f74131f..297e3d5 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -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. - **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/.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": "", "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 ### TableTower JSON diff --git a/export_presets.cfg b/export_presets.cfg index 85089d3..d7433c3 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -6,7 +6,7 @@ runnable=true dedicated_server=false custom_features="" export_filter="all_resources" -include_filter="" +include_filter="templates/*.json" exclude_filter="tests/*" export_path="build/linux/TableTower.x86_64" encryption_include_filters="" diff --git a/ui/group_card.gd b/ui/group_card.gd index 0ce7ef0..a446855 100644 --- a/ui/group_card.gd +++ b/ui/group_card.gd @@ -26,6 +26,8 @@ var main: Main var group: TableGroup ## "tid:eid" -> row, for the lit results a collapsed group lists. var lit_rows: Dictionary = {} +## The Build-mode ⋯ menu, or null. +var menu_button: MenuButton var _card: PanelContainer var _header: Control @@ -74,6 +76,7 @@ func rebuild() -> void: remove_child(c) c.queue_free() lit_rows.clear() + menu_button = null _card = null _header = null 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"]: mb.add_theme_color_override(c, fg) mb.mouse_default_cursor_shape = CURSOR_POINTING_HAND + menu_button = mb var pm := mb.get_popup() ModalCard.style_popup(pm) pm.add_item("Expand" if group.collapsed else "Collapse", MENU_TOGGLE) diff --git a/ui/main.gd b/ui/main.gd index 34b52e7..b657460 100644 --- a/ui/main.gd +++ b/ui/main.gd @@ -1930,8 +1930,12 @@ func _run_logic_cli(args: PackedStringArray) -> void: # --templates[=] open the template list # --insert-template= insert a template (builtin: or a user id) # [--template-values==|…] -# --save-template=
open the save dialog for one card -# --save-group-template= +# --insert-form= open a template's parameter form +# --save-template=
open the save dialog for one card +# --save-group-template= +# --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=,[,] centre the view on a world point (after Fit) func _run_group_cli(args: PackedStringArray) -> void: @@ -1962,12 +1966,20 @@ func _run_group_cli(args: PackedStringArray) -> void: push_warning("No template %s" % ins) else: 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") if st != "": - save_template_from([st], "card") + save_template_from([Roller.resolve(data, st)], "card") var sg := _arg_value(args, "--save-group-template") - if sg != "": - save_template_from([], "group", [sg]) + if sg != "" and not data.groups.is_empty(): + 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: if a == "--templates" or a.begins_with("--templates="): var p := open_template_picker() @@ -1981,6 +1993,21 @@ func _run_group_cli(args: PackedStringArray) -> void: # Let new cards and frames lay out. 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: