Added executeRyzomScript, executeTutorial and processTutorialEvent lua callbacks

ryzom/ui/improvements
Nuno 4 years ago
parent 46c7b0309d
commit f61d10c75e

@ -5503,7 +5503,7 @@ namespace NLGUI
string suri = elm.getAttribute("href"); string suri = elm.getAttribute("href");
if(suri.find("ah:") == 0) if(suri.find("ah:") == 0)
{ {
if (_TrustedDomain) if (_TrustedDomain || suri.find("ah:script:") == 0)
_Link.back() = suri; _Link.back() = suri;
} }
else else
@ -6360,11 +6360,13 @@ namespace NLGUI
void CGroupHTML::htmlOBJECTend(const CHtmlElement &elm) void CGroupHTML::htmlOBJECTend(const CHtmlElement &elm)
{ {
if (!_TrustedDomain)
return;
if (_ObjectType=="application/ryzom-data") if (_ObjectType=="application/ryzom-data")
{ {
if (!_TrustedDomain)
return;
if (!_ObjectData.empty()) if (!_ObjectData.empty())
{ {
if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum)) if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum))
@ -6374,6 +6376,24 @@ namespace NLGUI
_ObjectScript.clear(); _ObjectScript.clear();
} }
} }
else if (_ObjectType=="application/ryzom-tutorial")
{
strFindReplace(_ObjectScript, "[[", "\\[\\[");
strFindReplace(_ObjectScript, "]]", "\\]\\]");
strFindReplace(_ObjectScript, "\\[\\[", "]]..'[['..[[");
strFindReplace(_ObjectScript, "\\]\\]", "]]..']]'..[[");
CLuaManager::getInstance().executeLuaScript("\ngame:executeTutorial([["+_ObjectScript+"]])\n", true);
_ObjectScript.clear();
}
else if (_ObjectType=="application/ryzom-script")
{
strFindReplace(_ObjectScript, "[[", "\\[\\[");
strFindReplace(_ObjectScript, "]]", "\\]\\]");
strFindReplace(_ObjectScript, "\\[\\[", "]]..'[['..[[");
strFindReplace(_ObjectScript, "\\]\\]", "]]..']]'..[[");
CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+_ObjectScript+"]])\n", true);
_ObjectScript.clear();
}
_Object = false; _Object = false;
} }

@ -74,6 +74,8 @@ bool CGroupQuickHelp::submitEvent (const char *event)
// Update the text // Update the text
updateParagraph (); updateParagraph ();
CLuaManager::getInstance().executeLuaScript(toString("\ngame:processTutorialEvent(\"%s\")\n", event), true);
} }
} }
return false; return false;

@ -184,6 +184,23 @@ private:
REGISTER_ACTION_HANDLER(CHandlerLUA, "lua"); REGISTER_ACTION_HANDLER(CHandlerLUA, "lua");
std::deque<CRefPtr<CCtrlBase> > CHandlerLUA::_UICallerStack; std::deque<CRefPtr<CCtrlBase> > CHandlerLUA::_UICallerStack;
// ***************************************************************************
class CHandlerSCRIPT : public IActionHandler
{
public:
void execute(CCtrlBase *pCaller, const std::string &sParams)
{
string script = sParams;
strFindReplace(script, "[[", "\\[\\[");
strFindReplace(script, "]]", "\\]\\]");
strFindReplace(script, "\\[\\[", "]]..'[['..[[");
strFindReplace(script, "\\]\\]", "]]..']]'..[[");
strFindReplace(script, "|", "\n");
CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+script+"]])\n", true);
}
};
REGISTER_ACTION_HANDLER(CHandlerSCRIPT, "script");
// *************************************************************************** // ***************************************************************************
// Allow also to call script from expression // Allow also to call script from expression
static DECLARE_INTERFACE_USER_FCT(lua) static DECLARE_INTERFACE_USER_FCT(lua)

Loading…
Cancel
Save