From 1931ad0eabcfc8ce8db2225b35b1a7a24d8a413b Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 17 Aug 2012 20:36:35 +0200 Subject: [PATCH] CHANGED: #1471 Links are now serialized. --- code/nel/include/nel/gui/interface_group.h | 1 + code/nel/src/gui/interface_group.cpp | 48 ++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/code/nel/include/nel/gui/interface_group.h b/code/nel/include/nel/gui/interface_group.h index 3f21886c3..ceb686183 100644 --- a/code/nel/include/nel/gui/interface_group.h +++ b/code/nel/include/nel/gui/interface_group.h @@ -49,6 +49,7 @@ namespace NLGUI xmlNodePtr serializeControls( xmlNodePtr parentNode ) const; xmlNodePtr serializeViews( xmlNodePtr parentNode ) const; virtual xmlNodePtr serializeTreeData( xmlNodePtr parentNode ) const; + bool serializeLinks( xmlNodePtr parentNode ) const; virtual uint32 getMemory (); diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index 42dac362d..dd7c89e3c 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -674,6 +674,7 @@ namespace NLGUI serializeSubGroups( node ); serializeControls( node ); serializeViews( node ); + serializeLinks( node ); return node; } @@ -774,6 +775,53 @@ namespace NLGUI return node; } + + bool CInterfaceGroup::serializeLinks( xmlNodePtr parentNode ) const + { + if( parentNode == NULL ) + return false; + + const std::map< uint32, SLinkData > &linkMap = + CWidgetManager::getInstance()->getParser()->getLinkMap(); + + xmlNodePtr node = NULL; + + std::map< uint32, SLinkData >::const_iterator itr; + for( itr = linkMap.begin(); itr != linkMap.end(); ++itr ) + { + if( itr->second.parent != getId() ) + continue; + + const SLinkData &data = itr->second; + + node = xmlNewNode( NULL, BAD_CAST "link" ); + if( node == NULL ) + return false; + + xmlAddChild( parentNode, node ); + + xmlSetProp( node, BAD_CAST "expr", BAD_CAST data.expr.c_str() ); + + if( !data.target.empty() ) + xmlSetProp( node, BAD_CAST "target", BAD_CAST data.target.c_str() ); + + if( !data.action.empty() ) + { + xmlSetProp( node, BAD_CAST "action", BAD_CAST data.action.c_str() ); + + if( !data.params.empty() ) + xmlSetProp( node, BAD_CAST "params", BAD_CAST data.params.c_str() ); + + if( !data.cond.empty() ) + xmlSetProp( node, BAD_CAST "cond", BAD_CAST data.cond.c_str() ); + } + + } + + + return true; + } + // ------------------------------------------------------------------------------------------------ void CInterfaceGroup::parseMaxSizeRef(const char *ptr) {