From 56275ed792fe68a8bdd043cd9d382a96c226d0f3 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 3 Aug 2012 22:15:25 +0200 Subject: [PATCH] CHANGED: #1471 Implemented property setting for CCtrlTextButton. --HG-- branch : gsoc2012-gui-editor --- code/nel/include/nel/gui/ctrl_text_button.h | 1 + code/nel/include/nel/misc/rgba.h | 1 + code/nel/src/gui/ctrl_text_button.cpp | 184 ++++++++++++++++++++ code/nel/src/misc/rgba.cpp | 6 + 4 files changed, 192 insertions(+) diff --git a/code/nel/include/nel/gui/ctrl_text_button.h b/code/nel/include/nel/gui/ctrl_text_button.h index 18102cd63..5439cde95 100644 --- a/code/nel/include/nel/gui/ctrl_text_button.h +++ b/code/nel/include/nel/gui/ctrl_text_button.h @@ -43,6 +43,7 @@ namespace NLGUI CCtrlTextButton(const TCtorParam ¶m); std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); // Init part virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); diff --git a/code/nel/include/nel/misc/rgba.h b/code/nel/include/nel/misc/rgba.h index b20b25a1b..840380732 100644 --- a/code/nel/include/nel/misc/rgba.h +++ b/code/nel/include/nel/misc/rgba.h @@ -329,6 +329,7 @@ public: static CRGBA stringToRGBA( const char *ptr ); std::string toString() const; + bool fromString( const std::string &s ); /// Swap the B and R components, to simulate a CBRGA diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index cc66caf83..b46421e3e 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -184,6 +184,190 @@ namespace NLGUI 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) { diff --git a/code/nel/src/misc/rgba.cpp b/code/nel/src/misc/rgba.cpp index 060fa00b8..3296950b9 100644 --- a/code/nel/src/misc/rgba.cpp +++ b/code/nel/src/misc/rgba.cpp @@ -756,6 +756,12 @@ std::string CRGBA::toString() const return s; } +bool CRGBA::fromString( const std::string &s ) +{ + *this = stringToRGBA( s.c_str() ); + return true; +} + // *************************************************************************** // ***************************************************************************