see events page for information about events parameters in scripting interface. events are categorized by types, see PE_types.h, events_def.h. There are also some predefined events in Predefinedevents.h.
Global ParaEngine event handlers are exposed through scripting interface, API interface, and managed API interface. Managed API interface are exposed as multi-cast delegate in the EventCenter class of ParaEngineManaged class.
Two types of event firing are supported: (1) Fire event immediately, similar to SendMessage in Win32 (2) Pose Event, which return immediate without executing the event handlers. similar to PostMessages in Win32 Since event raisers and event handlers may be in the same thread, PoseEvent is there to prevent interlocking of program code.
Example: SelectionToolWindow in ParaIDE are implemented through the new managed event handling interface. Whenever the game engine changes selection, the plug-in interface will receive an event, and in the event handler, it will update the GUI to reflect the recent changes in selection.
Public Member Functions | |
void | RegisterEvent (const string &sID, const string &sScript) |
register a mouse or key event handler | |
void | RegisterEvent (DWORD nEventType, const string &sID, const string &sScript) |
same as above RegisterEvent(), except that it allows caller to explicitly specify the event type, instead of deriving it from the event name. | |
void | UnregisterEvent (const string &sID) |
unregister a mouse or key event handler | |
void | UnregisterAllEvent () |
unregister all mouse or key event handler | |
int | FireMouseEvents (CEventHandler::MouseEvent &e) |
Fire mouse events, call all of its handler scripts with sCode immediately. | |
int | FireMouseClickEvents (CEventHandler::MouseEvent &e) |
int | FireMouseMoveEvents (CEventHandler::MouseEvent &e) |
int | FireMouseDownEvents (CEventHandler::MouseEvent &e) |
int | FireMouseUpEvents (CEventHandler::MouseEvent &e) |
int | FireKeyEvents (CEventHandler::KeyEvent &e) |
int | FireKeyUpEvents (CEventHandler::KeyEvent &e) |
int | FireSystemEvents (CEventHandler::SystemEvent &e) |
int | FireEditorEvents (CEventHandler::EditorEvent &e) |
int | FireNetworkEvents (CEventHandler::NetworkEvent &e) |
bool | PostEvent (CEventHandler::Event &e, bool bUnique=true) |
Post a event to the unhandled event pool, and return immediately. | |
void | FireAllUnhandledEvents () |
fire all events in the unhandled events pool. | |
Static Public Member Functions | |
static CEventsCenter * | GetInstance () |
|
void ParaEngine::CEventsCenter::RegisterEvent | ( | const string & | sID, | |
const string & | sScript | |||
) |
register a mouse or key event handler
sID,: | a string identifier of the event handler. if sID begins with "_m" it is treated as a mouse click event, except that if sID begins with "_mm" it is treated as a mouse move event. if sID begins with "_md" it is treated as a mouse down event. if sID begins with "_mu" it is treated as a mouse up event. if sID begins with "_k" it is treated as a key down event. if sID begins with "_ku" it is treated as a key up event. if sID begins with "_n" it is treated as a network event handler. | |
sScript,: | the script to be executed when the event is triggered.This is usually a function call in NPL. sScript should be in the following format "{NPL filename};{sCode};". this is the same format in the UI event handler |
void ParaEngine::CEventsCenter::RegisterEvent | ( | DWORD | nEventType, | |
const string & | sID, | |||
const string & | sScript | |||
) |
same as above RegisterEvent(), except that it allows caller to explicitly specify the event type, instead of deriving it from the event name.
nEventType | any bit combination of CEventHandler::EventHandler_type | |
sID | any unique string identifier | |
sScript | the NPL script. |
int ParaEngine::CEventsCenter::FireMouseEvents | ( | CEventHandler::MouseEvent & | e | ) |
Fire mouse events, call all of its handler scripts with sCode immediately.
this function will return when all events have been handled. use PoseEvents(), if one wants to return without calling their handlers;
e | event parameters |
bool ParaEngine::CEventsCenter::PostEvent | ( | CEventHandler::Event & | e, | |
bool | bUnique = true | |||
) |
Post a event to the unhandled event pool, and return immediately.
Events in unhandled event pool are handled during each frame move.
e | ||
bUnique,: | if true, the event id is unique in the event pool, unless the ID is -1. If one tries to insert the event with the same id multiple times within a frame move, only the first one will be fired during each frame move. |
void ParaEngine::CEventsCenter::FireAllUnhandledEvents | ( | ) |
fire all events in the unhandled events pool.
This function is called automatically during each frame move.