CHANGED: #1471 CViewBitmap fields can now be serialized.

This commit is contained in:
dfighter1985 2012-08-12 03:20:03 +02:00
parent 0e4dc6af74
commit 5d83619f55
2 changed files with 37 additions and 0 deletions

View file

@ -60,6 +60,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;
/**
* parse an xml node and initialize the base view mambers. Must call CViewBase::parse

View file

@ -230,6 +230,42 @@ namespace NLGUI
CViewBase::setProperty( name, value );
}
xmlNodePtr CViewBitmap::serialize( xmlNodePtr parentNode, const char *type ) const
{
xmlNodePtr node = CViewBase::serialize( parentNode, type );
if( node == NULL )
return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "bitmap" );
xmlSetProp( node, BAD_CAST "color", BAD_CAST toString( _Color ).c_str() );
xmlSetProp( node, BAD_CAST "txtoffsetx", BAD_CAST toString( _TxtOffsetX ).c_str() );
xmlSetProp( node, BAD_CAST "txtoffsety", BAD_CAST toString( _TxtOffsetY ).c_str() );
xmlSetProp( node, BAD_CAST "txtwidth", BAD_CAST toString( _TxtWidth ).c_str() );
xmlSetProp( node, BAD_CAST "txtheight", BAD_CAST toString( _TxtHeight ).c_str() );
xmlSetProp( node, BAD_CAST "texture", BAD_CAST getTexture().c_str() );
xmlSetProp( node, BAD_CAST "scale", BAD_CAST toString( _Scale ).c_str() );
xmlSetProp( node, BAD_CAST "rot", BAD_CAST toString( _Rot ).c_str() );
xmlSetProp( node, BAD_CAST "flip", BAD_CAST toString( _Flip ).c_str() );
xmlSetProp( node, BAD_CAST "tile", BAD_CAST toString( _Tile ).c_str() );
xmlSetProp( node, BAD_CAST "inherit_gc_alpha", BAD_CAST toString( _InheritGCAlpha ).c_str() );
std::string align;
if( ( _Align & 1 ) != 0 )
align += "R";
else
align += "L";
if( ( _Align & 2 ) != 0 )
align += "T";
else
align += "B";
xmlSetProp( node, BAD_CAST "txtoffsetx", BAD_CAST align.c_str() );
return node;
}
// ----------------------------------------------------------------------------
bool CViewBitmap::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)