From 37053325f9f4c5c5ed5ec888bf3841f1a005819a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 10 Aug 2012 20:08:36 +0200 Subject: [PATCH] CHANGED: #1471 Controls are now serialized into the XML output file when saving. --HG-- branch : gsoc2012-gui-editor --- code/nel/include/nel/gui/interface_group.h | 2 ++ code/nel/src/gui/ctrl_base_button.cpp | 3 +++ code/nel/src/gui/ctrl_text_button.cpp | 3 +++ code/nel/src/gui/group_tab.cpp | 3 +++ code/nel/src/gui/interface_group.cpp | 23 ++++++++++++++++++---- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/code/nel/include/nel/gui/interface_group.h b/code/nel/include/nel/gui/interface_group.h index 12e83dda8..3dca37610 100644 --- a/code/nel/include/nel/gui/interface_group.h +++ b/code/nel/include/nel/gui/interface_group.h @@ -46,6 +46,8 @@ namespace NLGUI xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; xmlNodePtr serializeGroup( xmlNodePtr parentNode, const char *type ) const; xmlNodePtr serializeSubGroups( xmlNodePtr parentNode ) const; + xmlNodePtr serializeControls( xmlNodePtr parentNode ) const; + xmlNodePtr serializeViews( xmlNodePtr parentNode ) const; virtual uint32 getMemory (); diff --git a/code/nel/src/gui/ctrl_base_button.cpp b/code/nel/src/gui/ctrl_base_button.cpp index 9e232c263..d9c9dfaea 100644 --- a/code/nel/src/gui/ctrl_base_button.cpp +++ b/code/nel/src/gui/ctrl_base_button.cpp @@ -396,6 +396,9 @@ namespace NLGUI if( node == 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 "pushed", BAD_CAST toString( _Pushed ).c_str() ); xmlNewProp( node, BAD_CAST "over_when_pushed", BAD_CAST toString( _OverWhenPushed ).c_str() ); diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index 4c4cd279f..37d938d16 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -385,6 +385,9 @@ namespace NLGUI xmlNodePtr node = CCtrlBaseButton::serialize( parentNode, type ); if( node == NULL ) return NULL; + + if( xmlGetProp( node, BAD_CAST "type" ) == NULL ) + xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_button" ); std::string tex; tex = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal[ 0 ] ); diff --git a/code/nel/src/gui/group_tab.cpp b/code/nel/src/gui/group_tab.cpp index 0987fa56b..f2ca41885 100644 --- a/code/nel/src/gui/group_tab.cpp +++ b/code/nel/src/gui/group_tab.cpp @@ -798,6 +798,9 @@ namespace NLGUI if( node == 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() ); return node; diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index 7f0f3c1e3..defe7125b 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -672,6 +672,7 @@ namespace NLGUI return NULL; serializeSubGroups( node ); + serializeControls( node ); return node; } @@ -716,15 +717,29 @@ namespace NLGUI xmlNodePtr CInterfaceGroup::serializeSubGroups( xmlNodePtr parentNode ) const { - xmlNodePtr node = parentNode; - std::vector< CInterfaceGroup* >::const_iterator 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; } // ------------------------------------------------------------------------------------------------