Game Development Reference
In-Depth Information
uint8 m_pData;
} s_myEvent;
// we register an event (usually in the Initialize method
// of the plug-in)
...
REGISTER_EVENT(&s_myEvent);
...
// in some command, we trigger the event
void my_command(IParameterValues* pParams)
{
uint8* pSomeData;
// ....... do things with pSomeData
g_pEditor->TriggerEvent(
&s_myEvent,
IEventSink::eTriggerContext_After,
pSomeData);
}
In some plug-ins, an event sink registered for a particular event would be notified of the event being triggered,
as shown in Listing 11-19.
Listing 11-19. Creating and Registering an Event Sink
// declare our event sink
struct MyEventSink: IEventSink
{
void OnEvent(IEvent* pEvent,
ETriggerContext aContext,
void* pUserData)
{
// is this the event we're looking for?
if (!strcmp(pEvent->GetName(), “MyCoolEvent”))
{
uint8* pEventData = pEvent->GetUserData();
// ...do things when that event was triggered
}
}
} s_myEventSink;
// inside the plug-in's Initialize method, register
// the event sink
...
pEditor->RegisterEventSink(&s_myEventSink);
...
In Figure 11-3 , you can see a demo application of this system, with the editor skeleton having just one menu item
and a settings dialog where plug-ins are managed.
 
Search WWH ::




Custom Search