CHANGED: #1471 Decoupled CGroupHTML, CGroupParagraph, CViewLink from Ryzom game related code.

This commit is contained in:
dfighter1985 2012-06-30 05:58:02 +02:00
parent 215f7124d2
commit 31c887ede8
17 changed files with 407 additions and 403 deletions

View file

@ -43,6 +43,8 @@ namespace NLGUI
NLGUI::CLuaState* getLuaState() const{ return luaState; } NLGUI::CLuaState* getLuaState() const{ return luaState; }
bool executeLuaScript( const std::string &luaScript, bool smallScript = false );
private: private:
CLuaManager(); CLuaManager();

View file

@ -52,6 +52,8 @@ namespace NLGUI
virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0; virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0;
virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0; virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0;
virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ) = 0; virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ) = 0;
virtual uint getProcedureNumActions( const std::string &procName ) const = 0;
virtual bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string &params ) const = 0;
}; };
/// Manages the GUI widgets /// Manages the GUI widgets

View file

@ -34,6 +34,22 @@ namespace NLGUI
luaState = NULL; luaState = NULL;
} }
bool CLuaManager::executeLuaScript( const std::string &luaScript, bool smallScript )
{
try
{
if( smallScript )
luaState->executeSmallScript( luaScript );
else
luaState->executeScript( luaScript );
}
catch( const ELuaError &e )
{
nlwarning( e.luaWhat().c_str() );
return false;
}
return true;
}
} }

View file

@ -14,8 +14,6 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
//#include <crtdbg.h> //#include <crtdbg.h>
// LibWWW // LibWWW
@ -27,25 +25,21 @@ extern "C"
} }
#include "../libwww.h" #include "../libwww.h"
#include "group_html.h" #include "group_html.h"
#include "nel/gui/group_list.h" #include "nel/gui/group_list.h"
#include "nel/gui/group_container.h" #include "nel/gui/group_container.h"
#include "view_link.h" #include "view_link.h"
#include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_scroll.h"
#include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_button.h"
#include "dbctrl_sheet.h"
#include "nel/gui/ctrl_text_button.h" #include "nel/gui/ctrl_text_button.h"
#include "nel/gui/action_handler.h" #include "nel/gui/action_handler.h"
#include "group_paragraph.h" #include "group_paragraph.h"
#include "nel/gui/group_editbox.h" #include "nel/gui/group_editbox.h"
#include "interface_manager.h" #include "nel/gui/widget_manager.h"
#include "nel/gui/lua_manager.h"
#include "nel/gui/view_bitmap.h" #include "nel/gui/view_bitmap.h"
#include "../actions.h"
#include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/dbgroup_combo_box.h"
#include "nel/gui/lua_ihm.h" #include "nel/gui/lua_ihm.h"
#include "../time_client.h"
#include "nel/misc/i18n.h" #include "nel/misc/i18n.h"
#include "nel/misc/md5.h" #include "nel/misc/md5.h"
#include "nel/3d/texture_file.h" #include "nel/3d/texture_file.h"
@ -62,14 +56,15 @@ using namespace NLMISC;
//#define LOG_DL 1 //#define LOG_DL 1
CGroupHTML *CGroupHTML::_ConnectingLock = NULL; CGroupHTML *CGroupHTML::_ConnectingLock = NULL;
extern CActionsContext ActionsContext; CGroupHTML::SWebOptions CGroupHTML::options;
// Check if domain is on TrustedDomain // Check if domain is on TrustedDomain
bool CGroupHTML::isTrustedDomain(const string &domain) bool CGroupHTML::isTrustedDomain(const string &domain)
{ {
vector<string>::iterator it; vector<string>::iterator it;
it = find (ClientCfg.WebIgTrustedDomains.begin(), ClientCfg.WebIgTrustedDomains.end(), domain); it = find ( options.trustedDomains.begin(), options.trustedDomains.end(), domain);
return it != ClientCfg.WebIgTrustedDomains.end(); return it != options.trustedDomains.end();
} }
void CGroupHTML::setImage(CViewBase * view, const string &file) void CGroupHTML::setImage(CViewBase * view, const string &file)
@ -361,8 +356,7 @@ void CGroupHTML::checkDownloads()
CFile::moveFile(file.c_str(), (file+".tmp").c_str()); CFile::moveFile(file.c_str(), (file+".tmp").c_str());
if (lookupLocalFile (finalUrl, file.c_str(), false)) if (lookupLocalFile (finalUrl, file.c_str(), false))
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CLuaManager::getInstance().executeLuaScript( it->luaScript, true );
pIM->executeLuaScript(it->luaScript, true);
} }
} }
} }
@ -899,33 +893,8 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS]) if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS])
_LinkClass.push_back(value[MY_HTML_A_CLASS]); _LinkClass.push_back(value[MY_HTML_A_CLASS]);
// Quick help
if (_TrustedDomain && present[MY_HTML_A_Z_ACTION_SHORTCUT] && value[MY_HTML_A_Z_ACTION_SHORTCUT])
{
// Get the action category
string category;
if (present[MY_HTML_A_Z_ACTION_CATEGORY] && value[MY_HTML_A_Z_ACTION_CATEGORY])
category = value[MY_HTML_A_Z_ACTION_CATEGORY];
// Get the action params
string params;
if (present[MY_HTML_A_Z_ACTION_PARAMS] && value[MY_HTML_A_Z_ACTION_PARAMS])
params = value[MY_HTML_A_Z_ACTION_PARAMS];
// Get the action descriptor
CActionsManager *actionManager = ActionsContext.getActionsManager (category);
if (actionManager)
{
const CActionsManager::TActionComboMap &actionCombo = actionManager->getActionComboMap ();
CActionsManager::TActionComboMap::const_iterator ite = actionCombo.find (CAction::CName (value[MY_HTML_A_Z_ACTION_SHORTCUT], params.c_str()));
if (ite != actionCombo.end())
{
addString (ite->second.toUCString());
}
}
}
break; break;
case HTML_DIV: case HTML_DIV:
{ {
if (present[MY_HTML_DIV_NAME] && value[MY_HTML_DIV_NAME]) if (present[MY_HTML_DIV_NAME] && value[MY_HTML_DIV_NAME])
@ -972,8 +941,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
else else
parentId = _Paragraph->getId(); parentId = _Paragraph->getId();
CInterfaceManager *im = CInterfaceManager::getInstance(); CInterfaceGroup *inst = CWidgetManager::parser->createGroupInstance(templateName, parentId+":"+id, tmplParams);
CInterfaceGroup *inst = im->createGroupInstance(templateName, parentId+":"+id, tmplParams);
if (inst) if (inst)
{ {
inst->setId(parentId+":"+id); inst->setId(parentId+":"+id);
@ -1272,7 +1240,6 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
paragraphChange (); paragraphChange ();
} }
CInterfaceManager *im = CInterfaceManager::getInstance();
typedef pair<string, string> TTmplParam; typedef pair<string, string> TTmplParam;
vector<TTmplParam> tmplParams; vector<TTmplParam> tmplParams;
tmplParams.push_back(TTmplParam("id", name)); tmplParams.push_back(TTmplParam("id", name));
@ -1282,7 +1249,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
tmplParams.push_back(TTmplParam("active", "true")); tmplParams.push_back(TTmplParam("active", "true"));
if (!minWidth.empty()) if (!minWidth.empty())
tmplParams.push_back(TTmplParam("wmin", minWidth)); tmplParams.push_back(TTmplParam("wmin", minWidth));
CInterfaceGroup *buttonGroup = im->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams); CInterfaceGroup *buttonGroup = CWidgetManager::parser->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams);
if (buttonGroup) if (buttonGroup)
{ {
@ -1776,8 +1743,7 @@ void CGroupHTML::endElement (uint element_number)
{ {
if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum)) if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum))
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CLuaManager::getInstance().executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true);
pIM->executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true);
} }
_ObjectScript = ""; _ObjectScript = "";
} }
@ -1811,9 +1777,8 @@ void CGroupHTML::endUnparsedElement(const char *buffer, int length)
{ {
_ParsingLua = false; _ParsingLua = false;
// execute the embeded lua script // execute the embeded lua script
CInterfaceManager *pIM = CInterfaceManager::getInstance();
_LuaScript = "\nlocal __CURRENT_WINDOW__=\""+this->_Id+"\" \n"+_LuaScript; _LuaScript = "\nlocal __CURRENT_WINDOW__=\""+this->_Id+"\" \n"+_LuaScript;
pIM->executeLuaScript(_LuaScript, true); CLuaManager::getInstance().executeLuaScript(_LuaScript, true);
} }
} }
} }
@ -2219,8 +2184,6 @@ void CGroupHTML::doBrowse(const char *url)
// if a BrowseTree is bound to us, try to select the node that opens this URL (auto-locate) // if a BrowseTree is bound to us, try to select the node that opens this URL (auto-locate)
if(!_BrowseTree.empty()) if(!_BrowseTree.empty())
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CGroupTree *groupTree=dynamic_cast<CGroupTree*>(CWidgetManager::getInstance()->getElementFromId(_BrowseTree)); CGroupTree *groupTree=dynamic_cast<CGroupTree*>(CWidgetManager::getInstance()->getElementFromId(_BrowseTree));
if(groupTree) if(groupTree)
{ {
@ -2444,14 +2407,13 @@ void CGroupHTML::addString(const ucstring &str)
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
string param = "name=" + this->_Id + "|url=" + getLink(); string param = "name=" + this->_Id + "|url=" + getLink();
CInterfaceManager *im = CInterfaceManager::getInstance();
typedef pair<string, string> TTmplParam; typedef pair<string, string> TTmplParam;
vector<TTmplParam> tmplParams; vector<TTmplParam> tmplParams;
tmplParams.push_back(TTmplParam("id", "")); tmplParams.push_back(TTmplParam("id", ""));
tmplParams.push_back(TTmplParam("onclick", "browse")); tmplParams.push_back(TTmplParam("onclick", "browse"));
tmplParams.push_back(TTmplParam("onclick_param", param)); tmplParams.push_back(TTmplParam("onclick_param", param));
tmplParams.push_back(TTmplParam("active", "true")); tmplParams.push_back(TTmplParam("active", "true"));
CInterfaceGroup *buttonGroup = im->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams); CInterfaceGroup *buttonGroup = CWidgetManager::parser->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams);
if (buttonGroup) if (buttonGroup)
{ {
@ -2632,8 +2594,6 @@ CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const
// No more text in this text view // No more text in this text view
_CurrentViewLink = NULL; _CurrentViewLink = NULL;
CInterfaceManager *im = CInterfaceManager::getInstance();
if (im)
{ {
// Not added ? // Not added ?
std::vector<std::pair<std::string,std::string> > templateParams; std::vector<std::pair<std::string,std::string> > templateParams;
@ -2645,7 +2605,7 @@ CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const
templateParams.push_back (std::pair<std::string,std::string> ("want_return", multiLine?"true":"false")); templateParams.push_back (std::pair<std::string,std::string> ("want_return", multiLine?"true":"false"));
templateParams.push_back (std::pair<std::string,std::string> ("enter_recover_focus", "false")); templateParams.push_back (std::pair<std::string,std::string> ("enter_recover_focus", "false"));
templateParams.push_back (std::pair<std::string,std::string> ("max_num_chars", "1024")); templateParams.push_back (std::pair<std::string,std::string> ("max_num_chars", "1024"));
CInterfaceGroup *textArea = im->createGroupInstance (templateName.c_str(), CInterfaceGroup *textArea = CWidgetManager::parser->createGroupInstance (templateName.c_str(),
getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size());
// Group created ? // Group created ?
@ -2679,13 +2639,11 @@ CDBGroupComboBox *CGroupHTML::addComboBox(const std::string &templateName, const
} }
CInterfaceManager *im = CInterfaceManager::getInstance();
if (im)
{ {
// Not added ? // Not added ?
std::vector<std::pair<std::string,std::string> > templateParams; std::vector<std::pair<std::string,std::string> > templateParams;
templateParams.push_back (std::pair<std::string,std::string> ("id", name)); templateParams.push_back (std::pair<std::string,std::string> ("id", name));
CInterfaceGroup *group = im->createGroupInstance (templateName.c_str(), CInterfaceGroup *group = CWidgetManager::parser->createGroupInstance (templateName.c_str(),
getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size());
// Group created ? // Group created ?
@ -2736,7 +2694,6 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/
if(!CPath::exists(normal)) if(!CPath::exists(normal))
{ {
// search in the compressed texture // search in the compressed texture
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 id = rVR.getTextureIdFromName(normal); sint32 id = rVR.getTextureIdFromName(normal);
if(id == -1) if(id == -1)
@ -2756,7 +2713,6 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/
if(!CPath::exists(pushed)) if(!CPath::exists(pushed))
{ {
// search in the compressed texture // search in the compressed texture
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 id = rVR.getTextureIdFromName(pushed); sint32 id = rVR.getTextureIdFromName(pushed);
if(id == -1) if(id == -1)
@ -3030,7 +2986,6 @@ bool CGroupHTML::lookupLocalFile (string &result, const char *url, bool isUrl)
else else
{ {
// Is it a texture in the big texture ? // Is it a texture in the big texture ?
CInterfaceManager *pIM = CInterfaceManager::getInstance();
if (CViewRenderer::getInstance()->getTextureIdFromName (result) >= 0) if (CViewRenderer::getInstance()->getTextureIdFromName (result) >= 0)
{ {
return true; return true;
@ -3147,12 +3102,14 @@ void CGroupHTML::handle ()
{ {
H_AUTO(RZ_Interface_Html_handle) H_AUTO(RZ_Interface_Html_handle)
const CWidgetManager::SInterfaceTimes &times = CWidgetManager::getInstance()->getInterfaceTimes();
if (_Connecting) if (_Connecting)
{ {
nlassert (_ConnectingLock == this); nlassert (_ConnectingLock == this);
// Check timeout if needed // Check timeout if needed
if (_TimeoutValue != 0 && _ConnectingTimeout <= TimeInSec) if (_TimeoutValue != 0 && _ConnectingTimeout <= ( times.thisFrameMs / 1000.0f ) )
{ {
browseError(("Connection timeout : "+_URL).c_str()); browseError(("Connection timeout : "+_URL).c_str());
} }
@ -3184,7 +3141,7 @@ void CGroupHTML::handle ()
nlassert (_ConnectingLock == NULL); nlassert (_ConnectingLock == NULL);
_ConnectingLock = this; _ConnectingLock = this;
_Connecting = true; _Connecting = true;
_ConnectingTimeout = TimeInSec + _TimeoutValue; _ConnectingTimeout = ( times.thisFrameMs / 1000.0f ) + _TimeoutValue;
CButtonFreezer freezer; CButtonFreezer freezer;
@ -3238,7 +3195,7 @@ void CGroupHTML::handle ()
// add supported language header // add supported language header
HTList *langs = HTList_new(); HTList *langs = HTList_new();
// set the language code used by the client // set the language code used by the client
HTLanguage_add(langs, ClientCfg.getHtmlLanguageCode().c_str(), 1.0); HTLanguage_add(langs, options.languageCode.c_str(), 1.0);
HTRequest_setLanguage (_LibWWW->Request, langs, 1); HTRequest_setLanguage (_LibWWW->Request, langs, 1);
// get_document(_LibWWW->Request, _LibWWW->Anchor); // get_document(_LibWWW->Request, _LibWWW->Anchor);
@ -3343,7 +3300,7 @@ void CGroupHTML::handle ()
nlassert (_ConnectingLock == NULL); nlassert (_ConnectingLock == NULL);
_ConnectingLock = this; _ConnectingLock = this;
_Connecting = true; _Connecting = true;
_ConnectingTimeout = TimeInSec + _TimeoutValue; _ConnectingTimeout = ( times.thisFrameMs / 1000.0f ) + _TimeoutValue;
CButtonFreezer freezer; CButtonFreezer freezer;
this->visit(&freezer); this->visit(&freezer);
@ -3534,8 +3491,6 @@ const std::string &CGroupHTML::selectTreeNodeRecurs(CGroupTree::SNode *node, con
// *************************************************************************** // ***************************************************************************
bool CGroupHTML::actionLaunchUrlRecurs(const std::string &ah, const std::string &params, const std::string &url) bool CGroupHTML::actionLaunchUrlRecurs(const std::string &ah, const std::string &params, const std::string &url)
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance();
// check if this action match // check if this action match
if( (ah=="launch_help" || ah=="browse") && IActionHandler::getParam (params, "url") == url) if( (ah=="launch_help" || ah=="browse") && IActionHandler::getParam (params, "url") == url)
{ {
@ -3546,11 +3501,11 @@ bool CGroupHTML::actionLaunchUrlRecurs(const std::string &ah, const std::string
{ {
const std::string &procName= params; const std::string &procName= params;
// look into this proc // look into this proc
uint numActions= pIM->getProcedureNumActions(procName); uint numActions= CWidgetManager::parser->getProcedureNumActions(procName);
for(uint i=0;i<numActions;i++) for(uint i=0;i<numActions;i++)
{ {
string procAh, procParams; string procAh, procParams;
if(pIM->getProcedureAction(procName, i, procAh, procParams)) if( CWidgetManager::parser->getProcedureAction(procName, i, procAh, procParams))
{ {
// recurs proc if needed! // recurs proc if needed!
if (actionLaunchUrlRecurs(procAh, procParams, url)) if (actionLaunchUrlRecurs(procAh, procParams, url))
@ -3633,7 +3588,6 @@ void CGroupHTML::browseRedo()
// *************************************************************************** // ***************************************************************************
void CGroupHTML::updateUndoRedoButtons() void CGroupHTML::updateUndoRedoButtons()
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CCtrlBaseButton *butUndo= dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseUndoButton)); CCtrlBaseButton *butUndo= dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseUndoButton));
CCtrlBaseButton *butRedo= dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseRedoButton)); CCtrlBaseButton *butRedo= dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseRedoButton));
@ -3647,7 +3601,6 @@ void CGroupHTML::updateUndoRedoButtons()
// *************************************************************************** // ***************************************************************************
void CGroupHTML::updateRefreshButton() void CGroupHTML::updateRefreshButton()
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CCtrlBaseButton *butRefresh = dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseRefreshButton)); CCtrlBaseButton *butRefresh = dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseRefreshButton));
bool enabled = !_Browsing && !_Connecting; bool enabled = !_Browsing && !_Connecting;
@ -3957,3 +3910,5 @@ ucstring CGroupHTML::decodeHTMLEntities(const ucstring &str)
return result; return result;
} }

View file

@ -14,9 +14,6 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_GROUP_HTML_H #ifndef CL_GROUP_HTML_H
#define CL_GROUP_HTML_H #define CL_GROUP_HTML_H
@ -47,6 +44,7 @@ namespace NLGUI
class CGroupParagraph; class CGroupParagraph;
// HTML group // HTML group
/** /**
* Widget to have a resizable scrolltext and its scrollbar * Widget to have a resizable scrolltext and its scrollbar
@ -66,7 +64,20 @@ public:
friend void TextEndUnparsedElement(HText *me, const char *buffer, int length); friend void TextEndUnparsedElement(HText *me, const char *buffer, int length);
friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status); friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status);
struct SWebOptions
{
public:
std::string appName;
std::string appVersion;
std::string languageCode;
std::vector< std::string > trustedDomains;
SWebOptions()
{
}
};
static SWebOptions options;
// Constructor // Constructor
CGroupHTML(const TCtorParam &param); CGroupHTML(const TCtorParam &param);
@ -644,5 +655,4 @@ public:
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
}; };
#endif #endif

View file

@ -15,28 +15,21 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "group_paragraph.h" #include "group_paragraph.h"
#include "group_html.h" #include "group_html.h"
#include "interface_manager.h" #include "nel/gui/widget_manager.h"
#include "nel/gui/interface_element.h" #include "nel/gui/interface_element.h"
#include "../client_chat_manager.h" #include "nel/gui/view_pointer_base.h"
#include "nel/gui/view_bitmap.h" #include "nel/gui/view_bitmap.h"
#include "nel/gui/view_text_id.h" #include "nel/gui/view_text_id.h"
#include "nel/gui/group_container.h" #include "nel/gui/group_container.h"
#include "nel/misc/i_xml.h" #include "nel/misc/i_xml.h"
#include "nel/misc/i18n.h" #include "nel/misc/i18n.h"
#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/xml_auto_ptr.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
extern CClientChatManager ChatMngr;
NLMISC_REGISTER_OBJECT(CViewBase, CCtrlLink, std::string, "button_link"); NLMISC_REGISTER_OBJECT(CViewBase, CCtrlLink, std::string, "button_link");
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -737,7 +730,6 @@ void CGroupParagraph::checkCoords ()
sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal());
if (_LastW != (sint) parentWidth) if (_LastW != (sint) parentWidth)
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft();
if (pCB != NULL) if (pCB != NULL)
{ {
@ -770,7 +762,6 @@ void CGroupParagraph::draw ()
//rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,0,255) ); //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,0,255) );
if (_Over) if (_Over)
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance();
if (CWidgetManager::getInstance()->getModalWindow() == NULL) if (CWidgetManager::getInstance()->getModalWindow() == NULL)
@ -1229,3 +1220,4 @@ sint32 CGroupParagraph::getMinUsedW() const
} }
return minWidth; return minWidth;
} }

View file

@ -292,7 +292,6 @@ private:
}; };
#endif // NL_GROUP_PARAGRAPH_H #endif // NL_GROUP_PARAGRAPH_H
/* End of group_paragraph.h */ /* End of group_paragraph.h */

View file

@ -28,7 +28,7 @@
#include "interface_manager.h" #include "interface_manager.h"
#include "nel/gui/action_handler.h" #include "nel/gui/action_handler.h"
#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/xml_auto_ptr.h"
#include "../actions.h"
#include "../client_cfg.h" #include "../client_cfg.h"
using namespace std; using namespace std;
@ -213,6 +213,8 @@ void CGroupQuickHelp::setGroupTextSize (CInterfaceGroup *group, bool selected)
// *************************************************************************** // ***************************************************************************
extern CActionsContext ActionsContext;
void CGroupQuickHelp::beginElement (uint element_number, const BOOL *present, const char **value) void CGroupQuickHelp::beginElement (uint element_number, const BOOL *present, const char **value)
{ {
CGroupHTML::beginElement (element_number, present, value); CGroupHTML::beginElement (element_number, present, value);
@ -220,6 +222,34 @@ void CGroupQuickHelp::beginElement (uint element_number, const BOOL *present, co
// Paragraph ? // Paragraph ?
switch(element_number) switch(element_number)
{ {
case HTML_A:
// Quick help
if (_TrustedDomain && present[MY_HTML_A_Z_ACTION_SHORTCUT] && value[MY_HTML_A_Z_ACTION_SHORTCUT])
{
// Get the action category
string category;
if (present[MY_HTML_A_Z_ACTION_CATEGORY] && value[MY_HTML_A_Z_ACTION_CATEGORY])
category = value[MY_HTML_A_Z_ACTION_CATEGORY];
// Get the action params
string params;
if (present[MY_HTML_A_Z_ACTION_PARAMS] && value[MY_HTML_A_Z_ACTION_PARAMS])
params = value[MY_HTML_A_Z_ACTION_PARAMS];
// Get the action descriptor
CActionsManager *actionManager = ActionsContext.getActionsManager (category);
if (actionManager)
{
const CActionsManager::TActionComboMap &actionCombo = actionManager->getActionComboMap ();
CActionsManager::TActionComboMap::const_iterator ite = actionCombo.find (CAction::CName (value[MY_HTML_A_Z_ACTION_SHORTCUT], params.c_str()));
if (ite != actionCombo.end())
{
addString (ite->second.toUCString());
}
}
}
break;
case HTML_P: case HTML_P:
// Get the action name // Get the action name
if (present[MY_HTML_P_QUICK_HELP_EVENTS]) if (present[MY_HTML_P_QUICK_HELP_EVENTS])

View file

@ -21,6 +21,8 @@
// Memory // Memory
#include <memory> #include <memory>
#include "game_share/ryzom_version.h"
#include "nel/misc/i_xml.h" #include "nel/misc/i_xml.h"
#include "nel/misc/o_xml.h" #include "nel/misc/o_xml.h"
#include "nel/misc/algo.h" #include "nel/misc/algo.h"
@ -68,6 +70,7 @@
#include "group_in_scene_bubble.h" #include "group_in_scene_bubble.h"
#include "group_skills.h" #include "group_skills.h"
#include "group_compas.h" #include "group_compas.h"
#include "group_html.h"
// Misc // Misc
#include "../input.h" #include "../input.h"
@ -404,6 +407,10 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext
CViewRenderer::getInstance(); CViewRenderer::getInstance();
CViewTextID::setTextProvider( &SMTextProvider ); CViewTextID::setTextProvider( &SMTextProvider );
CViewTextFormated::setFormatter( &RyzomTextFormatter ); CViewTextFormated::setFormatter( &RyzomTextFormatter );
CGroupHTML::options.trustedDomains = ClientCfg.WebIgTrustedDomains;
CGroupHTML::options.languageCode = ClientCfg.getHtmlLanguageCode();
CGroupHTML::options.appName = "Ryzom";
CGroupHTML::options.appVersion = RYZOM_VERSION;
_Instance = this; _Instance = this;
NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS );
@ -3403,42 +3410,6 @@ void CInterfaceManager::setProcedureAction(const std::string &procName, uint act
} }
} }
// ------------------------------------------------------------------------------------------------
uint CInterfaceManager::getProcedureNumActions(const std::string &procName) const
{
CstItProcedureMap it= _ProcedureMap.find(procName);
if(it!=_ProcedureMap.end())
{
const CProcedure &proc= it->second;
return (uint)proc.Actions.size();
}
else
return 0;
}
// ------------------------------------------------------------------------------------------------
bool CInterfaceManager::getProcedureAction(const std::string &procName, uint actionIndex, std::string &ah, std::string &params) const
{
CstItProcedureMap it= _ProcedureMap.find(procName);
if(it!=_ProcedureMap.end())
{
const CProcedure &proc= it->second;
if(actionIndex<proc.Actions.size())
{
const CAction &action= proc.Actions[actionIndex];
// if not a variable parametrized Params
if(action.ParamBlocks.size()==1 && action.ParamBlocks[0].NumParam==-1)
{
ah= action.Action;
params= action.ParamBlocks[0].String;
return true;
}
}
}
return false;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CInterfaceManager::startAnim (const string &animId) void CInterfaceManager::startAnim (const string &animId)
{ {

View file

@ -271,10 +271,6 @@ public:
void runProcedure(const std::string &procName, CCtrlBase *pCaller, const std::vector<std::string> &paramList); void runProcedure(const std::string &procName, CCtrlBase *pCaller, const std::vector<std::string> &paramList);
// replace an action in a procedure (if possible) // replace an action in a procedure (if possible)
void setProcedureAction(const std::string &procName, uint actionIndex, const std::string &ah, const std::string &params); void setProcedureAction(const std::string &procName, uint actionIndex, const std::string &ah, const std::string &params);
// get info on procedure. return 0 if procedure not found
uint getProcedureNumActions(const std::string &procName) const;
// return false if procedure not found, or if bad action index. return false if has some param variable (@0...)
bool getProcedureAction(const std::string &procName, uint actionIndex, std::string &ah, std::string &params) const;
// Execute a anim // Execute a anim
void startAnim(const std::string &animId); void startAnim(const std::string &animId);
void stopAnim(const std::string &animId); void stopAnim(const std::string &animId);

View file

@ -3432,6 +3432,43 @@ void CInterfaceParser::removeAll()
} }
// ------------------------------------------------------------------------------------------------
uint CInterfaceParser::getProcedureNumActions(const std::string &procName) const
{
CstItProcedureMap it= _ProcedureMap.find(procName);
if(it!=_ProcedureMap.end())
{
const CProcedure &proc= it->second;
return (uint)proc.Actions.size();
}
else
return 0;
}
// ------------------------------------------------------------------------------------------------
bool CInterfaceParser::getProcedureAction(const std::string &procName, uint actionIndex, std::string &ah, std::string &params) const
{
CstItProcedureMap it= _ProcedureMap.find(procName);
if(it!=_ProcedureMap.end())
{
const CProcedure &proc= it->second;
if(actionIndex<proc.Actions.size())
{
const CAction &action= proc.Actions[actionIndex];
// if not a variable parametrized Params
if(action.ParamBlocks.size()==1 && action.ParamBlocks[0].NumParam==-1)
{
ah= action.Action;
params= action.ParamBlocks[0].String;
return true;
}
}
}
return false;
}
// *************************************************************************** // ***************************************************************************
bool CInterfaceParser::parseGeneratorRootContainer(xmlNodePtr cur, xmlNodePtr &rootTreeNode) bool CInterfaceParser::parseGeneratorRootContainer(xmlNodePtr cur, xmlNodePtr &rootTreeNode)
{ {

View file

@ -228,6 +228,12 @@ public:
void removeAll(); void removeAll();
// @} // @}
// get info on procedure. return 0 if procedure not found
uint getProcedureNumActions( const std::string &procName ) const;
// return false if procedure not found, or if bad action index. return false if has some param variable (@0...)
bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string &params ) const;
protected: protected:
/** /**

View file

@ -15,9 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include <nel/misc/file.h> #include <nel/misc/file.h>
extern "C" extern "C"
@ -40,7 +37,6 @@ extern "C"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
extern "C" extern "C"
{ {
@ -593,3 +589,5 @@ PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch,
//PUBLIC unsigned int WWW_TraceFlag = 0; //PUBLIC unsigned int WWW_TraceFlag = 0;
} // extern "C" } // extern "C"

View file

@ -23,8 +23,6 @@
#include "HTProt.h" #include "HTProt.h"
extern "C" HTProtCallback HTLoadNeLFile; extern "C" HTProtCallback HTLoadNeLFile;
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, void * param, int mode);
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch,
void * param, int mode);
#endif // LIBWWW_NEL_STREAM_H #endif // LIBWWW_NEL_STREAM_H

View file

@ -14,13 +14,8 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "nel/misc/bit_mem_stream.h" #include "nel/misc/bit_mem_stream.h"
#include "nel/misc/i18n.h" #include "nel/misc/i18n.h"
#include "view_link.h" #include "view_link.h"
using namespace std; using namespace std;
@ -62,3 +57,4 @@ bool CViewLink::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col)
// *************************************************************************** // ***************************************************************************

View file

@ -21,6 +21,8 @@
#include "nel/gui/view_text.h" #include "nel/gui/view_text.h"
class CGroupHTML;
/** /**
* class implementing a link view * class implementing a link view
* \author Cyril 'Hulud' Corvazier * \author Cyril 'Hulud' Corvazier
@ -41,7 +43,7 @@ public:
std::string LinkTitle; std::string LinkTitle;
// Set the main group // Set the main group
void setHTMLView(class CGroupHTML *html); void setHTMLView( CGroupHTML *html);
bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col); bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col);
protected: protected:
@ -50,7 +52,6 @@ protected:
CGroupHTML *HTML; CGroupHTML *HTML;
}; };
#endif // NL_VIEW_LINK_H #endif // NL_VIEW_LINK_H
/* End of view_link.h */ /* End of view_link.h */

View file

@ -15,9 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
// LibWWW // LibWWW
extern "C" extern "C"
{ {
@ -27,8 +24,6 @@ extern "C"
} }
#include "interface_v3/group_html.h" #include "interface_v3/group_html.h"
#include "game_share/ryzom_version.h"
#include "interface_v3/libwww_nel_stream.h" #include "interface_v3/libwww_nel_stream.h"
using namespace NLMISC; using namespace NLMISC;
@ -552,8 +547,8 @@ void initLibWWW()
/* Initiate libwww */ /* Initiate libwww */
HTLib_setAppName("Ryzom"); HTLib_setAppName( CGroupHTML::options.appName.c_str() );
HTLib_setAppVersion(RYZOM_VERSION); HTLib_setAppVersion( CGroupHTML::options.appVersion.c_str() );
/* Set up TCP as transport */ /* Set up TCP as transport */
VerifyLibWWW("HTTransport_add", HTTransport_add("buffered_tcp", HT_TP_SINGLE, HTReader_new, HTBufferWriter_new)); VerifyLibWWW("HTTransport_add", HTTransport_add("buffered_tcp", HT_TP_SINGLE, HTReader_new, HTBufferWriter_new));