|
|
@ -102,9 +102,10 @@ namespace DFHack {
|
|
|
|
|
|
|
|
|
|
|
|
static df::coord2d screenSize;
|
|
|
|
static df::coord2d screenSize;
|
|
|
|
|
|
|
|
|
|
|
|
template<typename FA, typename FR>
|
|
|
|
static void call_overlay_lua(color_ostream *out, const char *fn_name,
|
|
|
|
static void call_overlay_lua(color_ostream *out, const char *fn_name, int nargs,
|
|
|
|
int nargs = 0, int nres = 0,
|
|
|
|
int nres, FA && args_lambda, FR && res_lambda) {
|
|
|
|
Lua::LuaLambda && args_lambda = Lua::DEFAULT_LUA_LAMBDA,
|
|
|
|
|
|
|
|
Lua::LuaLambda && res_lambda = Lua::DEFAULT_LUA_LAMBDA) {
|
|
|
|
DEBUG(event).print("calling overlay lua function: '%s'\n", fn_name);
|
|
|
|
DEBUG(event).print("calling overlay lua function: '%s'\n", fn_name);
|
|
|
|
|
|
|
|
|
|
|
|
CoreSuspender guard;
|
|
|
|
CoreSuspender guard;
|
|
|
@ -115,30 +116,9 @@ static void call_overlay_lua(color_ostream *out, const char *fn_name, int nargs,
|
|
|
|
if (!out)
|
|
|
|
if (!out)
|
|
|
|
out = &Core::getInstance().getConsole();
|
|
|
|
out = &Core::getInstance().getConsole();
|
|
|
|
|
|
|
|
|
|
|
|
if (!lua_checkstack(L, 1 + nargs) ||
|
|
|
|
Lua::CallLuaModuleFunction(*out, L, "plugins.overlay", fn_name, nargs, nres,
|
|
|
|
!Lua::PushModulePublic(
|
|
|
|
std::forward<Lua::LuaLambda&&>(args_lambda),
|
|
|
|
*out, L, "plugins.overlay", fn_name)) {
|
|
|
|
std::forward<Lua::LuaLambda&&>(res_lambda));
|
|
|
|
out->printerr("Failed to load overlay Lua code\n");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::forward<FA&&>(args_lambda)(L);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Lua::SafeCall(*out, L, nargs, nres))
|
|
|
|
|
|
|
|
out->printerr("Failed Lua call to '%s'\n", fn_name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::forward<FR&&>(res_lambda)(L);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static auto DEFAULT_LAMBDA = [](lua_State *){};
|
|
|
|
|
|
|
|
template<typename FA>
|
|
|
|
|
|
|
|
static void call_overlay_lua(color_ostream *out, const char *fn_name, int nargs,
|
|
|
|
|
|
|
|
int nres, FA && args_lambda) {
|
|
|
|
|
|
|
|
call_overlay_lua(out, fn_name, nargs, nres, args_lambda, DEFAULT_LAMBDA);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void call_overlay_lua(color_ostream *out, const char *fn_name) {
|
|
|
|
|
|
|
|
call_overlay_lua(out, fn_name, 0, 0, DEFAULT_LAMBDA, DEFAULT_LAMBDA);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
template<class T>
|
|
|
|