CHANGED: #1471 GUI Procedures are now serialized.

This commit is contained in:
dfighter1985 2012-08-17 21:49:54 +02:00
parent 8402f2657f
commit 094bbd6e9a
4 changed files with 59 additions and 1 deletions

View file

@ -375,6 +375,7 @@ namespace NLGUI
void setEditorMode( bool b ){ editorMode = b; } void setEditorMode( bool b ){ editorMode = b; }
bool serializeVariables( xmlNodePtr parentNode ) const; bool serializeVariables( xmlNodePtr parentNode ) const;
bool serializeProcs( xmlNodePtr parentNode ) const;
}; };
} }

View file

@ -83,6 +83,7 @@ namespace NLGUI
virtual bool getLinkData( uint32 id, SLinkData &linkData ) = 0; virtual bool getLinkData( uint32 id, SLinkData &linkData ) = 0;
virtual void updateLinkData( uint32 id, const SLinkData &linkData ) = 0; virtual void updateLinkData( uint32 id, const SLinkData &linkData ) = 0;
virtual bool serializeVariables( xmlNodePtr parentNode ) const = 0; virtual bool serializeVariables( xmlNodePtr parentNode ) const = 0;
virtual bool serializeProcs( xmlNodePtr parentNode ) const = 0;
}; };
} }

View file

@ -2972,5 +2972,52 @@ namespace NLGUI
return true; return true;
} }
bool CInterfaceParser::serializeProcs( xmlNodePtr parentNode) const
{
if( parentNode == NULL )
return false;
xmlNodePtr procNode = NULL;
xmlNodePtr actionNode = NULL;
TProcedureMap::const_iterator itr;
for( itr = _ProcedureMap.begin(); itr != _ProcedureMap.end(); ++itr )
{
procNode = xmlNewNode( NULL, BAD_CAST "proc" );
if( procNode == NULL )
return false;
xmlAddChild( parentNode, procNode );
const CProcedure &proc = itr->second;
xmlSetProp( procNode, BAD_CAST "id", BAD_CAST itr->first.c_str() );
std::vector< CProcAction >::const_iterator itr2;
for( itr2 = proc.Actions.begin(); itr2 != proc.Actions.end(); ++itr2 )
{
actionNode = xmlNewNode( NULL, BAD_CAST "action" );
if( actionNode == NULL )
return false;
xmlAddChild( procNode, actionNode );
const CProcAction &action = *itr2;
xmlSetProp( actionNode, BAD_CAST "handler", BAD_CAST action.Action.c_str() );
if( !action.Parameters.empty() )
xmlSetProp( actionNode, BAD_CAST "params", BAD_CAST action.Parameters.c_str() );
if( !action.Conditions.empty() )
xmlSetProp( actionNode, BAD_CAST "cond", BAD_CAST action.Conditions.c_str() );
}
}
return true;
}
} }

View file

@ -43,6 +43,14 @@ namespace GUIEditor
return false; return false;
} }
if( !CWidgetManager::getInstance()->serializeOptions( root ) )
{
xmlFreeNode( root );
out.close();
return false;
}
if( !CWidgetManager::getInstance()->getParser()->serializeVariables( root ) ) if( !CWidgetManager::getInstance()->getParser()->serializeVariables( root ) )
{ {
xmlFreeNode( root ); xmlFreeNode( root );
@ -50,7 +58,8 @@ namespace GUIEditor
return false; return false;
} }
if( !CWidgetManager::getInstance()->serializeOptions( root ) )
if( !CWidgetManager::getInstance()->getParser()->serializeProcs( root ) )
{ {
xmlFreeNode( root ); xmlFreeNode( root );
out.close(); out.close();