CHANGED: #1471 interface options are now serialized.
This commit is contained in:
parent
66f6979be7
commit
b8cb3c43cd
5 changed files with 128 additions and 0 deletions
|
@ -81,6 +81,7 @@ namespace NLGUI
|
||||||
virtual ~CInterfaceOptions();
|
virtual ~CInterfaceOptions();
|
||||||
|
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
|
virtual xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||||
|
|
||||||
// return NullValue if param not found
|
// return NullValue if param not found
|
||||||
const CInterfaceOptionValue &getValue(const std::string &sParamName) const;
|
const CInterfaceOptionValue &getValue(const std::string &sParamName) const;
|
||||||
|
@ -110,6 +111,7 @@ namespace NLGUI
|
||||||
public:
|
public:
|
||||||
COptionsLayer( const TCtorParam &/* param */ );
|
COptionsLayer( const TCtorParam &/* param */ );
|
||||||
~COptionsLayer();
|
~COptionsLayer();
|
||||||
|
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
|
|
||||||
// Container optimizer
|
// Container optimizer
|
||||||
|
@ -165,6 +167,7 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
COptionsContainerInsertion( const TCtorParam &/* param */ );
|
COptionsContainerInsertion( const TCtorParam &/* param */ );
|
||||||
|
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
|
|
||||||
sint32 TxId_R_Arrow;
|
sint32 TxId_R_Arrow;
|
||||||
|
@ -179,6 +182,7 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
COptionsContainerMove( const TCtorParam &/* param */ );
|
COptionsContainerMove( const TCtorParam &/* param */ );
|
||||||
|
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
|
|
||||||
sint32 TrackW;
|
sint32 TrackW;
|
||||||
|
@ -199,6 +203,7 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
COptionsList( const TCtorParam &/* param */ );
|
COptionsList( const TCtorParam &/* param */ );
|
||||||
|
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||||
virtual bool parse (xmlNodePtr cur);
|
virtual bool parse (xmlNodePtr cur);
|
||||||
|
|
||||||
uint getNumParams() const {return _NumParams;}
|
uint getNumParams() const {return _NumParams;}
|
||||||
|
|
|
@ -392,6 +392,7 @@ namespace NLGUI
|
||||||
void addOptions( std::string name, CInterfaceOptions *options );
|
void addOptions( std::string name, CInterfaceOptions *options );
|
||||||
void removeOptions( std::string name );
|
void removeOptions( std::string name );
|
||||||
void removeAllOptions();
|
void removeAllOptions();
|
||||||
|
bool serializeOptions( xmlNodePtr parentNode ) const;
|
||||||
|
|
||||||
// Enable mouse Events to interface. if false, release Captures.
|
// Enable mouse Events to interface. if false, release Captures.
|
||||||
void enableMouseHandling( bool handle );
|
void enableMouseHandling( bool handle );
|
||||||
|
|
|
@ -84,6 +84,39 @@ namespace NLGUI
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xmlNodePtr CInterfaceOptions::serialize( xmlNodePtr parentNode, const std::string &name ) const
|
||||||
|
{
|
||||||
|
if( parentNode == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if( name.empty() )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
xmlNodePtr node = xmlNewNode( NULL, BAD_CAST "options" );
|
||||||
|
if( node == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
xmlSetProp( node, BAD_CAST "name", BAD_CAST name.c_str() );
|
||||||
|
xmlAddChild( parentNode, node );
|
||||||
|
|
||||||
|
std::map< std::string, CInterfaceOptionValue >::const_iterator itr;
|
||||||
|
for( itr = _ParamValue.begin(); itr != _ParamValue.end(); ++itr )
|
||||||
|
{
|
||||||
|
xmlNodePtr n = xmlNewNode( NULL, BAD_CAST "param" );
|
||||||
|
if( n == NULL )
|
||||||
|
{
|
||||||
|
xmlFreeNode( node );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlSetProp( n, BAD_CAST "name", BAD_CAST itr->first.c_str() );
|
||||||
|
xmlSetProp( n, BAD_CAST "value", BAD_CAST itr->second.getValStr().c_str() );
|
||||||
|
xmlAddChild( node, n );
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CInterfaceOptions::copyBasicMap(const CInterfaceOptions &other)
|
void CInterfaceOptions::copyBasicMap(const CInterfaceOptions &other)
|
||||||
{
|
{
|
||||||
|
@ -153,6 +186,17 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xmlNodePtr COptionsLayer::serialize( xmlNodePtr parentNode, const std::string &name ) const
|
||||||
|
{
|
||||||
|
xmlNodePtr node = CInterfaceOptions::serialize( parentNode, name );
|
||||||
|
if( node == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
xmlSetProp( node, BAD_CAST "type", BAD_CAST "layer" );
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
bool COptionsLayer::parse (xmlNodePtr cur)
|
bool COptionsLayer::parse (xmlNodePtr cur)
|
||||||
{
|
{
|
||||||
|
@ -252,6 +296,17 @@ namespace NLGUI
|
||||||
TxId_InsertionBar = -2;
|
TxId_InsertionBar = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xmlNodePtr COptionsContainerInsertion::serialize( xmlNodePtr parentNode, const std::string &name ) const
|
||||||
|
{
|
||||||
|
xmlNodePtr node = CInterfaceOptions::serialize( parentNode, name );
|
||||||
|
if( node == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
xmlSetProp( node, BAD_CAST "type", BAD_CAST "container_insertion_opt" );
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
bool COptionsContainerInsertion::parse(xmlNodePtr cur)
|
bool COptionsContainerInsertion::parse(xmlNodePtr cur)
|
||||||
{
|
{
|
||||||
|
@ -282,6 +337,17 @@ namespace NLGUI
|
||||||
ResizerSize = 8;
|
ResizerSize = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xmlNodePtr COptionsContainerMove::serialize( xmlNodePtr parentNode, const std::string &name ) const
|
||||||
|
{
|
||||||
|
xmlNodePtr node = CInterfaceOptions::serialize( parentNode, name );
|
||||||
|
if( node == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
xmlSetProp( node, BAD_CAST "type", BAD_CAST "container_move_opt" );
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
bool COptionsContainerMove::parse(xmlNodePtr cur)
|
bool COptionsContainerMove::parse(xmlNodePtr cur)
|
||||||
{
|
{
|
||||||
|
@ -304,6 +370,39 @@ namespace NLGUI
|
||||||
_NumParams= 0;
|
_NumParams= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmlNodePtr COptionsList::serialize( xmlNodePtr parentNode, const std::string &name ) const
|
||||||
|
{
|
||||||
|
if( parentNode == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if( name.empty() )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
xmlNodePtr node = xmlNewNode( NULL, BAD_CAST "options" );
|
||||||
|
if( node == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
xmlSetProp( node, BAD_CAST "name", BAD_CAST name.c_str() );
|
||||||
|
xmlSetProp( node, BAD_CAST "type", BAD_CAST "list" );
|
||||||
|
xmlAddChild( parentNode, node );
|
||||||
|
|
||||||
|
std::map< std::string, CInterfaceOptionValue >::const_iterator itr;
|
||||||
|
for( itr = _ParamValue.begin(); itr != _ParamValue.end(); ++itr )
|
||||||
|
{
|
||||||
|
xmlNodePtr n = xmlNewNode( NULL, BAD_CAST "param" );
|
||||||
|
if( n == NULL )
|
||||||
|
{
|
||||||
|
xmlFreeNode( node );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
xmlSetProp( n, BAD_CAST "value", BAD_CAST itr->second.getValStr().c_str() );
|
||||||
|
xmlAddChild( node, n );
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
bool COptionsList::parse (xmlNodePtr cur)
|
bool COptionsList::parse (xmlNodePtr cur)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2851,6 +2851,22 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CWidgetManager::serializeOptions( xmlNodePtr parentNode ) const
|
||||||
|
{
|
||||||
|
if( parentNode == NULL )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::map< std::string, NLMISC::CSmartPtr< CInterfaceOptions > >::const_iterator itr;
|
||||||
|
for( itr = _OptionsMap.begin(); itr != _OptionsMap.end(); ++itr )
|
||||||
|
{
|
||||||
|
if( itr->second->serialize( parentNode, itr->first ) == NULL )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CWidgetManager::enableMouseHandling( bool handle )
|
void CWidgetManager::enableMouseHandling( bool handle )
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,13 @@ namespace GUIEditor
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !CWidgetManager::getInstance()->serializeOptions( root ) )
|
||||||
|
{
|
||||||
|
xmlFreeNode( root );
|
||||||
|
out.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( mg->serializeGroup( root, "root" ) == NULL )
|
if( mg->serializeGroup( root, "root" ) == NULL )
|
||||||
{
|
{
|
||||||
xmlFreeNode( root );
|
xmlFreeNode( root );
|
||||||
|
|
Loading…
Reference in a new issue