Show bonus/malus timer text if available

feature/develop-atys
Nimetu 4 years ago
parent d210c23b26
commit 27826eb448

@ -23,7 +23,7 @@
#include "stdpch.h" #include "stdpch.h"
#include "dbgroup_list_sheet_bonus_malus.h" #include "dbgroup_list_sheet_bonus_malus.h"
#include "interface_manager.h" #include "interface_manager.h"
#include "nel/misc/xml_macros.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -35,87 +35,102 @@ NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListSheetBonusMalus, std::string, "lis
// *************************************************************************** // ***************************************************************************
CDBGroupListSheetBonusMalus::CDBGroupListSheetBonusMalus(const TCtorParam &param) CDBGroupListSheetBonusMalus::CDBGroupListSheetBonusMalus(const TCtorParam &param)
: 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 // 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 // Yoyo: I think it's better like this, + this is important for space consideration and because of XPCat/PVPOutpost
//_ListLeaveSpace= false; //_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 CCDBNodeBranch *root = Ctrl->getRootBranch();
CXMLAutoPtr prop; if (root)
prop = (char*) xmlGetProp( cur, (xmlChar*)"disable_texture" );
if (prop)
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance(); TimerDB = dynamic_cast<CCDBNodeLeaf *>(root->getNode(ICDBNode::CTextId("DISABLED_TIME"), false));
CViewRenderer &rVR = *CViewRenderer::getInstance(); DisabledDB = dynamic_cast<CCDBNodeLeaf *>(root->getNode(ICDBNode::CTextId("DISABLED"), false));
_TextId= rVR.getTextureIdFromName ((const char *)prop);
} }
// get the Node leaves to be tested each frame if (Ctrl)
uint i= 0;
for(;;)
{
string db= toString("%s:%d:" DISABLE_LEAF, _DbBranchName.c_str(), i);
CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(db, false);
if(!node)
{ {
break; CDBGroupListSheetBonusMalus *owner = dynamic_cast<CDBGroupListSheetBonusMalus *>(pFather);
} if (owner)
else
{ {
_DisableStates.push_back(node); _RegenTextColor = owner->_RegenTextColor;
i++; _RegenTextDisabledColor = owner->_RegenTextDisabledColor;
} Ctrl->setRegenText(owner->_RegenTextEnabled);
Ctrl->setRegenTextY(owner->_RegenTextY);
Ctrl->setRegenTextColor(owner->_RegenTextColor);
Ctrl->setRegenTextFontSize(owner->_RegenTextFontSize);
} }
return true; Ctrl->setRegenTextOutline(true);
}
} }
// *************************************************************************** // ***************************************************************************
void CDBGroupListSheetBonusMalus::draw () void CDBGroupListSheetBonusMalus::CSheetChildTimer::update(CDBGroupListSheet * /* pFather */)
{ {
CDBGroupListSheet::draw(); if(!TimerDB)
return;
// CInterfaceManager *pIM= CInterfaceManager::getInstance();
// CViewRenderer &rVR= *CViewRenderer::getInstance();
// sint32 drl= getRenderLayer()+1; NLMISC::TGameCycle tick = TimerDB->getValue32();
if (TimerCache != tick)
// May draw disable bitmaps on the ctrl sheets if disabled.
uint numCtrls= (uint)min(_SheetChildren.size(), _DisableStates.size());
for(uint i=0;i<numCtrls;i++)
{ {
CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl; TimerCache = TimerDB->getValue32();
// if the ctrl is displayed, and if the state is disabled Ctrl->setRegenTickRange(CTickRange(LastGameCycle, TimerCache));
if(ctrl->getActive()) if (DisabledDB)
{ {
if(_DisableStates[i]->getValue32()!=0) if (DisabledDB->getValue32() == 0)
{ {
ctrl->setGrayed(true); // active timer
/* Ctrl->setGrayed(false);
// YOYO: for now, don't display the gray bitmap. cross not cool. Ctrl->setRegenTextColor(_RegenTextColor);
CRGBA crossColor= ctrl->getSheetColor(); }
crossColor.A>>= 2; else
// Draw the disable bitmap on this control. +1 for the slot (ugly) {
rVR.drawRotFlipBitmap(drl, ctrl->getXReal()+1, ctrl->getYReal()+1, // skill disabled timer
CCtrlSheetInfo::BrickSheetWidth, CCtrlSheetInfo::BrickSheetHeight, 0, 0, _TextId, crossColor); Ctrl->setGrayed(true);
*/ Ctrl->setRegenTextColor(_RegenTextDisabledColor);
}
} }
else else
ctrl->setGrayed(false); {
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;
} }

@ -25,7 +25,6 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "dbgroup_list_sheet.h" #include "dbgroup_list_sheet.h"
// *************************************************************************** // ***************************************************************************
/** /**
* Special list_sheet that display some disalbe bitmap if needed according to DB * Special list_sheet that display some disalbe bitmap if needed according to DB
@ -40,14 +39,33 @@ public:
/// Constructor /// Constructor
CDBGroupListSheetBonusMalus(const TCtorParam &param); CDBGroupListSheetBonusMalus(const TCtorParam &param);
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: private:
sint32 _TextId; friend CSheetChildTimer;
std::vector<NLMISC::CCDBNodeLeaf*> _DisableStates; bool _RegenTextEnabled;
sint32 _RegenTextY;
uint32 _RegenTextFontSize;
NLMISC::CRGBA _RegenTextColor;
NLMISC::CRGBA _RegenTextDisabledColor;
}; };

Loading…
Cancel
Save