|
Odamex
Setting the Standard in Multiplayer Doom
|
An Event Register. More...
#include <event_handler.h>
Public Member Functions | |
| ~ODA_EventRegister () | |
| Destructor. | |
| EventHandler * | RegisterEventHandler (EVENT_FUNC_PTR funcPtr) |
| Register a function as an EventHandler. | |
| bool | DeleteEventHandler (EventHandler *handler) |
| Delete an event handler. | |
An Event Register.
Parent class for all classes that will have Agar event callback member functions.
Handling Agar events in ag-odalaunch:
Any Agar-based window/dialog that will register events with Agar needs to inherit from the ODA_EventRegister class.
A pointer to the EventReceiver function needs to be provided to Agar as the event callback function for any event that will call a class member function.
The Agar event must receive a pointer to an EventHandler returned from the RegisterEventHandler() function. This function receives the class member function that should be triggered by the event. When passing the function ptr cast to EVENT_FUNC_PTR. Any additional desired variables can be provided to the event after the required pointer.
The reason for this is that Agar is C-based and C functions cannot receive a class member function pointer. It is also illegal to cast a pointer-to-member-function to (void *) and vice versa.
Example: AG_SetEvent(win, "window-user-resize", EventReceiver, "%p", RegisterEventHandler((EVENT_FUNC_PTR)&OurClass::OnWindowResize));
| agOdalaunch::ODA_EventRegister::~ODA_EventRegister | ( | ) |
Destructor.
At destruction all EventHandlers registered through this class instance are automatically deleted.
| bool agOdalaunch::ODA_EventRegister::DeleteEventHandler | ( | EventHandler * | handler | ) |
Delete an event handler.
This method deletes an EventHandler from the list of registered handlers. You only need to call this if you want to delete an EventHandler before you are finished with the object instance derived from this class. All handlers are deleted automatically when the object instance is destructed.
| handler | An EventHandler. |
| EventHandler * agOdalaunch::ODA_EventRegister::RegisterEventHandler | ( | EVENT_FUNC_PTR | funcPtr | ) |
Register a function as an EventHandler.
This method allows member functions of ODA_EventRegister derived classes to be registered as an event handler. The returned EventHandler instance can be passed to Agar functions or other C-based functions as a pointer with the EventReceiver method provided as the event callback function.
| funcPtr | An ODA_EventRegister derived classes method. |