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
This commit is contained in:
dfighter1985 2012-06-02 21:48:11 +02:00
parent 0155fd6ed4
commit 1668d199c1
7 changed files with 26 additions and 33 deletions

View file

@ -14,15 +14,12 @@
// 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 "interface_group.h" #include "interface_group.h"
#include "nel/gui/interface_property.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 "group_container.h"
#include "../misc.h"
#include "interface_link.h" #include "interface_link.h"
#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/lua_ihm.h" #include "nel/gui/lua_ihm.h"
@ -157,7 +154,7 @@ bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
idparent = parentGroup->getId() +":"; idparent = parentGroup->getId() +":";
else else
idparent = "ui:"; 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) if (parentGroup)
idparent = parentGroup->getId(); idparent = parentGroup->getId();
} }
CInterfaceManager::getInstance()->addParentSizeAssociation (this, idparent); CWidgetManager::parser->addParentSizeAssociation( this, idparent );
} }
ptr = (char*) xmlGetProp (cur, (xmlChar*)"sizeref"); ptr = (char*) xmlGetProp (cur, (xmlChar*)"sizeref");
@ -527,7 +524,6 @@ void CInterfaceElement::relativeSInt64Read (CInterfaceProperty &rIP, const strin
return; return;
} }
CInterfaceManager *pIM = CInterfaceManager::getInstance();
sint32 decal = 0; sint32 decal = 0;
if (val[0] == ':') if (val[0] == ':')
decal = 1; decal = 1;
@ -574,7 +570,6 @@ void CInterfaceElement::relativeSInt32Read (CInterfaceProperty &rIP, const strin
return; return;
} }
CInterfaceManager *pIM = CInterfaceManager::getInstance();
sint32 decal = 0; sint32 decal = 0;
if (val[0] == ':') if (val[0] == ':')
decal = 1; decal = 1;
@ -615,7 +610,6 @@ void CInterfaceElement::relativeBoolRead (CInterfaceProperty &rIP, const string
} }
else else
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance();
sint32 decal = 0; sint32 decal = 0;
if (val[0] == ':') if (val[0] == ':')
decal = 1; decal = 1;
@ -661,7 +655,6 @@ void CInterfaceElement::relativeRGBARead(CInterfaceProperty &rIP,const std::stri
return; return;
} }
CInterfaceManager *pIM = CInterfaceManager::getInstance();
sint32 decal = 0; sint32 decal = 0;
if (val[0] == ':') if (val[0] == ':')
decal = 1; decal = 1;
@ -1000,7 +993,6 @@ void CInterfaceElement::copyOptionFrom(const CInterfaceElement &other)
void CInterfaceElement::center() void CInterfaceElement::center()
{ {
// center the pc // center the pc
CInterfaceManager *im = CInterfaceManager::getInstance();
CViewRenderer &vr = *CViewRenderer::getInstance(); CViewRenderer &vr = *CViewRenderer::getInstance();
uint32 sw, sh; uint32 sw, sh;
vr.getScreenSize(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) _Id.compare(_Id.size()-uiFilter.size(),string::npos,uiFilter)!=0)
) )
return; return;
CInterfaceManager *im = CInterfaceManager::getInstance();
CViewRenderer &vr = *CViewRenderer::getInstance(); CViewRenderer &vr = *CViewRenderer::getInstance();
vr.drawWiredQuad(_XReal, _YReal, _WReal, _HReal); vr.drawWiredQuad(_XReal, _YReal, _WReal, _HReal);
drawHotSpot(_PosRef, CRGBA::Red); drawHotSpot(_PosRef, CRGBA::Red);
@ -1063,7 +1054,6 @@ void CInterfaceElement::drawHotSpot(THotSpot hs, CRGBA col)
{ {
px = _XReal + _WReal - radius; px = _XReal + _WReal - radius;
} }
CInterfaceManager *im = CInterfaceManager::getInstance();
CViewRenderer &vr = *CViewRenderer::getInstance(); CViewRenderer &vr = *CViewRenderer::getInstance();
vr.drawFilledQuad(px - radius, py - radius, radius * 2, radius * 2, col); vr.drawFilledQuad(px - radius, py - radius, radius * 2, radius * 2, col);

View file

@ -113,7 +113,6 @@ void CInterfaceGroup::setActive(bool state)
if(state != getActive()) if(state != getActive())
{ {
CCtrlBase::setActive(state); CCtrlBase::setActive(state);
CInterfaceManager *pIM = CInterfaceManager::getInstance();
if (_AHOnActive != NULL && state) if (_AHOnActive != NULL && state)
{ {
CAHManager::getInstance()->runActionHandler (_AHOnActive, this, _AHOnActiveParams); CAHManager::getInstance()->runActionHandler (_AHOnActive, this, _AHOnActiveParams);
@ -323,7 +322,7 @@ bool CInterfaceGroup::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup)
if (parentGroup) if (parentGroup)
idparent = parentGroup->getId(); idparent = parentGroup->getId();
} }
CInterfaceManager::getInstance()->addParentSizeMaxAssociation (this, idparent); CWidgetManager::parser->addParentSizeMaxAssociation (this, idparent);
} }
// left & right clicks // left & right clicks
@ -346,7 +345,8 @@ bool CInterfaceGroup::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup)
// LuaClass script // LuaClass script
ptr = xmlGetProp (cur, (xmlChar*)"lua_class"); 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; return true;
} }
@ -693,8 +693,6 @@ bool CInterfaceGroup::handleEvent (const NLGUI::CEventDescriptor &event)
if (!_Active) if (!_Active)
return false; return false;
CInterfaceManager *im = CInterfaceManager::getInstance();
if (event.getType() == NLGUI::CEventDescriptor::system) if (event.getType() == NLGUI::CEventDescriptor::system)
{ {
NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event; NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event;
@ -866,10 +864,8 @@ void CInterfaceGroup::executeLuaScriptOnDraw()
{ {
// If some LUA script attached to me, execute it // If some LUA script attached to me, execute it
if(!_LUAOnDraw.empty()) if(!_LUAOnDraw.empty())
{
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CAHManager::getInstance()->runActionHandler("lua", this, _LUAOnDraw); CAHManager::getInstance()->runActionHandler("lua", this, _LUAOnDraw);
}
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -1748,7 +1744,6 @@ void CInterfaceGroup::onFrameUpdateWindowPos(sint dx, sint dy)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CInterfaceGroup::pushLUAEnvTable() void CInterfaceGroup::pushLUAEnvTable()
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CLuaState *lua= CLuaManager::getInstance().getLuaState(); CLuaState *lua= CLuaManager::getInstance().getLuaState();
nlassert(lua); nlassert(lua);
@ -1783,7 +1778,6 @@ void CInterfaceGroup::deleteLUAEnvTable(bool recurse)
{ {
if(_LUAEnvTableCreated) if(_LUAEnvTableCreated)
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CLuaState *lua= CLuaManager::getInstance().getLuaState(); CLuaState *lua= CLuaManager::getInstance().getLuaState();
nlassert(lua); nlassert(lua);

View file

@ -14,13 +14,11 @@
// 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 "action_handler.h"
#include "stdpch.h"
#include "interface_link.h" #include "interface_link.h"
#include "interface_group.h"
#include "interface_element.h" #include "interface_element.h"
#include "interface_manager.h" #include "widget_manager.h"
#include "nel/gui/interface_expr.h" #include "nel/gui/interface_expr.h"
#include "nel/gui/interface_expr_node.h" #include "nel/gui/interface_expr_node.h"
#include "nel/gui/reflect.h" #include "nel/gui/reflect.h"
@ -364,7 +362,6 @@ void CInterfaceLink::update()
} }
if(launch) if(launch)
{ {
CInterfaceManager *im = CInterfaceManager::getInstance();
CAHManager::getInstance()->runActionHandler(_ActionHandler, _AHParent, _AHParams); CAHManager::getInstance()->runActionHandler(_ActionHandler, _AHParent, _AHParams);
// do not add any code after this line because this can be deleted !!!! // 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 ! // Eval target !
string elt = Target.substr(0,Target.rfind(':')); string elt = Target.substr(0,Target.rfind(':'));
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt); CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt);
CInterfaceGroup *pIG = dynamic_cast<CInterfaceGroup*>(pIE); CInterfaceGroup *pIG = dynamic_cast<CInterfaceGroup*>(pIE);
if (pIG == NULL) if (pIG == NULL)

View file

@ -256,6 +256,7 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG )
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext )
{ {
CWidgetManager::parser = this;
this->driver = driver; this->driver = driver;
this->textcontext = textcontext; this->textcontext = textcontext;
CViewRenderer::setDriver( driver ); CViewRenderer::setDriver( driver );

View file

@ -50,7 +50,7 @@ class CCtrlBase;
*/ */
// this is the base class for CInterfaceManager // this is the base class for CInterfaceManager
class CInterfaceParser class CInterfaceParser : public IParser
{ {
public: public:

View file

@ -22,6 +22,7 @@
CWidgetManager* CWidgetManager::instance = NULL; CWidgetManager* CWidgetManager::instance = NULL;
std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal";
IParser* CWidgetManager::parser = NULL;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// SMasterGroup // SMasterGroup

View file

@ -28,6 +28,15 @@ class CCtrlBase;
class CInterfaceGroup; class CInterfaceGroup;
class CViewPointer; 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 /// Manages the GUI widgets
class CWidgetManager{ class CWidgetManager{
public: public:
@ -177,6 +186,8 @@ public:
CViewPointer* getPointer(){ return _Pointer; } CViewPointer* getPointer(){ return _Pointer; }
void setPointer( CViewPointer *pointer ){ _Pointer = pointer; } void setPointer( CViewPointer *pointer ){ _Pointer = pointer; }
static IParser *parser;
private: private:
CWidgetManager(); CWidgetManager();
~CWidgetManager(); ~CWidgetManager();