From 1e1f619b9ae5aa26058c499c988f45d1fb1b6d53 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sat, 9 Apr 2011 00:11:54 +0200 Subject: Moved Channels to Mana::Event::Channel Acked-by: Jared Adams --- src/event.h | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'src/event.h') diff --git a/src/event.h b/src/event.h index 22b76c6f..74a4e1f5 100644 --- a/src/event.h +++ b/src/event.h @@ -28,22 +28,6 @@ class ActorSprite; class Item; -enum Channels -{ - CHANNEL_ACTORSPRITE, - CHANNEL_ATTRIBUTES, - CHANNEL_BUYSELL, - CHANNEL_CHAT, - CHANNEL_CLIENT, - CHANNEL_CONFIG, - CHANNEL_GAME, - CHANNEL_ITEM, - CHANNEL_NOTICES, - CHANNEL_NPC, - CHANNEL_STATUS, - CHANNEL_STORAGE -}; - namespace Mana { @@ -57,14 +41,28 @@ enum BadEvent { class Listener; typedef std::set ListenerSet; -typedef std::map ListenMap; - class VariableData; typedef std::map VariableMap; class Event { public: + enum Channel + { + ActorSpriteChannel, + AttributesChannel, + BuySellChannel, + ChatChannel, + ClientChannel, + ConfigChannel, + GameChannel, + ItemChannel, + NoticesChannel, + NpcChannel, + StatusChannel, + StorageChannel + }; + enum Type { Announcement, @@ -286,19 +284,19 @@ public: /** * Sends this event to all classes listening to the given channel. */ - inline void trigger(Channels channel) const + inline void trigger(Channel channel) const { trigger(channel, *this); } /** * Sends the given event to all classes listening to the given channel. */ - static void trigger(Channels channel, const Event &event); + static void trigger(Channel channel, const Event &event); /** * Sends an empty event with the given name to all classes listening to the * given channel. */ - static inline void trigger(Channels channel, Type type) + static inline void trigger(Channel channel, Type type) { trigger(channel, Mana::Event(type)); } protected: @@ -308,13 +306,13 @@ protected: * Binds the given listener to the given channel. The listener will receive * all events triggered on the channel. */ - static void bind(Listener *listener, Channels channel); + static void bind(Listener *listener, Channel 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, Channels channel); + static void unbind(Listener *listener, Channel channel); /** * Unbinds the given listener from all channels. @@ -322,6 +320,7 @@ protected: static void remove(Listener *listener); private: + typedef std::map ListenMap; static ListenMap mBindings; Type mType; @@ -333,6 +332,6 @@ private: #define SERVER_NOTICE(message) { \ Mana::Event event(Mana::Event::ServerNotice); \ event.setString("message", message); \ -event.trigger(CHANNEL_NOTICES, event); } +event.trigger(Mana::Event::NoticesChannel, event); } #endif // EVENT_H -- cgit v1.2.3-60-g2f50