From 1668d199c18b56c3a261fef5f82d9354301467ee Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 2 Jun 2012 21:48:11 +0200 Subject: [PATCH] ADDED: #1471 IParser interface with a few methods, accessible from CWidgetManager, just so that I don't have to move CInterfaceParser right now. --HG-- branch : gui-refactoring --- .../src/interface_v3/interface_element.cpp | 20 +++++-------------- .../src/interface_v3/interface_group.cpp | 14 ++++--------- .../src/interface_v3/interface_link.cpp | 10 +++------- .../src/interface_v3/interface_manager.cpp | 1 + .../src/interface_v3/interface_parser.h | 2 +- .../src/interface_v3/widget_manager.cpp | 1 + .../client/src/interface_v3/widget_manager.h | 11 ++++++++++ 7 files changed, 26 insertions(+), 33 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index 90176baae..b0145363e 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -14,15 +14,12 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "interface_group.h" #include "nel/gui/interface_property.h" -#include "interface_manager.h" +#include "nel/gui/view_renderer.h" +#include "widget_manager.h" +#include "nel/gui/db_manager.h" #include "group_container.h" -#include "../misc.h" #include "interface_link.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/lua_ihm.h" @@ -157,7 +154,7 @@ bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) idparent = parentGroup->getId() +":"; else idparent = "ui:"; - CInterfaceManager::getInstance()->addParentPositionAssociation (this, idparent + string((const char*)ptr)); + CWidgetManager::parser->addParentPositionAssociation(this, idparent + string((const char*)ptr)); } } @@ -178,7 +175,7 @@ bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) if (parentGroup) idparent = parentGroup->getId(); } - CInterfaceManager::getInstance()->addParentSizeAssociation (this, idparent); + CWidgetManager::parser->addParentSizeAssociation( this, idparent ); } ptr = (char*) xmlGetProp (cur, (xmlChar*)"sizeref"); @@ -527,7 +524,6 @@ void CInterfaceElement::relativeSInt64Read (CInterfaceProperty &rIP, const strin return; } - CInterfaceManager *pIM = CInterfaceManager::getInstance(); sint32 decal = 0; if (val[0] == ':') decal = 1; @@ -574,7 +570,6 @@ void CInterfaceElement::relativeSInt32Read (CInterfaceProperty &rIP, const strin return; } - CInterfaceManager *pIM = CInterfaceManager::getInstance(); sint32 decal = 0; if (val[0] == ':') decal = 1; @@ -615,7 +610,6 @@ void CInterfaceElement::relativeBoolRead (CInterfaceProperty &rIP, const string } else { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); sint32 decal = 0; if (val[0] == ':') decal = 1; @@ -661,7 +655,6 @@ void CInterfaceElement::relativeRGBARead(CInterfaceProperty &rIP,const std::stri return; } - CInterfaceManager *pIM = CInterfaceManager::getInstance(); sint32 decal = 0; if (val[0] == ':') decal = 1; @@ -1000,7 +993,6 @@ void CInterfaceElement::copyOptionFrom(const CInterfaceElement &other) void CInterfaceElement::center() { // center the pc - CInterfaceManager *im = CInterfaceManager::getInstance(); CViewRenderer &vr = *CViewRenderer::getInstance(); uint32 sw, sh; vr.getScreenSize(sw, sh); @@ -1024,7 +1016,6 @@ void CInterfaceElement::renderWiredQuads(TRenderWired type, const std::string &u _Id.compare(_Id.size()-uiFilter.size(),string::npos,uiFilter)!=0) ) return; - CInterfaceManager *im = CInterfaceManager::getInstance(); CViewRenderer &vr = *CViewRenderer::getInstance(); vr.drawWiredQuad(_XReal, _YReal, _WReal, _HReal); drawHotSpot(_PosRef, CRGBA::Red); @@ -1063,7 +1054,6 @@ void CInterfaceElement::drawHotSpot(THotSpot hs, CRGBA col) { px = _XReal + _WReal - radius; } - CInterfaceManager *im = CInterfaceManager::getInstance(); CViewRenderer &vr = *CViewRenderer::getInstance(); vr.drawFilledQuad(px - radius, py - radius, radius * 2, radius * 2, col); diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 8104c5676..6681ea366 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -113,7 +113,6 @@ void CInterfaceGroup::setActive(bool state) if(state != getActive()) { CCtrlBase::setActive(state); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (_AHOnActive != NULL && state) { CAHManager::getInstance()->runActionHandler (_AHOnActive, this, _AHOnActiveParams); @@ -323,7 +322,7 @@ bool CInterfaceGroup::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) if (parentGroup) idparent = parentGroup->getId(); } - CInterfaceManager::getInstance()->addParentSizeMaxAssociation (this, idparent); + CWidgetManager::parser->addParentSizeMaxAssociation (this, idparent); } // left & right clicks @@ -346,7 +345,8 @@ bool CInterfaceGroup::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) // LuaClass script ptr = xmlGetProp (cur, (xmlChar*)"lua_class"); - if(ptr) CInterfaceManager::getInstance()->addLuaClassAssociation(this, (const char*)ptr); + if( ptr ) + CWidgetManager::parser->addLuaClassAssociation( this, (const char*)ptr ); return true; } @@ -693,8 +693,6 @@ bool CInterfaceGroup::handleEvent (const NLGUI::CEventDescriptor &event) if (!_Active) return false; - CInterfaceManager *im = CInterfaceManager::getInstance(); - if (event.getType() == NLGUI::CEventDescriptor::system) { NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event; @@ -866,10 +864,8 @@ void CInterfaceGroup::executeLuaScriptOnDraw() { // If some LUA script attached to me, execute it if(!_LUAOnDraw.empty()) - { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler("lua", this, _LUAOnDraw); - } + } // ------------------------------------------------------------------------------------------------ @@ -1748,7 +1744,6 @@ void CInterfaceGroup::onFrameUpdateWindowPos(sint dx, sint dy) // ------------------------------------------------------------------------------------------------ void CInterfaceGroup::pushLUAEnvTable() { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CLuaState *lua= CLuaManager::getInstance().getLuaState(); nlassert(lua); @@ -1783,7 +1778,6 @@ void CInterfaceGroup::deleteLUAEnvTable(bool recurse) { if(_LUAEnvTableCreated) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CLuaState *lua= CLuaManager::getInstance().getLuaState(); nlassert(lua); diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index c61891634..2ef066363 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -14,13 +14,11 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - - -#include "stdpch.h" +#include "action_handler.h" #include "interface_link.h" +#include "interface_group.h" #include "interface_element.h" -#include "interface_manager.h" +#include "widget_manager.h" #include "nel/gui/interface_expr.h" #include "nel/gui/interface_expr_node.h" #include "nel/gui/reflect.h" @@ -364,7 +362,6 @@ void CInterfaceLink::update() } if(launch) { - CInterfaceManager *im = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_ActionHandler, _AHParent, _AHParams); // do not add any code after this line because this can be deleted !!!! } @@ -543,7 +540,6 @@ void CInterfaceLink::setTargetProperty (const std::string &Target, const CInt { // Eval target ! string elt = Target.substr(0,Target.rfind(':')); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt); CInterfaceGroup *pIG = dynamic_cast(pIE); if (pIG == NULL) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 96b55998f..c1d3e2a71 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -256,6 +256,7 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG ) // ------------------------------------------------------------------------------------------------ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) { + CWidgetManager::parser = this; this->driver = driver; this->textcontext = textcontext; CViewRenderer::setDriver( driver ); diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 650e60cb9..70cf5a200 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -50,7 +50,7 @@ class CCtrlBase; */ // this is the base class for CInterfaceManager -class CInterfaceParser +class CInterfaceParser : public IParser { public: diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index 2bf490e13..f50c7113a 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -22,6 +22,7 @@ CWidgetManager* CWidgetManager::instance = NULL; std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; +IParser* CWidgetManager::parser = NULL; // ---------------------------------------------------------------------------- // SMasterGroup diff --git a/code/ryzom/client/src/interface_v3/widget_manager.h b/code/ryzom/client/src/interface_v3/widget_manager.h index 76d03b514..4b77010d2 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.h +++ b/code/ryzom/client/src/interface_v3/widget_manager.h @@ -28,6 +28,15 @@ class CCtrlBase; class CInterfaceGroup; class CViewPointer; +class IParser +{ +public: + virtual void addParentPositionAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; + virtual void addParentSizeAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; + virtual void addParentSizeMaxAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; + virtual void addLuaClassAssociation( CInterfaceGroup *group, const std::string &luaScript ) = 0; +}; + /// Manages the GUI widgets class CWidgetManager{ public: @@ -177,6 +186,8 @@ public: CViewPointer* getPointer(){ return _Pointer; } void setPointer( CViewPointer *pointer ){ _Pointer = pointer; } + static IParser *parser; + private: CWidgetManager(); ~CWidgetManager();