enable overlay from init scripts; self-enable bad

loading other plugin modules during plugin_init results in those other
plugin modules not getting initialized properly. specifically, their
DFHACK_PLUGIN_LUA_FUNCTIONS and commands don't get added to their lua
module namespaces.
develop
myk002 2022-11-07 15:29:13 -08:00
parent 1ebf58ff83
commit 6e0a583e8d
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 8 additions and 5 deletions

@ -89,6 +89,7 @@ enable automaterial
# Other interface improvement tools # Other interface improvement tools
enable \ enable \
overlay \
confirm \ confirm \
dwarfmonitor \ dwarfmonitor \
mousequery \ mousequery \

@ -249,10 +249,15 @@ IMPLEMENT_HOOKS(workshop_profile)
!INTERPOSE_HOOK(screen##_overlay, feed).apply(enable) || \ !INTERPOSE_HOOK(screen##_overlay, feed).apply(enable) || \
!INTERPOSE_HOOK(screen##_overlay, render).apply(enable) !INTERPOSE_HOOK(screen##_overlay, render).apply(enable)
DFhackCExport command_result plugin_enable(color_ostream &, bool enable) { DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
if (is_enabled == enable) if (is_enabled == enable)
return CR_OK; return CR_OK;
if (enable) {
screenSize = Screen::getWindowSize();
call_overlay_lua(&out, "reload");
}
DEBUG(control).print("%sing interpose hooks\n", enable ? "enabl" : "disabl"); DEBUG(control).print("%sing interpose hooks\n", enable ? "enabl" : "disabl");
if (INTERPOSE_HOOKS_FAILED(adopt_region) || if (INTERPOSE_HOOKS_FAILED(adopt_region) ||
@ -361,10 +366,7 @@ DFhackCExport command_result plugin_init(color_ostream &out, std::vector <Plugin
"Manage onscreen widgets.", "Manage onscreen widgets.",
overlay_cmd)); overlay_cmd));
screenSize = Screen::getWindowSize(); return CR_OK;
call_overlay_lua(&out, "reload");
return plugin_enable(out, true);
} }
DFhackCExport command_result plugin_shutdown(color_ostream &out) { DFhackCExport command_result plugin_shutdown(color_ostream &out) {