From 744b6e62e1252ca50445b21f671ad8d81dd28ea1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 27 Apr 2014 14:50:47 +0300 Subject: Add AttributeListener. --- src/gui/windows/ministatuswindow.cpp | 52 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'src/gui/windows/ministatuswindow.cpp') diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index 93a6a6a10..6fb330bbf 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -55,6 +55,7 @@ typedef std::vector ::const_iterator ProgressBarVectorCIter; MiniStatusWindow::MiniStatusWindow() : Window("MiniStatus", false, nullptr, "ministatus.xml"), InventoryListener(), + AttributeListener(), mBars(), mBarNames(), mIcons(), @@ -253,35 +254,40 @@ void MiniStatusWindow::drawIcons(Graphics *const graphics) void MiniStatusWindow::processEvent(const Channels channel A_UNUSED, const DepricatedEvent &event) { - if (event.getName() == EVENT_UPDATEATTRIBUTE) + if (event.getName() == EVENT_UPDATESTAT) { - const int id = event.getInt("id"); - if (id == PlayerInfo::HP || id == PlayerInfo::MAX_HP) - { + statusWindow->updateMPBar(mMpBar); + StatusWindow::updateJobBar(mJobBar); + } +} + +void MiniStatusWindow::attributeChanged(const int id, + const int oldVal A_UNUSED, + const int newVal A_UNUSED) +{ + switch (id) + { + case PlayerInfo::HP: + case PlayerInfo::MAX_HP: StatusWindow::updateHPBar(mHpBar); - } - else if (id == PlayerInfo::MP || id == PlayerInfo::MAX_MP) - { + break; + case PlayerInfo::MP: + case PlayerInfo::MAX_MP: statusWindow->updateMPBar(mMpBar); - } - else if (id == PlayerInfo::EXP || id == PlayerInfo::EXP_NEEDED) - { + break; + case PlayerInfo::EXP: + case PlayerInfo::EXP_NEEDED: StatusWindow::updateXPBar(mXpBar); - } - else if (id == PlayerInfo::TOTAL_WEIGHT - || id == PlayerInfo::MAX_WEIGHT) - { + break; + case PlayerInfo::TOTAL_WEIGHT: + case PlayerInfo::MAX_WEIGHT: StatusWindow::updateWeightBar(mWeightBar); - } - else if (id == PlayerInfo::MONEY) - { + break; + case PlayerInfo::MONEY: StatusWindow::updateMoneyBar(mMoneyBar); - } - } - else if (event.getName() == EVENT_UPDATESTAT) - { - statusWindow->updateMPBar(mMpBar); - StatusWindow::updateJobBar(mJobBar); + break; + default: + break; } } -- cgit v1.2.3-60-g2f50