diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-08-15 21:28:10 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-08-16 13:19:09 -0600 |
commit | d8d9232a67a03548b827bdb0515fe7a620a488f8 (patch) | |
tree | d6e0644f99e0ff89f9b320c0b479ba5a4e398125 /src/event.h | |
parent | a6c2b90c2dabac18ad8052d948bc540406b3a613 (diff) | |
download | mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.gz mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.bz2 mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.xz mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.zip |
Move more to the event system
Most of Net::InventoryHandler is now done through events. The
ActorSpriteManager was also replaced by events. A few odds and
ends were taken care of too.
Reviewed-by: Bertram
Diffstat (limited to 'src/event.h')
-rw-r--r-- | src/event.h | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/src/event.h b/src/event.h index 68560dae..c7382fc1 100644 --- a/src/event.h +++ b/src/event.h @@ -21,9 +21,12 @@ #ifndef EVENT_H #define EVENT_H -#include <string> #include <map> #include <set> +#include <string> + +class ActorSprite; +class Item; namespace Mana { @@ -65,6 +68,8 @@ public: const std::string &getName() const { return mEventName; } +// Integers + /** * Sets the given variable to the given integer, if it isn't already set. */ @@ -87,6 +92,8 @@ public: */ bool hasInt(const std::string &key) const; +// Strings + /** * Sets the given variable to the given string, if it isn't already set. */ @@ -110,6 +117,8 @@ public: */ bool hasString(const std::string &key) const; +// Floats + /** * Sets the given variable to the given floating-point, if it isn't already * set. @@ -133,6 +142,8 @@ public: */ bool hasFloat(const std::string &key) const; +// Booleans + /** * Sets the given variable to the given boolean, if it isn't already set. */ @@ -155,6 +166,57 @@ public: */ bool hasBool(const std::string &key) const; +// Items + + /** + * Sets the given variable to the given Item, if it isn't already set. + */ + void setItem(const std::string &key, Item *value) throw (BadEvent); + + /** + * Returns the given variable if it is set and an Item. + */ + Item *getItem(const std::string &key) const throw (BadEvent); + + /** + * Returns the given variable if it is set and an Item, returning the + * given default otherwise. + */ + inline Item *getItem(const std::string &key, Item *defaultValue) const + { try { return getItem(key); } catch (BadEvent) { return defaultValue; }} + + /** + * Returns true if the given variable exists and is an Item. + */ + bool hasItem(const std::string &key) const; + +// ActorSprites + + /** + * Sets the given variable to the given actor, if it isn't already set. + */ + void setActor(const std::string &key, ActorSprite *value) throw (BadEvent); + + /** + * Returns the given variable if it is set and an actor. + */ + ActorSprite *getActor(const std::string &key) const throw (BadEvent); + + /** + * Returns the given variable if it is set and an actor, returning the + * given default otherwise. + */ + inline ActorSprite *getActor(const std::string &key, + ActorSprite *defaultValue) const + { try { return getActor(key); } catch (BadEvent) { return defaultValue; }} + + /** + * Returns true if the given variable exists and is an actor. + */ + bool hasActor(const std::string &key) const; + +// Triggers + /** * Sends this event to all classes listening to the given channel. */ |