From 8006dbeabebeb5ebf76b6060d08dd81645278303 Mon Sep 17 00:00:00 2001 From: Inky Date: Wed, 3 Jul 2019 18:45:39 +0300 Subject: [PATCH] Changed: export reflect texture(pushed, over) on CCtrlTextButton element --HG-- branch : menu_navi --- code/nel/include/nel/gui/ctrl_text_button.h | 13 +++++ code/nel/src/gui/ctrl_text_button.cpp | 63 +++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/code/nel/include/nel/gui/ctrl_text_button.h b/code/nel/include/nel/gui/ctrl_text_button.h index e88ec81e1..713c5ad1c 100644 --- a/code/nel/include/nel/gui/ctrl_text_button.h +++ b/code/nel/include/nel/gui/ctrl_text_button.h @@ -124,6 +124,16 @@ namespace NLGUI void setTexturePushed(const std::string &l, const std::string &m, const std::string &r); void setTextureOver(const std::string &l, const std::string &m, const std::string &r); + // lua + void setTextureLua (const std::string &name); + void setTexturePushedLua (const std::string &name); + void setTextureOverLua (const std::string &name); + + // return texture _l.tga + std::string getTexture () const; + std::string getTexturePushed () const; + std::string getTextureOver() const; + int luaGetViewText(CLuaState &ls); REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton) @@ -134,6 +144,9 @@ namespace NLGUI REFLECT_SINT32("wmin", getWMin, setWMin) REFLECT_SINT32("hmin", getHMin, setHMin) REFLECT_LUA_METHOD("getViewText", luaGetViewText) + REFLECT_STRING("texture", getTexture, setTextureLua); + REFLECT_STRING("texture_pushed", getTexturePushed, setTexturePushedLua); + REFLECT_STRING("texture_over", getTextureOver, setTextureOverLua); REFLECT_EXPORT_END void onRemoved(); diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index d10dfa0c9..0cea8c8b3 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -1074,6 +1074,69 @@ namespace NLGUI // *************************************************************************** + void CCtrlTextButton::setTextureLua(const std::string &name) + { + _TextureIdNormal[0].setTexture(std::string(name + "_l.tga").c_str()); + _TextureIdNormal[1].setTexture(std::string(name + "_m.tga").c_str()); + _TextureIdNormal[2].setTexture(std::string(name + "_r.tga").c_str()); + } + + // *************************************************************************** + + void CCtrlTextButton::setTexturePushedLua(const std::string &name) + { + _TextureIdPushed[0].setTexture(std::string(name + "_l.tga").c_str()); + _TextureIdPushed[1].setTexture(std::string(name + "_m.tga").c_str()); + _TextureIdPushed[2].setTexture(std::string(name + "_r.tga").c_str()); + } + + // *************************************************************************** + + void CCtrlTextButton::setTextureOverLua(const std::string &name) + { + _TextureIdOver[0].setTexture(std::string(name + "_l.tga").c_str()); + _TextureIdOver[1].setTexture(std::string(name + "_m.tga").c_str()); + _TextureIdOver[2].setTexture(std::string(name + "_r.tga").c_str()); + } + + // *************************************************************************** + + std::string CCtrlTextButton::getTexture() const + { + std::string tx = CViewRenderer::getInstance()->getTextureNameFromId(_TextureIdNormal[0]); + std::string::size_type i = tx.rfind("_l.tga"); + if (i != std::string::npos) + tx = tx.substr(0, i); + + return tx; + } + + // *************************************************************************** + + std::string CCtrlTextButton::getTexturePushed() const + { + std::string tx = CViewRenderer::getInstance()->getTextureNameFromId(_TextureIdOver[0]); + std::string::size_type i = tx.rfind("_l.tga"); + if (i != std::string::npos) + tx = tx.substr(0, i); + + return tx; + } + + // *************************************************************************** + + std::string CCtrlTextButton::getTextureOver() const + { + std::string tx = CViewRenderer::getInstance()->getTextureNameFromId(_TextureIdPushed[0]); + std::string::size_type i = tx.rfind("_l.tga"); + if (i != std::string::npos) + tx = tx.substr(0, i); + + return tx; + } + + // *************************************************************************** + int CCtrlTextButton::luaGetViewText(CLuaState &ls) { const char *funcName = "getViewText";