CHANGED: #1471 Controls are now serialized into the XML output file when saving.

This commit is contained in:
dfighter1985 2012-08-10 20:08:36 +02:00
parent 8e7c4f262f
commit 652683dd18
5 changed files with 30 additions and 4 deletions

View file

@ -46,6 +46,8 @@ namespace NLGUI
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
xmlNodePtr serializeGroup( xmlNodePtr parentNode, const char *type ) const; xmlNodePtr serializeGroup( xmlNodePtr parentNode, const char *type ) const;
xmlNodePtr serializeSubGroups( xmlNodePtr parentNode ) const; xmlNodePtr serializeSubGroups( xmlNodePtr parentNode ) const;
xmlNodePtr serializeControls( xmlNodePtr parentNode ) const;
xmlNodePtr serializeViews( xmlNodePtr parentNode ) const;
virtual uint32 getMemory (); virtual uint32 getMemory ();

View file

@ -396,6 +396,9 @@ namespace NLGUI
if( node == NULL ) if( node == NULL )
return NULL; return NULL;
if( xmlGetProp( node, BAD_CAST "type" ) == NULL )
xmlSetProp( node, BAD_CAST "type", BAD_CAST "button" );
xmlNewProp( node, BAD_CAST "button_type", BAD_CAST getTypeString().c_str() ); xmlNewProp( node, BAD_CAST "button_type", BAD_CAST getTypeString().c_str() );
xmlNewProp( node, BAD_CAST "pushed", BAD_CAST toString( _Pushed ).c_str() ); xmlNewProp( node, BAD_CAST "pushed", BAD_CAST toString( _Pushed ).c_str() );
xmlNewProp( node, BAD_CAST "over_when_pushed", BAD_CAST toString( _OverWhenPushed ).c_str() ); xmlNewProp( node, BAD_CAST "over_when_pushed", BAD_CAST toString( _OverWhenPushed ).c_str() );

View file

@ -385,6 +385,9 @@ namespace NLGUI
xmlNodePtr node = CCtrlBaseButton::serialize( parentNode, type ); xmlNodePtr node = CCtrlBaseButton::serialize( parentNode, type );
if( node == NULL ) if( node == NULL )
return NULL; return NULL;
if( xmlGetProp( node, BAD_CAST "type" ) == NULL )
xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_button" );
std::string tex; std::string tex;
tex = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal[ 0 ] ); tex = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal[ 0 ] );

View file

@ -798,6 +798,9 @@ namespace NLGUI
if( node == NULL ) if( node == NULL )
return NULL; return NULL;
if( xmlGetProp( node, BAD_CAST "type" ) == NULL )
xmlSetProp( node, BAD_CAST "type", BAD_CAST "tab_button" );
xmlNewProp( node, BAD_CAST "group", BAD_CAST _AssociatedGroup.c_str() ); xmlNewProp( node, BAD_CAST "group", BAD_CAST _AssociatedGroup.c_str() );
return node; return node;

View file

@ -672,6 +672,7 @@ namespace NLGUI
return NULL; return NULL;
serializeSubGroups( node ); serializeSubGroups( node );
serializeControls( node );
return node; return node;
} }
@ -716,15 +717,29 @@ namespace NLGUI
xmlNodePtr CInterfaceGroup::serializeSubGroups( xmlNodePtr parentNode ) const xmlNodePtr CInterfaceGroup::serializeSubGroups( xmlNodePtr parentNode ) const
{ {
xmlNodePtr node = parentNode;
std::vector< CInterfaceGroup* >::const_iterator itr; std::vector< CInterfaceGroup* >::const_iterator itr;
for( itr = _ChildrenGroups.begin(); itr != _ChildrenGroups.end(); ++itr ) for( itr = _ChildrenGroups.begin(); itr != _ChildrenGroups.end(); ++itr )
{ {
(*itr)->serialize( node, "group" ); (*itr)->serialize( parentNode, "group" );
} }
return node; return parentNode;
}
xmlNodePtr CInterfaceGroup::serializeControls( xmlNodePtr parentNode ) const
{
std::vector< CCtrlBase* >::const_iterator itr;
for( itr = _Controls.begin(); itr != _Controls.end(); ++itr )
{
(*itr)->serialize( parentNode, "ctrl" );
}
return parentNode;
}
xmlNodePtr CInterfaceGroup::serializeViews( xmlNodePtr parentNode ) const
{
return parentNode;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------