diff --git a/code/nel/include/nel/gui/interface_group.h b/code/nel/include/nel/gui/interface_group.h index cef9abb45..b646c38b6 100644 --- a/code/nel/include/nel/gui/interface_group.h +++ b/code/nel/include/nel/gui/interface_group.h @@ -321,6 +321,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 diff --git a/code/nel/include/nel/gui/lua_ihm.h b/code/nel/include/nel/gui/lua_ihm.h index e45e1125f..a7c5f9e2b 100644 --- a/code/nel/include/nel/gui/lua_ihm.h +++ b/code/nel/include/nel/gui/lua_ihm.h @@ -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); diff --git a/code/nel/src/gui/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp index b36b9cca8..3a5134c05 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -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(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);