diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp index 175d7339b..5fb68745c 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp +++ b/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,102 @@ NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListSheetBonusMalus, std::string, "lis // *************************************************************************** CDBGroupListSheetBonusMalus::CDBGroupListSheetBonusMalus(const TCtorParam ¶m) -: CDBGroupListSheet(param) +: CDBGroupListSheet(param), + _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); } - 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)); + + return true; +} + diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h index 05774ec8d..c70e9f465 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h +++ b/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,33 @@ 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; + sint32 _RegenTextY; + uint32 _RegenTextFontSize; + NLMISC::CRGBA _RegenTextColor; + NLMISC::CRGBA _RegenTextDisabledColor; };