Changed: get the lua script executed at checkCoords time

--HG--
branch : lua
hg/atys
Inky 5 years ago
parent 570c73576c
commit 9dec7f9dbe

@ -313,6 +313,8 @@ namespace NLGUI
void deleteLUAEnvTable(bool recurse = false);
// Set the LUA script to execute at checkCoords time (empty to reset)
void setLuaScriptOnDraw(const std::string &script);
// Get the LUA script executed at checkCoords time
inline CStringShared getLuaScriptOnDraw() { return _LUAOnDraw; }
//
void executeLuaScriptOnDraw();
// Set the LUA script to execute when a list of DB change (of forms: "@DB1,@DB2" ....). The dbList is the key

@ -161,6 +161,7 @@ namespace NLGUI
static int luaMethodCall(lua_State *ls);
static int setOnDraw(CLuaState &ls); // params: CInterfaceGroup*, "script". return: none
static int getOnDraw(CLuaState &ls); // params: CInterfaceGroup*. return: "script" (nil if none)
static int addOnDbChange(CLuaState &ls); // params: CInterfaceGroup*, "dblist", "script". return: none
static int removeOnDbChange(CLuaState &ls);// params: CInterfaceGroup*. return: none
static int setCaptureKeyboard(CLuaState &ls);

@ -794,6 +794,35 @@ namespace NLGUI
return 0;
}
// ***************************************************************************
int CLuaIHM::getOnDraw(CLuaState &ls)
{
//H_AUTO(Lua_CLuaIHM_getOnDraw
CLuaStackChecker lsc(&ls, 1);
// params: CInterfaceElement*.
// return: "script" (nil if empty)
CLuaIHM::checkArgCount(ls, "getOnDraw", 1);
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getOnDraw() requires a UI object in param 1");
// retrieve arguments
CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
if (pIE)
{
// must be a group
CInterfaceGroup *group = dynamic_cast<CInterfaceGroup*>(pIE);
if (group)
{
if (!group->getLuaScriptOnDraw().empty()) {
ls.push(group->getLuaScriptOnDraw());
return 1;
}
}
}
ls.pushNil();
return 1;
}
// ***************************************************************************
int CLuaIHM::addOnDbChange(CLuaState &ls)
{
@ -1589,6 +1618,7 @@ namespace NLGUI
// *** Register Functions
ls.registerFunc("setOnDraw", setOnDraw);
ls.registerFunc("getOnDraw", getOnDraw);
ls.registerFunc("setCaptureKeyboard", setCaptureKeyboard);
ls.registerFunc("resetCaptureKeyboard", resetCaptureKeyboard);
ls.registerFunc("setTopWindow", setTopWindow);

Loading…
Cancel
Save