本文整理汇总了C++中EventPtr::GetEventType方法的典型用法代码示例。如果您正苦于以下问题:C++ EventPtr::GetEventType方法的具体用法?C++ EventPtr::GetEventType怎么用?C++ EventPtr::GetEventType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventPtr
的用法示例。
在下文中一共展示了EventPtr::GetEventType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleEvent
//--------------------------------------------------------------------------------
bool App::HandleEvent( EventPtr pEvent )
{
eEVENT e = pEvent->GetEventType();
if ( e == SYSTEM_KEYBOARD_KEYDOWN )
{
EvtKeyDownPtr pKeyDown = std::static_pointer_cast<EvtKeyDown>( pEvent );
unsigned int key = pKeyDown->GetCharacterCode();
}
else if ( e == SYSTEM_KEYBOARD_KEYUP )
{
EvtKeyUpPtr pKeyUp = std::static_pointer_cast<EvtKeyUp>( pEvent );
unsigned int key = pKeyUp->GetCharacterCode();
if ( 'A' == key ) // 'A' Key - restart animations
{
m_pDisplacedActor->PlayAllAnimations();
m_pSkinnedActor->PlayAllAnimations();
return( true );
}
}
// Call the parent class's event handler if we haven't handled the event.
return( RenderApplication::HandleEvent( pEvent ) );
}
示例2: HandleEvent
//--------------------------------------------------------------------------------
bool RenderApplication::HandleEvent( EventPtr pEvent )
{
// This method body is included here for future use, to allow the
// RenderApplication to handle some events if needed.
eEVENT e = pEvent->GetEventType();
if ( e == WINDOW_RESIZE )
{
EvtWindowResizePtr pResize = std::static_pointer_cast<EvtWindowResize>( pEvent );
this->HandleWindowResize( pResize->GetWindowHandle(), pResize->NewWidth(), pResize->NewHeight() );
return( true );
}
else if ( e == SYSTEM_KEYBOARD_KEYUP )
{
EvtKeyUpPtr pKeyUp = std::static_pointer_cast<EvtKeyUp>( pEvent );
unsigned int key = pKeyUp->GetCharacterCode();
if ( key == VK_F1 ) // 'F1' Key - Toggle the multithreading state
{
ToggleMultiThreadedMode();
return true;
}
else if ( key == '\t' ) // TAB Key - Toggle the console on and off.
{
if ( m_InputMode == InputMode::Camera )
{
m_InputMode = InputMode::Console;
m_pScene->GetRoot()->AttachChild( m_pConsole->GetNode() );
}
else
{
m_InputMode = InputMode::Camera;
m_pScene->GetRoot()->DetachChild( m_pConsole->GetNode() );
}
return true;
}
}
if ( m_InputMode == InputMode::Camera ) {
if ( CameraEventHub.ProcessEvent( pEvent ) ) {
return true;
}
}
if ( m_InputMode == InputMode::Console ) {
if ( ConsoleEventHub.ProcessEvent( pEvent ) ) {
return true;
}
}
// Call the parent class's event handler if we haven't handled the event.
return( Application::HandleEvent( pEvent ) );
}
示例3: HandleEvent
//--------------------------------------------------------------------------------
bool App::HandleEvent( EventPtr pEvent )
{
eEVENT e = pEvent->GetEventType();
if ( e == SYSTEM_KEYBOARD_KEYDOWN )
{
EvtKeyDownPtr pKeyDown = std::static_pointer_cast<EvtKeyDown>( pEvent );
unsigned int key = pKeyDown->GetCharacterCode();
}
else if ( e == SYSTEM_KEYBOARD_KEYUP )
{
EvtKeyUpPtr pKeyUp = std::static_pointer_cast<EvtKeyUp>( pEvent );
unsigned int key = pKeyUp->GetCharacterCode();
if ( 'W' == key )
{
// Toggle Wireframe
m_bSolidRender = !m_bSolidRender;
m_pTerrainEffect->m_iRasterizerState = m_bSolidRender ? m_rsSolid : m_rsWireframe;
}
else if ( 'D' == key )
{
// Debug colours - show LOD or N-dot-L shading
switch( m_smCurrentShading )
{
case SolidColour:
m_smCurrentShading = SimpleShading;
break;
case SimpleShading:
m_smCurrentShading = LodDebugView;
break;
case LodDebugView:
m_smCurrentShading = SolidColour;
break;
}
m_pTerrainEffect->SetDomainShader( m_TerrainDomainShaders[ m_smCurrentShading ] );
}
else if ( 'L' == key )
{
// Toggle between simple and CS-based LOD
m_bSimpleComplexity = !m_bSimpleComplexity;
m_pTerrainEffect->SetHullShader( m_bSimpleComplexity ? m_iSimpleHullShader : m_iComplexHullShader );
}
else if ( 'A' == key )
{
// Toggle automated camera
m_bViewPointInAutoMode = !m_bViewPointInAutoMode;
}
}
// Call the parent class's event handler if we haven't handled the event.
return( Application::HandleEvent( pEvent ) );
}
示例4: VProcessEvents
bool EventManagerImpl::VProcessEvents(long p_time)
{
//TODO ThreadSafeQueue
std::cout << "HAHAHA" << std::endl;
int queueToProcess = m_activeQueue;
m_activeQueue = (m_activeQueue + 1) % EVENTMANAGER_NUM_QUEUES;
m_queues[m_activeQueue].clear();
while (!m_queues[queueToProcess].empty())
{
EventPtr pEvent = m_queues[queueToProcess].front();
m_queues[queueToProcess].pop_front();
//TODO Log Processing Event ...
const EventType& eventType = pEvent->GetEventType();
auto findIt = m_eventListeners.find(eventType);
if (findIt != m_eventListeners.end())
{
const EventListenerList& eventListeners = findIt->second;
for (auto itListener = eventListeners.begin(); itListener != eventListeners.end(); ++itListener)
{
EventListenerPtr listener = (*itListener);
listener->VprocessEvent(pEvent);
}
}
// Time check
}
//If we couldn't process allEvents, we push them to the front of the new active queue
bool queueFlushed = (m_queues[queueToProcess].empty());
if (!queueFlushed)
{
while (!m_queues[queueToProcess].empty())
{
EventPtr pEvent = m_queues[queueToProcess].back();
m_queues[queueToProcess].pop_back();
m_queues[m_activeQueue].push_front(pEvent);
}
}
return queueFlushed;
}
示例5: VTriggerEvent
bool EventManagerImpl::VTriggerEvent(EventPtr& p_event)
{
//TODO log
bool processed = false;
auto findIt = m_eventListeners.find(p_event->GetEventType());
if (findIt != m_eventListeners.end())
{
const EventListenerList& eventListenerList = findIt->second;
for (EventListenerList::const_iterator itListener = eventListenerList.begin(); itListener != eventListenerList.end(); ++itListener)
{
EventListenerPtr listener = (*itListener);
listener->VprocessEvent(p_event);
processed = true;
}
}
return processed;
}
示例6: HandleEvent
bool Application::HandleEvent(EventPtr event)
{
EventType eventType = event->GetEventType();
if (eventType == EventType::INFO_MESSAGE)
{
// 若是信息,弹窗提醒
EventInfoMessagePtr infoMessageEvent = std::static_pointer_cast<EventInfoMessage>(event);
MessageBox(0, infoMessageEvent->GetInfoMessage().c_str(), L"Info Message", MB_ICONINFORMATION | MB_SYSTEMMODAL);
}
else if (eventType == EventType::ERROR_MESSAGE)
{
// 若是错误信息,弹窗提醒并结束运行
EventErrorMessagePtr errorMessageEvent = std::static_pointer_cast<EventErrorMessage>(event);
MessageBox(0, errorMessageEvent->GetErrorMessage().c_str(), L"Error Message", MB_ICONERROR | MB_SYSTEMMODAL);
RequestTermination();
}
else if (eventType == EventType::SYSTEM_KEYBOARD_KEYUP)
{
EventKeyUpPtr keyUevent = std::static_pointer_cast<EventKeyUp>(event);
//Attention mark:实际上这里应该提供一个可以配置的按键映射,考虑到这个handleEvent是可以自行重载的故,可以在这里暂时不用考虑
// 判断按下的是哪个键
UINT key = keyUevent->GetCharacterCode();
if (key == VK_ESCAPE)
{
// 按下的是Esc, 该键用于结束程序运行
RequestTermination();
return true;
}
else if (key == VK_SPACE)
{
// 按下空格,保存当前帧图像
mSaveScreenShot = true;
return true;
}
}
return true;
}
示例7: VQueueEvent
bool EventManagerImpl::VQueueEvent(EventPtr& p_event) {
if (m_activeQueue < 0 || m_activeQueue > EVENTMANAGER_NUM_QUEUES)
return false; //BIG ERROR
//std::cout << "Neues Event: " << EventTypeValueNames[p_event->GetEventType()] << std::endl;
if (!p_event)
{
return false;
}
auto findIt = m_eventListeners.find(p_event->GetEventType());
if (findIt != m_eventListeners.end())
{
m_queues[m_activeQueue].push_back(p_event);
return true;
}
else
{
return false;
}
}