mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-19 21:56:13 +00:00
CHANGED: #1471 Tree/node data is now serialized.
This commit is contained in:
parent
c6b86393e1
commit
24cd25d29e
7 changed files with 92 additions and 8 deletions
|
@ -169,6 +169,7 @@ namespace NLGUI
|
|||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
xmlNodePtr serializeTreeData( xmlNodePtr parentNode ) const;
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace NLGUI
|
|||
xmlNodePtr serializeSubGroups( xmlNodePtr parentNode ) const;
|
||||
xmlNodePtr serializeControls( xmlNodePtr parentNode ) const;
|
||||
xmlNodePtr serializeViews( xmlNodePtr parentNode ) const;
|
||||
virtual xmlNodePtr serializeTreeData( xmlNodePtr parentNode ) const;
|
||||
|
||||
virtual uint32 getMemory ();
|
||||
|
||||
|
|
|
@ -393,6 +393,7 @@ namespace NLGUI
|
|||
void removeOptions( std::string name );
|
||||
void removeAllOptions();
|
||||
bool serializeOptions( xmlNodePtr parentNode ) const;
|
||||
bool serializeTreeData( xmlNodePtr parentNode ) const;
|
||||
|
||||
// Enable mouse Events to interface. if false, release Captures.
|
||||
void enableMouseHandling( bool handle );
|
||||
|
|
|
@ -2061,6 +2061,30 @@ namespace NLGUI
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -758,6 +758,22 @@ namespace NLGUI
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -2865,6 +2865,33 @@ namespace NLGUI
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
|
|
|
@ -64,6 +64,13 @@ namespace GUIEditor
|
|||
return false;
|
||||
}
|
||||
|
||||
if( !CWidgetManager::getInstance()->serializeTreeData( root ) )
|
||||
{
|
||||
xmlFreeNode( root );
|
||||
out.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
level = -1;
|
||||
serializeTree( root );
|
||||
|
||||
|
@ -98,16 +105,23 @@ namespace GUIEditor
|
|||
prop = prop->next;
|
||||
}
|
||||
|
||||
out << tabs << ">" << std::endl << std::endl;
|
||||
|
||||
xmlNodePtr child = node->children;
|
||||
while( child != NULL )
|
||||
if( node->children != NULL )
|
||||
{
|
||||
serializeTree( child );
|
||||
child = child->next;
|
||||
}
|
||||
out << tabs << ">" << std::endl << std::endl;
|
||||
|
||||
out << tabs << "</" << node->name << ">" << std::endl << std::endl;
|
||||
xmlNodePtr child = node->children;
|
||||
while( child != NULL )
|
||||
{
|
||||
serializeTree( child );
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
out << tabs << "</" << node->name << ">" << std::endl << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
out << tabs << "/>" << std::endl << std::endl;
|
||||
}
|
||||
|
||||
level--;
|
||||
|
||||
|
|
Loading…
Reference in a new issue