refresh overlay and helpdb on new world to pick up mod content

develop
Myk Taylor 2023-03-11 12:51:46 -08:00
parent e7f8fbb235
commit 42b18d001b
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 19 additions and 0 deletions

@ -12,6 +12,8 @@ local TAG_DEFINITIONS = 'hack/docs/docs/Tags.txt'
local SCRIPT_DOC_BEGIN = '[====['
local SCRIPT_DOC_END = ']====]'
local GLOBAL_KEY = 'HELPDB'
-- enums
local ENTRY_TYPES = {
BUILTIN='builtin',
@ -423,6 +425,14 @@ function refresh()
ensure_db()
end
dfhack.onStateChange[GLOBAL_KEY] = function(sc)
if sc ~= SC_WORLD_LOADED then
return
end
-- pick up widgets from active mods
refresh()
end
local function parse_blocks(text)
local blocks = {}
for line in text:gmatch('[^\n]*') do

@ -8,6 +8,7 @@ local widgets = require('gui.widgets')
local OVERLAY_CONFIG_FILE = 'dfhack-config/overlay.json'
local OVERLAY_WIDGETS_VAR = 'OVERLAY_WIDGETS'
local GLOBAL_KEY = 'OVERLAY'
local DEFAULT_X_POS, DEFAULT_Y_POS = -2, -2
@ -311,6 +312,14 @@ function reload()
reposition_widgets()
end
dfhack.onStateChange[GLOBAL_KEY] = function(sc)
if sc ~= SC_WORLD_LOADED then
return
end
-- pick up widgets from active mods
reload()
end
local function dump_widget_config(name, widget)
local pos = overlay_config[name].pos
print(('widget %s is positioned at x=%d, y=%d'):format(name, pos.x, pos.y))