From 43f8540ca27379bb046cf24e2f81cce4ace23d6c Mon Sep 17 00:00:00 2001 From: Alistair-Afton Date: Wed, 16 Sep 2026 16:52:25 +0200 Subject: [PATCH] overlay: support Lua screen focus paths Allow native viewscreen overlays to match a DFHack Lua screen layered over the native screen. Register the designation renderer for gui/quickfort so smoothing designations are visible immediately after blueprint placement. --- docs/changelog.txt | 1 + plugins/lua/dig.lua | 1 + plugins/lua/overlay.lua | 4 ++++ test/plugins/dig.lua | 30 ++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 test/plugins/dig.lua diff --git a/docs/changelog.txt b/docs/changelog.txt index be0b51c69e..1607ec3947 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -74,6 +74,7 @@ Template for new versions: - `buildingplan`: fix roller material estimate asking for one chain per tile instead of one chain total - `buildingplan`: fix "Unlink all" only unlinking some mechanisms (or crashing) when freeing mechanisms from the building - `tiletypes`: remove plants (including trees) rooted on a tile that is painted into something that cannot host them, so cleared ground no longer regrows floating trees +- `gui/quickfort`: show smoothing designations immediately after applying a blueprint - `timestream`: deal properly with units who have breathing difficulties - `stocks`: overlay now resets scroll position when collapsing categories so the item list is no longer left blank and unscrollable - Fixed persistent site data API (``dfhack.persistent.saveSiteData``/``getSiteData``) failing on newly reclaimed fortresses until the first save diff --git a/plugins/lua/dig.lua b/plugins/lua/dig.lua index 192989d8a1..e8cf3eb723 100644 --- a/plugins/lua/dig.lua +++ b/plugins/lua/dig.lua @@ -365,6 +365,7 @@ DesignatedOverlay.ATTRS{ 'dwarfmode/Designate/TRACK', 'dwarfmode/Designate/FORTIFY', 'dwarfmode/Designate/ERASE', + 'dwarfmode/dfhack/lua/quickfort', }, default_enabled=true, frame={w=0, h=0}, diff --git a/plugins/lua/overlay.lua b/plugins/lua/overlay.lua index cdfaac89e1..c45180fabe 100644 --- a/plugins/lua/overlay.lua +++ b/plugins/lua/overlay.lua @@ -486,6 +486,10 @@ local function matches_focus_strings(db_entry, vs_name, vs) if dfhack.gui.matchFocusString(fs, vs) then return true end + local lua_focus = fs:match('^[^/]+/(dfhack/lua/.*)$') + if lua_focus and dfhack.gui.matchFocusString(lua_focus) then + return true + end end end return matched diff --git a/test/plugins/dig.lua b/test/plugins/dig.lua new file mode 100644 index 0000000000..7f19e7d8a5 --- /dev/null +++ b/test/plugins/dig.lua @@ -0,0 +1,30 @@ +config.mode = 'fortress' +config.target = 'dig' + +local gui = require('gui') +local overlay = require('plugins.overlay') + +local TestScreen = defclass(TestScreen, gui.ZScreen) +TestScreen.ATTRS{focus_path='quickfort'} + +function test.ascii_designations_visible_in_quickfort() + require('plugins.dig') + overlay.rescan() + local widget = overlay.get_state().db['dig.asciidesignated'].widget + expect.eq('dwarfmode/dfhack/lua/quickfort', + widget.viewscreens[#widget.viewscreens]) + + local render = mock.func() + local screen = TestScreen{} + screen:show() + dfhack.with_finalize( + function() screen:dismiss() end, + function() + mock.patch(widget, 'render', render, function() + overlay.render_viewscreen_widgets( + 'viewscreen_dwarfmodest', + dfhack.gui.getViewscreenByType(df.viewscreen_dwarfmodest, 0)) + end) + end) + expect.eq(1, render.call_count) +end