Skip to content

sort: clickable stress icons in the top bar - #5953

Merged
ab9rf merged 2 commits into
DFHack:developfrom
Alistair-Afton:sort-stress-icons
Sep 21, 2026
Merged

ab9rf merged 2 commits into
DFHack:developfrom
Alistair-Afton:sort-stress-icons

Conversation

@Alistair-Afton

Copy link
Copy Markdown
Contributor

Summary

  • Adds an invisible hotspot overlay widget (sort.stress_icons) over the seven stress/happiness icons next to the "Pop" label in the fortress-mode top bar.
  • Clicking an icon opens a searchable ListBox of the citizens in that stress category (e.g. "Citizens: Unhappy").
  • Selecting a citizen dismisses the list and centers the map on them via dfhack.gui.revealInDwarfmodeMap.
  • Empty categories show a brief message instead of an empty list.
  • Icon positions are discovered each second by scanning the top bar for the Pop label, so the hotspot tracks window resizes and fort-name length changes. Only active on dwarfmode/Default.
  • Includes a new in-engine test file (test/plugins/sort.lua) covering rect detection, click handling, list filtering, and map centering.

Test plan

  • test -t plugins.sort in-game on a fortress save: 5/5 tests, 38/38 checks pass
  • Clicked all seven icons in-game: populated categories open the filtered list; empty categories show the "no citizens" message
  • Selecting a dwarf recenters the map viewport on their position (verified across z-levels)
  • Clicks outside the icons pass through to the map; clicks on the modal list are consumed

@Alistair-Afton

Copy link
Copy Markdown
Contributor Author

Windows test-leg failures are the known DF startup crash (DF exited with 3221226356 at launch, before plugins load) — same signature appears in passing runs' logs, e.g. the fix-workshop-search-names run. Rebased onto develop (which now includes the #5943 retry fixes) to retrigger.

@Alistair-Afton
Alistair-Afton force-pushed the sort-stress-icons branch 2 times, most recently from 91028c6 to cf3d323 Compare September 18, 2026 05:44
Adds an invisible hotspot overlay over the seven stress/happiness icons
next to the Pop label. Clicking an icon opens a filterable list of the
citizens in that stress category, and selecting one centers the map on
them.
@Alistair-Afton

Copy link
Copy Markdown
Contributor Author

Correction to the above: the Windows failures were not the startup crash — the tests ran (310/314) and errored on icon_rects being nil. On Windows CI the window is hidden, so the vanilla top bar never renders and the Pop text the scan anchors on is absent. Fixed in 7d9af7f: the wrapper waits ~20 frames for the top bar, marks scanning unavailable when absent, and the click/list/reveal tests inject synthetic rects so the logic is still exercised. CI is now green on all legs.

The dialog choice held a unit reference captured when the list opened;
if the citizen died or left the map while the list was up, dereferencing
it was unsafe. Store the unit id and look it up again on select.
@ab9rf
ab9rf merged commit 519efc6 into DFHack:develop Sep 21, 2026
14 checks passed
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.

2 participants