From d75e87d2dcb61a3dd838be2253438b55eee9e95c Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 13 Aug 2012 00:48:06 +0200 Subject: [PATCH] CHANGED: #1471 CGroupEditBox fields can now be serialized. --HG-- branch : gsoc2012-gui-editor --- code/nel/include/nel/gui/group_editbox.h | 1 + code/nel/src/gui/group_editbox.cpp | 86 ++++++++++++++++++++++++ code/nel/src/gui/interface_element.cpp | 7 +- code/nel/src/gui/interface_group.cpp | 7 ++ code/nel/src/gui/interface_parser.cpp | 3 +- code/nel/src/gui/view_text.cpp | 1 - 6 files changed, 100 insertions(+), 5 deletions(-) diff --git a/code/nel/include/nel/gui/group_editbox.h b/code/nel/include/nel/gui/group_editbox.h index ee7ae3115..9d7494cfd 100644 --- a/code/nel/include/nel/gui/group_editbox.h +++ b/code/nel/include/nel/gui/group_editbox.h @@ -50,6 +50,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; bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp index e6ae7c19f..9a059f10b 100644 --- a/code/nel/src/gui/group_editbox.cpp +++ b/code/nel/src/gui/group_editbox.cpp @@ -432,6 +432,92 @@ namespace NLGUI CInterfaceGroup::setProperty( name, value ); } + xmlNodePtr CGroupEditBox::serialize( xmlNodePtr parentNode, const char *type ) const + { + xmlNodePtr node = CInterfaceGroup::serialize( parentNode, type ); + if( node == NULL ) + return NULL; + + xmlSetProp( node, BAD_CAST "type", BAD_CAST "edit_box" ); + + xmlSetProp( node, BAD_CAST "onchange", BAD_CAST _AHOnChange.c_str() ); + xmlSetProp( node, BAD_CAST "onchange_params", BAD_CAST _ParamsOnChange.c_str() ); + xmlSetProp( node, BAD_CAST "on_focus_lost", BAD_CAST _AHOnFocusLost.c_str() ); + xmlSetProp( node, BAD_CAST "on_focus_lost_params", BAD_CAST _AHOnFocusLostParams.c_str() ); + xmlSetProp( node, BAD_CAST "on_focus", BAD_CAST _AHOnFocus.c_str() ); + xmlSetProp( node, BAD_CAST "on_focus_params", BAD_CAST _AHOnFocusParams.c_str() ); + xmlSetProp( node, BAD_CAST "max_num_chars", BAD_CAST toString( _MaxNumChar ).c_str() ); + xmlSetProp( node, BAD_CAST "max_num_return", BAD_CAST toString( _MaxNumReturn ).c_str() ); + xmlSetProp( node, BAD_CAST "max_chars_size", BAD_CAST toString( _MaxCharsSize ).c_str() ); + xmlSetProp( node, BAD_CAST "enter_loose_focus", BAD_CAST toString( _LooseFocusOnEnter ).c_str() ); + xmlSetProp( node, BAD_CAST "enter_recover_focus", BAD_CAST toString( _RecoverFocusOnEnter ).c_str() ); + xmlSetProp( node, BAD_CAST "prompt", BAD_CAST _Prompt.toString().c_str() ); + + std::string e; + switch( _EntryType ) + { + case Integer: + e = "integer"; + break; + + case PositiveInteger: + e = "positive_integer"; + break; + + case Float: + e = "float"; + break; + + case PositiveFloat: + e = "positive_float"; + break; + + case Alpha: + e = "alpha"; + break; + + case AlphaNum: + e = "alpha_num"; + break; + + case AlphaNumSpace: + e = "alpha_num_space"; + break; + + case Password: + e = "password"; + break; + + case Filename: + e = "filename"; + break; + + case PlayerName: + e = "playername"; + break; + } + + xmlSetProp( node, BAD_CAST "enter_type", BAD_CAST e.c_str() ); + xmlSetProp( node, BAD_CAST "menu_r", BAD_CAST _ListMenuRight.c_str() ); + xmlSetProp( node, BAD_CAST "max_historic", BAD_CAST toString( _MaxHistoric ).c_str() ); + xmlSetProp( node, BAD_CAST "backup_father_container_pos", + BAD_CAST toString( _BackupFatherContainerPos ).c_str() ); + xmlSetProp( node, BAD_CAST "want_return", BAD_CAST toString( _WantReturn ).c_str() ); + xmlSetProp( node, BAD_CAST "savable", BAD_CAST toString( _Savable ).c_str() ); + xmlSetProp( node, BAD_CAST "max_float_prec", BAD_CAST toString( _MaxFloatPrec ).c_str() ); + + std::string s; + s.reserve( _NegativeFilter.size() ); + + std::vector< char >::const_iterator itr; + for( itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr ) + s.push_back( *itr ); + + xmlSetProp( node, BAD_CAST "negative_filter", BAD_CAST s.c_str() ); + + return node; + } + // ---------------------------------------------------------------------------- bool CGroupEditBox::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) { diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index f2e0e55b2..81dbb584f 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -1532,15 +1532,16 @@ namespace NLGUI idParent = _Parent->getId() + ":"; else idParent = "ui:"; - + CWidgetManager::getInstance()->getParser()->addParentSizeAssociation( this, idParent + Id ); } else { if( _Parent != NULL ) + { idParent = _Parent->getId(); + CWidgetManager::getInstance()->getParser()->addParentSizeAssociation( this, idParent ); + } } - - CWidgetManager::getInstance()->getParser()->addParentSizeAssociation( this, idParent + Id ); } CStringMapper* CStringShared::_UIStringMapper = NULL; diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index defe7125b..96eea2aa8 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -673,6 +673,7 @@ namespace NLGUI serializeSubGroups( node ); serializeControls( node ); + serializeViews( node ); return node; } @@ -739,6 +740,12 @@ namespace NLGUI xmlNodePtr CInterfaceGroup::serializeViews( xmlNodePtr parentNode ) const { + std::vector< CViewBase* >::const_iterator itr; + for( itr = _Views.begin(); itr != _Views.end(); ++itr ) + { + (*itr)->serialize( parentNode, "view" ); + } + return parentNode; } diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 5bcec4210..6f74493e2 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -1353,7 +1353,8 @@ namespace NLGUI if (parentGroup->getElement(view->getId()) != NULL) { // Remove old groupe and replace - if (reload) + // TODO: Don't save widgets created by complex widgets + if ( true /*reload*/) parentGroup->delElement (view->getId()); else { diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index 9a442a3c7..818ca8c35 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -546,7 +546,6 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "continuous_update", BAD_CAST toString( _ContinuousUpdate ).c_str() ); xmlSetProp( node, BAD_CAST "hardtext", BAD_CAST _Text.toString().c_str() ); xmlSetProp( node, BAD_CAST "hardtext_format", BAD_CAST _HardtextFormat.c_str() ); - xmlSetProp( node, BAD_CAST "", BAD_CAST "" ); return node; }