From ea8ed3fcf5ecc96882ef450fe2a89b0860bdfb90 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 28 Jul 2012 23:12:22 +0200 Subject: [PATCH] CHANGED: #1471 Implemented CCtrlTextButton property querying. --- code/nel/include/nel/gui/ctrl_text_button.h | 2 + code/nel/include/nel/misc/rgba.h | 2 + code/nel/src/gui/ctrl_text_button.cpp | 124 ++++++++++++++++++ code/nel/src/gui/interface_element.cpp | 2 +- code/nel/src/misc/rgba.cpp | 13 ++ .../gui_editor/widgets/CtrlTextButton.xml | 117 +++++++++++++++++ 6 files changed, 259 insertions(+), 1 deletion(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/CtrlTextButton.xml diff --git a/code/nel/include/nel/gui/ctrl_text_button.h b/code/nel/include/nel/gui/ctrl_text_button.h index a6d43c50f..18102cd63 100644 --- a/code/nel/include/nel/gui/ctrl_text_button.h +++ b/code/nel/include/nel/gui/ctrl_text_button.h @@ -42,6 +42,8 @@ namespace NLGUI /// Constructor CCtrlTextButton(const TCtorParam ¶m); + std::string getProperty( const std::string &name ) const; + // 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 700c98a41..b20b25a1b 100644 --- a/code/nel/include/nel/misc/rgba.h +++ b/code/nel/include/nel/misc/rgba.h @@ -328,6 +328,8 @@ public: static CRGBA stringToRGBA( const char *ptr ); + std::string toString() const; + /// Swap the B and R components, to simulate a CBRGA void swapBR() diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index f47279ad2..cc66caf83 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -60,6 +60,130 @@ namespace NLGUI _ForceTextOver = false; } + std::string CCtrlTextButton::getProperty( const std::string &name ) const + { + 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 ); + return tex; + } + 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 ); + return tex; + } + 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 ); + return tex; + } + else + if( name == "wmargin" ) + { + return toString( _WMargin ); + } + else + if( name == "wmin" ) + { + return toString( _WMin ); + } + else + if( name == "text_y" ) + { + return toString( _TextY ); + } + else + if( name == "text_x" ) + { + return toString( _TextX ); + } + else + if( name == "text_underlined" ) + { + return toString( _ViewText->getUnderlined() ); + } + else + if( name == "text_posref" ) + { + std::string pr; + pr = CInterfaceElement::HotSpotToString( _TextParentPosRef ); + pr += " "; + pr += CInterfaceElement::HotSpotToString( _TextPosRef ); + return pr; + } + else + if( name == "text_color_normal" ) + { + return toString( _TextColorNormal ); + } + else + if( name == "text_color_pushed" ) + { + return toString( _TextColorPushed ); + } + else + if( name == "text_color_over" ) + { + return toString( _TextColorOver ); + } + else + if( name == "text_shadow_color_normal" ) + { + return toString( _TextShadowColorNormal ); + } + else + if( name == "text_shadow_color_pushed" ) + { + return toString( _TextShadowColorPushed ); + } + else + if( name == "text_shadow_color_over" ) + { + return toString( _TextShadowColorOver ); + } + else + if( name == "text_global_color_normal" ) + { + return toString( _TextModulateGlobalColorNormal ); + } + else + if( name == "text_global_color_pushed" ) + { + return toString( _TextModulateGlobalColorPushed ); + } + else + if( name == "text_global_color_over" ) + { + return toString( _TextModulateGlobalColorOver ); + } + else + if( name == "force_text_over" ) + { + return toString( _ForceTextOver ); + } + else + if( name == "text_header_color" ) + { + return toString( _TextHeaderColor ); + } + else + return CCtrlBaseButton::getProperty( name ); + } + // *************************************************************************** bool CCtrlTextButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) { diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 7f6d5c6d0..9ac109937 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -219,7 +219,7 @@ namespace NLGUI { if( name == "id" ) { - return getId(); + return stripId( getId() ); } else if( name == "active" ) diff --git a/code/nel/src/misc/rgba.cpp b/code/nel/src/misc/rgba.cpp index b0ae2edc9..060fa00b8 100644 --- a/code/nel/src/misc/rgba.cpp +++ b/code/nel/src/misc/rgba.cpp @@ -743,6 +743,19 @@ CRGBA CRGBA::stringToRGBA( const char *ptr ) return CRGBA( r,g,b,a ); } +std::string CRGBA::toString() const +{ + std::string s; + s = NLMISC::toString( R ); + s += " "; + s += NLMISC::toString( G ); + s += " "; + s += NLMISC::toString( B ); + s += " "; + s += NLMISC::toString( A ); + return s; +} + // *************************************************************************** // *************************************************************************** diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/CtrlTextButton.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/CtrlTextButton.xml new file mode 100644 index 000000000..f66c500b1 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/CtrlTextButton.xml @@ -0,0 +1,117 @@ + +
+ CtrlTextButton + CCtrlTextButton + CtrlBaseButton + + false + +
+ + + tx_normal + string + + + + tx_pushed + string + + + + tx_over + string + + + + hardtext + string + + + + wmargin + int + 0 + + + wmin + int + 0 + + + text_y + int + -2 + + + text_x + int + -2 + + + text_underlined + bool + false + + + text_posref + string + MM MM + + + text_color_normal + string + 255 255 255 255 + + + text_color_pushed + string + 255 255 255 255 + + + text_color_over + string + 255 255 255 255 + + + text_shadow_color_normal + string + 0 0 0 255 + + + text_shadow_color_pushed + string + 0 0 0 255 + + + text_shadow_color_over + string + 0 0 0 255 + + + text_global_color_normal + bool + true + + + text_global_color_pushed + bool + true + + + text_global_color_over + bool + true + + + force_text_over + bool + false + + + text_header_color + bool + false + + +