virtual void ProcessEvent( EFlowEvent evt, SActivationInfo* pActInfo )
    {
        switch ( evt )
        {
        case eFE_Suspend:
            pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
            break;

        case eFE_Resume:
            pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
            break;

        case eFE_Initialize:
            break;

        case eFE_Activate:
        {
            if ( IsPortActive( pActInfo, EIP_ACTIVATE ) ) {
                m_iViewId = GetPortInt( pActInfo, EIP_VIEWID );
                m_bHandlerRegistered = false;
                pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
            }
        }
        break;

        case eFE_Update:
            if ( !m_bHandlerRegistered )
            {
                CCoherentViewListener* pViewListener = gCoherentUISystem->GetViewListener( m_iViewId );
                if ( pViewListener && pViewListener->IsReadyForBindings() )
                {
                    Coherent::UI::View* pView = pViewListener->GetView();
                    if ( pView )
                    {
                        std::string sEvent = GetPortString( pActInfo, EIP_EVENT );
                        pView->RegisterForEvent( sEvent.c_str(), Coherent::UI::MakeHandler(this, &CFlowCUIHandleEvent::HandleEvent));
                        m_bHandlerRegistered = true;
                    }
                }
            }
            if ( m_bReceivedEvent )
            {
                m_bReceivedEvent = false;
                string strArg = m_event.strArg.c_str();
                ActivateOutput( pActInfo, EIP_ARG1, strArg );
                ActivateOutput( pActInfo, EIP_ARG2, m_event.boolArg );
            }
            break;
        }
    }
Ejemplo n.º 2
0
    void CCoherentUISystem::UpdateHUD()
    {
        static Vec3 lastPosition = Vec3Constants<Vec3::value_type>::fVec3_Zero;
        static float lastRotation = 0;

        CCoherentViewListener* pHUDListener = NULL;
        pHUDListener = ( m_HudViewListener ? m_HudViewListener.get() : NULL );

        if ( pHUDListener )
        {
            CCamera& camera = gEnv->pSystem->GetViewCamera();
            Vec3 viewDir = camera.GetViewdir();
            float rotation = cry_atan2f( viewDir.y, viewDir.x ) * 180.0f / 3.14159f;
            // Adjust rotation so it is the same as in the game
            rotation = -rotation - 135.0f;
            Coherent::UI::View* pView = pHUDListener->GetView();

            if ( pView && pHUDListener->IsReadyForBindings() )
            {
                if ( rotation != lastRotation )
                {
                    pView->TriggerEvent( "SetAbsoluteCompassRotation", rotation );
                    // Adjust the rotation for the map, too...
                    pView->TriggerEvent( "SetPlayerRotationOnMap", rotation - 45.0f );

                    lastRotation = rotation;
                }

                Vec3 cameraPosition = camera.GetPosition();

                if ( ( cameraPosition - lastPosition ).GetLengthSquared() > VEC_EPSILON )
                {
                    pView->TriggerEvent( "SetPlayerPositionOnMap", cameraPosition.x, cameraPosition.y );

                    lastPosition = cameraPosition;
                }
            }
        }
    }