Mana
|
#include <event.h>
Public Types | |
enum | Channel { ActorSpriteChannel , AttributesChannel , BuySellChannel , ChatChannel , ClientChannel , ConfigChannel , GameChannel , ItemChannel , NoticesChannel , NpcChannel , StorageChannel , QuestsChannel } |
enum | Type { Announcement , Being , ClearDialog , Close , CloseAll , CloseDialog , ConfigOptionChanged , Constructed , LoadingDatabases , Destroyed , Destructed , Destructing , DoCloseInventory , DoDrop , DoEquip , DoMove , DoUnequip , DoUse , EnginesInitialized , EnginesInitializing , GuiWindowsLoaded , GuiWindowsLoading , GuiWindowsUnloaded , GuiWindowsUnloading , IntegerInput , MapLoaded , Menu , Message , Next , NpcCount , Player , Post , PostCount , ServerNotice , StateChange , StorageCount , StringInput , UpdateAttribute , UpdateStat , UpdateStatusEffect , Whisper , WhisperError , QuestVarsChanged } |
Public Member Functions | |
Event (Type type) | |
Makes an event with the given name. | |
template<typename T > | |
Event (Type type, const T &value) | |
Makes an event with the given name and value. | |
~Event () | |
Type | getType () const |
Returns the name of the event. | |
template<typename T > | |
void | setValue (const T &value) |
Sets the value of the event. | |
template<typename T > | |
const T & | value () const |
Returns the value of the event. | |
template<typename T > | |
bool | hasValue (const T &value) const |
Returns whether the event has the given the value. | |
void | setInt (const std::string &key, int value) |
Sets the given variable to the given integer, if it isn't already set. | |
int | getInt (const std::string &key) const |
Returns the given variable if it is set and an integer. | |
int | getInt (const std::string &key, int defaultValue) const |
Returns the given variable if it is set and an integer, returning the given default otherwise. | |
void | setString (const std::string &key, const std::string &value) |
Sets the given variable to the given string, if it isn't already set. | |
const std::string & | getString (const std::string &key) const |
Returns the given variable if it is set and a string. | |
std::string | getString (const std::string &key, const std::string &defaultValue) const |
Returns the given variable if it is set and a string, returning the given default otherwise. | |
void | setFloat (const std::string &key, double value) |
Sets the given variable to the given floating-point, if it isn't already set. | |
double | getFloat (const std::string &key) const |
Returns the given variable if it is set and a floating-point. | |
double | getFloat (const std::string &key, float defaultValue) const |
Returns the given variable if it is set and a floating-point, returning the given default otherwise. | |
void | setBool (const std::string &key, bool value) |
Sets the given variable to the given boolean, if it isn't already set. | |
bool | getBool (const std::string &key) const |
Returns the given variable if it is set and a boolean. | |
bool | getBool (const std::string &key, bool defaultValue) const |
Returns the given variable if it is set and a boolean, returning the given default otherwise. | |
void | setItem (const std::string &key, Item *value) |
Sets the given variable to the given Item, if it isn't already set. | |
Item * | getItem (const std::string &key) const |
Returns the given variable if it is set and an Item. | |
Item * | getItem (const std::string &key, Item *defaultValue) const |
Returns the given variable if it is set and an Item, returning the given default otherwise. | |
void | setActor (const std::string &key, ActorSprite *value) |
Sets the given variable to the given actor, if it isn't already set. | |
ActorSprite * | getActor (const std::string &key) const |
Returns the given variable if it is set and an actor. | |
ActorSprite * | getActor (const std::string &key, ActorSprite *defaultValue) const |
Returns the given variable if it is set and an actor, returning the given default otherwise. | |
void | trigger (Channel channel) const |
Sends this event to all classes listening to the given channel. | |
Static Public Member Functions | |
static void | trigger (Channel channel, const Event &event) |
Sends the given event to all classes listening to the given channel. | |
static void | trigger (Channel channel, Type type) |
Sends an empty event with the given name to all classes listening to the given channel. | |
Static Protected Member Functions | |
static void | bind (EventListener *listener, Channel channel) |
Binds the given listener to the given channel. | |
static void | unbind (EventListener *listener, Channel channel) |
Unbinds the given listener from the given channel. | |
static void | remove (EventListener *listener) |
Unbinds the given listener from all channels. | |
Private Types | |
using | ListenMap = std::map< Channel, std::set< EventListener * > > |
Private Attributes | |
const Type | mType |
std::map< std::string, VariableData * > | mData |
std::any | mValue |
Static Private Attributes | |
static ListenMap | mBindings |
Friends | |
class | EventListener |
|
private |
enum Event::Channel |
enum Event::Type |
|
inline |
|
inline |
|
staticprotected |
ActorSprite * Event::getActor | ( | const std::string & | key | ) | const |
|
inline |
bool Event::getBool | ( | const std::string & | key | ) | const |
|
inline |
double Event::getFloat | ( | const std::string & | key | ) | const |
|
inline |
int Event::getInt | ( | const std::string & | key | ) | const |
|
inline |
Item * Event::getItem | ( | const std::string & | key | ) | const |
const std::string & Event::getString | ( | const std::string & | key | ) | const |
|
inline |
|
inline |
|
inline |
|
staticprotected |
void Event::setActor | ( | const std::string & | key, |
ActorSprite * | value | ||
) |
void Event::setBool | ( | const std::string & | key, |
bool | value | ||
) |
void Event::setFloat | ( | const std::string & | key, |
double | value | ||
) |
void Event::setInt | ( | const std::string & | key, |
int | value | ||
) |
void Event::setItem | ( | const std::string & | key, |
Item * | value | ||
) |
void Event::setString | ( | const std::string & | key, |
const std::string & | value | ||
) |
|
inline |
|
inline |
|
staticprotected |
|
inline |
|
friend |
|
staticprivate |
|
private |