CHANGED: #1471 Tree/node data is now serialized.

This commit is contained in:
dfighter1985 2012-08-17 04:37:07 +02:00
parent c6b86393e1
commit 24cd25d29e
7 changed files with 92 additions and 8 deletions

View file

@ -169,6 +169,7 @@ namespace NLGUI
std::string getProperty( const std::string &name ) const; std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value ); void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
xmlNodePtr serializeTreeData( xmlNodePtr parentNode ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);

View file

@ -48,6 +48,7 @@ namespace NLGUI
xmlNodePtr serializeSubGroups( xmlNodePtr parentNode ) const; xmlNodePtr serializeSubGroups( xmlNodePtr parentNode ) const;
xmlNodePtr serializeControls( xmlNodePtr parentNode ) const; xmlNodePtr serializeControls( xmlNodePtr parentNode ) const;
xmlNodePtr serializeViews( xmlNodePtr parentNode ) const; xmlNodePtr serializeViews( xmlNodePtr parentNode ) const;
virtual xmlNodePtr serializeTreeData( xmlNodePtr parentNode ) const;
virtual uint32 getMemory (); virtual uint32 getMemory ();

View file

@ -393,6 +393,7 @@ namespace NLGUI
void removeOptions( std::string name ); void removeOptions( std::string name );
void removeAllOptions(); void removeAllOptions();
bool serializeOptions( xmlNodePtr parentNode ) const; bool serializeOptions( xmlNodePtr parentNode ) const;
bool serializeTreeData( 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 );

View file

@ -2061,6 +2061,30 @@ namespace NLGUI
return node; return node;
} }
xmlNodePtr CGroupContainer::serializeTreeData( xmlNodePtr parentNode ) const
{
xmlNodePtr node = CInterfaceGroup::serializeTreeData( parentNode );
if( node == NULL )
return NULL;
if( _List == NULL )
return NULL;
CInterfaceGroup *g = NULL;
for( sint32 i = 0; i < _List->getChildrenNb(); i++ )
{
g = dynamic_cast< CInterfaceGroup* >( _List->getChild( i ) );
if( g == NULL )
continue;
if( g->serializeTreeData( node ) == NULL )
return NULL;
}
return node;
}
// *************************************************************************** // ***************************************************************************
bool CGroupContainer::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) bool CGroupContainer::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
{ {

View file

@ -758,6 +758,22 @@ namespace NLGUI
return parentNode; return parentNode;
} }
xmlNodePtr CInterfaceGroup::serializeTreeData( xmlNodePtr parentNode ) const
{
if( parentNode == NULL )
return NULL;
xmlNodePtr node = xmlNewNode( NULL, BAD_CAST "tree" );
if( node == NULL )
return NULL;
xmlAddChild( parentNode, node );
xmlSetProp( node, BAD_CAST "node", BAD_CAST CInterfaceElement::stripId( getId() ).c_str() );
return node;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CInterfaceGroup::parseMaxSizeRef(const char *ptr) void CInterfaceGroup::parseMaxSizeRef(const char *ptr)
{ {

View file

@ -2867,6 +2867,33 @@ namespace NLGUI
} }
bool CWidgetManager::serializeTreeData( xmlNodePtr parentNode ) const
{
if( parentNode == NULL )
return NULL;
std::vector< SMasterGroup >::size_type i;
for( i = 0; i < _MasterGroups.size(); i++ )
{
const SMasterGroup &mg = _MasterGroups[ i ];
std::vector< CInterfaceGroup* >::size_type j;
for( j = 0; j < mg.Group->getNumGroup(); j++ )
{
CInterfaceGroup *g = mg.Group->getGroup( j );
if( dynamic_cast< CGroupModal* >( g ) != NULL )
continue;
if( g->serializeTreeData( parentNode ) == NULL )
return false;
}
}
return true;
}
// *************************************************************************** // ***************************************************************************
void CWidgetManager::enableMouseHandling( bool handle ) void CWidgetManager::enableMouseHandling( bool handle )
{ {

View file

@ -64,6 +64,13 @@ namespace GUIEditor
return false; return false;
} }
if( !CWidgetManager::getInstance()->serializeTreeData( root ) )
{
xmlFreeNode( root );
out.close();
return false;
}
level = -1; level = -1;
serializeTree( root ); serializeTree( root );
@ -98,6 +105,8 @@ namespace GUIEditor
prop = prop->next; prop = prop->next;
} }
if( node->children != NULL )
{
out << tabs << ">" << std::endl << std::endl; out << tabs << ">" << std::endl << std::endl;
xmlNodePtr child = node->children; xmlNodePtr child = node->children;
@ -108,6 +117,11 @@ namespace GUIEditor
} }
out << tabs << "</" << node->name << ">" << std::endl << std::endl; out << tabs << "</" << node->name << ">" << std::endl << std::endl;
}
else
{
out << tabs << "/>" << std::endl << std::endl;
}
level--; level--;