mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-05 14:59:01 +00:00
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 bool parse (xmlNodePtr cur);
|
||||
virtual xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||
|
||||
// return NullValue if param not found
|
||||
const CInterfaceOptionValue &getValue(const std::string &sParamName) const;
|
||||
|
@ -110,6 +111,7 @@ namespace NLGUI
|
|||
public:
|
||||
COptionsLayer( const TCtorParam &/* param */ );
|
||||
~COptionsLayer();
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||
virtual bool parse (xmlNodePtr cur);
|
||||
|
||||
// Container optimizer
|
||||
|
@ -165,6 +167,7 @@ namespace NLGUI
|
|||
{
|
||||
public:
|
||||
COptionsContainerInsertion( const TCtorParam &/* param */ );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||
virtual bool parse (xmlNodePtr cur);
|
||||
|
||||
sint32 TxId_R_Arrow;
|
||||
|
@ -179,6 +182,7 @@ namespace NLGUI
|
|||
{
|
||||
public:
|
||||
COptionsContainerMove( const TCtorParam &/* param */ );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||
virtual bool parse (xmlNodePtr cur);
|
||||
|
||||
sint32 TrackW;
|
||||
|
@ -199,6 +203,7 @@ namespace NLGUI
|
|||
{
|
||||
public:
|
||||
COptionsList( const TCtorParam &/* param */ );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||
virtual bool parse (xmlNodePtr cur);
|
||||
|
||||
uint getNumParams() const {return _NumParams;}
|
||||
|
|
|
@ -392,6 +392,7 @@ namespace NLGUI
|
|||
void addOptions( std::string name, CInterfaceOptions *options );
|
||||
void removeOptions( std::string name );
|
||||
void removeAllOptions();
|
||||
bool serializeOptions( xmlNodePtr parentNode ) const;
|
||||
|
||||
// Enable mouse Events to interface. if false, release Captures.
|
||||
void enableMouseHandling( bool handle );
|
||||
|
|
|
@ -84,6 +84,39 @@ namespace NLGUI
|
|||
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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -252,6 +296,17 @@ namespace NLGUI
|
|||
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)
|
||||
{
|
||||
|
@ -282,6 +337,17 @@ namespace NLGUI
|
|||
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)
|
||||
{
|
||||
|
@ -304,6 +370,39 @@ namespace NLGUI
|
|||
_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)
|
||||
{
|
||||
|
|
|
@ -2849,6 +2849,22 @@ namespace NLGUI
|
|||
{
|
||||
_OptionsMap.clear();
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
|
|
|
@ -43,6 +43,13 @@ namespace GUIEditor
|
|||
return false;
|
||||
}
|
||||
|
||||
if( !CWidgetManager::getInstance()->serializeOptions( root ) )
|
||||
{
|
||||
xmlFreeNode( root );
|
||||
out.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if( mg->serializeGroup( root, "root" ) == NULL )
|
||||
{
|
||||
xmlFreeNode( root );
|
||||
|
|
Loading…
Reference in a new issue