summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/statuswindow.cpp1
-rw-r--r--src/localplayer.cpp18
-rw-r--r--src/localplayer.h8
-rw-r--r--src/playerinfo.cpp30
-rw-r--r--src/playerinfo.h2
5 files changed, 45 insertions, 14 deletions
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 5ba7fdea..6114cc41 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -260,6 +260,7 @@ void StatusWindow::event(const std::string &channel, const Mana::Event &event)
else if (event.getName() == "UpdateStat")
{
int id = event.getInt("id");
+
if (id == Net::getPlayerHandler()->getJobLocation())
{
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index b2061643..0aa76f51 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -24,6 +24,7 @@
#include "client.h"
#include "configuration.h"
#include "effectmanager.h"
+#include "event.h"
#include "flooritem.h"
#include "graphics.h"
#include "guild.h"
@@ -1144,6 +1145,23 @@ void LocalPlayer::optionChanged(const std::string &value)
}
}
+void LocalPlayer::event(const std::string &channel, const Mana::Event &event)
+{
+ if (channel == "Attributes")
+ {
+ if (event.getName() == "UpdateAttribute")
+ {
+ if (event.getInt("id") == EXP)
+ {
+ int change = event.getInt("newValue")
+ - event.getInt("oldValue");
+
+ addMessageToQueue(toString(change) + " xp");
+ }
+ }
+ }
+}
+
void LocalPlayer::changeAwayMode()
{
mAwayMode = !mAwayMode;
diff --git a/src/localplayer.h b/src/localplayer.h
index 2bcf90f8..99c3acf5 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -22,8 +22,9 @@
#ifndef LOCALPLAYER_H
#define LOCALPLAYER_H
-#include "being.h"
#include "actorspritelistener.h"
+#include "being.h"
+#include "listener.h"
#include "gui/userpalette.h"
@@ -48,7 +49,8 @@ class AwayListener : public gcn::ActionListener
/**
* The local player character.
*/
-class LocalPlayer : public Being, public ActorSpriteListener
+class LocalPlayer : public Being, public ActorSpriteListener,
+ public Mana::Listener
{
public:
/**
@@ -202,6 +204,8 @@ class LocalPlayer : public Being, public ActorSpriteListener
*/
void optionChanged(const std::string &value);
+ void event(const std::string &channel, const Mana::Event &event);
+
/**
* set a following player by right clicking.
*/
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index e63db6cf..24cbe0ce 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -50,15 +50,16 @@ int mLevelProgress = 0;
// --- Triggers ---------------------------------------------------------------
-void triggerAttr(int id)
+void triggerAttr(int id, int old)
{
Mana::Event event("UpdateAttribute");
event.setInt("id", id);
- event.setInt("value", mData.mAttributes.find(id)->second);
+ event.setInt("oldValue", old);
+ event.setInt("newValue", mData.mAttributes.find(id)->second);
Mana::EventManager::trigger("Attributes", event);
}
-void triggerStat(int id)
+void triggerStat(int id, const std::string &changed, int old1, int old2 = 0)
{
StatMap::iterator it = mData.mStats.find(id);
Mana::Event event("UpdateStat");
@@ -66,7 +67,10 @@ void triggerStat(int id)
event.setInt("base", it->second.base);
event.setInt("mod", it->second.mod);
event.setInt("exp", it->second.exp);
- event.setInt("expneeded", it->second.expneed);
+ event.setInt("expNeeded", it->second.expNeed);
+ event.setString("changed", changed);
+ event.setInt("oldValue1", old1);
+ event.setInt("oldValue2", old2);
Mana::EventManager::trigger("Attributes", event);
}
@@ -83,9 +87,10 @@ int getAttribute(int id)
void setAttribute(int id, int value, bool notify)
{
+ int old = mData.mAttributes[id];
mData.mAttributes[id] = value;
if (notify)
- triggerAttr(id);
+ triggerAttr(id, old);
}
// --- Stats ------------------------------------------------------------------
@@ -101,14 +106,14 @@ int getStatBase(int id)
void setStatBase(int id, int value, bool notify)
{
+ int old = mData.mStats[id].base;
mData.mStats[id].base = value;
if (notify)
- triggerStat(id);
+ triggerStat(id, "base", old);
}
int getStatMod(int id)
{
-
StatMap::const_iterator it = mData.mStats.find(id);
if (it != mData.mStats.end())
return it->second.mod;
@@ -118,9 +123,10 @@ int getStatMod(int id)
void setStatMod(int id, int value, bool notify)
{
+ int old = mData.mStats[id].mod;
mData.mStats[id].mod = value;
if (notify)
- triggerStat(id);
+ triggerStat(id, "mod", old);
}
int getStatEffective(int id)
@@ -139,7 +145,7 @@ std::pair<int, int> getStatExperience(int id)
if (it != mData.mStats.end())
{
a = it->second.exp;
- b = it->second.expneed;
+ b = it->second.expNeed;
}
else
{
@@ -151,10 +157,12 @@ std::pair<int, int> getStatExperience(int id)
void setStatExperience(int id, int have, int need, bool notify)
{
+ int oldExp = mData.mStats[id].exp;
+ int oldExpNeed = mData.mStats[id].expNeed;
mData.mStats[id].exp = have;
- mData.mStats[id].expneed = need;
+ mData.mStats[id].expNeed = need;
if (notify)
- triggerStat(id);
+ triggerStat(id, "exp", oldExp, oldExpNeed);
}
// --- Inventory / Equipment --------------------------------------------------
diff --git a/src/playerinfo.h b/src/playerinfo.h
index 1c722a7c..3214e64e 100644
--- a/src/playerinfo.h
+++ b/src/playerinfo.h
@@ -47,7 +47,7 @@ struct Stat
int base;
int mod;
int exp;
- int expneed;
+ int expNeed;
};
typedef std::map<int, int> IntMap;