Skip to content

squads: add "select all" toggle to squads sidebar - #1637

Open
Alistair-Afton wants to merge 4 commits into
DFHack:masterfrom
Alistair-Afton:squads-select-all
Open

Alistair-Afton wants to merge 4 commits into
DFHack:masterfrom
Alistair-Afton:squads-select-all

Conversation

@Alistair-Afton

@Alistair-Afton Alistair-Afton commented Sep 18, 2026

Copy link
Copy Markdown

Fixes DFHack/dfhack#5762.

Adds a Ctrl-A: Select all toggle to the squads sidebar via an overlay widget (squads.select_all).

  • Activating selects all squads; when all are selected, the label reads "Deselect all" and activating deselects them all
  • Works via mouse click and the Ctrl-A hotkey
  • Anchors itself directly above the "Create new squad" button, centered on it, and tracks when the squad list or window size changes (positions saved via gui/overlay are respected)
  • Reflects external selection changes — toggling individual squad checkboxes keeps the label accurate
  • Ignores activation while a squad/cell nickname is being typed
  • Only visible while the squads panel is open (dwarfmode/Squads focus)

Test plan

  • test -t overlay/squads — 4/4 tests pass (hotkey select, hotkey deselect, click toggle, external-change tracking)
  • Verified in-game: widget renders above "Create new squad", hotkey and click toggle selection
  • Re-anchors when squads are added/removed; widget hidden when panel closed; focus string unchanged across order-giving sub-states

Adds an overlay widget to the squads sidebar panel that selects all
squads with one click (or the Ctrl-A hotkey). Activating it again when
all squads are selected deselects them all.

The widget anchors itself below the 'Create new squad' button and
tracks external selection changes so its state stays accurate when the
user clicks individual squad checkboxes. User-set positions (via
gui/overlay) are respected.

Implements DFHack/dfhack#5762
Move the widget from below the button to directly above it, centered on
the button — the space below collides with the order icon row (shown
when squads are selected) and the button's hover help text.

Replace ToggleHotkeyLabel's On/Off suffix with a plain HotkeyLabel whose
text switches between 'Select all' and 'Deselect all'.

Fix the anchor never updating: frame.t/r changes only take effect after
updateLayout(), which now runs when the anchored position changes. Also
gate rescans on squad count/scroll/window-height so repositioning is
near-instant while staying cheap, and retry while unanchored so a
transient scan miss doesn't stick.
With a 0.1s update throttle the widget rendered at its default position
before the anchor scan ran, visibly jumping to its final spot. Run the
anchor check every tick (gated by the existing cheap scan-key bail) so
it is positioned before the first visible frame.
The disband prompt shares the dwarfmode/Squads focus string, so the
widget stayed visible (and kept consuming its hotkey) over it. Gate
widget visibility on the squads interface's disband_confirmation flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Idea: Select all squads with one button

1 participant