mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-30 04:40:53 +00:00
CHANGED: #1471 Apparently the *root* group needed to be serializes separately, otherwise the parser cannot read it back.
This commit is contained in:
parent
c3d958a17d
commit
198a8b39db
5 changed files with 52 additions and 6 deletions
|
@ -44,6 +44,8 @@ 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 serializeGroup( xmlNodePtr parentNode, const char *type ) const;
|
||||
xmlNodePtr serializeSubGroups( xmlNodePtr parentNode ) const;
|
||||
|
||||
virtual uint32 getMemory ();
|
||||
|
||||
|
|
|
@ -666,6 +666,17 @@ namespace NLGUI
|
|||
}
|
||||
|
||||
xmlNodePtr CInterfaceGroup::serialize( xmlNodePtr parentNode, const char *type ) const
|
||||
{
|
||||
xmlNodePtr node = serializeGroup( parentNode, type );
|
||||
if( node == NULL )
|
||||
return NULL;
|
||||
|
||||
serializeSubGroups( node );
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
xmlNodePtr CInterfaceGroup::serializeGroup( xmlNodePtr parentNode, const char *type ) const
|
||||
{
|
||||
xmlNodePtr node = CCtrlBase::serialize( parentNode, type );
|
||||
if( node == NULL )
|
||||
|
@ -700,6 +711,13 @@ namespace NLGUI
|
|||
xmlNewProp( node, BAD_CAST "lua_class",
|
||||
BAD_CAST CWidgetManager::getInstance()->getParser()->getLuaClassAssociation( (CInterfaceGroup*)this ).c_str() );
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
xmlNodePtr CInterfaceGroup::serializeSubGroups( xmlNodePtr parentNode ) const
|
||||
{
|
||||
xmlNodePtr node = parentNode;
|
||||
|
||||
std::vector< CInterfaceGroup* >::const_iterator itr;
|
||||
for( itr = _ChildrenGroups.begin(); itr != _ChildrenGroups.end(); ++itr )
|
||||
{
|
||||
|
|
|
@ -240,6 +240,11 @@ namespace GUIEditor
|
|||
tr( "There was an error while trying to save the project." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
QMessageBox::information( this,
|
||||
tr( "Save successful" ),
|
||||
tr( "Project saved successfully!" ) );
|
||||
|
||||
}
|
||||
|
||||
void GUIEditorWindow::close()
|
||||
|
|
|
@ -43,13 +43,21 @@ namespace GUIEditor
|
|||
return false;
|
||||
}
|
||||
|
||||
if( mg->serialize( root, "root" ) == NULL )
|
||||
if( mg->serializeGroup( root, "root" ) == NULL )
|
||||
{
|
||||
xmlFreeNode( root );
|
||||
out.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if( mg->serializeSubGroups( root ) == NULL )
|
||||
{
|
||||
xmlFreeNode( root );
|
||||
out.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
level = -1;
|
||||
serializeTree( root );
|
||||
|
||||
|
||||
|
@ -61,7 +69,13 @@ namespace GUIEditor
|
|||
|
||||
bool WidgetSerializer::serializeTree( _xmlNode *node )
|
||||
{
|
||||
out << "<" << node->name;
|
||||
level++;
|
||||
|
||||
std::string tabs;
|
||||
for( int i = 0; i < level; i++ )
|
||||
tabs.push_back( '\t' );
|
||||
|
||||
out << tabs << "<" << node->name;
|
||||
|
||||
xmlAttrPtr prop = node->properties;
|
||||
while( prop != NULL )
|
||||
|
@ -72,12 +86,12 @@ namespace GUIEditor
|
|||
std::string value =
|
||||
std::string( reinterpret_cast< const char* >( xmlGetProp( node, BAD_CAST name.c_str() ) ) );
|
||||
|
||||
out << " " << name << "=\"" << value << "\"" << std::endl;
|
||||
out << " " << name << "=\"" << value << "\"" << std::endl << tabs;
|
||||
|
||||
prop = prop->next;
|
||||
}
|
||||
|
||||
out << ">" << std::endl;
|
||||
out << tabs << ">" << std::endl << std::endl;
|
||||
|
||||
xmlNodePtr child = node->children;
|
||||
while( child != NULL )
|
||||
|
@ -86,7 +100,9 @@ namespace GUIEditor
|
|||
child = child->next;
|
||||
}
|
||||
|
||||
out << "</" << node->name << ">" << std::endl;
|
||||
out << tabs << "</" << node->name << ">" << std::endl << std::endl;
|
||||
|
||||
level--;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,11 @@ namespace GUIEditor
|
|||
class WidgetSerializer
|
||||
{
|
||||
public:
|
||||
WidgetSerializer(){}
|
||||
WidgetSerializer()
|
||||
{
|
||||
level = 0;
|
||||
}
|
||||
|
||||
~WidgetSerializer(){}
|
||||
|
||||
void setFile( const std::string &name ){ fileName = name; }
|
||||
|
@ -40,6 +44,7 @@ namespace GUIEditor
|
|||
|
||||
std::string fileName;
|
||||
std::ofstream out;
|
||||
long level;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue