summaryrefslogtreecommitdiff
path: root/src/gui/windows/statuswindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-04-27 16:24:12 +0300
committerAndrei Karas <akaras@inbox.ru>2014-04-27 16:24:12 +0300
commita6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0 (patch)
treebd1e6b6a1cdb42b5e6d4489158d438fe8c05f533 /src/gui/windows/statuswindow.cpp
parentaf0ae4d0b7c56d540639bb1f4ba7cc458ec718c1 (diff)
downloadmanaverse-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.tar.gz
manaverse-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.tar.bz2
manaverse-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.tar.xz
manaverse-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.zip
Add StatListener.
Diffstat (limited to 'src/gui/windows/statuswindow.cpp')
-rw-r--r--src/gui/windows/statuswindow.cpp88
1 files changed, 41 insertions, 47 deletions
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 5897ae64b..53abb7fdf 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -145,6 +145,7 @@ StatusWindow::StatusWindow() :
"?", false, nullptr, "status.xml"),
ActionListener(),
AttributeListener(),
+ StatListener(),
// TRANSLATORS: status window label
mLvlLabel(new Label(this, strprintf(_("Level: %d"), 0))),
// TRANSLATORS: status window label
@@ -170,8 +171,6 @@ StatusWindow::StatusWindow() :
mCopyButton(new Button(this, _("Copy to chat"), "copy", this)),
mAttrs()
{
- listen(CHANNEL_ATTRIBUTES);
-
setWindowName("Status");
if (setupWindow)
setupWindow->registerWindowForReset(this);
@@ -335,68 +334,63 @@ StatusWindow::StatusWindow() :
mLvlLabel->adjustSize();
}
-void StatusWindow::processEvent(const Channels channel A_UNUSED,
- const DepricatedEvent &event)
+void StatusWindow::statChanged(const int id,
+ const int oldVal1,
+ const int oldVal2 A_UNUSED)
{
static bool blocked = false;
if (blocked)
return;
- const DepricatedEvents &eventName = event.getName();
- if (eventName == EVENT_UPDATESTAT)
+ if (id == Net::getPlayerHandler()->getJobLocation())
{
- const int id = event.getInt("id");
- if (id == Net::getPlayerHandler()->getJobLocation())
+ if (mJobLvlLabel)
{
- if (mJobLvlLabel)
- {
- int lvl = PlayerInfo::getStatBase(id);
- const int oldExp = event.getInt("oldValue1");
- const std::pair<int, int> exp
- = PlayerInfo::getStatExperience(id);
+ int lvl = PlayerInfo::getStatBase(id);
+ const int oldExp = oldVal1;
+ const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
- if (!lvl)
+ if (!lvl)
+ {
+ // possible server broken and don't send job level,
+ // then we fixing it :)
+ if (exp.second < 20000)
{
- // possible server broken and don't send job level,
- // then we fixing it :)
- if (exp.second < 20000)
- {
- lvl = 0;
- }
- else
- {
- lvl = (exp.second - 20000) / 150;
- blocked = true;
- PlayerInfo::setStatBase(id, lvl);
- blocked = false;
- }
+ lvl = 0;
}
-
- if (exp.first < oldExp && exp.second >= 20000)
- { // possible job level up. but server broken and don't send
- // new job exp limit, we fixing it
- lvl ++;
+ else
+ {
+ lvl = (exp.second - 20000) / 150;
blocked = true;
- PlayerInfo::setStatExperience(
- id, exp.first, 20000 + lvl * 150);
PlayerInfo::setStatBase(id, lvl);
blocked = false;
}
+ }
- // TRANSLATORS: status window label
- mJobLvlLabel->setCaption(strprintf(_("Job: %d"), lvl));
- mJobLvlLabel->adjustSize();
-
- updateProgressBar(mJobBar, id, false);
+ if (exp.first < oldExp && exp.second >= 20000)
+ { // possible job level up. but server broken and don't send
+ // new job exp limit, we fixing it
+ lvl ++;
+ blocked = true;
+ PlayerInfo::setStatExperience(
+ id, exp.first, 20000 + lvl * 150);
+ PlayerInfo::setStatBase(id, lvl);
+ blocked = false;
}
+
+ // TRANSLATORS: status window label
+ mJobLvlLabel->setCaption(strprintf(_("Job: %d"), lvl));
+ mJobLvlLabel->adjustSize();
+
+ updateProgressBar(mJobBar, id, false);
}
- else
- {
- updateMPBar(mMpBar, true);
- const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
- it->second->update();
- }
+ }
+ else
+ {
+ updateMPBar(mMpBar, true);
+ const Attrs::const_iterator it = mAttrs.find(id);
+ if (it != mAttrs.end() && it->second)
+ it->second->update();
}
}