From a96cdafb290b3140daf5044d1e0fdaf361d2171f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 12 Oct 2014 23:05:22 +0200 Subject: [PATCH] Parent positions should now be saved right again. --- code/nel/include/nel/gui/interface_element.h | 1 + code/nel/src/gui/interface_element.cpp | 36 ++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index 0be4c02e3..a8a04b454 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -492,6 +492,7 @@ namespace NLGUI bool isEditorSelected() const{ return editorSelected; } void setPosParent( const std::string &id ); + void getPosParent( std::string &id ) const; void setSizeParent( const std::string &id ); void setSerializable( bool b ){ serializable = b; } diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index c9b480516..e3928e85f 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -294,8 +294,10 @@ namespace NLGUI xmlNewProp( node, BAD_CAST "w", BAD_CAST toString( _W ).c_str() ); xmlNewProp( node, BAD_CAST "h", BAD_CAST toString( _H ).c_str() ); xmlNewProp( node, BAD_CAST "posref", BAD_CAST HotSpotCoupleToString( _ParentPosRef, _PosRef ).c_str() ); - xmlNewProp( node, BAD_CAST "posparent", - BAD_CAST CWidgetManager::getInstance()->getParser()->getParentPosAssociation( (CInterfaceElement*)this ).c_str() ); + + std::string pp; + getPosParent( pp ); + xmlNewProp( node, BAD_CAST "posparent", BAD_CAST pp.c_str() ); xmlNewProp( node, BAD_CAST "sizeref", BAD_CAST getSizeRefAsString().c_str() ); xmlNewProp( node, BAD_CAST "sizeparent", BAD_CAST CWidgetManager::getInstance()->getParser()->getParentSizeAssociation( (CInterfaceElement*)this ).c_str() ); @@ -1541,6 +1543,36 @@ namespace NLGUI } } + void CInterfaceElement::getPosParent( std::string &id ) const + { + + // If there's no pos parent set, then the parent group is the pos parent + if( getParentPos() == NULL ) + { + id = "parent"; + return; + } + + // If pos parent and parent are the same then ofc the parent group is the pos parent... + CInterfaceElement *p = getParent(); + if( getParentPos() == p ) + { + id = "parent"; + return; + } + + // If parent is in the same group, use the short id + p = getParentPos(); + if( p->isInGroup( getParent() ) ) + { + id = p->getShortId(); + return; + } + + // Otherwise use the full id + id = p->getId(); + } + void CInterfaceElement::setSizeParent( const std::string &id ) { std::string Id = stripId( id );