CHANGED: #1471 Implemented property setting for CCtrlTextButton.

--HG--
branch : gsoc2012-gui-editor
This commit is contained in:
dfighter1985 2012-08-03 22:15:25 +02:00
parent 569973afa7
commit 56275ed792
4 changed files with 192 additions and 0 deletions

View file

@ -43,6 +43,7 @@ namespace NLGUI
CCtrlTextButton(const TCtorParam &param); CCtrlTextButton(const TCtorParam &param);
std::string getProperty( const std::string &name ) const; std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
// Init part // Init part
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);

View file

@ -329,6 +329,7 @@ public:
static CRGBA stringToRGBA( const char *ptr ); static CRGBA stringToRGBA( const char *ptr );
std::string toString() const; std::string toString() const;
bool fromString( const std::string &s );
/// Swap the B and R components, to simulate a CBRGA /// Swap the B and R components, to simulate a CBRGA

View file

@ -184,6 +184,190 @@ namespace NLGUI
return CCtrlBaseButton::getProperty( name ); return CCtrlBaseButton::getProperty( name );
} }
void CCtrlTextButton::setProperty( const std::string &name, const std::string &value )
{
if( name == "tx_normal" )
{
std::string tex;
tex = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal[ 0 ] );
std::string::size_type i = tex.rfind( "_l.tga" );
if( i != std::string::npos )
tex = tex.substr( 0, i );
_TextureIdNormal[ 0 ].setTexture( std::string( value + "_l.tga" ).c_str() );
_TextureIdNormal[ 1 ].setTexture( std::string( value + "_m.tga" ).c_str() );
_TextureIdNormal[ 2 ].setTexture( std::string( value + "_r.tga" ).c_str() );
return;
}
else
if( name == "tx_pushed" )
{
std::string tex;
tex = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdPushed[ 0 ] );
std::string::size_type i = tex.rfind( "_l.tga" );
if( i != std::string::npos )
tex = tex.substr( 0, i );
_TextureIdPushed[ 0 ].setTexture( std::string( value + "_l.tga" ).c_str() );
_TextureIdPushed[ 1 ].setTexture( std::string( value + "_m.tga" ).c_str() );
_TextureIdPushed[ 2 ].setTexture( std::string( value + "_r.tga" ).c_str() );
return;
}
else
if( name == "tx_over" )
{
std::string tex;
tex = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdOver[ 0 ] );
std::string::size_type i = tex.rfind( "_l.tga" );
if( i != std::string::npos )
tex = tex.substr( 0, i );
_TextureIdOver[ 0 ].setTexture( std::string( value + "_l.tga" ).c_str() );
_TextureIdOver[ 1 ].setTexture( std::string( value + "_m.tga" ).c_str() );
_TextureIdOver[ 2 ].setTexture( std::string( value + "_r.tga" ).c_str() );
return;
}
else
if( name == "wmargin" )
{
sint32 i;
if( fromString( value, i ) )
_WMargin = i;
return;
}
else
if( name == "wmin" )
{
sint32 i;
if( fromString( value, i ) )
_WMin = i;
return;
}
else
if( name == "text_y" )
{
sint32 i;
if( fromString( value, i ) )
_TextY = i;
return;
}
else
if( name == "text_x" )
{
sint32 i;
if( fromString( value, i ) )
_TextX = i;
return;
}
else
if( name == "text_underlined" )
{
bool b;
if( fromString( value, b ) )
_ViewText->setUnderlined( b );
return;
}
else
if( name == "text_posref" )
{
THotSpot parent, posref;
CInterfaceElement::convertHotSpotCouple( value.c_str(), parent, posref );
_TextPosRef = posref;
_TextParentPosRef = parent;
return;
}
else
if( name == "text_color_normal" )
{
CRGBA c;
if( fromString( value, c ) )
_TextColorNormal = c;
return;
}
else
if( name == "text_color_pushed" )
{
CRGBA c;
if( fromString( value, c ) )
_TextColorPushed = c;
return;
}
else
if( name == "text_color_over" )
{
CRGBA c;
if( fromString( value, c ) )
_TextColorOver = c;
return;
}
else
if( name == "text_shadow_color_normal" )
{
CRGBA c;
if( fromString( value, c ) )
_TextShadowColorNormal = c;
return;
}
else
if( name == "text_shadow_color_pushed" )
{
CRGBA c;
if( fromString( value, c ) )
_TextShadowColorPushed = c;
return;
}
else
if( name == "text_shadow_color_over" )
{
CRGBA c;
if( fromString( value, c ) )
_TextShadowColorOver = c;
return;
}
else
if( name == "text_global_color_normal" )
{
bool b;
if( fromString( value, b ) )
_TextModulateGlobalColorNormal = b;
return;
}
else
if( name == "text_global_color_pushed" )
{
bool b;
if( fromString( value, b ) )
_TextModulateGlobalColorPushed = b;
return;
}
else
if( name == "text_global_color_over" )
{
bool b;
if( fromString( value, b ) )
_TextModulateGlobalColorOver = b;
return;
}
else
if( name == "force_text_over" )
{
bool b;
if( fromString( value, b ) )
_ForceTextOver = b;
return;
}
else
if( name == "text_header_color" )
{
bool b;
if( fromString( value, b ) )
_TextHeaderColor = b;
return;
}
else
CCtrlBaseButton::setProperty( name, value );
}
// *************************************************************************** // ***************************************************************************
bool CCtrlTextButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) bool CCtrlTextButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
{ {

View file

@ -756,6 +756,12 @@ std::string CRGBA::toString() const
return s; return s;
} }
bool CRGBA::fromString( const std::string &s )
{
*this = stringToRGBA( s.c_str() );
return true;
}
// *************************************************************************** // ***************************************************************************
// *************************************************************************** // ***************************************************************************