mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 23:56:15 +00:00
CHANGED: #1471 Classes derived from CInterfaceOptions are now instantiated using a factory.
This commit is contained in:
parent
5ffd1d3067
commit
4ed62dc1c4
5 changed files with 39 additions and 30 deletions
|
@ -72,7 +72,12 @@ namespace NLGUI
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CInterfaceOptions();
|
// for factory construction
|
||||||
|
struct TCtorParam
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
CInterfaceOptions( const TCtorParam &/* param */ );
|
||||||
virtual ~CInterfaceOptions();
|
virtual ~CInterfaceOptions();
|
||||||
|
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
|
@ -103,7 +108,7 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
COptionsLayer();
|
COptionsLayer( const TCtorParam &/* param */ );
|
||||||
~COptionsLayer();
|
~COptionsLayer();
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
|
|
||||||
|
@ -159,7 +164,7 @@ namespace NLGUI
|
||||||
class COptionsContainerInsertion : public CInterfaceOptions
|
class COptionsContainerInsertion : public CInterfaceOptions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
COptionsContainerInsertion();
|
COptionsContainerInsertion( const TCtorParam &/* param */ );
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
|
|
||||||
sint32 TxId_R_Arrow;
|
sint32 TxId_R_Arrow;
|
||||||
|
@ -173,7 +178,7 @@ namespace NLGUI
|
||||||
class COptionsContainerMove : public CInterfaceOptions
|
class COptionsContainerMove : public CInterfaceOptions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
COptionsContainerMove();
|
COptionsContainerMove( const TCtorParam &/* param */ );
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
|
|
||||||
sint32 TrackW;
|
sint32 TrackW;
|
||||||
|
@ -193,7 +198,7 @@ namespace NLGUI
|
||||||
class COptionsList : public CInterfaceOptions
|
class COptionsList : public CInterfaceOptions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
COptionsList();
|
COptionsList( const TCtorParam &/* param */ );
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
|
|
||||||
uint getNumParams() const {return _NumParams;}
|
uint getNumParams() const {return _NumParams;}
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include "nel/gui/interface_element.h"
|
#include "nel/gui/interface_element.h"
|
||||||
#include "nel/gui/interface_options.h"
|
#include "nel/gui/interface_options.h"
|
||||||
#include "nel/gui/view_renderer.h"
|
#include "nel/gui/view_renderer.h"
|
||||||
|
#include "nel/misc/factory.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace NLMISC;
|
using namespace NLMISC;
|
||||||
|
@ -44,7 +46,7 @@ namespace NLGUI
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
CInterfaceOptions::CInterfaceOptions()
|
CInterfaceOptions::CInterfaceOptions( const TCtorParam &/* param */ )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +134,9 @@ namespace NLGUI
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
COptionsLayer::COptionsLayer()
|
NLMISC_REGISTER_OBJECT(CInterfaceOptions, COptionsLayer, std::string, "layer");
|
||||||
|
COptionsLayer::COptionsLayer( const TCtorParam ¶m ) :
|
||||||
|
CInterfaceOptions( param )
|
||||||
{
|
{
|
||||||
TxId_TL = TxId_T = TxId_TR = TxId_L = TxId_R = TxId_Blank = TxId_BL = TxId_B = -2;
|
TxId_TL = TxId_T = TxId_TR = TxId_L = TxId_R = TxId_Blank = TxId_BL = TxId_B = -2;
|
||||||
TxId_BR = TxId_BL_Open = TxId_B_Open = TxId_BR_Open = TxId_EL_Open = TxId_EM_Open = TxId_ER_Open =-2;
|
TxId_BR = TxId_BL_Open = TxId_B_Open = TxId_BR_Open = TxId_EL_Open = TxId_EM_Open = TxId_ER_Open =-2;
|
||||||
|
@ -237,7 +241,9 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
COptionsContainerInsertion::COptionsContainerInsertion()
|
NLMISC_REGISTER_OBJECT(CInterfaceOptions, COptionsContainerInsertion, std::string, "container_insertion_opt");
|
||||||
|
COptionsContainerInsertion::COptionsContainerInsertion( const TCtorParam ¶m ) :
|
||||||
|
CInterfaceOptions( param )
|
||||||
{
|
{
|
||||||
TxId_R_Arrow = -2;
|
TxId_R_Arrow = -2;
|
||||||
TxId_L_Arrow = -2;
|
TxId_L_Arrow = -2;
|
||||||
|
@ -264,7 +270,9 @@ namespace NLGUI
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
COptionsContainerMove::COptionsContainerMove()
|
NLMISC_REGISTER_OBJECT(CInterfaceOptions, COptionsContainerMove, std::string, "container_move_opt");
|
||||||
|
COptionsContainerMove::COptionsContainerMove( const TCtorParam ¶m ) :
|
||||||
|
CInterfaceOptions( param )
|
||||||
{
|
{
|
||||||
TrackW = -8;
|
TrackW = -8;
|
||||||
TrackH = 22;
|
TrackH = 22;
|
||||||
|
@ -289,7 +297,9 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
COptionsList::COptionsList()
|
NLMISC_REGISTER_OBJECT(CInterfaceOptions, COptionsList, std::string, "list");
|
||||||
|
COptionsList::COptionsList( const TCtorParam ¶m ) :
|
||||||
|
CInterfaceOptions( param )
|
||||||
{
|
{
|
||||||
_NumParams= 0;
|
_NumParams= 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ using namespace NLMISC;
|
||||||
|
|
||||||
extern CEntityAnimationManager *EAM;
|
extern CEntityAnimationManager *EAM;
|
||||||
|
|
||||||
|
NLMISC_REGISTER_OBJECT(CInterfaceOptions, CMissionIconList, std::string, "mission_icons");
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
bool CMissionIconList::parse(xmlNodePtr cur)
|
bool CMissionIconList::parse(xmlNodePtr cur)
|
||||||
|
@ -90,7 +91,9 @@ bool CMissionIconList::parse(xmlNodePtr cur)
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
COptionsAnimationSet::COptionsAnimationSet()
|
NLMISC_REGISTER_OBJECT(CInterfaceOptions, COptionsAnimationSet, std::string, "animation_set");
|
||||||
|
COptionsAnimationSet::COptionsAnimationSet( const TCtorParam ¶m ) :
|
||||||
|
CInterfaceOptions( param )
|
||||||
{
|
{
|
||||||
AnimationSet= NULL;
|
AnimationSet= NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ using namespace NLGUI;
|
||||||
class CMissionIconList : public CInterfaceOptions
|
class CMissionIconList : public CInterfaceOptions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
CMissionIconList( const TCtorParam ¶m ) : CInterfaceOptions( param ){}
|
||||||
|
~CMissionIconList(){}
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
sint32 getBackTexID(uint index) const { return index >= IconBackTexID.size() ? -1 : IconBackTexID[index]; }
|
sint32 getBackTexID(uint index) const { return index >= IconBackTexID.size() ? -1 : IconBackTexID[index]; }
|
||||||
sint32 getTexID(uint index) const { return index >= IconTexID.size() ? -1 : IconTexID[index]; }
|
sint32 getTexID(uint index) const { return index >= IconTexID.size() ? -1 : IconTexID[index]; }
|
||||||
|
@ -40,7 +42,7 @@ private:
|
||||||
class COptionsAnimationSet : public CInterfaceOptions
|
class COptionsAnimationSet : public CInterfaceOptions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
COptionsAnimationSet();
|
COptionsAnimationSet( const TCtorParam &/* param */ );
|
||||||
// see code for important release note
|
// see code for important release note
|
||||||
virtual ~COptionsAnimationSet();
|
virtual ~COptionsAnimationSet();
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "nel/gui/lua_ihm.h"
|
#include "nel/gui/lua_ihm.h"
|
||||||
#include "nel/gui/lua_manager.h"
|
#include "nel/gui/lua_manager.h"
|
||||||
|
|
||||||
#include "interface_options_ryzom.h"
|
|
||||||
#include "interface_3d_scene.h"
|
#include "interface_3d_scene.h"
|
||||||
#include "lua_ihm_ryzom.h"
|
#include "lua_ihm_ryzom.h"
|
||||||
#include "interface_ddx.h"
|
#include "interface_ddx.h"
|
||||||
|
@ -1207,28 +1206,18 @@ bool CInterfaceParser::parseOptions (xmlNodePtr cur, CInterfaceGroup * /* parent
|
||||||
H_AUTO(parseOptions )
|
H_AUTO(parseOptions )
|
||||||
|
|
||||||
// build the options from type
|
// build the options from type
|
||||||
CInterfaceOptions *options;
|
CInterfaceOptions *options = NULL;
|
||||||
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"type" ));
|
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"type" ));
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
if (nlstricmp(ptr.getDatas(), "layer") == 0)
|
options = NLMISC_GET_FACTORY( CInterfaceOptions, std::string ).createObject( std::string( (const char*)ptr ), CInterfaceOptions::TCtorParam() );
|
||||||
options = new COptionsLayer;
|
|
||||||
else if (nlstricmp(ptr.getDatas(), "container_insertion_opt") == 0)
|
if( options == NULL )
|
||||||
options = new COptionsContainerInsertion;
|
options = new CInterfaceOptions( CInterfaceOptions::TCtorParam() );
|
||||||
else if (nlstricmp(ptr.getDatas(), "container_move_opt") == 0)
|
|
||||||
options = new COptionsContainerMove;
|
|
||||||
else if (nlstricmp(ptr.getDatas(), "list") == 0)
|
|
||||||
options = new COptionsList;
|
|
||||||
else if (nlstricmp(ptr.getDatas(), "mission_icons") == 0)
|
|
||||||
options = new CMissionIconList;
|
|
||||||
else if (nlstricmp(ptr.getDatas(), "animation_set") == 0)
|
|
||||||
options = new COptionsAnimationSet;
|
|
||||||
else
|
|
||||||
options = new CInterfaceOptions;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
options = new CInterfaceOptions;
|
options = new CInterfaceOptions( CInterfaceOptions::TCtorParam() );
|
||||||
}
|
}
|
||||||
|
|
||||||
CWidgetManager *wm = CWidgetManager::getInstance();
|
CWidgetManager *wm = CWidgetManager::getInstance();
|
||||||
|
@ -1277,7 +1266,7 @@ bool CInterfaceParser::parseGroup (xmlNodePtr cur, CInterfaceGroup * parentGroup
|
||||||
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"type" ));
|
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"type" ));
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
group = dynamic_cast<CInterfaceGroup*>(NLMISC_GET_FACTORY(CViewBase, std::string).createObject(string((const char*)ptr), CViewBase::TCtorParam()));
|
group = dynamic_cast<CInterfaceGroup*>( NLMISC_GET_FACTORY(CViewBase, std::string).createObject(string((const char*)ptr), CViewBase::TCtorParam()) );
|
||||||
if (group == NULL)
|
if (group == NULL)
|
||||||
{
|
{
|
||||||
group = dynamic_cast<CInterfaceGroup*>(NLMISC_GET_FACTORY(CViewBase, std::string).createObject("interface_group", CViewBase::TCtorParam()));
|
group = dynamic_cast<CInterfaceGroup*>(NLMISC_GET_FACTORY(CViewBase, std::string).createObject("interface_group", CViewBase::TCtorParam()));
|
||||||
|
|
Loading…
Reference in a new issue