Parent positions should now be saved right again.

This commit is contained in:
dfighter1985 2014-10-12 23:05:22 +02:00
parent f27f391724
commit a96cdafb29
2 changed files with 35 additions and 2 deletions

View file

@ -492,6 +492,7 @@ namespace NLGUI
bool isEditorSelected() const{ return editorSelected; } bool isEditorSelected() const{ return editorSelected; }
void setPosParent( const std::string &id ); void setPosParent( const std::string &id );
void getPosParent( std::string &id ) const;
void setSizeParent( const std::string &id ); void setSizeParent( const std::string &id );
void setSerializable( bool b ){ serializable = b; } void setSerializable( bool b ){ serializable = b; }

View file

@ -294,8 +294,10 @@ namespace NLGUI
xmlNewProp( node, BAD_CAST "w", BAD_CAST toString( _W ).c_str() ); 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 "h", BAD_CAST toString( _H ).c_str() );
xmlNewProp( node, BAD_CAST "posref", BAD_CAST HotSpotCoupleToString( _ParentPosRef, _PosRef ).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 "sizeref", BAD_CAST getSizeRefAsString().c_str() );
xmlNewProp( node, BAD_CAST "sizeparent", xmlNewProp( node, BAD_CAST "sizeparent",
BAD_CAST CWidgetManager::getInstance()->getParser()->getParentSizeAssociation( (CInterfaceElement*)this ).c_str() ); 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 ) void CInterfaceElement::setSizeParent( const std::string &id )
{ {
std::string Id = stripId( id ); std::string Id = stripId( id );