summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-08-12 21:47:59 -0600
committerJared Adams <jaxad0127@gmail.com>2010-08-12 22:01:57 -0600
commiteb2c0cae1cb7a02b72c15de0f4e8f4a68a9fa53a (patch)
tree8b1fab9acbd0eb568d7f7e0b31f8fd4ac02b18a4 /src
parent2293b1c5ef0bb7378140bf73f1fef03a4504bdd2 (diff)
downloadmana-eb2c0cae1cb7a02b72c15de0f4e8f4a68a9fa53a.tar.gz
mana-eb2c0cae1cb7a02b72c15de0f4e8f4a68a9fa53a.tar.bz2
mana-eb2c0cae1cb7a02b72c15de0f4e8f4a68a9fa53a.tar.xz
mana-eb2c0cae1cb7a02b72c15de0f4e8f4a68a9fa53a.zip
Simplify working with the event system
EventManager has been merged into Event, with some new convinience methods added. Reviewed-by: Chuck Miller
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/actorsprite.cpp6
-rw-r--r--src/being.cpp4
-rw-r--r--src/client.cpp4
-rw-r--r--src/event.cpp40
-rw-r--r--src/event.h52
-rw-r--r--src/eventmanager.cpp67
-rw-r--r--src/eventmanager.h62
-rw-r--r--src/game.cpp20
-rw-r--r--src/gui/npcdialog.cpp24
-rw-r--r--src/gui/npcpostdialog.cpp4
-rw-r--r--src/gui/recorder.cpp2
-rw-r--r--src/gui/socialwindow.cpp2
-rw-r--r--src/gui/trade.cpp2
-rw-r--r--src/listener.cpp8
-rw-r--r--src/localplayer.cpp2
-rw-r--r--src/net/manaserv/chathandler.cpp8
-rw-r--r--src/net/manaserv/guildhandler.cpp2
-rw-r--r--src/net/manaserv/npchandler.cpp20
-rw-r--r--src/net/manaserv/partyhandler.cpp2
-rw-r--r--src/net/manaserv/playerhandler.cpp4
-rw-r--r--src/net/manaserv/tradehandler.cpp2
-rw-r--r--src/net/tmwa/adminhandler.cpp2
-rw-r--r--src/net/tmwa/buysellhandler.cpp2
-rw-r--r--src/net/tmwa/chathandler.cpp14
-rw-r--r--src/net/tmwa/gamehandler.cpp2
-rw-r--r--src/net/tmwa/guildhandler.cpp2
-rw-r--r--src/net/tmwa/inventoryhandler.cpp2
-rw-r--r--src/net/tmwa/npchandler.cpp16
-rw-r--r--src/net/tmwa/partyhandler.cpp2
-rw-r--r--src/net/tmwa/playerhandler.cpp4
-rw-r--r--src/net/tmwa/specialhandler.cpp2
-rw-r--r--src/net/tmwa/tradehandler.cpp2
-rw-r--r--src/playerinfo.cpp16
-rw-r--r--src/statuseffect.cpp2
36 files changed, 184 insertions, 225 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ba929208..4a442bd6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -443,8 +443,6 @@ SET(SRCS
equipment.h
event.cpp
event.h
- eventmanager.cpp
- eventmanager.h
flooritem.cpp
flooritem.h
game.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 6de1e6dd..fb3c7327 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -342,8 +342,6 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
equipment.h \
event.cpp \
event.h \
- eventmanager.cpp \
- eventmanager.h \
flooritem.cpp \
flooritem.h \
game.cpp \
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 535708f0..cdc23dc6 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -23,7 +23,7 @@
#include "client.h"
#include "effectmanager.h"
-#include "eventmanager.h"
+#include "event.h"
#include "imagesprite.h"
#include "localplayer.h"
#include "log.h"
@@ -264,7 +264,7 @@ void ActorSprite::updateStunMode(int oldMode, int newMode)
Mana::Event event("Stun");
event.setInt("oldMode", oldMode);
event.setInt("newMode", newMode);
- Mana::EventManager::trigger("ActorSprite", event);
+ event.trigger("ActorSprite");
}
handleStatusEffect(StatusEffect::getStatusEffect(oldMode, false), -1);
@@ -278,7 +278,7 @@ void ActorSprite::updateStatusEffect(int index, bool newStatus)
Mana::Event event("UpdateStatusEffect");
event.setInt("index", index);
event.setBool("newStatus", newStatus);
- Mana::EventManager::trigger("ActorSprite", event);
+ event.trigger("ActorSprite");
}
handleStatusEffect(StatusEffect::getStatusEffect(index, newStatus), index);
diff --git a/src/being.cpp b/src/being.cpp
index 9c56dec3..1b95b17d 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -26,7 +26,7 @@
#include "client.h"
#include "configuration.h"
#include "effectmanager.h"
-#include "eventmanager.h"
+#include "event.h"
#include "graphics.h"
#include "guild.h"
#include "localplayer.h"
@@ -1200,7 +1200,7 @@ void Being::talkTo()
{
Mana::Event event("doTalk");
event.setInt("npcId", mId);
- Mana::EventManager::trigger("NPC", event);
+ event.trigger("NPC");
}
void Being::event(const std::string &channel, const Mana::Event &event)
diff --git a/src/client.cpp b/src/client.cpp
index 4209e2fa..1e1d17a9 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -25,7 +25,7 @@
#include "chatlog.h"
#include "configuration.h"
#include "emoteshortcut.h"
-#include "eventmanager.h"
+#include "event.h"
#include "game.h"
#include "itemshortcut.h"
#include "keyboardconfig.h"
@@ -590,7 +590,7 @@ int Client::exec()
Mana::Event event("StateChange");
event.setInt("oldState", mOldState);
event.setInt("newState", mState);
- Mana::EventManager::trigger("Client", event);
+ event.trigger("Client");
}
if (mOldState == STATE_GAME)
diff --git a/src/event.cpp b/src/event.cpp
index dde04920..38213cd2 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -20,11 +20,14 @@
#include "event.h"
+#include "listener.h"
#include "variabledata.h"
namespace Mana
{
+ListenMap Event::mBindings;
+
Event::~Event()
{
VariableMap::iterator it = mData.begin();
@@ -144,4 +147,41 @@ bool Event::hasBool(const std::string &key) const
|| it->second->getType() != VariableData::DATA_BOOL);
}
+void Event::trigger(const std::string &channel, const Event &event)
+{
+ ListenMap::iterator it = mBindings.find(channel);
+
+ // Make sure something is listening
+ if (it == mBindings.end())
+ return;
+
+ // Loop though all listeners
+ ListenerSet::iterator lit = it->second.begin();
+ while (lit != it->second.end())
+ {
+ (*lit)->event(channel, event);
+ lit++;
+ }
+}
+
+void Event::bind(Listener *listener, const std::string &channel)
+{
+ mBindings[channel].insert(listener);
+}
+
+void Event::unbind(Listener *listener, const std::string &channel)
+{
+ mBindings[channel].erase(listener);
+}
+
+void Event::remove(Listener *listener)
+{
+ ListenMap::iterator it = mBindings.begin();
+ while (it != mBindings.end())
+ {
+ it->second.erase(listener);
+ it++;
+ }
+}
+
} // namespace Mana
diff --git a/src/event.h b/src/event.h
index b27b9c33..68560dae 100644
--- a/src/event.h
+++ b/src/event.h
@@ -23,6 +23,7 @@
#include <string>
#include <map>
+#include <set>
namespace Mana
{
@@ -34,9 +35,19 @@ enum BadEvent {
KEY_ALREADY_EXISTS
};
+class Listener;
+
+typedef std::set<Listener *> ListenerSet;
+typedef std::map<std::string, ListenerSet > ListenMap;
+
class VariableData;
typedef std::map<std::string, VariableData *> VariableMap;
+#define SERVER_NOTICE(message) { \
+Mana::Event event("ServerNotice"); \
+event.setString("message", message); \
+event.trigger("Notices", event); }
+
class Event
{
public:
@@ -144,7 +155,48 @@ public:
*/
bool hasBool(const std::string &key) const;
+ /**
+ * Sends this event to all classes listening to the given channel.
+ */
+ inline void trigger(const std::string &channel) const
+ { trigger(channel, *this); }
+
+ /**
+ * Sends the given event to all classes listening to the given channel.
+ */
+ static void trigger(const std::string &channel, const Event &event);
+
+ /**
+ * Sends an empty event with the given name to all classes listening to the
+ * given channel.
+ */
+ static inline void trigger(const std::string& channel,
+ const std::string& name)
+ { trigger(channel, Mana::Event(name)); }
+
+protected:
+ friend class Listener;
+
+ /**
+ * Binds the given listener to the given channel. The listener will receive
+ * all events triggered on the channel.
+ */
+ static void bind(Listener *listener, const std::string &channel);
+
+ /**
+ * Unbinds the given listener from the given channel. The listener will no
+ * longer receive any events from the channel.
+ */
+ static void unbind(Listener *listener, const std::string &channel);
+
+ /**
+ * Unbinds the given listener from all channels.
+ */
+ static void remove(Listener *listener);
+
private:
+ static ListenMap mBindings;
+
std::string mEventName;
VariableMap mData;
diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp
deleted file mode 100644
index 86b61781..00000000
--- a/src/eventmanager.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2010 The Mana Developers
- *
- * This file is part of The Mana Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "eventmanager.h"
-
-#include "listener.h"
-
-namespace Mana
-{
-
-ListenMap EventManager::mBindings;
-
-void EventManager::trigger(const std::string &channel, const Event &event)
-{
- ListenMap::iterator it = mBindings.find(channel);
-
- // Make sure something is listening
- if (it == mBindings.end())
- return;
-
- // Loop though all listeners
- ListenerSet::iterator lit = it->second.begin();
- while (lit != it->second.end())
- {
- (*lit)->event(channel, event);
- lit++;
- }
-}
-
-void EventManager::remove(Listener *listener)
-{
- ListenMap::iterator it = mBindings.begin();
- while (it != mBindings.end())
- {
- it->second.erase(listener);
- it++;
- }
-}
-
-void EventManager::bind(Listener *listener, const std::string &channel)
-{
- mBindings[channel].insert(listener);
-}
-
-void EventManager::unbind(Listener *listener, const std::string &channel)
-{
- mBindings[channel].erase(listener);
-}
-
-} // namespace Mana
diff --git a/src/eventmanager.h b/src/eventmanager.h
deleted file mode 100644
index ac6c997c..00000000
--- a/src/eventmanager.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2010 The Mana Developers
- *
- * This file is part of The Mana Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef EVENTMANAGER_H
-#define EVENTMANAGER_H
-
-#include "event.h"
-
-#include <string>
-#include <map>
-#include <set>
-
-#define SERVER_NOTICE(message) { \
-Mana::Event event("ServerNotice"); \
-event.setString("message", message); \
-Mana::EventManager::trigger("Notices", event); }
-
-namespace Mana
-{
-
-class Listener;
-
-typedef std::set<Listener *> ListenerSet;
-typedef std::map<std::string, ListenerSet > ListenMap;
-
-class EventManager
-{
-public:
- // Sends event to all listener on the channel
- static void trigger(const std::string &channel, const Event &event);
-
- // Removes a listener from all channels
- static void remove(Listener *listener);
-
- // Adds or removes a listener to a channel.
- static void bind(Listener *listener, const std::string &channel);
- static void unbind(Listener *listener, const std::string &channel);
-
-private:
- static ListenMap mBindings;
-};
-
-} // namespace Mana
-
-#endif
diff --git a/src/game.cpp b/src/game.cpp
index 0994e5e4..18bad69c 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -28,7 +28,7 @@
#include "commandhandler.h"
#include "configuration.h"
#include "effectmanager.h"
-#include "eventmanager.h"
+#include "event.h"
#include "emoteshortcut.h"
#include "graphics.h"
#include "itemshortcut.h"
@@ -129,7 +129,7 @@ ChatTab *localChatTab = NULL;
*/
static void initEngines()
{
- Mana::EventManager::trigger("Game", Mana::Event("EnginesInitalizing"));
+ Mana::Event::trigger("Game", "EnginesInitalizing");
actorSpriteManager = new ActorSpriteManager;
commandHandler = new CommandHandler;
@@ -139,7 +139,7 @@ static void initEngines()
particleEngine = new Particle(NULL);
particleEngine->setupEngine();
- Mana::EventManager::trigger("Game", Mana::Event("EnginesInitalized"));
+ Mana::Event::trigger("Game", "EnginesInitalized");
}
/**
@@ -147,7 +147,7 @@ static void initEngines()
*/
static void createGuiWindows()
{
- Mana::EventManager::trigger("Game", Mana::Event("GuiWindowsLoading"));
+ Mana::Event::trigger("Game", "GuiWindowsLoading");
setupWindow->clearWindowsForReset();
@@ -179,7 +179,7 @@ static void createGuiWindows()
NpcDialog::setup();
- Mana::EventManager::trigger("Game", Mana::Event("GuiWindowsLoaded"));
+ Mana::Event::trigger("Game", "GuiWindowsLoaded");
}
#define del_0(X) { delete X; X = 0; }
@@ -189,7 +189,7 @@ static void createGuiWindows()
*/
static void destroyGuiWindows()
{
- Mana::EventManager::trigger("Game", Mana::Event("GuiWindowsUnloading"));
+ Mana::Event::trigger("Game", "GuiWindowsUnloading");
logger->setChatWindow(NULL);
del_0(localChatTab) // Need to do this first, so it can remove itself
@@ -209,7 +209,7 @@ static void destroyGuiWindows()
del_0(specialsWindow)
del_0(socialWindow)
- Mana::EventManager::trigger("Game", Mana::Event("GuiWindowsUnloaded"));
+ Mana::Event::trigger("Game", "GuiWindowsUnloaded");
}
Game *Game::mInstance = 0;
@@ -261,7 +261,7 @@ Game::Game():
setupWindow->setInGame(true);
- Mana::EventManager::trigger("Game", Mana::Event("Constructed"));
+ Mana::Event::trigger("Game", "Constructed");
}
Game::~Game()
@@ -282,7 +282,7 @@ Game::~Game()
mInstance = 0;
- Mana::EventManager::trigger("Game", Mana::Event("Destructed"));
+ Mana::Event::trigger("Game", "Destructed");
}
static bool saveScreenshot()
@@ -971,5 +971,5 @@ void Game::changeMap(const std::string &mapPath)
Mana::Event event("MapLoaded");
event.setString("mapPath", mapPath);
- Mana::EventManager::trigger("Game", event);
+ event.trigger("Game");
}
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index a14e88eb..935962a0 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -22,7 +22,7 @@
#include "gui/npcdialog.h"
#include "configuration.h"
-#include "eventmanager.h"
+#include "event.h"
#include "listener.h"
#include "playerinfo.h"
@@ -50,10 +50,6 @@
#define NpcEvent(name) Mana::Event event(name);\
event.setInt("npcId", mNpcId);
-#define FireEvent(event) Mana::EventManager::trigger("NPC", event);
-
-#define FireEvent2(name) NpcEvent(name) FireEvent(event)
-
typedef std::map<int, NpcDialog*> NpcDialogs;
class NpcEventListener : public Mana::Listener
@@ -231,7 +227,7 @@ void NpcDialog::action(const gcn::ActionEvent &event)
NpcEvent("doMenu")
event.setInt("choice", selectedIndex + 1);
- FireEvent(event);
+ event.trigger("NPC");
}
else if (mInputState == NPC_INPUT_STRING)
{
@@ -239,7 +235,7 @@ void NpcDialog::action(const gcn::ActionEvent &event)
NpcEvent("doStringInput")
event.setString("value", printText);
- FireEvent(event);
+ event.trigger("NPC");
}
else if (mInputState == NPC_INPUT_INTEGER)
{
@@ -247,7 +243,7 @@ void NpcDialog::action(const gcn::ActionEvent &event)
NpcEvent("doIntegerInput")
event.setInt("value", mIntField->getValue());
- FireEvent(event);
+ event.trigger("NPC");
}
// addText will auto remove the input layout
addText(strprintf("\n> \"%s\"\n", printText.c_str()), false);
@@ -285,12 +281,14 @@ void NpcDialog::action(const gcn::ActionEvent &event)
void NpcDialog::nextDialog()
{
- FireEvent2("doNext")
+ NpcEvent("doNext");
+ event.trigger("NPC");
}
void NpcDialog::closeDialog()
{
- FireEvent2("doClose")
+ NpcEvent("doClose");
+ event.trigger("NPC");
close();
}
@@ -561,7 +559,8 @@ void NpcEventListener::event(const std::string &channel,
if (!dialog)
{
int mNpcId = id;
- FireEvent2("doNext")
+ NpcEvent("doNext");
+ event.trigger("NPC");
return;
}
@@ -575,7 +574,8 @@ void NpcEventListener::event(const std::string &channel,
if (!dialog)
{
int mNpcId = id;
- FireEvent2("doClose")
+ NpcEvent("doClose");
+ event.trigger("NPC");
return;
}
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index c35f77a3..0662515e 100644
--- a/src/gui/npcpostdialog.cpp
+++ b/src/gui/npcpostdialog.cpp
@@ -21,7 +21,7 @@
#include "gui/npcpostdialog.h"
-#include "eventmanager.h"
+#include "event.h"
#include "playerinfo.h"
#include "gui/widgets/button.h"
@@ -101,7 +101,7 @@ void NpcPostDialog::action(const gcn::ActionEvent &event)
event.setInt("npcId", mNpcId);
event.setString("recipient", mSender->getText());
event.setString("text", mText->getText());
- Mana::EventManager::trigger("NPC", event);
+ event.trigger("NPC");
}
setVisible(false);
}
diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp
index 53024e7c..2345369e 100644
--- a/src/gui/recorder.cpp
+++ b/src/gui/recorder.cpp
@@ -21,7 +21,7 @@
#include "gui/recorder.h"
#include "client.h"
-#include "eventmanager.h"
+#include "event.h"
#include "gui/chat.h"
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 8911c8fd..88cd5732 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -20,7 +20,7 @@
#include "gui/socialwindow.h"
-#include "eventmanager.h"
+#include "event.h"
#include "guild.h"
#include "localplayer.h"
#include "party.h"
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 6d3c7b21..bfb61c33 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -21,7 +21,7 @@
#include "gui/trade.h"
-#include "eventmanager.h"
+#include "event.h"
#include "inventory.h"
#include "item.h"
#include "localplayer.h"
diff --git a/src/listener.cpp b/src/listener.cpp
index 5aac7b66..a9182c42 100644
--- a/src/listener.cpp
+++ b/src/listener.cpp
@@ -20,24 +20,24 @@
#include "listener.h"
-#include "eventmanager.h"
+#include "event.h"
namespace Mana
{
Listener::~Listener()
{
- EventManager::remove(this);
+ Event::remove(this);
}
void Listener::listen(const std::string &channel)
{
- EventManager::bind(this, channel);
+ Event::bind(this, channel);
}
void Listener::ignore(const std::string &channel)
{
- EventManager::unbind(this, channel);
+ Event::unbind(this, channel);
}
} // namespace Mana
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 53648725..33a07373 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -24,7 +24,7 @@
#include "client.h"
#include "configuration.h"
#include "effectmanager.h"
-#include "eventmanager.h"
+#include "event.h"
#include "flooritem.h"
#include "graphics.h"
#include "guild.h"
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index 71e4efde..147bab0a 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -26,7 +26,7 @@
#include "client.h"
#include "channel.h"
#include "channelmanager.h"
-#include "eventmanager.h"
+#include "event.h"
#include "playerrelations.h"
#include "gui/widgets/channeltab.h"
@@ -171,7 +171,7 @@ void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
event.setInt("permissions", player_relations
.checkPermissionSilently(being->getName(),
PlayerRelation::SPEECH_LOG | PlayerRelation::SPEECH_FLOAT));
- Mana::EventManager::trigger("Chat", event);
+ event.trigger("Chat");
}
void ChatHandler::handleEnterChannelResponse(Net::MessageIn &msg)
@@ -234,7 +234,7 @@ void ChatHandler::handlePrivateMessage(Net::MessageIn &msg)
Mana::Event event("Whisper");
event.setString("nick", userNick);
event.setString("message", chatMsg);
- Mana::EventManager::trigger("Chat", event);
+ event.trigger("Chat");
}
void ChatHandler::handleAnnouncement(Net::MessageIn &msg)
@@ -242,7 +242,7 @@ void ChatHandler::handleAnnouncement(Net::MessageIn &msg)
std::string chatMsg = msg.readString();
Mana::Event event("Announcement");
event.setString("message", chatMsg);
- Mana::EventManager::trigger("Chat", event);
+ event.trigger("Chat");
}
void ChatHandler::handleChatMessage(Net::MessageIn &msg)
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index 750fadda..821d70bd 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -21,7 +21,7 @@
#include "net/manaserv/guildhandler.h"
-#include "eventmanager.h"
+#include "event.h"
#include "guild.h"
#include "log.h"
#include "localplayer.h"
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index 9f63c837..f7e04c1b 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -22,7 +22,7 @@
#include "net/manaserv/npchandler.h"
#include "actorspritemanager.h"
-#include "eventmanager.h"
+#include "event.h"
#include "net/manaserv/connection.h"
#include "net/manaserv/messagein.h"
@@ -52,7 +52,7 @@ NpcHandler::NpcHandler()
handledMessages = _messages;
npcHandler = this;
- Mana::EventManager::bind(this, "NPC");
+ listen("NPC");
}
void NpcHandler::handleMessage(Net::MessageIn &msg)
@@ -77,7 +77,7 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
event->setString("choice" + toString(count), msg.readString());
}
event->setInt("choiceCount", count);
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
case GPMSG_NPC_NUMBER:
@@ -86,43 +86,43 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
event->setInt("min", msg.readInt32());
event->setInt("max", msg.readInt32());
event->setInt("default", msg.readInt32());
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
case GPMSG_NPC_STRING:
event = new Mana::Event("StringInput");
event->setInt("id", npcId);
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
case GPMSG_NPC_POST:
event = new Mana::Event("Post");
event->setInt("id", npcId);
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
case GPMSG_NPC_ERROR:
event = new Mana::Event("End");
event->setInt("id", npcId);
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
case GPMSG_NPC_MESSAGE:
event = new Mana::Event("Message");
event->setInt("id", npcId);
event->setString("text", msg.readString(msg.getUnreadLength()));
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
delete event;
event = new Mana::Event("Next");
event->setInt("id", npcId);
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
case GPMSG_NPC_CLOSE:
event = new Mana::Event("Close");
event->setInt("id", npcId);
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
}
diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp
index 00bb0fae..370d6496 100644
--- a/src/net/manaserv/partyhandler.cpp
+++ b/src/net/manaserv/partyhandler.cpp
@@ -21,7 +21,7 @@
#include "net/manaserv/partyhandler.h"
-#include "eventmanager.h"
+#include "event.h"
#include "log.h"
#include "localplayer.h"
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 2028afd9..4957bbbc 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -24,7 +24,7 @@
#include "client.h"
#include "effectmanager.h"
-#include "eventmanager.h"
+#include "event.h"
#include "game.h"
#include "localplayer.h"
#include "log.h"
@@ -60,7 +60,7 @@ void RespawnRequestListener::action(const gcn::ActionEvent &event)
{
Net::getPlayerHandler()->respawn();
- Mana::EventManager::trigger("NPC", Mana::Event("CloseAll"));
+ Mana::Event::trigger("NPC", "CloseAll");
}
extern Connection *gameServerConnection;
diff --git a/src/net/manaserv/tradehandler.cpp b/src/net/manaserv/tradehandler.cpp
index a80fc6e6..30ff6890 100644
--- a/src/net/manaserv/tradehandler.cpp
+++ b/src/net/manaserv/tradehandler.cpp
@@ -22,7 +22,7 @@
#include "net/manaserv/tradehandler.h"
#include "actorspritemanager.h"
-#include "eventmanager.h"
+#include "event.h"
#include "item.h"
#include "localplayer.h"
#include "playerinfo.h"
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp
index feaf7efd..b72c2a13 100644
--- a/src/net/tmwa/adminhandler.cpp
+++ b/src/net/tmwa/adminhandler.cpp
@@ -23,7 +23,7 @@
#include "actorspritemanager.h"
#include "being.h"
-#include "eventmanager.h"
+#include "event.h"
#include "game.h"
#include "playerrelations.h"
diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp
index 3e9156a1..5368ba9d 100644
--- a/src/net/tmwa/buysellhandler.cpp
+++ b/src/net/tmwa/buysellhandler.cpp
@@ -22,7 +22,7 @@
#include "net/tmwa/buysellhandler.h"
#include "actorspritemanager.h"
-#include "eventmanager.h"
+#include "event.h"
#include "inventory.h"
#include "item.h"
#include "localplayer.h"
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index a5d7f337..2b647f68 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -23,7 +23,7 @@
#include "actorspritemanager.h"
#include "being.h"
-#include "eventmanager.h"
+#include "event.h"
#include "game.h"
#include "localplayer.h"
#include "playerrelations.h"
@@ -86,7 +86,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
event.setString("nick", nick);
event.setString("error", strprintf(_("Whisper could "
"not be sent, %s is offline."), nick.c_str()));
- Mana::EventManager::trigger("Chat", event);
+ event.trigger("Chat");
}
break;
case 0x02:
@@ -95,7 +95,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
event.setString("nick", nick);
event.setString("error", strprintf(_("Whisper could "
"not be sent, ignored by %s."), nick.c_str()));
- Mana::EventManager::trigger("Chat", event);
+ event.Event::trigger("Chat");
}
break;
}
@@ -118,7 +118,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
Mana::Event event("Whisper");
event.setString("nick", nick);
event.setString("message", chatMsg);
- Mana::EventManager::trigger("Chat", event);
+ event.trigger("Chat");
}
}
else
@@ -180,7 +180,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
event.setString("nick", sender_name);
event.setInt("beingId", beingId);
event.setInt("permissions", perms);
- Mana::EventManager::trigger("Chat", event);
+ event.trigger("Chat");
break;
}
@@ -213,13 +213,13 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
event.setInt("permissions", player_relations.getDefault()
& (PlayerRelation::SPEECH_LOG
| PlayerRelation::SPEECH_FLOAT));
- Mana::EventManager::trigger("Chat", event);
+ event.trigger("Chat");
}
else
{
Mana::Event event("Announcement");
event.setString("message", chatMsg);
- Mana::EventManager::trigger("Chat", event);
+ event.trigger("Chat");
}
break;
}
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index 03d27b47..2a9508d3 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -22,7 +22,7 @@
#include "net/tmwa/gamehandler.h"
#include "client.h"
-#include "eventmanager.h"
+#include "event.h"
#include "game.h"
#include "localplayer.h"
#include "log.h"
diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp
index a09f2dfe..67fe5d98 100644
--- a/src/net/tmwa/guildhandler.cpp
+++ b/src/net/tmwa/guildhandler.cpp
@@ -21,7 +21,7 @@
#include "net/tmwa/guildhandler.h"
#include "guild.h"
-#include "eventmanager.h"
+#include "event.h"
#include "localplayer.h"
#include "log.h"
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index ae9731ba..c1a96788 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -23,7 +23,7 @@
#include "configuration.h"
#include "equipment.h"
-#include "eventmanager.h"
+#include "event.h"
#include "inventory.h"
#include "item.h"
#include "itemshortcut.h"
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index b61dc520..e1615fec 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -22,7 +22,7 @@
#include "net/tmwa/npchandler.h"
#include "actorspritemanager.h"
-#include "eventmanager.h"
+#include "event.h"
#include "localplayer.h"
#include "net/messagein.h"
@@ -69,7 +69,7 @@ NpcHandler::NpcHandler()
handledMessages = _messages;
npcHandler = this;
- Mana::EventManager::bind(this, "NPC");
+ listen("NPC");
}
void NpcHandler::handleMessage(Net::MessageIn &msg)
@@ -88,42 +88,42 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
event = new Mana::Event("Menu");
event->setInt("id", npcId);
parseMenu(event, msg.readString(msg.getLength() - 8));
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
case SMSG_NPC_MESSAGE:
event = new Mana::Event("Message");
event->setInt("id", npcId);
event->setString("text", msg.readString(msg.getLength() - 8));
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
case SMSG_NPC_CLOSE:
// Show the close button
event = new Mana::Event("Close");
event->setInt("id", npcId);
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
case SMSG_NPC_NEXT:
// Show the next button
event = new Mana::Event("Next");
event->setInt("id", npcId);
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
case SMSG_NPC_INT_INPUT:
// Request for an integer
event = new Mana::Event("IntegerInput");
event->setInt("id", npcId);
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
case SMSG_NPC_STR_INPUT:
// Request for a string
event = new Mana::Event("StringInput");
event->setInt("id", npcId);
- Mana::EventManager::trigger("NPC", *event);
+ event->trigger("NPC");
break;
}
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index fa3d63f1..3d7aa263 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -21,7 +21,7 @@
#include "net/tmwa/partyhandler.h"
#include "actorspritemanager.h"
-#include "eventmanager.h"
+#include "event.h"
#include "localplayer.h"
#include "log.h"
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index 98cbc8fb..0079aedc 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -21,7 +21,7 @@
#include "net/tmwa/playerhandler.h"
-#include "eventmanager.h"
+#include "event.h"
#include "game.h"
#include "localplayer.h"
#include "log.h"
@@ -81,7 +81,7 @@ namespace {
viewport->closePopupMenu();
- Mana::EventManager::trigger("NPC", Mana::Event("CloseAll"));
+ Mana::Event::trigger("NPC", "CloseAll");
}
} deathListener;
diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp
index 09d83cbe..577bda7e 100644
--- a/src/net/tmwa/specialhandler.cpp
+++ b/src/net/tmwa/specialhandler.cpp
@@ -21,7 +21,7 @@
#include "net/tmwa/specialhandler.h"
-#include "eventmanager.h"
+#include "event.h"
#include "log.h"
#include "playerinfo.h"
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index e9712d5e..ee7931bd 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -21,7 +21,7 @@
#include "net/tmwa/tradehandler.h"
-#include "eventmanager.h"
+#include "event.h"
#include "inventory.h"
#include "item.h"
#include "localplayer.h"
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index a6cc60e6..cebd15dc 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -22,7 +22,7 @@
#include "client.h"
#include "equipment.h"
-#include "eventmanager.h"
+#include "event.h"
#include "inventory.h"
#include "listener.h"
#include "log.h"
@@ -62,7 +62,7 @@ void triggerAttr(int id, int old)
event.setInt("id", id);
event.setInt("oldValue", old);
event.setInt("newValue", mData.mAttributes.find(id)->second);
- Mana::EventManager::trigger("Attributes", event);
+ event.trigger("Attributes");
}
void triggerStat(int id, const std::string &changed, int old1, int old2 = 0)
@@ -77,7 +77,7 @@ void triggerStat(int id, const std::string &changed, int old1, int old2 = 0)
event.setString("changed", changed);
event.setInt("oldValue1", old1);
event.setInt("oldValue2", old2);
- Mana::EventManager::trigger("Attributes", event);
+ event.trigger("Attributes");
}
// --- Attributes -------------------------------------------------------------
@@ -223,7 +223,7 @@ void setStorageCount(int count)
Mana::Event event("StorageCount");
event.setInt("oldCount", old);
event.setInt("newCount", count);
- Mana::EventManager::trigger("Storage", event);
+ event.trigger("Storage");
}
}
@@ -244,7 +244,7 @@ void setNPCInteractionCount(int count)
Mana::Event event("NPCCount");
event.setInt("oldCount", old);
event.setInt("newCount", count);
- Mana::EventManager::trigger("NPC", event);
+ event.trigger("NPC");
}
}
@@ -263,7 +263,7 @@ void setNPCPostCount(int count)
Mana::Event event("PostCount");
event.setInt("oldCount", old);
event.setInt("newCount", count);
- Mana::EventManager::trigger("NPC", event);
+ event.trigger("NPC");
}
}
@@ -284,7 +284,7 @@ void setBuySellState(BuySellState buySellState)
Mana::Event event("StateChange");
event.setInt("oldState", old);
event.setInt("newState", buySellState);
- Mana::EventManager::trigger("BuySell", event);
+ event.trigger("BuySell");
}
}
@@ -302,7 +302,7 @@ void setTrading(bool trading)
{
Mana::Event event("Trading");
event.setBool("trading", trading);
- Mana::EventManager::trigger("Status", event);
+ event.trigger("Status");
}
}
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index 68bae823..d7c3f17a 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -21,7 +21,7 @@
#include "statuseffect.h"
-#include "eventmanager.h"
+#include "event.h"
#include "log.h"
#include "sound.h"