Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Template for new versions:
- ``dfhack.military.removeFromSquad``: Lua API for ``Military::removeFromSquad``
- ``gui.dwarfmode``: adventure mode cursor now supported in ``getCursorPos``, ``setCursorPos``, and ``clearCursorPos`` funcitons
- ``dfhack.buildings.checkFreeTiles``: now replaces the extents parameter for a building pointer
- ``overlay.isOverlayEnabled``: new API for querying whether a given overlay is enabled

## Removed

Expand Down
17 changes: 17 additions & 0 deletions docs/dev/overlay-dev-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,23 @@ If you need to improve performance, here are some potential options:
3. Move hotspots into C++ code, either in a new core library function or in a
dedicated plugin

Overlay framework API
---------------------

The overlay plugin Lua interface provides a few functions for interacting with
the framework. You can get a reference to the API via::

local overlay = require('plugins.overlay')

* ``overlay.rescan()``

Rescans all module-loadable Lua scripts for registered overlays and loads
updated widget definitions.

* ``overlay.isOverlayEnabled(name)``

Returns whether the overlay with the given name is enabled.

Development workflows
---------------------

Expand Down
6 changes: 6 additions & 0 deletions plugins/lua/overlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ local overlay_config = {} -- map of widget name to persisted state
local active_hotspot_widgets = {} -- map of widget names to the db entry
local active_viewscreen_widgets = {} -- map of vs_name to map of w.names -> db

-- for use by gui/overlay
function get_state()
return {index=widget_index, config=overlay_config, db=widget_db}
end
Expand Down Expand Up @@ -73,6 +74,11 @@ local function save_config()
end
end

function isOverlayEnabled(name)
if not overlay_config[name] then return false end
return overlay_config[name].enabled
end

-- ----------- --
-- utility fns --
-- ----------- --
Expand Down