From 2703faf21272316e17689b7a04ac95deb110f76d Mon Sep 17 00:00:00 2001 From: RobinFiredrake Date: Sun, 8 Nov 2026 21:29:59 -0600 Subject: [PATCH] Inspector polish: pinned New value, title follows typing, CLI flags, README Co-Authored-By: Claude Opus 5.5 --- README.md | 23 +++++++++++++++-------- docs/LOGIC.md | 2 +- ui/inspector.gd | 29 +++++++++++++++++++++++++---- ui/inspector_card.gd | 4 ++-- ui/main.gd | 18 ++++++++++++++++++ ui/value_picker.gd | 14 ++++++++------ 6 files changed, 69 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 25e7659..9e023bf 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,16 @@ godot --path . last few rolls. - **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 ● - onto another table to lay a pipe. Click a pipe to set how many times it rolls, save its - result as a variable, or remove it. The ⚙ on a card opens its settings: details, tags, - plain or dice table (e.g. 2d6), and Card mode. + 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 + 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 + 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; + 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 + settings (Card mode and the rest). The top bar's **Plain / Text** switch shows rules in + plain words or as rule text. » hides the inspector. - **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, groups, templates, Pack and Reset sample. **Ctrl+Z** undoes and **Ctrl+Shift+Z** or @@ -40,8 +47,8 @@ godot --path . `[[Names -> hero]]` (saves the result as `{hero}` for the rest of the roll). `{@town|Towns}` keeps a value across rolls until you clear it in the tray's Variables tab. BBCode such as `[b]bold[/b]` works anywhere you type. -- **Logic cards** (see `docs/LOGIC.md`): Build mode's **+ Table ▾** also adds choice cards - (which option, how many, open ended), loops, variables and sheets. A choice card pauses the +- **Logic cards** (see `docs/LOGIC.md`): Build mode's **+ Card ▾** also adds check cards, + choice cards (which option, how many, open ended), loops, variables, collections and sheets. A choice card pauses the roll with a pop-up (1–9 pick, R for Random, Enter confirms, Esc cancels); the steps so far light up behind it. Loops show their rule (`× @rooms`, `while @hp > 0`); variable cards show their live value; sheet cards show their template filled in, and become the tray's @@ -51,7 +58,7 @@ godot --path . - **Branching:** click a pipe in Build mode to give it an **Only if** condition (`@str >= 8`), or mark it **Otherwise** so it runs only when none of that result's conditions are true. All of a result's conditions and pipe counts are checked once, before - any pipe runs, and only the pipes taken light up. A **Router** card (+ Table ▾) lists cases + any pipe runs, and only the pipes taken light up. A **Router** card (+ Card ▾) lists cases ("if @species = "Aslan"", "if @str >= 10", "Otherwise") and takes the first true one. - **Options from variables:** a pick card's settings can take its options from variables (`@skill_*` gives one option per set skill, `@contacts` one per list item), filtered with @@ -66,7 +73,7 @@ godot --path . - **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 + 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 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 @@ -74,7 +81,7 @@ godot --path . 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…** + save dialog finds them and asks for a label and default. **+ Card ▾ → 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. diff --git a/docs/LOGIC.md b/docs/LOGIC.md index a1110cc..93349e4 100644 --- a/docs/LOGIC.md +++ b/docs/LOGIC.md @@ -170,7 +170,7 @@ lazy). No existing test changed. ## 3b. Router cards -A router (`kind: "router"`, "Router" in the **+ Table ▾** menu, "if / else if / otherwise") +A router (`kind: "router"`, "Router" in the **+ Card ▾** menu, "if / else if / otherwise") has no dice. Its entries are **cases**, each with an entry-level `when` expression. - When the chain reaches it, the cases are checked top to bottom and the **first** true case diff --git a/ui/inspector.gd b/ui/inspector.gd index d7be295..7f7429b 100644 --- a/ui/inspector.gd +++ b/ui/inspector.gd @@ -26,6 +26,7 @@ var _sync_queued := false var _writing := false ## Run after every write, to refresh live sentences and problem lines. var _live: Array[Callable] = [] +var _title_label: Label # Parts the tests drive (rebuilt with the panel). var effects: EffectsBuilder @@ -173,6 +174,7 @@ func wrote(t: RollTable, all_cards: bool = false, rebuild_panel: bool = false) - for f in _live: if f.is_valid(): f.call() + _refresh_title() if rebuild_panel: rebuild() @@ -377,6 +379,7 @@ func _head(kind: String, title: String) -> Control: v.size_flags_horizontal = Control.SIZE_EXPAND_FILL v.add_child(InspectorKit.flabel(kind)) var tl := Style.make_label(title, Style.display(), 22, Style.INK) + _title_label = tl tl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART tl.custom_minimum_size = Vector2(120, 0) v.add_child(tl) @@ -394,6 +397,21 @@ func _head(kind: String, title: String) -> Control: return h +## Keeps the heading in step with the name or text being typed. +func _refresh_title() -> void: + if not is_instance_valid(_title_label): + return + var t := selected_table() + match str(selection.get("kind", "")): + "card": + if t: + _title_label.text = _title_of(t.name, "(no name)") + "result": + var e := selected_entry() + if e: + _title_label.text = _title_of(e.text, "(no text)") + + func _empty() -> void: _content.add_child(_head("Inspector", "Nothing selected")) _content.add_child(InspectorKit.note("Select a card, a result or a pipe to edit it.", Style.MUTED, 15)) @@ -425,7 +443,7 @@ func _result_section(t: RollTable, e: TableEntry) -> void: fields["text"] = le _content.add_child(InspectorKit.field("Text", le)) - var det := InspectorKit.text_box(e.details, "Shown when you hover the result (optional)", 52.0) + var det := InspectorKit.text_box(e.details, "Shown on hover (optional)", 36.0) InspectorKit.tag(det, "res.details") det.text_changed.connect(func() -> void: set_entry_details(det.text)) fields["details"] = det @@ -573,8 +591,10 @@ func _pipe_box(t: RollTable, e: TableEntry, to: String) -> Control: set_pipe_count(to, s) ) cr.add_child(count) - cr.add_child(InspectorKit.word("times · saves as")) - var save := InspectorKit.line(e.save_for(to), "nothing", 96.0) + cr.add_child(InspectorKit.word("times")) + var sr := InspectorKit.hbox(6) + sr.add_child(InspectorKit.word("Saves as")) + var save := InspectorKit.line(e.save_for(to), "nothing (or a name)") save.tooltip_text = "Keep the result as a value: a name lasts one roll, @name is kept between rolls" InspectorKit.tag(save, "pipe.%s.save" % to) save.text_changed.connect(func(s: String) -> void: @@ -583,10 +603,11 @@ func _pipe_box(t: RollTable, e: TableEntry, to: String) -> Control: InspectorKit.mark(save, msg == "") set_pipe_save(to, s) ) - cr.add_child(save) + sr.add_child(save) parts["count"] = count parts["save"] = save v.add_child(cr) + v.add_child(sr) v.add_child(cerr) var rm := InspectorKit.link("Remove pipe", "Delete this pipe") diff --git a/ui/inspector_card.gd b/ui/inspector_card.gd index 01f0873..2596507 100644 --- a/ui/inspector_card.gd +++ b/ui/inspector_card.gd @@ -49,7 +49,7 @@ static func build(insp: Inspector, box: VBoxContainer, t: RollTable) -> void: RollTable.KIND_SHEET: _sheet(insp, box, t) - var det := InspectorKit.text_box(t.details, "Notes shown under the card's title (optional)", 52.0) + var det := InspectorKit.text_box(t.details, "Notes about this card (optional)", 36.0) InspectorKit.tag(det, "card.details") det.text_changed.connect(func() -> void: insp.apply_settings({"details": det.text})) insp.fields["details"] = det @@ -532,7 +532,7 @@ static func case_block(insp: Inspector, t: RollTable, e: TableEntry, framed: boo if other and not last: fv.add_child(InspectorKit.note("Empty, so this case is an Otherwise and the cases after it never run.", Style.WARN_INK, 13)) v.add_child(fv) - if opening and framed: + if opening: insp.remove_meta("open_case") if framed: var p := PanelContainer.new() diff --git a/ui/main.gd b/ui/main.gd index f01419b..2d39d90 100644 --- a/ui/main.gd +++ b/ui/main.gd @@ -382,6 +382,12 @@ func _rebuild_cards() -> void: _rebuild_groups() _update_selection_bar() _update_collapse_all() + # A board loaded or replaced starts with nothing in the inspector; an + # undo keeps the selection (the inspector follows the board). + if inspector and not _keep_history: + inspector.clear() + elif inspector: + inspector.sync() func _refresh_lit() -> void: @@ -3616,7 +3622,14 @@ func remove_collection_member(t: RollTable, item: String) -> void: # --pick-open open the inspector's first value picker # --vars=name=value,… set board values (e.g. collection members) # --light=,… light pipes and their results, as if rolled +# --window=x resize the window first (screenshots) +# --inspect-scroll= scroll the inspector down func _run_inspector_cli(args: PackedStringArray) -> void: + var win := _arg_value(args, "--window") + if win.contains("x"): + get_window().size = Vector2i(win.get_slice("x", 0).to_int(), win.get_slice("x", 1).to_int()) + for i in 3: + await get_tree().process_frame var rv := _arg_value(args, "--rules") if rv != "": set_rules_view(rv) @@ -3643,6 +3656,11 @@ func _run_inspector_cli(args: PackedStringArray) -> void: select_result(sel.get_slice(":", 0), sel.get_slice(":", 1)) else: select_card(sel) + var scroll := _arg_value(args, "--inspect-scroll") + if scroll != "": + for i in 3: + await get_tree().process_frame + inspector._scroll.scroll_vertical = scroll.to_int() if args.has("--pick-open"): for i in 3: await get_tree().process_frame diff --git a/ui/value_picker.gd b/ui/value_picker.gd index 2175d79..814a00b 100644 --- a/ui/value_picker.gd +++ b/ui/value_picker.gd @@ -27,6 +27,7 @@ var _popup: PopupPanel var _search: LineEdit var _list: VBoxContainer var _scroll: ScrollContainer +var _new_button: Button ## Names currently listed (after the search), in order. var _shown: Array[String] = [] @@ -193,6 +194,9 @@ func _build_popup() -> void: _list.add_theme_constant_override("separation", 0) _list.size_flags_horizontal = Control.SIZE_EXPAND_FILL _scroll.add_child(_list) + _new_button = _row_button("+ New value…", "", true) + _new_button.pressed.connect(func() -> void: _ask_new(_search.text.strip_edges())) + v.add_child(_new_button) add_child(_popup) @@ -215,12 +219,10 @@ func _fill(query: String) -> void: _list.add_child(m) _list.add_child(_item_button(it)) _shown.append(str(it["name"])) - if allow_new: - var q := query.strip_edges() - var b := _row_button("+ New value…" if q == "" else "+ New value “%s”…" % q, "", true) - b.pressed.connect(func() -> void: _ask_new(q)) - _list.add_child(b) - if _shown.is_empty() and not allow_new: + var q := query.strip_edges() + _new_button.visible = allow_new + _new_button.text = "+ New value…" if q == "" else "+ New value “%s”…" % q + if _shown.is_empty(): _list.add_child(InspectorKit.note("Nothing matches.", Style.MUTED, 14)) _scroll.custom_minimum_size.y = clampf(_list.get_combined_minimum_size().y, 40.0, 300.0) if _popup.visible: