Skip to content

Commit 9e7d2d9

Browse files
authored
Merge pull request #5296 from myk002/myk_overlay_enabled
[overlay] add API for querying whether an overlay is enabled
2 parents acd6ec9 + 0676850 commit 9e7d2d9

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Template for new versions:
8585
- ``dfhack.military.removeFromSquad``: Lua API for ``Military::removeFromSquad``
8686
- ``gui.dwarfmode``: adventure mode cursor now supported in ``getCursorPos``, ``setCursorPos``, and ``clearCursorPos`` funcitons
8787
- ``dfhack.buildings.checkFreeTiles``: now replaces the extents parameter for a building pointer
88+
- ``overlay.isOverlayEnabled``: new API for querying whether a given overlay is enabled
8889

8990
## Removed
9091

docs/dev/overlay-dev-guide.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,23 @@ If you need to improve performance, here are some potential options:
228228
3. Move hotspots into C++ code, either in a new core library function or in a
229229
dedicated plugin
230230

231+
Overlay framework API
232+
---------------------
233+
234+
The overlay plugin Lua interface provides a few functions for interacting with
235+
the framework. You can get a reference to the API via::
236+
237+
local overlay = require('plugins.overlay')
238+
239+
* ``overlay.rescan()``
240+
241+
Rescans all module-loadable Lua scripts for registered overlays and loads
242+
updated widget definitions.
243+
244+
* ``overlay.isOverlayEnabled(name)``
245+
246+
Returns whether the overlay with the given name is enabled.
247+
231248
Development workflows
232249
---------------------
233250

plugins/lua/overlay.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ local overlay_config = {} -- map of widget name to persisted state
2424
local active_hotspot_widgets = {} -- map of widget names to the db entry
2525
local active_viewscreen_widgets = {} -- map of vs_name to map of w.names -> db
2626

27+
-- for use by gui/overlay
2728
function get_state()
2829
return {index=widget_index, config=overlay_config, db=widget_db}
2930
end
@@ -73,6 +74,11 @@ local function save_config()
7374
end
7475
end
7576

77+
function isOverlayEnabled(name)
78+
if not overlay_config[name] then return false end
79+
return overlay_config[name].enabled
80+
end
81+
7682
-- ----------- --
7783
-- utility fns --
7884
-- ----------- --

0 commit comments

Comments
 (0)