From 0985fd8acd69ce1b9ec9377fa723c0d4883634c0 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 12 Aug 2012 01:19:05 +0200 Subject: [PATCH] CHANGED: #1471 CViewTextFormated and CViewTextID fields can now be serialized. --- code/nel/include/nel/gui/view_text_formated.h | 1 + code/nel/include/nel/gui/view_text_id.h | 1 + code/nel/src/gui/ctrl_base_button.cpp | 4 +--- code/nel/src/gui/ctrl_button.cpp | 3 +-- code/nel/src/gui/ctrl_col_pick.cpp | 3 +-- code/nel/src/gui/ctrl_scroll.cpp | 4 +--- code/nel/src/gui/ctrl_text_button.cpp | 3 +-- code/nel/src/gui/ctrl_tooltip.cpp | 3 +-- code/nel/src/gui/dbview_digit.cpp | 3 +-- code/nel/src/gui/group_tab.cpp | 4 +--- code/nel/src/gui/view_text.cpp | 4 +--- code/nel/src/gui/view_text_formated.cpp | 12 ++++++++++ code/nel/src/gui/view_text_id.cpp | 23 +++++++++++++++++++ 13 files changed, 46 insertions(+), 22 deletions(-) diff --git a/code/nel/include/nel/gui/view_text_formated.h b/code/nel/include/nel/gui/view_text_formated.h index dc30682ef..abc33eab9 100644 --- a/code/nel/include/nel/gui/view_text_formated.h +++ b/code/nel/include/nel/gui/view_text_formated.h @@ -48,6 +48,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; virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual void checkCoords(); const ucstring &getFormatString() const { return _FormatString; } diff --git a/code/nel/include/nel/gui/view_text_id.h b/code/nel/include/nel/gui/view_text_id.h index e12ba4351..d26b1a701 100644 --- a/code/nel/include/nel/gui/view_text_id.h +++ b/code/nel/include/nel/gui/view_text_id.h @@ -93,6 +93,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; virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual void checkCoords(); diff --git a/code/nel/src/gui/ctrl_base_button.cpp b/code/nel/src/gui/ctrl_base_button.cpp index d9c9dfaea..105e67420 100644 --- a/code/nel/src/gui/ctrl_base_button.cpp +++ b/code/nel/src/gui/ctrl_base_button.cpp @@ -396,9 +396,7 @@ namespace NLGUI if( node == NULL ) return NULL; - if( xmlGetProp( node, BAD_CAST "type" ) == NULL ) - xmlSetProp( node, BAD_CAST "type", BAD_CAST "button" ); - + 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_button.cpp b/code/nel/src/gui/ctrl_button.cpp index 50cbd1519..a3d1f85aa 100644 --- a/code/nel/src/gui/ctrl_button.cpp +++ b/code/nel/src/gui/ctrl_button.cpp @@ -153,8 +153,7 @@ namespace NLGUI if( node == NULL ) return NULL; - if( xmlGetProp( node, BAD_CAST "type" ) == NULL ) - xmlSetProp( node, BAD_CAST "type", BAD_CAST "button" ); + xmlSetProp( node, BAD_CAST "type", BAD_CAST "button" ); xmlNewProp( node, BAD_CAST "tx_normal", BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal ).c_str() ); diff --git a/code/nel/src/gui/ctrl_col_pick.cpp b/code/nel/src/gui/ctrl_col_pick.cpp index 66b0f0a73..4810e0f04 100644 --- a/code/nel/src/gui/ctrl_col_pick.cpp +++ b/code/nel/src/gui/ctrl_col_pick.cpp @@ -156,8 +156,7 @@ namespace NLGUI if( node == NULL ) return NULL; - if( xmlGetProp( node, BAD_CAST "type" ) == NULL ) - xmlSetProp( node, BAD_CAST "type", BAD_CAST "colpick" ); + xmlSetProp( node, BAD_CAST "type", BAD_CAST "colpick" ); xmlSetProp( node, BAD_CAST "texture", BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _Texture ).c_str() ); diff --git a/code/nel/src/gui/ctrl_scroll.cpp b/code/nel/src/gui/ctrl_scroll.cpp index d7b3c5274..bae2ea065 100644 --- a/code/nel/src/gui/ctrl_scroll.cpp +++ b/code/nel/src/gui/ctrl_scroll.cpp @@ -398,9 +398,7 @@ namespace NLGUI if( node == NULL ) return NULL; - if( xmlGetProp( node, BAD_CAST "type" ) == NULL ) - xmlSetProp( node, BAD_CAST "type", BAD_CAST "scroll" ); - + xmlSetProp( node, BAD_CAST "type", BAD_CAST "scroll" ); xmlSetProp( node, BAD_CAST "tx_bottomleft", BAD_CAST getTextureBottomOrLeft().c_str() ); xmlSetProp( node, BAD_CAST "tx_middle", BAD_CAST getTextureMiddle().c_str() ); xmlSetProp( node, BAD_CAST "tx_topright", BAD_CAST getTextureTopOrRight().c_str() ); diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index 37d938d16..d8a2b79d1 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -386,8 +386,7 @@ namespace NLGUI if( node == NULL ) return NULL; - if( xmlGetProp( node, BAD_CAST "type" ) == NULL ) - xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_button" ); + 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/ctrl_tooltip.cpp b/code/nel/src/gui/ctrl_tooltip.cpp index 7b895dad6..821370ecb 100644 --- a/code/nel/src/gui/ctrl_tooltip.cpp +++ b/code/nel/src/gui/ctrl_tooltip.cpp @@ -51,8 +51,7 @@ namespace NLGUI if( node == NULL ) return NULL; - if( xmlGetProp( node, BAD_CAST "type" ) == NULL ) - xmlSetProp( node, BAD_CAST "type", BAD_CAST "tooltip" ); + xmlSetProp( node, BAD_CAST "type", BAD_CAST "tooltip" ); return node; } diff --git a/code/nel/src/gui/dbview_digit.cpp b/code/nel/src/gui/dbview_digit.cpp index f4045cbd4..151e6e0e0 100644 --- a/code/nel/src/gui/dbview_digit.cpp +++ b/code/nel/src/gui/dbview_digit.cpp @@ -109,8 +109,7 @@ namespace NLGUI if( node == NULL ) return NULL; - if( xmlGetProp( node, BAD_CAST "type" ) == NULL ) - xmlSetProp( node, BAD_CAST "type", BAD_CAST "digit" ); + xmlSetProp( node, BAD_CAST "type", BAD_CAST "digit" ); if( _Number.getNodePtr() != NULL ) xmlSetProp( node, BAD_CAST "value", BAD_CAST _Number.getNodePtr()->getFullName().c_str() ); diff --git a/code/nel/src/gui/group_tab.cpp b/code/nel/src/gui/group_tab.cpp index fc2a57038..1ee559b99 100644 --- a/code/nel/src/gui/group_tab.cpp +++ b/code/nel/src/gui/group_tab.cpp @@ -798,9 +798,7 @@ namespace NLGUI if( node == NULL ) return NULL; - if( xmlGetProp( node, BAD_CAST "type" ) == NULL ) - xmlSetProp( node, BAD_CAST "type", BAD_CAST "tab" ); - + xmlSetProp( node, BAD_CAST "type", BAD_CAST "tab" ); xmlNewProp( node, BAD_CAST "group", BAD_CAST _AssociatedGroup.c_str() ); return node; diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index 6aab429fe..9a442a3c7 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -501,9 +501,7 @@ namespace NLGUI if( node == NULL ) return NULL; - if( xmlGetProp( node, BAD_CAST "type" ) == NULL ) - xmlSetProp( node, BAD_CAST "type", BAD_CAST "text" ); - + xmlSetProp( node, BAD_CAST "type", BAD_CAST "text" ); xmlSetProp( node, BAD_CAST "color", BAD_CAST toString( _Color ).c_str() ); xmlSetProp( node, BAD_CAST "global_color", BAD_CAST toString( _ModulateGlobalColor ).c_str() ); xmlSetProp( node, BAD_CAST "fontsize", diff --git a/code/nel/src/gui/view_text_formated.cpp b/code/nel/src/gui/view_text_formated.cpp index ac7f36b7f..280f7be9f 100644 --- a/code/nel/src/gui/view_text_formated.cpp +++ b/code/nel/src/gui/view_text_formated.cpp @@ -46,6 +46,18 @@ namespace NLGUI CViewText::setProperty( name, value ); } + xmlNodePtr CViewTextFormated::serialize( xmlNodePtr parentNode, const char *type ) const + { + xmlNodePtr node = CViewText::serialize( parentNode, type ); + if( node == NULL ) + return NULL; + + xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_formated" ); + xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().c_str() ); + + return NULL; + } + // **************************************************************************** bool CViewTextFormated::parse(xmlNodePtr cur,CInterfaceGroup * parentGroup) { diff --git a/code/nel/src/gui/view_text_id.cpp b/code/nel/src/gui/view_text_id.cpp index 520c266e0..12e657260 100644 --- a/code/nel/src/gui/view_text_id.cpp +++ b/code/nel/src/gui/view_text_id.cpp @@ -106,6 +106,29 @@ namespace NLGUI CViewText::setProperty( name, value ); } + + xmlNodePtr CViewTextID::serialize( xmlNodePtr parentNode, const char *type ) const + { + xmlNodePtr node = CViewText::serialize( parentNode, type ); + if( node == NULL ) + return NULL; + + xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_id" ); + + if( _DBTextId.getNodePtr() != NULL ) + xmlSetProp( node, BAD_CAST "textid", BAD_CAST _DBTextId.getNodePtr()->getFullName().c_str() ); + else + xmlSetProp( node, BAD_CAST "textid", BAD_CAST "" ); + + xmlSetProp( node, BAD_CAST "dynamic_string", + BAD_CAST NLMISC::toString( _DynamicString ).c_str() ); + + xmlSetProp( node, BAD_CAST "format_taged", + BAD_CAST NLMISC::toString( _IsTextFormatTaged ).c_str() ); + + return node; + } + // *************************************************************************** bool CViewTextID::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) {