CHANGED: #1471 Moved some Lua related code from CInterfaceManager to CLuaManager and CInterfaceParser.
This commit is contained in:
parent
7e8e21e2f6
commit
c9692cfc05
17 changed files with 87 additions and 151 deletions
|
@ -299,17 +299,23 @@ namespace NLGUI
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::map< std::string, IParserModule* > moduleMap;
|
std::map< std::string, IParserModule* > moduleMap;
|
||||||
// LUA
|
|
||||||
// ----------------------------------------------------------------------------------
|
|
||||||
// LUA Interface State. NB: The LUA environnement is not shared between Login/OutGame/InGame
|
|
||||||
NLMISC::CSmartPtr<CLuaState> _LuaState;
|
|
||||||
virtual void initLUA();
|
|
||||||
void uninitLUA();
|
|
||||||
// List of script loaded (for reloadLua command)
|
// List of script loaded (for reloadLua command)
|
||||||
std::set<std::string> _LuaFileScripts;
|
std::set<std::string> _LuaFileScripts;
|
||||||
// Load A .lua. false if parse error. string 'error' contains the eventual error desc (but warning still displayed)
|
|
||||||
bool loadLUA(const std::string &luaFile, std::string &error);
|
|
||||||
bool cacheUIParsing;
|
bool cacheUIParsing;
|
||||||
|
bool luaInitialized;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void initLUA();
|
||||||
|
void uninitLUA();
|
||||||
|
bool isLuaInitialized() const{ return luaInitialized; }
|
||||||
|
|
||||||
|
/// Load A .lua. false if parse error. string 'error' contains the eventual error desc (but warning still displayed)
|
||||||
|
bool loadLUA( const std::string &luaFile, std::string &error );
|
||||||
|
|
||||||
|
/// Reload all LUA scripts inserted through <lua>
|
||||||
|
void reloadAllLuaFileScripts();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,13 +45,17 @@ namespace NLGUI
|
||||||
|
|
||||||
bool executeLuaScript( const std::string &luaScript, bool smallScript = false );
|
bool executeLuaScript( const std::string &luaScript, bool smallScript = false );
|
||||||
|
|
||||||
|
void ResetLuaState();
|
||||||
|
|
||||||
|
void forceGarbageCollect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CLuaManager();
|
CLuaManager();
|
||||||
|
|
||||||
static CLuaManager *instance;
|
static CLuaManager *instance;
|
||||||
static bool debugLua;
|
static bool debugLua;
|
||||||
|
|
||||||
NLMISC::CSmartPtr< NLGUI::CLuaState > luaState;
|
NLGUI::CLuaState *luaState;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,14 +198,12 @@ namespace NLGUI
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
CInterfaceParser::CInterfaceParser()
|
CInterfaceParser::CInterfaceParser()
|
||||||
{
|
{
|
||||||
// LUA
|
luaInitialized = false;
|
||||||
_LuaState= NULL;
|
|
||||||
cacheUIParsing = false;
|
cacheUIParsing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CInterfaceParser::~CInterfaceParser()
|
CInterfaceParser::~CInterfaceParser()
|
||||||
{
|
{
|
||||||
_LuaState = NULL;
|
|
||||||
removeAllModules();
|
removeAllModules();
|
||||||
}
|
}
|
||||||
/** Convert a string into a memstream
|
/** Convert a string into a memstream
|
||||||
|
@ -2674,15 +2672,7 @@ namespace NLGUI
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CInterfaceParser::initLUA()
|
void CInterfaceParser::initLUA()
|
||||||
{
|
{
|
||||||
// do nothing if LUA environment already exists
|
|
||||||
if( _LuaState != NULL )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// create a new LUA environnement
|
|
||||||
nlassert(_LuaState==NULL);
|
|
||||||
CLuaManager::enableLuaDebugging();
|
CLuaManager::enableLuaDebugging();
|
||||||
CLuaManager::getInstance();
|
|
||||||
_LuaState= CLuaManager::getInstance().getLuaState();
|
|
||||||
|
|
||||||
#ifdef LUA_NEVRAX_VERSION
|
#ifdef LUA_NEVRAX_VERSION
|
||||||
extern ILuaIDEInterface *LuaDebuggerIDE;
|
extern ILuaIDEInterface *LuaDebuggerIDE;
|
||||||
|
@ -2690,18 +2680,16 @@ namespace NLGUI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// register LUA methods
|
// register LUA methods
|
||||||
CLuaIHM::registerAll(*_LuaState);
|
CLuaIHM::registerAll( *( CLuaManager::getInstance().getLuaState() ) );
|
||||||
|
luaInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CInterfaceParser::uninitLUA()
|
void CInterfaceParser::uninitLUA()
|
||||||
{
|
{
|
||||||
// Delete all LUA environnement (and hence variables)
|
|
||||||
// delete _LuaState;
|
|
||||||
// _LuaState= NULL;
|
|
||||||
|
|
||||||
// delete all .lua file loaded
|
|
||||||
_LuaFileScripts.clear();
|
_LuaFileScripts.clear();
|
||||||
|
CLuaManager::getInstance().ResetLuaState();
|
||||||
|
luaInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -2740,10 +2728,9 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse script
|
// Parse script
|
||||||
nlassert(_LuaState);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_LuaState->executeFile(pathName);
|
CLuaManager::getInstance().getLuaState()->executeFile(pathName);
|
||||||
}
|
}
|
||||||
catch(const ELuaError &e)
|
catch(const ELuaError &e)
|
||||||
{
|
{
|
||||||
|
@ -2755,5 +2742,18 @@ namespace NLGUI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInterfaceParser::reloadAllLuaFileScripts()
|
||||||
|
{
|
||||||
|
std::set< std::string >::const_iterator it;
|
||||||
|
for( it = _LuaFileScripts.begin(); it != _LuaFileScripts.end(); ++it )
|
||||||
|
{
|
||||||
|
std::string error;
|
||||||
|
// if fail to reload a script, display the error code
|
||||||
|
if( !loadLUA( *it, error ) )
|
||||||
|
{
|
||||||
|
nlwarning( LuaHelperStuff::formatLuaErrorSysInfo( error ).c_str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace NLGUI
|
||||||
|
|
||||||
CLuaManager::~CLuaManager()
|
CLuaManager::~CLuaManager()
|
||||||
{
|
{
|
||||||
|
delete luaState;
|
||||||
luaState = NULL;
|
luaState = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,5 +52,18 @@ namespace NLGUI
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CLuaManager::ResetLuaState()
|
||||||
|
{
|
||||||
|
delete luaState;
|
||||||
|
luaState = new CLuaState( debugLua );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLuaManager::forceGarbageCollect()
|
||||||
|
{
|
||||||
|
nlinfo("Collecting Garbaged LUA variables");
|
||||||
|
luaState->setGCThreshold( 0 );
|
||||||
|
nlinfo( NLMISC::toString( "Memory Used : %d Kb", luaState->getGCCount() ).c_str() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5105,7 +5105,7 @@ NLMISC_COMMAND(luaScript, "Execute a lua script", "direct_script_code")
|
||||||
}
|
}
|
||||||
|
|
||||||
// not smallScript because suppose var can change a lot
|
// not smallScript because suppose var can change a lot
|
||||||
pIM->executeLuaScript(script, false);
|
CLuaManager::getInstance().executeLuaScript(script, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5186,7 +5186,7 @@ NLMISC_COMMAND(luaGC, "Force a garbage collector of lua", "")
|
||||||
CInterfaceManager *pIM= CInterfaceManager::getInstance();
|
CInterfaceManager *pIM= CInterfaceManager::getInstance();
|
||||||
if(ClientCfg.AllowDebugLua)
|
if(ClientCfg.AllowDebugLua)
|
||||||
{
|
{
|
||||||
pIM->luaGarbageCollect();
|
CLuaManager::getInstance().forceGarbageCollect();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -838,7 +838,7 @@ void updateBGDownloaderUI()
|
||||||
{
|
{
|
||||||
if (LuaBGDSuccessFlag)
|
if (LuaBGDSuccessFlag)
|
||||||
{
|
{
|
||||||
LuaBGDSuccessFlag = im->executeLuaScript("bgdownloader:setPatchSuccess()");
|
LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:setPatchSuccess()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -858,19 +858,19 @@ void updateBGDownloaderUI()
|
||||||
}
|
}
|
||||||
if (LuaBGDSuccessFlag && bgWindowVisible)
|
if (LuaBGDSuccessFlag && bgWindowVisible)
|
||||||
{
|
{
|
||||||
LuaBGDSuccessFlag = im->executeLuaScript(toString("bgdownloader:setPatchProgress(%f)", progress));
|
LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript(toString("bgdownloader:setPatchProgress(%f)", progress));
|
||||||
}
|
}
|
||||||
// display current priority of the downloader
|
// display current priority of the downloader
|
||||||
if (LuaBGDSuccessFlag && bgWindowVisible)
|
if (LuaBGDSuccessFlag && bgWindowVisible)
|
||||||
{
|
{
|
||||||
LuaBGDSuccessFlag = im->executeLuaScript("bgdownloader:displayPriority()");
|
LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:displayPriority()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BGDownloader::TaskResult_Success:
|
case BGDownloader::TaskResult_Success:
|
||||||
if (LuaBGDSuccessFlag && bgWindowVisible)
|
if (LuaBGDSuccessFlag && bgWindowVisible)
|
||||||
{
|
{
|
||||||
LuaBGDSuccessFlag = im->executeLuaScript("bgdownloader:setPatchSuccess()");
|
LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:setPatchSuccess()");
|
||||||
}
|
}
|
||||||
// task finished
|
// task finished
|
||||||
AvailablePatchs = 0;
|
AvailablePatchs = 0;
|
||||||
|
@ -887,7 +887,7 @@ void updateBGDownloaderUI()
|
||||||
// error case
|
// error case
|
||||||
if (LuaBGDSuccessFlag && bgWindowVisible)
|
if (LuaBGDSuccessFlag && bgWindowVisible)
|
||||||
{
|
{
|
||||||
LuaBGDSuccessFlag = im->executeLuaScript("bgdownloader:setPatchError()");
|
LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:setPatchError()");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -900,12 +900,12 @@ void updateBGDownloaderUI()
|
||||||
if (isBGDownloadEnabled())
|
if (isBGDownloadEnabled())
|
||||||
{
|
{
|
||||||
// no necessary patch for now
|
// no necessary patch for now
|
||||||
LuaBGDSuccessFlag = im->executeLuaScript("bgdownloader:setNoNecessaryPatch()");
|
LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:setNoNecessaryPatch()");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no download ui
|
// no download ui
|
||||||
LuaBGDSuccessFlag = im->executeLuaScript("bgdownloader:setNoDownloader()");
|
LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:setNoDownloader()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1080,7 +1080,7 @@ public:
|
||||||
CInterfaceManager *pIM= CInterfaceManager::getInstance();
|
CInterfaceManager *pIM= CInterfaceManager::getInstance();
|
||||||
|
|
||||||
// start the npc web page
|
// start the npc web page
|
||||||
pIM->executeLuaScript("game:startNpcWebPage()", true);
|
CLuaManager::getInstance().executeLuaScript("game:startNpcWebPage()", true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_ACTION_HANDLER( CHandlerContextWebPage, "context_web_page");
|
REGISTER_ACTION_HANDLER( CHandlerContextWebPage, "context_web_page");
|
||||||
|
|
|
@ -1422,7 +1422,7 @@ public:
|
||||||
CInterfaceManager *im = CInterfaceManager::getInstance();
|
CInterfaceManager *im = CInterfaceManager::getInstance();
|
||||||
im->displaySystemInfo(ucstring("@{6F6F}") + playerName +ucstring(" @{FFFF}") + CI18N::get("uiRingInvitationSent"), "BC");
|
im->displaySystemInfo(ucstring("@{6F6F}") + playerName +ucstring(" @{FFFF}") + CI18N::get("uiRingInvitationSent"), "BC");
|
||||||
// force a refresh of the ui
|
// force a refresh of the ui
|
||||||
im->executeLuaScript("CharTracking:forceRefresh()");
|
CLuaManager::getInstance().executeLuaScript("CharTracking:forceRefresh()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -127,7 +127,7 @@ void CGroupHTMLCS::getParameters (std::vector<CParameter> ¶meters, bool enco
|
||||||
{
|
{
|
||||||
webIgReady = true;
|
webIgReady = true;
|
||||||
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||||
pIM->executeLuaScript("game:onWebIgReady()");
|
CLuaManager::getInstance().executeLuaScript("game:onWebIgReady()");
|
||||||
}
|
}
|
||||||
|
|
||||||
// For each line
|
// For each line
|
||||||
|
|
|
@ -622,15 +622,15 @@ void CInterfaceManager::destroy ()
|
||||||
|
|
||||||
void CInterfaceManager::initLUA()
|
void CInterfaceManager::initLUA()
|
||||||
{
|
{
|
||||||
if( _LuaState != NULL )
|
if( isLuaInitialized() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CInterfaceParser::initLUA();
|
CInterfaceParser::initLUA();
|
||||||
|
|
||||||
if( _LuaState == NULL )
|
if( !isLuaInitialized() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CLuaIHMRyzom::RegisterRyzomFunctions( *_LuaState );
|
CLuaIHMRyzom::RegisterRyzomFunctions( *( CLuaManager::getInstance().getLuaState() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -1518,7 +1518,7 @@ void CInterfaceManager::updateFrameEvents()
|
||||||
luaDebuggerMainLoop();
|
luaDebuggerMainLoop();
|
||||||
|
|
||||||
// handle gc for lua
|
// handle gc for lua
|
||||||
if (_LuaState) _LuaState->handleGC();
|
CLuaManager::getInstance().getLuaState()->handleGC();
|
||||||
|
|
||||||
CBGDownloaderAccess::getInstance().update();
|
CBGDownloaderAccess::getInstance().update();
|
||||||
|
|
||||||
|
@ -3251,72 +3251,6 @@ void CInterfaceManager::connectYuboChat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
bool CInterfaceManager::executeLuaScript(const std::string &luaScript, bool smallScript)
|
|
||||||
{
|
|
||||||
H_AUTO ( RZ_Interface_executeLuaScript )
|
|
||||||
|
|
||||||
nlassert(_LuaState);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if(smallScript)
|
|
||||||
_LuaState->executeSmallScript(luaScript);
|
|
||||||
else
|
|
||||||
_LuaState->executeScript(luaScript);
|
|
||||||
}
|
|
||||||
catch(const ELuaError &e)
|
|
||||||
{
|
|
||||||
std::string msg = e.luaWhat();
|
|
||||||
char filename[MAX_PATH];
|
|
||||||
char exceptionName[MAX_PATH];
|
|
||||||
uint32 line;
|
|
||||||
// Hamster: quick fix on AJM code but sscanf is still awfull
|
|
||||||
if (sscanf(msg.c_str(), "%s: %s.lua:%d:",exceptionName, filename, &line) == 3) // NB: test not exact here, but should work in 99,9 % of cases
|
|
||||||
{
|
|
||||||
msg = CLuaIHMRyzom::createGotoFileButtonTag(filename, line) + msg;
|
|
||||||
nlwarning(LuaHelperStuff::formatLuaErrorNlWarn(msg).c_str());
|
|
||||||
displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(msg));
|
|
||||||
}
|
|
||||||
else // AJM: handle the other 0.1% of cases
|
|
||||||
{
|
|
||||||
// Yoyo: seems that previous test doesn't work.... btw, must still print the message please...
|
|
||||||
std::vector<string> error;
|
|
||||||
splitString(msg.c_str(), ":", error);
|
|
||||||
if (error.size() > 3)
|
|
||||||
{
|
|
||||||
std::vector<string> contextList;
|
|
||||||
explode(luaScript, string("\n"), contextList);
|
|
||||||
fromString(error[2], line);
|
|
||||||
if (line >= 3 && contextList.size() >= line)
|
|
||||||
msg = error[0]+": \n>>> "+contextList[line-3]+"\n>>> "+contextList[line-2]+"\n>>> "+contextList[line-1]+"\nError:"+error[2]+": "+error[3];
|
|
||||||
else if (line >= 2 && contextList.size() >= line)
|
|
||||||
msg = error[0]+": \n>>>"+contextList[line-2]+"\n>>>"+contextList[line-1]+"\nError:"+error[2]+": "+error[3];
|
|
||||||
else if (line >= 1 && contextList.size() >= line)
|
|
||||||
msg = error[0]+": \n>>>"+contextList[line-1]+"\nError:"+error[2]+": "+error[3];
|
|
||||||
}
|
|
||||||
nlwarning(LuaHelperStuff::formatLuaErrorNlWarn(msg).c_str());
|
|
||||||
displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(msg));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
void CInterfaceManager::reloadAllLuaFileScripts()
|
|
||||||
{
|
|
||||||
std::set<std::string>::const_iterator it= _LuaFileScripts.begin();
|
|
||||||
for(;it!=_LuaFileScripts.end();it++)
|
|
||||||
{
|
|
||||||
string error;
|
|
||||||
// if fail to reload a script, display the error code
|
|
||||||
if(!loadLUA(*it, error))
|
|
||||||
{
|
|
||||||
displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(error));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
std::vector<std::string> CInterfaceManager::getInGameXMLInterfaceFiles()
|
std::vector<std::string> CInterfaceManager::getInGameXMLInterfaceFiles()
|
||||||
{
|
{
|
||||||
|
@ -3374,8 +3308,7 @@ void CInterfaceManager::dumpLuaString(const std::string &str)
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CInterfaceManager::getLuaValueInfo(std::string &str, sint index)
|
void CInterfaceManager::getLuaValueInfo(std::string &str, sint index)
|
||||||
{
|
{
|
||||||
nlassert(_LuaState);
|
CLuaState &ls= *( CLuaManager::getInstance().getLuaState() );
|
||||||
CLuaState &ls= *_LuaState;
|
|
||||||
|
|
||||||
sint type= ls.type(index);
|
sint type= ls.type(index);
|
||||||
if(type==LUA_TNIL)
|
if(type==LUA_TNIL)
|
||||||
|
@ -3421,8 +3354,7 @@ void CInterfaceManager::getLuaValueInfo(std::string &str, sint index)
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CInterfaceManager::dumpLuaKeyValueInfo(uint recursTableLevel, uint tabLevel)
|
void CInterfaceManager::dumpLuaKeyValueInfo(uint recursTableLevel, uint tabLevel)
|
||||||
{
|
{
|
||||||
nlassert(_LuaState);
|
CLuaState &ls= *( CLuaManager::getInstance().getLuaState() );
|
||||||
CLuaState &ls= *_LuaState;
|
|
||||||
CLuaStackChecker lsc(&ls);
|
CLuaStackChecker lsc(&ls);
|
||||||
|
|
||||||
// Dump Key Str
|
// Dump Key Str
|
||||||
|
@ -3458,11 +3390,7 @@ void CInterfaceManager::dumpLuaKeyValueInfo(uint recursTableLevel, uint tabLeve
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CInterfaceManager::dumpLuaState(uint detail)
|
void CInterfaceManager::dumpLuaState(uint detail)
|
||||||
{
|
{
|
||||||
if(!_LuaState)
|
CLuaState *_LuaState = CLuaManager::getInstance().getLuaState();
|
||||||
{
|
|
||||||
dumpLuaString("LUA State not created");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// clamp detailed info to 2 (display at max content of eaxh Env of each group)
|
// clamp detailed info to 2 (display at max content of eaxh Env of each group)
|
||||||
clamp(detail, 0U, 2U);
|
clamp(detail, 0U, 2U);
|
||||||
|
@ -3496,16 +3424,6 @@ void CInterfaceManager::dumpLuaState(uint detail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
void CInterfaceManager::luaGarbageCollect()
|
|
||||||
{
|
|
||||||
if(!_LuaState)
|
|
||||||
return;
|
|
||||||
dumpLuaString("Collecting Garbaged LUA variables");
|
|
||||||
_LuaState->setGCThreshold(0);
|
|
||||||
dumpLuaString(NLMISC::toString("Memory Used : %d Kb", _LuaState->getGCCount()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CInterfaceManager::createLocalBranch(const std::string &fileName, NLMISC::IProgressCallback &progressCallBack)
|
void CInterfaceManager::createLocalBranch(const std::string &fileName, NLMISC::IProgressCallback &progressCallBack)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,8 @@
|
||||||
|
|
||||||
#include "../ingame_database_manager.h"
|
#include "../ingame_database_manager.h"
|
||||||
|
|
||||||
|
#include "nel/gui/lua_manager.h"
|
||||||
|
|
||||||
//the network database node
|
//the network database node
|
||||||
extern CCDBSynchronised IngameDbMngr;
|
extern CCDBSynchronised IngameDbMngr;
|
||||||
|
|
||||||
|
@ -365,14 +367,8 @@ public:
|
||||||
|
|
||||||
/// \name LUA
|
/// \name LUA
|
||||||
// @{
|
// @{
|
||||||
/// Execute a lua script (smallScript for speed optimisation, see lua_helper). return false if parse/execute error (warning/sysinfo displayed)
|
|
||||||
bool executeLuaScript(const std::string &luaScript, bool smallScript= false);
|
|
||||||
/// Reload all LUA scripts inserted through <lua>
|
|
||||||
void reloadAllLuaFileScripts();
|
|
||||||
/// For debug: dump in the sysinfo and nlwarning state of lua. detail range from 0 to 2 (clamped).
|
/// For debug: dump in the sysinfo and nlwarning state of lua. detail range from 0 to 2 (clamped).
|
||||||
void dumpLuaState(uint detail);
|
void dumpLuaState(uint detail);
|
||||||
/// For debug: force a garbage collector
|
|
||||||
void luaGarbageCollect();
|
|
||||||
// @}
|
// @}
|
||||||
|
|
||||||
// Get the list of InGame XML Interface files, with any AddOn ones
|
// Get the list of InGame XML Interface files, with any AddOn ones
|
||||||
|
|
|
@ -133,7 +133,7 @@ public:
|
||||||
|
|
||||||
// execute a small script. NB: use a small script here because
|
// execute a small script. NB: use a small script here because
|
||||||
// most often action handlers are called from xml files => lot of redundant script
|
// most often action handlers are called from xml files => lot of redundant script
|
||||||
pIM->executeLuaScript(sParams, true);
|
CLuaManager::getInstance().executeLuaScript(sParams, true);
|
||||||
|
|
||||||
// pop UI caller
|
// pop UI caller
|
||||||
if(pCaller)
|
if(pCaller)
|
||||||
|
@ -179,7 +179,7 @@ static DECLARE_INTERFACE_USER_FCT(lua)
|
||||||
// assign return value in retId.
|
// assign return value in retId.
|
||||||
script= retId + "= " + script;
|
script= retId + "= " + script;
|
||||||
// execute a small script here, because most often exprs are called from xml files => lot of redundant script
|
// execute a small script here, because most often exprs are called from xml files => lot of redundant script
|
||||||
pIM->executeLuaScript(script, true);
|
CLuaManager::getInstance().executeLuaScript(script, true);
|
||||||
|
|
||||||
|
|
||||||
// *** retrieve and convert return value
|
// *** retrieve and convert return value
|
||||||
|
|
|
@ -1520,7 +1520,7 @@ bool mainLoop()
|
||||||
CSessionBrowserImpl::getInstance().init(CLuaManager::getInstance().getLuaState());
|
CSessionBrowserImpl::getInstance().init(CLuaManager::getInstance().getLuaState());
|
||||||
}
|
}
|
||||||
|
|
||||||
CInterfaceManager::getInstance()->executeLuaScript("game:onMainLoopBegin()");
|
CLuaManager::getInstance().executeLuaScript("game:onMainLoopBegin()");
|
||||||
|
|
||||||
|
|
||||||
if (StartInitTime != 0)
|
if (StartInitTime != 0)
|
||||||
|
@ -1782,7 +1782,7 @@ bool mainLoop()
|
||||||
if (group)
|
if (group)
|
||||||
group->updateAllLinks();
|
group->updateAllLinks();
|
||||||
// send a msg to lua for specific ui update
|
// send a msg to lua for specific ui update
|
||||||
pIM->executeLuaScript("game:onInGameDbInitialized()");
|
CLuaManager::getInstance().executeLuaScript("game:onInGameDbInitialized()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2896,7 +2896,7 @@ bool mainLoop()
|
||||||
// This code must remain at the very end of the main loop.
|
// This code must remain at the very end of the main loop.
|
||||||
if(LoginSM.getCurrentState() == CLoginStateMachine::st_enter_far_tp_main_loop)
|
if(LoginSM.getCurrentState() == CLoginStateMachine::st_enter_far_tp_main_loop)
|
||||||
{
|
{
|
||||||
CInterfaceManager::getInstance()->executeLuaScript("game:onFarTpStart()");
|
CLuaManager::getInstance().executeLuaScript("game:onFarTpStart()");
|
||||||
// Will loop the network until the end of the relogging process
|
// Will loop the network until the end of the relogging process
|
||||||
FarTP.farTPmainLoop();
|
FarTP.farTPmainLoop();
|
||||||
|
|
||||||
|
@ -2974,7 +2974,7 @@ bool mainLoop()
|
||||||
lastConnectionState = CNetworkConnection::Connected;
|
lastConnectionState = CNetworkConnection::Connected;
|
||||||
connectionState = NetMngr.getConnectionState();
|
connectionState = NetMngr.getConnectionState();
|
||||||
|
|
||||||
CInterfaceManager::getInstance()->executeLuaScript("game:onFarTpEnd()");
|
CLuaManager::getInstance().executeLuaScript("game:onFarTpEnd()");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of main loop
|
} // end of main loop
|
||||||
|
@ -2982,7 +2982,7 @@ bool mainLoop()
|
||||||
CInterfaceManager *im = CInterfaceManager::getInstance();
|
CInterfaceManager *im = CInterfaceManager::getInstance();
|
||||||
if (CLuaManager::getInstance().getLuaState())
|
if (CLuaManager::getInstance().getLuaState())
|
||||||
{
|
{
|
||||||
CInterfaceManager::getInstance()->executeLuaScript("game:onMainLoopEnd()");
|
CLuaManager::getInstance().executeLuaScript("game:onMainLoopEnd()");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop Running Profiles (kick result)
|
// Stop Running Profiles (kick result)
|
||||||
|
@ -4550,7 +4550,7 @@ void displayDebugClusters()
|
||||||
void inGamePatchUncompleteWarning()
|
void inGamePatchUncompleteWarning()
|
||||||
{
|
{
|
||||||
CInterfaceManager *im = CInterfaceManager::getInstance();
|
CInterfaceManager *im = CInterfaceManager::getInstance();
|
||||||
im->executeLuaScript("bgdownloader:inGamePatchUncompleteWarning()");
|
CLuaManager::getInstance().executeLuaScript("bgdownloader:inGamePatchUncompleteWarning()");
|
||||||
/*
|
/*
|
||||||
CInterfaceManager *im = CInterfaceManager::getInstance();
|
CInterfaceManager *im = CInterfaceManager::getInstance();
|
||||||
CGroupContainer *gc = dynamic_cast<CGroupContainer *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:bg_downloader"));
|
CGroupContainer *gc = dynamic_cast<CGroupContainer *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:bg_downloader"));
|
||||||
|
|
|
@ -893,7 +893,7 @@ void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const u
|
||||||
// for now, '&' are removed by server so use another format until a special msg is made
|
// for now, '&' are removed by server so use another format until a special msg is made
|
||||||
if (strFindReplace(finalString, ucstring("<R2_INVITE>"), ucstring()))
|
if (strFindReplace(finalString, ucstring("<R2_INVITE>"), ucstring()))
|
||||||
{
|
{
|
||||||
CInterfaceManager::getInstance()->executeLuaScript("RingAccessPoint:forceRefresh()");
|
CLuaManager::getInstance().executeLuaScript("RingAccessPoint:forceRefresh()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1704,8 +1704,7 @@ void impulseTeamInvitation(NLMISC::CBitMemStream &impulse)
|
||||||
impulse.serial(textID);
|
impulse.serial(textID);
|
||||||
if (PermanentlyBanned) return;
|
if (PermanentlyBanned) return;
|
||||||
|
|
||||||
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
CLuaManager::getInstance().executeLuaScript("game:onTeamInvation("+toString(textID)+")", 0);
|
||||||
pIM->executeLuaScript("game:onTeamInvation("+toString(textID)+")", 0);
|
|
||||||
}// impulseTeamInvitation //
|
}// impulseTeamInvitation //
|
||||||
|
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
|
|
|
@ -7646,8 +7646,7 @@ class CAHR2FreezeUnfreezeBotObjects : public IActionHandler
|
||||||
{
|
{
|
||||||
virtual void execute(CCtrlBase * /* pCaller */, const std::string &/* sParams */)
|
virtual void execute(CCtrlBase * /* pCaller */, const std::string &/* sParams */)
|
||||||
{
|
{
|
||||||
CInterfaceManager *im = CInterfaceManager::getInstance();
|
CLuaManager::getInstance().executeLuaScript("r2:freezeUnfreezeBotObjects()");
|
||||||
im->executeLuaScript("r2:freezeUnfreezeBotObjects()");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_ACTION_HANDLER(CAHR2FreezeUnfreezeBotObjects, "r2ed_freeze_unfreeze_botobjects");
|
REGISTER_ACTION_HANDLER(CAHR2FreezeUnfreezeBotObjects, "r2ed_freeze_unfreeze_botobjects");
|
||||||
|
|
|
@ -114,7 +114,7 @@ void CToolCreateEntity::commit(const NLMISC::CVector &createPosition, float crea
|
||||||
if (!getEditor().verifyRoomLeft(0, 1))
|
if (!getEditor().verifyRoomLeft(0, 1))
|
||||||
{
|
{
|
||||||
|
|
||||||
getUI().executeLuaScript("r2:checkStaticQuota(1)");
|
CLuaManager::getInstance().executeLuaScript("r2:checkStaticQuota(1)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setContextHelp(CI18N::get("uiR2EDDrawArrayContextHelp"));
|
setContextHelp(CI18N::get("uiR2EDDrawArrayContextHelp"));
|
||||||
|
|
|
@ -1662,7 +1662,7 @@ void CUserEntity::moveToAction(CEntityCL *ent)
|
||||||
break;
|
break;
|
||||||
// Outpost
|
// Outpost
|
||||||
case CUserEntity::Outpost:
|
case CUserEntity::Outpost:
|
||||||
IM->executeLuaScript("game:outpostBCOpenStateWindow()", 0);
|
CLuaManager::getInstance().executeLuaScript("game:outpostBCOpenStateWindow()", 0);
|
||||||
break;
|
break;
|
||||||
// BuildTotem
|
// BuildTotem
|
||||||
case CUserEntity::BuildTotem:
|
case CUserEntity::BuildTotem:
|
||||||
|
|
Loading…
Reference in a new issue