From dba92deea558cff642112ba7ff5f8a3085286b44 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 04:19:02 +0800 Subject: [PATCH 1/5] Avoid useless string operations --- code/nel/include/nel/misc/string_common.h | 7 ++++--- code/nel/src/gui/interface_element.cpp | 9 ++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/code/nel/include/nel/misc/string_common.h b/code/nel/include/nel/misc/string_common.h index 3fd46b835..372ee4be5 100644 --- a/code/nel/include/nel/misc/string_common.h +++ b/code/nel/include/nel/misc/string_common.h @@ -246,9 +246,10 @@ inline bool fromString(const std::string &str, sint64 &val) { bool ret = sscanf( inline bool fromString(const std::string &str, float &val) { bool ret = sscanf(str.c_str(), "%f", &val) == 1; if (!ret) val = 0.0f; return ret; } inline bool fromString(const std::string &str, double &val) { bool ret = sscanf(str.c_str(), "%lf", &val) == 1; if (!ret) val = 0.0; return ret; } -// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, anything else is undefined. -// (str[0] == '1' || (str[0] & 0xD2) == 0x50) -// - Kaetemi +/// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, and empty strings, anything else is undefined. +/// - Kaetemi +inline bool toBool(const char *str) { return str[0] == '1' || (str[0] & 0xD2) == 0x50; } +inline bool toBool(const std::string &str) { return toBool(str.c_str()); } // Safe because first byte may be null bool fromString(const std::string &str, bool &val); diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 4a736314d..98f4ab7d6 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -1028,21 +1028,16 @@ namespace NLGUI } // ------------------------------------------------------------------------------------------------ - bool CInterfaceElement::convertBool (const char *ptr) + bool CInterfaceElement::convertBool (const char *ptr) { - std::string str = toLower(ptr); - bool b = false; - fromString( str, b ); - return b; + return NLMISC::toBool(ptr); } // ------------------------------------------------------------------------------------------------ NLMISC::CVector CInterfaceElement::convertVector (const char *ptr) { float x = 0.0f, y = 0.0f, z = 0.0f; - sscanf (ptr, "%f %f %f", &x, &y, &z); - return CVector(x,y,z); } From fdb271bdb3afe172d4ef0753f9429f7ebf2892fb Mon Sep 17 00:00:00 2001 From: Nimetu Date: Wed, 31 Mar 2021 13:30:43 +0300 Subject: [PATCH 2/5] Add macros to read properties from xmlNode --- code/nel/include/nel/misc/xml_macros.h | 74 ++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 code/nel/include/nel/misc/xml_macros.h diff --git a/code/nel/include/nel/misc/xml_macros.h b/code/nel/include/nel/misc/xml_macros.h new file mode 100644 index 000000000..d25cd4c30 --- /dev/null +++ b/code/nel/include/nel/misc/xml_macros.h @@ -0,0 +1,74 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef XML_MACROS_H +#define XML_MACROS_H + +// +// xmlNodePtr cur; +// CXMLAutoPtr prop; +// +// sint i; +// XML_READ_SINT(cur, "prop_name", i, -1); +// + +#define XML_READ_UINT(node, name, var, def) { \ + uint tmp; \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop && fromString((const char*)prop, tmp)) \ + var = tmp; \ + else \ + var = def; \ +} + +#define XML_READ_SINT(node, name, var, def) { \ + sint tmp; \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop && fromString((const char*)prop, tmp)) \ + var = tmp; \ + else \ + var = def; \ +} + +#define XML_READ_BOOL(node, name, var, def) { \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop) \ + var = NLMISC::toBool((const char*)prop); \ + else \ + var = def; \ +} + +#define XML_READ_COLOR(node, name, var, def) { \ + NLMISC::CRGBA tmp; \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop && fromString((const char*)prop, tmp)) \ + var = tmp; \ + else \ + var = def; \ +} + +#define XML_READ_STRING(node, name, var, def) { \ + prop = (char *) xmlGetProp(node, (xmlChar*)name); \ + if (prop) \ + var = (const char*)prop; \ + else \ + var = def; \ +} + +#endif // XML_MACROS_H + From c09ed63120947d871ad2c32115609d670333ba12 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 1 Apr 2021 14:23:36 +0300 Subject: [PATCH 3/5] Add xml options for icon regen text --- .../client/src/interface_v3/dbctrl_sheet.cpp | 128 ++++++++++++++---- .../client/src/interface_v3/dbctrl_sheet.h | 23 ++++ 2 files changed, 122 insertions(+), 29 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 7b188742c..9306003c4 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -56,6 +56,7 @@ #include "../r2/editor.h" #include "nel/gui/lua_manager.h" +#include "nel/misc/xml_macros.h" extern CSheetManager SheetMngr; @@ -543,6 +544,14 @@ CCtrlDraggable(param) _RegenText = NULL; _RegenTextValue = 0; + _RegenTextEnabled = true; + _RegenTextShadow = true; + _RegenTextOutline = false; + _RegenTextY = 2; + _RegenTextFontSize = 8; + _RegenTextColor = NLMISC::CRGBA::White; + _RegenTextShadowColor = NLMISC::CRGBA::Black; + _RegenTextOutlineColor = NLMISC::CRGBA::Black; } // ---------------------------------------------------------------------------- @@ -655,6 +664,15 @@ bool CDBCtrlSheet::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) prop = (char*) xmlGetProp( cur, (xmlChar*)"focus_buff_icon" ); if (prop) _FocusBuffIcon = string((const char *)prop); + XML_READ_BOOL(cur, "regen_text", _RegenTextEnabled, true); + XML_READ_BOOL(cur, "regen_text_shadow", _RegenTextShadow, true); + XML_READ_BOOL(cur, "regen_text_outline", _RegenTextOutline, false); + XML_READ_SINT(cur, "regen_text_y", _RegenTextY, 2); + XML_READ_UINT(cur, "regen_text_fontsize", _RegenTextFontSize, 8); + XML_READ_COLOR(cur, "regen_text_color", _RegenTextColor, NLMISC::CRGBA::White); + XML_READ_COLOR(cur, "regen_text_shadow_color", _RegenTextShadowColor, NLMISC::CRGBA::Black); + XML_READ_COLOR(cur, "regen_text_outline_color", _RegenTextOutlineColor, NLMISC::CRGBA::Black); + updateActualType(); // Init size for Type initSheetSize(); @@ -2097,35 +2115,8 @@ void CDBCtrlSheet::draw() rVR.drawQuad(_RenderLayer + 1, regenTris[tri], backTex, CRGBA::White, false); } - if (!_RegenText) { - _RegenText = new CViewText(CViewBase::TCtorParam()); - _RegenText->setId(getId() + ":regen"); - _RegenText->setParent(_Parent); - _RegenText->setOverflowText(ucstring("")); - _RegenText->setModulateGlobalColor(false); - _RegenText->setMultiLine(false); - _RegenText->setTextMode(CViewText::ClipWord); - _RegenText->setFontSizing("0", "0"); - // TODO: font size / color hardcoded. - _RegenText->setFontSize(8); - _RegenText->setColor(CRGBA::White); - _RegenText->setShadow(true); - _RegenText->setActive(true); - _RegenText->updateTextContext(); - } - - // TODO: ticks in second hardcoded - uint32 nextValue = _RegenTickRange.EndTick > LastGameCycle ? (_RegenTickRange.EndTick - LastGameCycle) / 10 : 0; - if (_RegenTextValue != nextValue) - { - _RegenTextValue = nextValue; - _RegenText->setText(toString("%d", _RegenTextValue)); - _RegenText->updateTextContext(); - } - _RegenText->setXReal(_XReal+1); - _RegenText->setYReal(_YReal+2); - _RegenText->setRenderLayer(_RenderLayer+2); - _RegenText->draw(); + if (_RegenTextEnabled) + drawRegenText(); } } @@ -2155,6 +2146,85 @@ void CDBCtrlSheet::draw() } } +// ---------------------------------------------------------------------------- +void CDBCtrlSheet::drawRegenText() +{ + if (!_RegenText) { + _RegenText = new CViewText(CViewBase::TCtorParam()); + _RegenText->setId(getId() + ":regen"); + _RegenText->setParent(_Parent); + _RegenText->setOverflowText(std::string()); + _RegenText->setModulateGlobalColor(false); + _RegenText->setMultiLine(false); + _RegenText->setTextMode(CViewText::ClipWord); + _RegenText->setFontSize(_RegenTextFontSize); + _RegenText->setColor(_RegenTextColor); + // do not set shadow if outline is set to avoid clearing it on draw (would call invalidate) + _RegenText->setShadow(_RegenTextShadow && !_RegenTextOutline); + _RegenText->setShadowOutline(false);//_RegenTextOutline); + _RegenText->setShadowColor(_RegenTextShadowColor); + + _RegenText->setActive(true); + _RegenText->updateTextContext(); + } + + // TODO: 10 hardcoded (ticks in second) + uint32 nextValue = _RegenTickRange.EndTick > LastGameCycle ? (_RegenTickRange.EndTick - LastGameCycle) / 10 : 0; + if (_RegenTextValue != nextValue) + { + _RegenTextValue = nextValue; + // format as "10m", "9'59", "59" + if (_RegenTextValue > 600) + { + _RegenText->setText(toString("%dm", _RegenTextValue / 60)); + } + else if (_RegenTextValue > 0) + { + if (_RegenTextValue < 60) + _RegenText->setText(toString("%d", _RegenTextValue)); + else + _RegenText->setText(toString("%d'%02d", _RegenTextValue / 60, _RegenTextValue % 60)); + } + else + { + _RegenText->setText(ucstring()); + } + + _RegenText->updateTextContext(); + // todo: posref + _RegenText->setX(_WReal / 2 -_RegenText->getMaxUsedW() / 2); + // move RegenTextY=0 to baseline + _RegenText->setY(_RegenTextY - _RegenText->getFontLegHeight()); + } + + _RegenText->setXReal(_XReal + _RegenText->getX()); + _RegenText->setYReal(_YReal + _RegenText->getY()); + _RegenText->setRenderLayer(_RenderLayer+2); + + // TODO: create shader for this + if (_RegenTextOutline) + { + // player.xml t_bonus_text template way of drawing + sint x = _RegenText->getXReal(); + sint y = _RegenText->getYReal(); + + _RegenText->setColor(_RegenTextShadowColor); + _RegenText->setXReal(x-1); _RegenText->setYReal(y+0); _RegenText->draw(); + _RegenText->setXReal(x+1); _RegenText->setYReal(y+0); _RegenText->draw(); + _RegenText->setXReal(x+0); _RegenText->setYReal(y-1); _RegenText->draw(); + _RegenText->setXReal(x+0); _RegenText->setYReal(y+1); _RegenText->draw(); + + _RegenText->setColor(_RegenTextColor); + _RegenText->setXReal(x); _RegenText->setYReal(y); + _RegenText->draw(); + _RegenText->draw(); + } + else + { + _RegenText->draw(); + _RegenText->draw(); + } +} // ---------------------------------------------------------------------------- void CDBCtrlSheet::drawRotatedQuad(CViewRenderer &vr, float angle, float scale, uint renderLayer, uint32 texId, sint32 texWidth, sint32 texHeight) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index f9a85dd05..9f3d04397 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -602,6 +602,16 @@ public: void setRegenTickRange(const CTickRange &tickRange); const CTickRange &getRegenTickRange() const { return _RegenTickRange; } + // Default regen text is displayed on bottom of icon. + void setRegenText(bool b) { _RegenTextEnabled = b; } + void setRegenTextY(sint32 y) { _RegenTextY = y; } + void setRegenTextShadow(bool b) { _RegenTextShadow = b; } + void setRegenTextShadowColor(NLMISC::CRGBA c) { _RegenTextShadowColor = c; } + void setRegenTextOutline(bool b) { _RegenTextOutline = b; } + void setRegenTextOutlineColor(NLMISC::CRGBA c) { _RegenTextOutlineColor = c; } + void setRegenTextFontSize(uint32 s) { _RegenTextFontSize = s; } + void setRegenTextColor(NLMISC::CRGBA c) { _RegenTextColor = c; } + // start notify anim (at the end of regen usually) void startNotifyAnim(); @@ -739,6 +749,16 @@ protected: CTickRange _RegenTickRange; NLGUI::CViewText *_RegenText; uint32 _RegenTextValue; + // + bool _RegenTextEnabled; + bool _RegenTextShadow; + bool _RegenTextOutline; + sint32 _RegenTextY; + uint32 _RegenTextFontSize; + NLMISC::CRGBA _RegenTextShadowColor; + NLMISC::CRGBA _RegenTextOutlineColor; + NLMISC::CRGBA _RegenTextColor; + /// D'n'd sint32 _DragX, _DragY; @@ -852,6 +872,9 @@ private: // gelper to draw the notify animation void drawRotatedQuad(CViewRenderer &vr, float angle, float scale, uint renderLayer, uint32 textureId, sint32 texWidth, sint32 texHeight); + // create and draw regen text over icon + void drawRegenText(); + }; /** User type (used with expression system of the interface, see interface_expr.h, that contains a pointer to a CDBCtrlSheet From 383e362ed75f41f06b415689fda645107479f1fe Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 1 Apr 2021 14:24:15 +0300 Subject: [PATCH 4/5] Show bonus/malus timer text if available --- .../client/src/interface_v3/dbctrl_sheet.cpp | 68 ++++++++-- .../client/src/interface_v3/dbctrl_sheet.h | 13 +- .../dbgroup_list_sheet_bonus_malus.cpp | 127 ++++++++++-------- .../dbgroup_list_sheet_bonus_malus.h | 29 +++- 4 files changed, 164 insertions(+), 73 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 9306003c4..b69a428db 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -547,6 +547,7 @@ CCtrlDraggable(param) _RegenTextEnabled = true; _RegenTextShadow = true; _RegenTextOutline = false; + _RegenTextFctLua = false; _RegenTextY = 2; _RegenTextFontSize = 8; _RegenTextColor = NLMISC::CRGBA::White; @@ -672,6 +673,8 @@ bool CDBCtrlSheet::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) XML_READ_COLOR(cur, "regen_text_color", _RegenTextColor, NLMISC::CRGBA::White); XML_READ_COLOR(cur, "regen_text_shadow_color", _RegenTextShadowColor, NLMISC::CRGBA::Black); XML_READ_COLOR(cur, "regen_text_outline_color", _RegenTextOutlineColor, NLMISC::CRGBA::Black); + XML_READ_STRING(cur, "regen_text_fct", _RegenTextFct, ""); + _RegenTextFctLua = startsWith(_RegenTextFct, "lua:"); updateActualType(); // Init size for Type @@ -2155,13 +2158,13 @@ void CDBCtrlSheet::drawRegenText() _RegenText->setParent(_Parent); _RegenText->setOverflowText(std::string()); _RegenText->setModulateGlobalColor(false); - _RegenText->setMultiLine(false); + _RegenText->setMultiLine(true); _RegenText->setTextMode(CViewText::ClipWord); _RegenText->setFontSize(_RegenTextFontSize); _RegenText->setColor(_RegenTextColor); // do not set shadow if outline is set to avoid clearing it on draw (would call invalidate) _RegenText->setShadow(_RegenTextShadow && !_RegenTextOutline); - _RegenText->setShadowOutline(false);//_RegenTextOutline); + _RegenText->setShadowOutline(false); _RegenText->setShadowColor(_RegenTextShadowColor); _RegenText->setActive(true); @@ -2169,29 +2172,62 @@ void CDBCtrlSheet::drawRegenText() } // TODO: 10 hardcoded (ticks in second) - uint32 nextValue = _RegenTickRange.EndTick > LastGameCycle ? (_RegenTickRange.EndTick - LastGameCycle) / 10 : 0; + sint32 nextValue; + if (_RegenTickRange.EndTick > LastGameCycle) + nextValue = (_RegenTickRange.EndTick - LastGameCycle) / 10; + else if (_RegenTextFctLua) + nextValue = ((sint64)_RegenTickRange.EndTick - (sint64)LastGameCycle) / 10; + else + nextValue = 0; + if (_RegenTextValue != nextValue) { _RegenTextValue = nextValue; - // format as "10m", "9'59", "59" - if (_RegenTextValue > 600) - { - _RegenText->setText(toString("%dm", _RegenTextValue / 60)); - } - else if (_RegenTextValue > 0) + if (_RegenTextFct.empty()) { - if (_RegenTextValue < 60) - _RegenText->setText(toString("%d", _RegenTextValue)); + // format as "10m", "9'59", "59" + if (_RegenTextValue > 600) + { + _RegenText->setText(toString("%dm", _RegenTextValue / 60)); + } + else if (_RegenTextValue > 0) + { + if (_RegenTextValue < 60) + _RegenText->setText(toString("%d", _RegenTextValue)); + else + _RegenText->setText(toString("%d'%02d", _RegenTextValue / 60, _RegenTextValue % 60)); + } else - _RegenText->setText(toString("%d'%02d", _RegenTextValue / 60, _RegenTextValue % 60)); + { + _RegenText->setText(ucstring()); + } } else { - _RegenText->setText(ucstring()); + std::string fct; + if (_RegenTextFctLua) + { + CCDBNodeBranch *root = getRootBranch(); + if (root) + fct = toString("%s(%d, '%s')", _RegenTextFct.c_str(), _RegenTextValue, root->getFullName().c_str()); + else + fct = toString("%s(%d, nil)", _RegenTextFct.c_str(), _RegenTextValue); + } + else + { + fct = toString("%s(%d)", _RegenTextFct.c_str(), _RegenTextValue); + } + + // if using color tags in format, then RegenText color should be set to CRGBA::White + // as tag color is modulated with main color + std::string result; + if (CInterfaceExpr::evalAsString(fct, result)) + _RegenText->setTextFormatTaged(result); } _RegenText->updateTextContext(); // todo: posref + // note: if x,y is moved outside icon area it might get cliped and not be visible (wreal/hreal == 0) _RegenText->setX(_WReal / 2 -_RegenText->getMaxUsedW() / 2); // move RegenTextY=0 to baseline _RegenText->setY(_RegenTextY - _RegenText->getFontLegHeight()); @@ -4813,6 +4849,12 @@ std::string CDBCtrlSheet::getContextHelpWindowName() const return CCtrlBase::getContextHelpWindowName(); } +// *************************************************************************** +void CDBCtrlSheet::setRegenTextFct(const std::string &s) +{ + _RegenTextFct = s; + _RegenTextFctLua = startsWith(s, "lua:"); +} // *************************************************************************** void CDBCtrlSheet::setRegenTickRange(const CTickRange &tickRange) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index 9f3d04397..6b0e08ee6 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -604,6 +604,15 @@ public: // Default regen text is displayed on bottom of icon. void setRegenText(bool b) { _RegenTextEnabled = b; } + // Allow to override default formatter. + // First parameter will be replaced with current timer value (always >= 0) + // If its a lua function, then parameters are + // 1: current timer value; can be negative + // 2: DB path for ctrl root (ie UI:VARIABLES:BONUSES:0), or nil + // + // ie: "secondsToTimeStringShort" -> CInterfaceExpr::evalAsString("secondsToTimeStringShort(123)", ret) + // ie: "lua:secondsToTimeStringShort" -> CInterfaceExpr::evalAsString("lua:secondsToTimeStringShort(123, 'UI:VARIABLES:BONUSES:0')", ret) + void setRegenTextFct(const std::string &s); void setRegenTextY(sint32 y) { _RegenTextY = y; } void setRegenTextShadow(bool b) { _RegenTextShadow = b; } void setRegenTextShadowColor(NLMISC::CRGBA c) { _RegenTextShadowColor = c; } @@ -748,8 +757,10 @@ protected: CTickRange _RegenTickRange; NLGUI::CViewText *_RegenText; - uint32 _RegenTextValue; + sint32 _RegenTextValue; // + std::string _RegenTextFct; + bool _RegenTextFctLua; bool _RegenTextEnabled; bool _RegenTextShadow; bool _RegenTextOutline; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp index 175d7339b..f41dd3085 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp @@ -23,7 +23,7 @@ #include "stdpch.h" #include "dbgroup_list_sheet_bonus_malus.h" #include "interface_manager.h" - +#include "nel/misc/xml_macros.h" using namespace std; using namespace NLMISC; @@ -35,87 +35,106 @@ NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListSheetBonusMalus, std::string, "lis // *************************************************************************** CDBGroupListSheetBonusMalus::CDBGroupListSheetBonusMalus(const TCtorParam ¶m) -: CDBGroupListSheet(param) +: CDBGroupListSheet(param), + _RegenTextEnabled(true), + _RegenTextY(-14), _RegenTextFontSize(8), + _RegenTextColor(NLMISC::CRGBA::White), + _RegenTextDisabledColor(NLMISC::CRGBA(127,127,127)) { - _TextId= -1; - // want leave space between controls in the list // Yoyo: I think it's better like this, + this is important for space consideration and because of XPCat/PVPOutpost //_ListLeaveSpace= false; } - // *************************************************************************** -bool CDBGroupListSheetBonusMalus::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) +CDBGroupListSheetBonusMalus::CSheetChildTimer::CSheetChildTimer() +: TimerDB(NULL), DisabledDB(NULL), TimerCache(0), + _RegenTextColor(NLMISC::CRGBA::White), + _RegenTextDisabledColor(NLMISC::CRGBA(127,127,127)) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); +} - if(!CDBGroupListSheet::parse(cur, parentGroup)) - return false; +// *************************************************************************** +void CDBGroupListSheetBonusMalus::CSheetChildTimer::init(CDBGroupListSheet *pFather, uint index) +{ + // init my parent + CSheetChild::init(pFather, index); - // read the texture - CXMLAutoPtr prop; - prop = (char*) xmlGetProp( cur, (xmlChar*)"disable_texture" ); - if (prop) + CCDBNodeBranch *root = Ctrl->getRootBranch(); + if (root) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - _TextId= rVR.getTextureIdFromName ((const char *)prop); + TimerDB = dynamic_cast(root->getNode(ICDBNode::CTextId("DISABLED_TIME"), false)); + DisabledDB = dynamic_cast(root->getNode(ICDBNode::CTextId("DISABLED"), false)); } - // get the Node leaves to be tested each frame - uint i= 0; - for(;;) + if (Ctrl) { - string db= toString("%s:%d:" DISABLE_LEAF, _DbBranchName.c_str(), i); - CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(db, false); - if(!node) + CDBGroupListSheetBonusMalus *owner = dynamic_cast(pFather); + if (owner) { - break; + _RegenTextColor = owner->_RegenTextColor; + _RegenTextDisabledColor = owner->_RegenTextDisabledColor; + Ctrl->setRegenText(owner->_RegenTextEnabled); + Ctrl->setRegenTextY(owner->_RegenTextY); + Ctrl->setRegenTextColor(owner->_RegenTextColor); + Ctrl->setRegenTextFontSize(owner->_RegenTextFontSize); + if (!owner->_RegenTextFct.empty()) + Ctrl->setRegenTextFct(owner->_RegenTextFct); } - else - { - _DisableStates.push_back(node); - i++; - } - } - return true; + Ctrl->setRegenTextOutline(true); + } } // *************************************************************************** -void CDBGroupListSheetBonusMalus::draw () +void CDBGroupListSheetBonusMalus::CSheetChildTimer::update(CDBGroupListSheet * /* pFather */) { - CDBGroupListSheet::draw(); - -// CInterfaceManager *pIM= CInterfaceManager::getInstance(); -// CViewRenderer &rVR= *CViewRenderer::getInstance(); - -// sint32 drl= getRenderLayer()+1; + if(!TimerDB) + return; - // May draw disable bitmaps on the ctrl sheets if disabled. - uint numCtrls= (uint)min(_SheetChildren.size(), _DisableStates.size()); - for(uint i=0;igetValue32(); + if (TimerCache != tick) { - CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl; - // if the ctrl is displayed, and if the state is disabled - if(ctrl->getActive()) + TimerCache = TimerDB->getValue32(); + Ctrl->setRegenTickRange(CTickRange(LastGameCycle, TimerCache)); + if (DisabledDB) { - if(_DisableStates[i]->getValue32()!=0) + if (DisabledDB->getValue32() == 0) { - ctrl->setGrayed(true); - /* - // YOYO: for now, don't display the gray bitmap. cross not cool. - CRGBA crossColor= ctrl->getSheetColor(); - crossColor.A>>= 2; - // Draw the disable bitmap on this control. +1 for the slot (ugly) - rVR.drawRotFlipBitmap(drl, ctrl->getXReal()+1, ctrl->getYReal()+1, - CCtrlSheetInfo::BrickSheetWidth, CCtrlSheetInfo::BrickSheetHeight, 0, 0, _TextId, crossColor); - */ + // active timer + Ctrl->setGrayed(false); + Ctrl->setRegenTextColor(_RegenTextColor); } else - ctrl->setGrayed(false); + { + // skill disabled timer + Ctrl->setGrayed(true); + Ctrl->setRegenTextColor(_RegenTextDisabledColor); + } + } + else + { + Ctrl->setGrayed(true); } } } +// *************************************************************************** +bool CDBGroupListSheetBonusMalus::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) +{ + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + + if(!CDBGroupListSheet::parse(cur, parentGroup)) + return false; + + CXMLAutoPtr prop; + XML_READ_BOOL(cur, "regen_text", _RegenTextEnabled, true); + XML_READ_SINT(cur, "regen_text_y", _RegenTextY, -14); + XML_READ_UINT(cur, "regen_text_fontsize", _RegenTextFontSize, 8); + XML_READ_COLOR(cur, "regen_text_color", _RegenTextColor, NLMISC::CRGBA::White); + XML_READ_COLOR(cur, "regen_text_disabled_color", _RegenTextDisabledColor, NLMISC::CRGBA(127, 127, 127)); + XML_READ_STRING(cur, "regen_text_fct", _RegenTextFct, ""); + + return true; +} + diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h index 05774ec8d..d63e664ed 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h @@ -25,7 +25,6 @@ #include "nel/misc/types_nl.h" #include "dbgroup_list_sheet.h" - // *************************************************************************** /** * Special list_sheet that display some disalbe bitmap if needed according to DB @@ -40,14 +39,34 @@ public: /// Constructor CDBGroupListSheetBonusMalus(const TCtorParam ¶m); - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + // A child node + struct CSheetChildTimer : public CDBGroupListSheet::CSheetChild + { + CSheetChildTimer(); + virtual void init(CDBGroupListSheet *pFather, uint index) NL_OVERRIDE; + virtual void update(CDBGroupListSheet *pFather) NL_OVERRIDE; + + NLMISC::CCDBNodeLeaf *TimerDB; + NLMISC::CCDBNodeLeaf *DisabledDB; + uint TimerCache; + + NLMISC::CRGBA _RegenTextColor; + NLMISC::CRGBA _RegenTextDisabledColor; + }; + + virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup) NL_OVERRIDE; - virtual void draw (); + virtual CSheetChild *createSheetChild() NL_OVERRIDE { return new CSheetChildTimer; } private: - sint32 _TextId; + friend CSheetChildTimer; - std::vector _DisableStates; + bool _RegenTextEnabled; + std::string _RegenTextFct; + sint32 _RegenTextY; + uint32 _RegenTextFontSize; + NLMISC::CRGBA _RegenTextColor; + NLMISC::CRGBA _RegenTextDisabledColor; }; From 26482eef1b8fba8ebefd8d5d4a8a89444f3fb674 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 1 Apr 2021 20:51:57 +0300 Subject: [PATCH 5/5] Revert "Add missing PowerRoot effect families to sheetid conversions table." This reverts commit ff9aa6c6081a61444cb36a3e79e49c92d0abf084. --- .../ryzom/common/src/game_share/effect_families.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/code/ryzom/common/src/game_share/effect_families.cpp b/code/ryzom/common/src/game_share/effect_families.cpp index 391626393..8d00cf200 100644 --- a/code/ryzom/common/src/game_share/effect_families.cpp +++ b/code/ryzom/common/src/game_share/effect_families.cpp @@ -323,19 +323,6 @@ namespace EFFECT_FAMILIES { "thorn_wall_aura.sbrick", PowerThornWall }, { "water_wall_aura.sbrick", PowerWaterWall }, { "lightning_wall_aura.sbrick", PowerLightningWall }, - - { "life_aura.sbrick", PowerRootLifeAura }, - { "stamina_aura.sbrick", PowerRootStaminaAura }, - { "sap_aura.sbrick", PowerRootSapAura }, - { "umbrella_aura.sbrick", PowerRootUmbrella }, - { "melee_protection_aura.sbrick", PowerRootProtection }, - { "anti_magic_shield_aura.sbrick", PowerRootAntiMagicShield }, - { "war_cry_aura.sbrick", PowerRootWarCry }, - { "fire_wall_aura.sbrick", PowerRootFireWall }, - { "thorn_wall_aura.sbrick", PowerRootThornWall }, - { "water_wall_aura.sbrick", PowerRootWaterWall }, - { "lightning_wall_aura.sbrick", PowerRootLightningWall }, - { "chg_charac.sbrick", PowerChgCharac }, { "mod_defense.sbrick", PowerModDefenseSkill }, { "mod_dodge.sbrick", PowerModDodgeSkill },