CCoherentViewListener* CCoherentUISystem::GetViewListener( int id ) { if ( m_HudViewListener ) { Coherent::UI::View* pHudView = m_HudViewListener->GetView(); if ( pHudView != nullptr && pHudView->GetId() == id ) { return m_HudViewListener.get(); } } for ( View::const_iterator iter = m_Views.begin(); iter != m_Views.end(); ++iter ) { Coherent::UI::View* pView = iter->first->GetView(); if ( pView->GetId() == id ) { return iter->first; } } return NULL; }
virtual void ProcessEvent( EFlowEvent evt, SActivationInfo* pActInfo ) { switch ( evt ) { case eFE_Suspend: break; case eFE_Resume: break; case eFE_Initialize: INITIALIZE_OUTPUTS( pActInfo ); break; case eFE_SetEntityId: m_pEntity = pActInfo->pEntity; break; case eFE_Activate: if ( IsPortActive( pActInfo, EIP_ACTIVATE ) && m_pEntity ) { // get the view definition std::string sUrl = GetPortString( pActInfo, EIP_URL ); std::wstring sUrlW( sUrl.length(), L' ' ); sUrlW.assign( sUrl.begin(), sUrl.end() ); Coherent::UI::ViewInfo info; info.Width = GetPortInt( pActInfo, EIP_WIDTH ); info.Height = GetPortInt( pActInfo, EIP_HEIGHT ); info.IsTransparent = GetPortBool( pActInfo, EIP_TRANSPARENT ); info.UsesSharedMemory = GetPortBool( pActInfo, EIP_SHARED_MEMORY ); info.SupportClickThrough = GetPortBool( pActInfo, EIP_CLICKABLE ); m_pViewConfig->ViewInfo = info; m_pViewConfig->Url = sUrlW; m_pViewConfig->Entity = m_pEntity; m_pViewConfig->CollisionMesh = GetPortString( pActInfo, EIP_MESH ); // indicate that we have to create/update the view later m_bViewNeedsUpdate = true; pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true ); } break; case eFE_Update: // make sure the view is created/updated, after the system is ready if ( m_bViewNeedsUpdate && gCoherentUISystem->IsReady() ) { if ( m_pViewListener ) { gCoherentUISystem->DeleteView( m_pViewListener ); } m_pViewListener = gCoherentUISystem->CreateView( m_pViewConfig ); m_bViewNeedsUpdate = false; } // set the view id output after the view is available if ( m_pViewListener ) { Coherent::UI::View* view = m_pViewListener->GetView(); if ( view ) { ActivateOutput<int>( pActInfo, EOP_VIEWID, view->GetId() ); // updates are not necessary until next initialization pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false ); } } break; } }
virtual void ProcessEvent( EFlowEvent evt, SActivationInfo* pActInfo ) { switch ( evt ) { case eFE_Suspend: break; case eFE_Resume: break; case eFE_Initialize: INITIALIZE_OUTPUTS( pActInfo ); break; case eFE_Activate: { if ( IsPortActive( pActInfo, EIP_ACTIVATE ) ) { // get the view definition std::string sPath = GetPortString( pActInfo, EIP_PATH ); m_sPathW.assign( sPath.begin(), sPath.end() ); // indicate that we have to create/update the view later m_bViewNeedsUpdate = true; pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true ); } } break; case eFE_Update: // make sure the view is created, after the system is ready if ( m_bViewNeedsUpdate && gCoherentUISystem->IsReady() ) { if ( m_pViewListener ) { // update only Coherent::UI::View* view = m_pViewListener->GetView(); view->Load( m_sPathW.c_str() ); view->Reload( true ); } else { // create m_pViewListener = gCoherentUISystem->CreateHUDView( m_sPathW ); } m_bViewNeedsUpdate = false; } // set the view id output after the view is available if ( m_pViewListener ) { Coherent::UI::View* view = m_pViewListener->GetView(); if ( view ) { ActivateOutput<int>( pActInfo, EOP_VIEWID, view->GetId() ); // updates are not necessary until next initialization pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false ); } } break; } }