From 5a74dc3f3a1a1e1cb2e6d76b7c9074f7cfbb92b4 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 10 Aug 2012 19:23:39 +0200 Subject: [PATCH] CHANGED: #1471 CCtrlButton fields can now be serialized. --HG-- branch : gsoc2012-gui-editor --- code/nel/include/nel/gui/ctrl_button.h | 1 + code/nel/src/gui/ctrl_button.cpp | 33 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/code/nel/include/nel/gui/ctrl_button.h b/code/nel/include/nel/gui/ctrl_button.h index ac832421f..8ec5c23e9 100644 --- a/code/nel/include/nel/gui/ctrl_button.h +++ b/code/nel/include/nel/gui/ctrl_button.h @@ -47,6 +47,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; // Init part virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); diff --git a/code/nel/src/gui/ctrl_button.cpp b/code/nel/src/gui/ctrl_button.cpp index 108e99e16..57c505d87 100644 --- a/code/nel/src/gui/ctrl_button.cpp +++ b/code/nel/src/gui/ctrl_button.cpp @@ -146,6 +146,39 @@ namespace NLGUI CCtrlBaseButton::setProperty( name, value ); } + + xmlNodePtr CCtrlButton::serialize( xmlNodePtr parentNode, const char *type ) const + { + xmlNodePtr node = CCtrlBaseButton::serialize( parentNode, type ); + if( node == NULL ) + return NULL; + + xmlNewProp( node, BAD_CAST "tx_normal", + BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal ).c_str() ); + + xmlNewProp( node, BAD_CAST "tx_pushed", + BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdPushed ).c_str() ); + + xmlNewProp( node, BAD_CAST "tx_over", + BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdOver ).c_str() ); + + xmlNewProp( node, BAD_CAST "scale", BAD_CAST toString( _Scale ).c_str() ); + + std::string align; + if( ( _Align & 1 ) != 0 ) + align = "r"; + else + align = "l"; + if( ( _Align & 2 ) != 0 ) + align += "t"; + else + align += "b"; + + xmlNewProp( node, BAD_CAST "align", BAD_CAST align.c_str() ); + + return node; + } + // ---------------------------------------------------------------------------- bool CCtrlButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) {