summaryrefslogtreecommitdiff
path: root/src/event.h
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2010-11-11 23:12:29 -0500
committerChuck Miller <shadowmil@gmail.com>2010-11-11 23:12:29 -0500
commita4640305fd0d88c6332112712aa69e496368e01b (patch)
tree0f039b331026ca2b9718a920b24e2344f9e56b25 /src/event.h
parent5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e (diff)
downloadmana-client-a4640305fd0d88c6332112712aa69e496368e01b.tar.gz
mana-client-a4640305fd0d88c6332112712aa69e496368e01b.tar.bz2
mana-client-a4640305fd0d88c6332112712aa69e496368e01b.tar.xz
mana-client-a4640305fd0d88c6332112712aa69e496368e01b.zip
Replace Event names with enums instead of strings
Diffstat (limited to 'src/event.h')
-rw-r--r--src/event.h65
1 files changed, 59 insertions, 6 deletions
diff --git a/src/event.h b/src/event.h
index 42f4d068..99bd6fcb 100644
--- a/src/event.h
+++ b/src/event.h
@@ -43,6 +43,60 @@ enum Channels
CHANNEL_STORAGE
};
+enum Events
+{
+ EVENT_ANNOUNCEMENT,
+ EVENT_BEING,
+ EVENT_CLOSE,
+ EVENT_CLOSEALL,
+ EVENT_CONSTRUCTED,
+ EVENT_DBSLOADING,
+ EVENT_DESTROYED,
+ EVENT_DESTRUCTED,
+ EVENT_DESTRUCTING,
+ EVENT_DOCLOSE,
+ EVENT_DOCLOSEINVENTORY,
+ EVENT_DODROP,
+ EVENT_DOEQUIP,
+ EVENT_DOINTEGERINPUT,
+ EVENT_DOMENU,
+ EVENT_DOMOVE,
+ EVENT_DONEXT,
+ EVENT_DOSENDLETTER,
+ EVENT_DOSPLIT,
+ EVENT_DOSTRINGINPUT,
+ EVENT_DOTALK,
+ EVENT_DOUNEQUIP,
+ EVENT_DOUSE,
+ EVENT_END,
+ EVENT_ENGINESINITALIZED,
+ EVENT_ENGINESINITALIZING,
+ EVENT_GUIWINDOWSLOADED,
+ EVENT_GUIWINDOWSLOADING,
+ EVENT_GUIWINDOWSUNLOADED,
+ EVENT_GUIWINDOWSUNLOADING,
+ EVENT_INTEGERINPUT,
+ EVENT_MAPLOADED,
+ EVENT_MENU,
+ EVENT_MESSAGE,
+ EVENT_NEXT,
+ EVENT_NPCCOUNT,
+ EVENT_PLAYER,
+ EVENT_POST,
+ EVENT_POSTCOUNT,
+ EVENT_SERVERNOTICE,
+ EVENT_STATECHANGE,
+ EVENT_STORAGECOUNT,
+ EVENT_STRINGINPUT,
+ EVENT_STUN,
+ EVENT_TRADING,
+ EVENT_UPDATEATTRIBUTE,
+ EVENT_UPDATESTAT,
+ EVENT_UPDATESTATUSEFFECT,
+ EVENT_WHISPER,
+ EVENT_WHISPERERROR
+};
+
namespace Mana
{
@@ -62,7 +116,7 @@ class VariableData;
typedef std::map<std::string, VariableData *> VariableMap;
#define SERVER_NOTICE(message) { \
-Mana::Event event("ServerNotice"); \
+Mana::Event event(EVENT_SERVERNOTICE); \
event.setString("message", message); \
event.trigger(CHANNEL_NOTICES, event); }
@@ -72,7 +126,7 @@ public:
/**
* Makes an event with the given name.
*/
- Event(const std::string &name)
+ Event(Events name)
{ mEventName = name; }
~Event();
@@ -80,7 +134,7 @@ public:
/**
* Returns the name of the event.
*/
- const std::string &getName() const
+ Events getName() const
{ return mEventName; }
// Integers
@@ -247,8 +301,7 @@ public:
* Sends an empty event with the given name to all classes listening to the
* given channel.
*/
- static inline void trigger(Channels channel,
- const std::string& name)
+ static inline void trigger(Channels channel, Events name)
{ trigger(channel, Mana::Event(name)); }
protected:
@@ -274,7 +327,7 @@ protected:
private:
static ListenMap mBindings;
- std::string mEventName;
+ Events mEventName;
VariableMap mData;
};