AutoPtr<IArrayMap> EnterTransitionCoordinator::MapNamedElements( //ArrayMap<String, View>
    /* [in] */ IArrayList* accepted,    //<String>
    /* [in] */ IArrayList* localNames)  //<String>
{
    AutoPtr<IArrayMap> sharedElements;
    CArrayMap::New((IArrayMap**)&sharedElements);
    AutoPtr<IViewGroup> vg;
    GetDecor((IViewGroup**)&vg);
    IView* decorView = IView::Probe(vg);
    if (decorView != NULL) {
        decorView->FindNamedViews(IMap::Probe(sharedElements));
    }
    if (accepted != NULL) {
        Int32 size;
        localNames->GetSize(&size);
        for (Int32 i = 0; i < size; i++) {
            AutoPtr<IInterface> localNameObj, acceptedObj;
            localNames->Get(i, (IInterface**)&localNameObj);
            accepted->Get(i, (IInterface**)&acceptedObj);

            if (localNameObj != NULL && !Object::Equals(localNameObj, acceptedObj)) {
                AutoPtr<IInterface> viewObj;
                sharedElements->Remove(localNameObj, (IInterface**)&viewObj);
                if (viewObj != NULL) {
                    sharedElements->Put(acceptedObj, viewObj);
                }
            }
        }
    }
    return sharedElements;
}
void EnterTransitionCoordinator::StartEnterTransition(
    /* [in] */ ITransition* transition)
{
    AutoPtr<IViewGroup> vg;
    GetDecor((IViewGroup**)&vg);
    IView* decorView = IView::Probe(vg);
    if (!mIsReturning && decorView != NULL) {
        AutoPtr<IDrawable> background;
        decorView->GetBackground((IDrawable**)&background);
        if (background != NULL) {
            background->Mutate();
            AutoPtr<IWindow> window;
            GetWindow((IWindow**)&window);
            window->SetBackgroundDrawable(background);
            AutoPtr<ArrayOf<Int32> > args = ArrayOf<Int32>::Alloc(1);
            args->Set(0, 255);
            mBackgroundAnimator = ObjectAnimator::OfInt32(
                IInterface::Probe(background), String("alpha"), args);
            IAnimator* va = IAnimator::Probe(mBackgroundAnimator);
            va->SetDuration(GetFadeDuration());
            AutoPtr<IAnimatorListener> listener = new MyAnimatorListenerAdapter(this);
            va->AddListener(listener);
            va->Start();
        }
        else if (transition != NULL) {
            AutoPtr<ITransitionListener> listener = new EnterTransitionListener(this);
            transition->AddListener(listener);
        }
        else {
            MakeOpaque();
        }
    }
}
ECode EnterTransitionCoordinator::ViewInstancesReady(
    /* [in] */ IArrayList* accepted,    //ArrayList<String>
    /* [in] */ IArrayList* localNames,  //ArrayList<String>
    /* [in] */ IArrayList* localViews)  //ArrayList<View>
{
    Boolean remap = FALSE;
    Int32 size;
    localViews->GetSize(&size);
    Boolean attached;
    String transitionNmae;
    for (Int32 i = 0; i < size; i++) {
        AutoPtr<IInterface> obj, localNameObj;
        localViews->Get(i, (IInterface**)&obj);
        IView* view = IView::Probe(obj);
        view->GetTransitionName(&transitionNmae);
        localNames->Get(i, (IInterface**)&localNameObj);
        if (!TextUtils::Equals(transitionNmae, Object::ToString(localNameObj))
                || (view->IsAttachedToWindow(&attached), !attached)) {
            remap = TRUE;
            break;
        }
    }
    if (remap) {
        return TriggerViewsReady(MapNamedElements(accepted, localNames));
    }
    else {
        return TriggerViewsReady(MapSharedElements(accepted, localViews));
    }
}
ECode EnterTransitionCoordinator::TriggerViewsReady(
    /* [in] */ IArrayMap* sharedElements) //ArrayMap<String, View>
{
    if (mAreViewsReady) {
        return NOERROR;
    }

    mAreViewsReady = TRUE;
    // Ensure the views have been laid out before capturing the views -- we need the epicenter.
    Boolean isEmpty;
    sharedElements->IsEmpty(&isEmpty);
    if (isEmpty) {
        ViewsReady(sharedElements);
        return NOERROR;
    }

    AutoPtr<IInterface> obj;
    sharedElements->Get(0, (IInterface**)&obj);
    IView* sharedElement = IView::Probe(obj);
    Boolean requested;
    sharedElement->IsLayoutRequested(&requested);

    if (!requested) {
        ViewsReady(sharedElements);
    }
    else {
        AutoPtr<IOnPreDrawListener> listener = new SharedElementOnPreDrawListener(
            this, sharedElements, sharedElement);
        AutoPtr<IViewTreeObserver> vto;
        sharedElement->GetViewTreeObserver((IViewTreeObserver**)&vto);
        vto->AddOnPreDrawListener(listener);
    }

    return NOERROR;
}
Example #5
0
//---------------------------------
void CScreenEffects::CamShake(Vec3 rotateShake, Vec3 shiftShake, float freq, float shakeTime, float randomness, int shakeID)
{
	if (g_pGameCVars && g_pGameCVars->g_detachCamera==0)
	{
		IViewSystem *pViewSystem = g_pGame->GetIGameFramework()->GetIViewSystem();
		if (pViewSystem)
		{
			IView *pView = pViewSystem->GetActiveView();
			if (pView)
			{
				const bool bClientActorView = pViewSystem->IsClientActorViewActive();;
				if (gEnv->pFlashUI)
				{
					gEnv->pFlashUI->SetHudElementsVisible(bClientActorView);
				}

				if (bClientActorView && shakeID == eCS_GID_Player)
				{
					CCCPOINT(Camera_DoShake);
					pView->SetViewShake(Ang3(rotateShake), shiftShake, shakeTime, freq, randomness, shakeID, false);
				}
			}
		}
	}
}
ECode EnterTransitionCoordinator::constructor(
    /* [in] */ IActivity* activity,
    /* [in] */ IResultReceiver* resultReceiver,
    /* [in] */ IArrayList* sharedElementNames,
    /* [in] */ Boolean isReturning)
{
    AutoPtr<IWindow> window;
    activity->GetWindow((IWindow**)&window);

    FAIL_RETURN(ActivityTransitionCoordinator::constructor(
        window, sharedElementNames, GetListener(activity, isReturning), isReturning))
    mActivity = activity;
    SetResultReceiver(resultReceiver);
    PrepareEnter();
    AutoPtr<IBundle> resultReceiverBundle;
    CBundle::New((IBundle**)&resultReceiverBundle);
    resultReceiverBundle->PutParcelable(
        ActivityTransitionCoordinator::KEY_REMOTE_RECEIVER, this);

    mResultReceiver->Send(
        IActivityTransitionCoordinator::MSG_SET_REMOTE_RECEIVER, resultReceiverBundle);

    AutoPtr<IViewGroup> vg;
    GetDecor((IViewGroup**)&vg);
    IView* decorView = IView::Probe(vg);
    if (decorView != NULL) {
        AutoPtr<IViewTreeObserver> vto;
        decorView->GetViewTreeObserver((IViewTreeObserver**)&vto);
        AutoPtr<IOnPreDrawListener> listener = new DecorViewOnPreDrawListener(this, decorView);
        vto->AddOnPreDrawListener(listener);
    }
    return NOERROR;
}
void EnterTransitionCoordinator::StartRejectedAnimations(
    /* [in] */ IArrayList* rejectedSnapshots) //ArrayList<View>
{
    Boolean bval;
    if (rejectedSnapshots == NULL || (rejectedSnapshots->IsEmpty(&bval), bval)) {
        return;
    }
    AutoPtr<IViewGroup> vg;
    GetDecor((IViewGroup**)&vg);
    IView* decorView = IView::Probe(vg);
    if (decorView != NULL) {
        AutoPtr<IViewOverlay> vo;
        decorView->GetOverlay((IViewOverlay**)&vo);
        IViewGroupOverlay* overlay = IViewGroupOverlay::Probe(vo);
        AutoPtr<IObjectAnimator> animator;
        Int32 numRejected;
        rejectedSnapshots->GetSize(&numRejected);
        AutoPtr<ArrayOf<Float> > args = ArrayOf<Float>::Alloc(2);
        args->Set(0, 0);
        args->Set(1, 0);
        for (Int32 i = 0; i < numRejected; i++) {
            AutoPtr<IInterface> obj;
            rejectedSnapshots->Get(i, (IInterface**)&obj);
            IView* snapshot = IView::Probe(obj);
            overlay->Add(snapshot);
            animator = ObjectAnimator::OfFloat(
                snapshot, Elastos::Droid::View::View::ALPHA, args);
            IAnimator::Probe(animator)->Start();
        }

        AutoPtr<IAnimatorListener> listener = new RejectedAnimatorListenerAdapter(
            this, decorView, rejectedSnapshots);
        IAnimator::Probe(animator)->AddListener(listener);
    }
}
ECode EnterTransitionCoordinator::Stop()
{
    // Restore the background to its previous state since the
    // Activity is stopping.
    if (mBackgroundAnimator != NULL) {
        IAnimator* va = IAnimator::Probe(mBackgroundAnimator);
        va->End();
        mBackgroundAnimator = NULL;
    }
    else if (mWasOpaque) {
        AutoPtr<IViewGroup> vg;
        GetDecor((IViewGroup**)&vg);
        IView* decorView = IView::Probe(vg);
        if (decorView != NULL) {
            AutoPtr<IDrawable> drawable;
            decorView->GetBackground((IDrawable**)&drawable);
            if (drawable != NULL) {
                drawable->SetAlpha(1);
            }
        }
    }
    MakeOpaque();
    mIsCanceled = TRUE;
    mResultReceiver = NULL;
    mActivity = NULL;
    MoveSharedElementsFromOverlay();
    if (mTransitioningViews != NULL) {
        ShowViews(mTransitioningViews, TRUE);
    }
    ShowViews(mSharedElements, TRUE);
    ClearState();
    return NOERROR;
}
void CAddTriggerController::onLMouseUp	(int x, int y)
{
    IView *pView = getIView();
    ICameraSceneNode *cam = pView->getSceneMgr()->getActiveCamera();

    // get position
    core::vector3df hit;
    bool b = getPickPosition( &hit );

    if ( b )
    {
        core::vector3df camPos = cam->getAbsolutePosition();
        core::line3df camRay( camPos, hit );

        if ( camRay.getLength() < 5000 )
        {
            CTrigger *pObj =	pView->getCurrentZone()->createTrigger();

            pObj->setPosition( hit );
            pObj->setVisible( true );

            // add history
            CHistoryManager* pHistory = CHistoryManager::createGetInstance();
            pHistory->beginHistory();
            pHistory->addHistoryCreateObj( pObj );
            pHistory->endHistory();
        }
        else
            pView->alertError( L"Can not create object because is too far" );
    }
    else
        pView->alertError( L"Can not create object because is too far" );
}
void EnterTransitionCoordinator::PrepareEnter()
{
    AutoPtr<IViewGroup> vg;
    GetDecor((IViewGroup**)&vg);
    IView* decorView = IView::Probe(vg);
    if (mActivity == NULL || decorView == NULL) {
        return;
    }
    mActivity->OverridePendingTransition(0, 0);
    if (!mIsReturning) {
        mActivity->ConvertToTranslucent(NULL, NULL, &mWasOpaque);
        AutoPtr<IDrawable> background;
        decorView->GetBackground((IDrawable**)&background);
        if (background != NULL) {
            AutoPtr<IWindow> window;
            window->SetBackgroundDrawable(NULL);
            background->Mutate();
            background->SetAlpha(0);
            window->SetBackgroundDrawable(background);
        }
    }
    else {
        mActivity = NULL; // all done with it now.
    }
}
// Shake the view as requested
void CPlayerView::ViewShakePostProcess(CPlayer &rPlayer, SViewParams &viewParams)
{
	if (rPlayer.m_stats.inFreefall.Value())
	{
		IView *pView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetViewByEntityId(rPlayer.GetEntityId());

		if (pView)
		{
			float dot(0.1f * min(19.0f, 5.0f + max(0.0f, rPlayer.m_stats.velocity * viewParams.rotation.GetColumn1())));

			if (rPlayer.m_stats.inFreefall.Value() == 2)
			{
				dot *= 0.5f;
			}

			//float white[4] = {1,1,1,1};
			//gEnv->pRenderer->Draw2dLabel( 100, 50, 2, white, false, "dot:%f vel:%f", dot, rPlayer.m_stats.velocity.len() );
			pView->SetViewShake(Ang3(0.0005f, 0.001f, 0.0005f)*dot, Vec3(0.003f, 0.0f, 0.003f)*dot, 0.3f, 0.015f, 1.0f, 2);
		}
	}

	//testing code
	/*if (m_stats.inAir < 0.1f && m_stats.flatSpeed > GetStanceInfo(STANCE_STAND)->maxSpeed * 1.1f)
	{
	float shake(g_pGameCVars->cl_sprintShake);

	IView *pView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetViewByEntityId(GetEntityId());
	if (pView)
	pView->SetViewShake(ZERO,Vec3(m_stats.flatSpeed*0.0035f,0,m_stats.flatSpeed*0.0035f) * shake,0.1f,0.05f,0.5f,1);
	}*/
}
void CCinematicInput::UpdateAdditiveCameraInput( IScriptSystem* pScriptSystem, float frameTime )
{
	CCinematicInput::SUpdateContext updateCtx;

	pScriptSystem->GetGlobalValue("Cinematic_CameraLookUp", updateCtx.m_lookUpLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookDown", updateCtx.m_lookDownLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookLeft", updateCtx.m_lookLeftLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookRight", updateCtx.m_lookRightLimit);
	float recenterCamera = 0.0f;
	pScriptSystem->GetGlobalValue("Cinematic_CameraDoNotCenter", recenterCamera);

	updateCtx.m_lookUpLimit = DEG2RAD(updateCtx.m_lookUpLimit);
	updateCtx.m_lookDownLimit = DEG2RAD(updateCtx.m_lookDownLimit);
	updateCtx.m_lookLeftLimit = DEG2RAD(updateCtx.m_lookLeftLimit);
	updateCtx.m_lookRightLimit = DEG2RAD(updateCtx.m_lookRightLimit);
	updateCtx.m_recenter = (recenterCamera < 0.01f);

	updateCtx.m_frameTime = frameTime;

	CActor* pClientActor = static_cast<CActor*>(g_pGame->GetIGameFramework()->GetClientActor());
	if (pClientActor)
	{
		CRY_ASSERT(pClientActor->GetActorClass() == CPlayer::GetActorClassType());
		CPlayer* pClientPlayer = static_cast<CPlayer*>(pClientActor);

		IPlayerInput* pIPlayerInput = pClientPlayer->GetPlayerInput();
		if(pIPlayerInput && pIPlayerInput->GetType() == IPlayerInput::PLAYER_INPUT)
		{
			CPlayerInput * pPlayerInput = static_cast<CPlayerInput*>(pIPlayerInput);

			Ang3 frameAccumulatedAngles(0.0f, 0.0f, 0.0f);

#if CINEMATIC_INPUT_PC_MOUSE
			const bool isAimingWithMouse = pPlayerInput->IsAimingWithMouse();

			RefreshInputMethod(isAimingWithMouse);

			if (isAimingWithMouse)
			{
				frameAccumulatedAngles = UpdateAdditiveCameraInputWithMouse(updateCtx, pPlayerInput->GetRawMouseInput());
			}
			else
			{
				frameAccumulatedAngles = UpdateAdditiveCameraInputWithController(updateCtx, pPlayerInput->GetRawControllerInput());
			}
#else
			frameAccumulatedAngles = UpdateAdditiveCameraInputWithController(updateCtx, pPlayerInput->GetRawControllerInput());
#endif

			IView* pActiveView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetActiveView();
			if (pActiveView)
			{
				pActiveView->SetFrameAdditiveCameraAngles(frameAccumulatedAngles);
			}
		}
	}
}
void CAddObjectController::cancelController()
{
	IView *pView = getIView();
	wchar_t *currentTemplate = pView->getCurrentObjectTemplate();
	
	CGameObject *p = CObjTemplateFactory::getGameObject( currentTemplate );
	if ( p )
		p->setVisible( false );
}
Example #14
0
// selectObject
// detect list objs at rect
void CDocument::selectObject( int x, int y, int w, int h, bool isControlHold )
{
	IView *pView = getIView();
	ISceneManager *smgr = pView->getSceneMgr();	
	
	ICameraSceneNode *camera = smgr->getActiveCamera();

	// if no camera
	if (  camera == NULL )
		return;

	const SViewFrustum* viewFrustum = camera->getViewFrustum();
	ISceneCollisionManager *collMan = smgr->getSceneCollisionManager();

	int screenX = -1, screenY = -1;
		
	ArrayZoneIter iZone = m_zones.begin(), iEnd = m_zones.end();
	while ( iZone != iEnd )
	{
		ArrayGameObject* listObj = (*iZone)->getChilds();
		ArrayGameObjectIter iObj = listObj->begin(), objEnd = listObj->end();
		ISceneNode *pNode = NULL;

		while ( iObj != objEnd )
		{
			CGameObject *pGameObj = (CGameObject*)(*iObj);
			
			pNode = pGameObj->getSceneNode();
			
			if ( pNode != NULL && pGameObj->isVisible() )
			{
				core::vector3df center = pGameObj->getPosition();

				// check object is in frustum
				if ( viewFrustum->getBoundingBox().isPointInside( center ) )
				{					
					if ( pView->getScreenCoordinatesFrom3DPosition( center, &screenX, &screenY ) )
					{
						if ( x <= screenX && screenX <= x + w && y <= screenY && screenY <= y + h )
						{
							
							if ( isControlHold == false || pGameObj->getObjectState() == CGameObject::Normal )
								m_selectObjects.push_back( pGameObj );							

						}	// inselect
					}	// getScreenCoordinatesFrom3DPosition			
				} // frustum
			}

			iObj++;
		}

		iZone++;
	}

}
Example #15
0
	virtual void ProcessEvent( EFlowEvent event,SActivationInfo* pActInfo )
	{
		switch (event)
		{
		case eFE_Initialize:
		{
			CreateView();
			return;
		}
		break;
		case eFE_Activate:
		{
			if (IsPortActive(pActInfo, EIP_Enable))
			{
				if (m_pView == NULL)
					CreateView();

				if (m_pView == NULL)
					return;

				if (pActInfo->pEntity == NULL)
					return;

				SViewParams params;

				params.justActivated  = true;
				params.fov            = DEG2RAD(GetPortFloat(pActInfo, EIP_FOV));
				params.blend          = GetPortBool(pActInfo, EIP_Blend);
				params.blendFOVOffset = DEG2RAD(GetPortFloat(pActInfo, EIP_BlendFOVOffset));
				params.blendFOVSpeed  = GetPortFloat(pActInfo, EIP_BlendFOVSpeed);
				params.blendPosOffset = GetPortVec3(pActInfo, EIP_BlendPosOffset);
				params.blendPosSpeed  = GetPortFloat(pActInfo, EIP_BlendPosSpeed);
				params.blendRotSpeed  = GetPortFloat(pActInfo, EIP_BlendRotSpeed);
				params.blendRotOffset = Quat::CreateRotationXYZ(static_cast<Ang3>(GetPortVec3(pActInfo, EIP_BlendRotOffset)));

				m_pView->SetCurrentParams(params);
				m_pView->LinkTo(pActInfo->pEntity);

				m_pViewSystem->SetActiveView(m_pView);
			}
			else if (IsPortActive(pActInfo, EIP_Disable))
			{
				if (m_pLocalPlayerView)
					m_pViewSystem->SetActiveView(m_pLocalPlayerView);
			}
			else if (IsPortActive(pActInfo, EIP_FOV))
			{
				SViewParams params;
				params.fov = DEG2RAD(GetPortFloat(pActInfo, EIP_FOV));
				m_pView->SetCurrentParams(params);
			}
		}
		break;
		}
	}
//---------------------------------
void CScreenEffects::CamShake(Vec3 shiftShake, Vec3 rotateShake, float freq, float shakeTime, float randomness, int shakeID)
{
	if (m_ownerActor->IsClient())
	{
		IView *view = gEnv->pGame->GetIGameFramework()->GetIViewSystem()->GetActiveView();
		if (view)
		{
			view->SetViewShake(Ang3(shiftShake), rotateShake, shakeTime, shakeTime, randomness, shakeID, false);
		}
	}
}
Example #17
0
// Shake the view as requested
void CPlayerView::ViewShakePostProcess(CPlayer &rPlayer,SViewParams &viewParams)
{
	if (rPlayer.m_stats.inFreefall.Value())
	{
		IView *pView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetViewByEntityId(rPlayer.GetEntityId());
		if (pView)
		{
			float dot(0.1f * min(19.0f,5.0f + max(0.0f,rPlayer.m_stats.velocity*viewParams.rotation.GetColumn1())));
			if (rPlayer.m_stats.inFreefall.Value()==2)
				dot *= 0.5f;

			//float white[4] = {1,1,1,1};
			//gEnv->pRenderer->Draw2dLabel( 100, 50, 2, white, false, "dot:%f vel:%f", dot, rPlayer.m_stats.velocity.len() );
			
			pView->SetViewShake(Ang3(0.0005f,0.001f,0.0005f)*dot,Vec3(0.003f,0.0f,0.003f)*dot,0.3f,0.015f,1.0f,2);
		}
	}

#if 0
	if (m_io.viewShake.amount>0.001f)
	{
		viewParams.shakeDuration = m_io.viewShake.duration;
		viewParams.shakeFrequency = m_io.viewShake.frequency;
		viewParams.shakeAmount = m_io.viewShake.angle;
		viewParams.shakeID = 1;

		memset(&m_io.viewShake,0,sizeof(SViewShake));
	}
	/*else if (IsZeroG() && m_stats.flatSpeed > 10.0f)
	{
	viewParams.shakeDuration = 0.1f;
	viewParams.shakeFrequency = 0.1f;
	viewParams.shakeAmount = Ang3(m_stats.flatSpeed*0.001f,0,0);
	}*/
	else if (m_in.stats_inAir < 0.1f && m_in.stats_flatSpeed > m_in.stand_MaxSpeed * 1.1f)
	{
		viewParams.shakeDuration = 0.1f ;/// (shake*shake);
		viewParams.shakeFrequency = 0.1f ;/// (shake*shake);
		viewParams.shakeAmount = Ang3(m_in.stats_flatSpeed*0.0015f,m_in.stats_flatSpeed*0.00035f,m_in.stats_flatSpeed*0.00035f) * m_in.shake;
		viewParams.shakeID = 0;
	}
#endif
	//testing code
	/*if (m_stats.inAir < 0.1f && m_stats.flatSpeed > GetStanceInfo(STANCE_STAND)->maxSpeed * 1.1f)
	{
	float shake(g_pGameCVars->cl_sprintShake);

	IView *pView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetViewByEntityId(GetEntityId());
	if (pView)
	pView->SetViewShake(ZERO,Vec3(m_stats.flatSpeed*0.0035f,0,m_stats.flatSpeed*0.0035f) * shake,0.1f,0.05f,0.5f,1);
	}*/
}
Example #18
0
void CCinematicInput::UpdateAdditiveCameraInput(IScriptSystem *pScriptSystem, float frameTime)
{
	float lookUpLimit = 0.0f, lookDownLimit = 0.0f;
	float lookLeftLimit = 0.0f, lookRightLimit = 0.0f;

	pScriptSystem->GetGlobalValue("Cinematic_CameraLookUp", lookUpLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookDown", lookDownLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookLeft", lookLeftLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookRight", lookRightLimit);

	lookUpLimit = DEG2RAD(lookUpLimit);
	lookDownLimit = DEG2RAD(lookDownLimit);
	lookLeftLimit = DEG2RAD(lookLeftLimit);
	lookRightLimit = DEG2RAD(lookRightLimit);

	CActor *pClientActor = static_cast<CActor *>(g_pGame->GetIGameFramework()->GetClientActor());

	if(pClientActor)
	{
		CRY_ASSERT(pClientActor->GetActorClass() == CPlayer::GetActorClassType());
		CPlayer *pClientPlayer = static_cast<CPlayer *>(pClientActor);

		IPlayerInput *pIPlayerInput = pClientPlayer->GetPlayerInput();

		if(pIPlayerInput && pIPlayerInput->GetType() == IPlayerInput::PLAYER_INPUT)
		{
			CPlayerInput *pPlayerInput = static_cast<CPlayerInput *>(pIPlayerInput);

			Ang3 rawMouseInput = pPlayerInput->GetRawMouseInput() * 0.25f;
			rawMouseInput.z = - rawMouseInput.z;
			rawMouseInput.x *= (g_pGameCVars->cl_invertMouse == 0) ? 1.0f : -1.0f;

			Ang3 rawControllerInput = pPlayerInput->GetRawControllerInput() + rawMouseInput;
			//Yaw angle (Z axis)
			rawControllerInput.z = -clamp((float)__fsel(rawControllerInput.z, rawControllerInput.z * lookRightLimit, rawControllerInput.z * lookLeftLimit), -lookLeftLimit, lookRightLimit);
			//Pitch angle (X axis)
			rawControllerInput.x *= (g_pGameCVars->cl_invertController == 0) ? 1.0f : -1.0f;
			rawControllerInput.x = clamp((float)__fsel(rawControllerInput.x, rawControllerInput.x * lookUpLimit, rawControllerInput.x * lookDownLimit), -lookDownLimit, lookUpLimit);
			//No roll allowed
			rawControllerInput.y = 0.0f;

			Interpolate(m_currentRawInputAngles, rawControllerInput, 2.5f, frameTime);

			IView *pActiveView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetActiveView();

			if(pActiveView)
			{
				pActiveView->SetFrameAdditiveCameraAngles(m_currentRawInputAngles);
			}
		}
	}
}
void EnterTransitionCoordinator::SendSharedElementDestination()
{
    Boolean allReady, bval;
    AutoPtr<IViewGroup> vg;
    GetDecor((IViewGroup**)&vg);
    IView* decorView = IView::Probe(vg);
    AutoPtr<ITransition> evt;
    GetEnterViewsTransition((ITransition**)&evt);
    if (AllowOverlappingTransitions() && evt != NULL) {
        allReady = FALSE;
    }
    else if (decorView == NULL) {
        allReady = TRUE;
    }
    else {
        decorView->IsLayoutRequested(&allReady);
        allReady = !allReady;
        if (allReady) {
            Int32 size;
            mSharedElements->GetSize(&size);
            IView* view;
            for (Int32 i = 0; i < size; i++) {
                AutoPtr<IInterface> obj;
                mSharedElements->Get(i, (IInterface**)&obj);
                view = IView::Probe(obj);
                view->IsLayoutRequested(&bval);
                if (bval) {
                    allReady = FALSE;
                    break;
                }
            }
        }
    }

    if (allReady) {
        AutoPtr<IBundle> state = CaptureSharedElementState();
        SetSharedElementMatrices();
        MoveSharedElementsToOverlay();
        mResultReceiver->Send(
            IActivityTransitionCoordinator::MSG_SHARED_ELEMENT_DESTINATION, state);
    }
    else if (decorView != NULL) {
        AutoPtr<IViewTreeObserver> vto;
        decorView->GetViewTreeObserver((IViewTreeObserver**)&vto);
        AutoPtr<IOnPreDrawListener> listener = new DestinationDecorViewOnPreDrawListener(this, decorView);
        vto->AddOnPreDrawListener(listener);
    }
    if (AllowOverlappingTransitions()) {
        StartEnterTransitionOnly();
    }
}
Example #20
0
	//----------------------------------------------------------------------
	void Shake( SActivationInfo* pActInfo, bool bUpdateOnly )
	{
		IView* pView = GetView( pActInfo );
		if (!pView)
			return;

		int currentFrameId = gEnv->pRenderer->GetFrameID();

		if (!bUpdateOnly && (m_lastShakeFrameID == currentFrameId))
			return;

		SInputParams inputParams;
		ReadCurrentInputParams( pActInfo, inputParams );

		IView::SShakeParams params;

		params.bGroundOnly     = inputParams.groundOnly;
		params.isSmooth        = inputParams.isSmooth;
		params.shakeAngle      = inputParams.angle;
		params.shakeShift      = inputParams.shift;
		params.sustainDuration = inputParams.sustainDuration;
		params.bPermanent      = (params.sustainDuration == -1);
		float freq = inputParams.frequency;
		if (iszero(freq) == false)
			freq = 1.0f / freq;
		params.frequency       = freq;
		params.randomness      = inputParams.randomness;
		params.bFlipVec        = true;        // GetPortBool(pActInfo, EIP_Flip);
		params.bUpdateOnly     = bUpdateOnly; // it's an update if and only if Frequency has been changed
		params.fadeInDuration  = inputParams.fadeInDuration;
		params.fadeOutDuration = inputParams.fadeOutDuration;
		params.shakeID         = FLOWGRAPH_SHAKE_ID;

		float    distance    = inputParams.distance;
		IEntity* pEntityNode = pActInfo->pEntity;
		if (pEntityNode)
		{
			distance = pView->GetCurrentParams()->position.GetDistance( pEntityNode->GetWorldPos());
		}

		const float rangeMin = inputParams.rangeMin;
		const float rangeMax = inputParams.rangeMax;
		float       amount   = min(1.f, max(0.f, (rangeMax - distance) / (rangeMax - rangeMin)));

		params.shakeAngle *= amount;
		params.shakeShift *= amount;

		pView->SetViewShakeEx( params );

		m_lastShakeFrameID = currentFrameId;
	}
void EnterTransitionCoordinator::StartSharedElementTransition(
    /* [in] */ IBundle* sharedElementState)
{
    AutoPtr<IViewGroup> vg;
    GetDecor((IViewGroup**)&vg);
    IView* decorView = IView::Probe(vg);
    if (decorView == NULL) {
        return;
    }
    // Remove rejected shared elements
    AutoPtr<IArrayList> rejectedNames;
    CArrayList::New(ICollection::Probe(mAllSharedElementNames), (IArrayList**)&rejectedNames);
    rejectedNames->RemoveAll(ICollection::Probe(mSharedElementNames));
    AutoPtr<IArrayList> rejectedSnapshots = CreateSnapshots(
        sharedElementState, ICollection::Probe(rejectedNames));
    if (mListener != NULL) {
        mListener->OnRejectSharedElements(IList::Probe(rejectedSnapshots));
    }
    StartRejectedAnimations(rejectedSnapshots);

    // Now start shared element transition
    AutoPtr<IArrayList> sharedElementSnapshots = CreateSnapshots(
        sharedElementState, ICollection::Probe(mSharedElementNames));
    ShowViews(mSharedElements, TRUE);
    ScheduleSetSharedElementEnd(sharedElementSnapshots);
    AutoPtr<IArrayList> originalImageViewState = SetSharedElementState(
        sharedElementState, sharedElementSnapshots);
    RequestLayoutForSharedElements();

    Boolean startEnterTransition = AllowOverlappingTransitions() && !mIsReturning;
    Boolean startSharedElementTransition = TRUE;
    SetGhostVisibility(IView::INVISIBLE);
    ScheduleGhostVisibilityChange(IView::INVISIBLE);
    AutoPtr<ITransition> transition = BeginTransition(
        vg, startEnterTransition, startSharedElementTransition);
    ScheduleGhostVisibilityChange(IView::VISIBLE);
    SetGhostVisibility(IView::VISIBLE);

    if (startEnterTransition) {
        StartEnterTransition(transition);
    }

    SetOriginalSharedElementState(mSharedElements, originalImageViewState);

    if (mResultReceiver != NULL) {
        // We can't trust that the view will disappear on the same frame that the shared
        // element appears here. Assure that we get at least 2 frames for double-buffering.
        AutoPtr<IRunnable> runnable = new OnAnimationRunnable(this);
        decorView->PostOnAnimation(runnable);
    }
}
Example #22
0
void ViewManager::objectAdded(QObject *obj)
{
    IView *view = Aggregation::query<IView>(obj);
    if (!view)
        return;

    QWidget *viewWidget = 0;
    viewWidget = view->widget();
    m_statusBarWidgets.at(view->defaultPosition())->layout()->addWidget(viewWidget);

    m_viewMap.insert(view, viewWidget);
    viewWidget->setObjectName(view->uniqueViewName());
    m_mainWnd->addContextObject(view);
}
Example #23
0
void UeGui::CHistoryInformationHook::OnGetRouteName( void* sender, const UeQuery::SQLRecord * data )
{
  if (NULL == sender)
  {
    return;
  }

  CViewHook::m_curHookType = CViewHook::DHT_HistoryInformationHook;
  CHistoryInformationHook* historyInformationHook = static_cast<CHistoryInformationHook*>(sender);
  historyInformationHook->EditRecord(data->m_asciiName);  
  //QJW 
  IView *view = IView::GetView();
  view->RefreshUI();
}
bool CBaseAddController::getPickPosition( core::vector3df *pos )
{
	IView *pView = getIView();

	// move object
	core::line3df	ray = pView->getSelectRay();

	// check hit on terrain
	CDocument *pDoc = (CDocument*) pView->getDocument();
	ArrayZone* zones = pDoc->getAllZone();
	
	ArrayZoneIter i = zones->begin(), end = zones->end();
	while ( i != end )
	{
		core::vector3df		colPoint;
		core::triangle3df	colTri;
		float maxDistance = ray.getLengthSQ();

		if ( (*i)->getTerrainCollision( ray, maxDistance, colPoint, colTri ) == true )
		{
			*pos = colPoint;
			return true;
		}
		i++;
	}

	core::plane3df	plane( core::vector3df(0.0f, 0.0f, 0.0f), core::vector3df(0.0f, 1.0f, 0.0f) );
	
	// get position
	core::vector3df hit;
	bool b = plane.getIntersectionWithLine( ray.start, ray.getVector(), hit );
	
	if ( b )
	{
		ICameraSceneNode *cam = pView->getSceneMgr()->getActiveCamera();

		core::vector3df camPos = cam->getAbsolutePosition();		
		core::line3df camRay( camPos, hit );

		if ( camRay.getLength() < 5000 )
		{
			*pos = hit;
			return true;
		}
	}

	return false;
}
Example #25
0
int CScriptBind_Actor::SetViewShake(IFunctionHandler *pH, Ang3 shakeAngle, Vec3 shakeShift, float duration, float frequency, float randomness)
{
	CActor *pActor = GetActor(pH);
	if (!pActor)
		return pH->EndFunction();

	EntityId actorId = pActor->GetEntityId();
	IView* pView = m_pGameFW->GetIViewSystem()->GetViewByEntityId(actorId);
	if (pView)
	{
		const int SCRIPT_SHAKE_ID = 42;
		pView->SetViewShake(shakeAngle, shakeShift, duration, frequency, randomness, SCRIPT_SHAKE_ID);
	}

	return pH->EndFunction();
}
ECode EnterTransitionCoordinator::OnAnimationRunnable::Run()
{
    if (mAnimations++ < EnterTransitionCoordinator::MIN_ANIMATION_FRAMES) {
        AutoPtr<IViewGroup> vg;
        mHost->GetDecor((IViewGroup**)&vg);
        IView* decorView = IView::Probe(vg);
        if (decorView != NULL) {
            decorView->PostOnAnimation(this);
        }
    }
    else if (mHost->mResultReceiver != NULL) {
        mHost->mResultReceiver->Send(
            IActivityTransitionCoordinator::MSG_HIDE_SHARED_ELEMENTS, NULL);
        mHost->mResultReceiver = NULL; // all done sending messages.
    }
    return NOERROR;
}
Example #27
0
ECode ActionBarContainer::SetTabContainer(
    /* [in] */ IScrollingTabContainerView* tabView)
{
    if (mTabContainer != NULL) {
        RemoveView(mTabContainer);
    }
    mTabContainer = IView::Probe(tabView);
    if (tabView != NULL) {
        IView* view = IView::Probe(tabView);
        AddView(view);
        AutoPtr<IViewGroupLayoutParams> lp;
        view->GetLayoutParams((IViewGroupLayoutParams**)&lp);
        lp->SetWidth(IViewGroupLayoutParams::MATCH_PARENT);
        lp->SetHeight(IViewGroupLayoutParams::WRAP_CONTENT);
        tabView->SetAllowCollapse(FALSE);
    }
    return NOERROR;
}
//------------------------------------------------------------------------
void CShake::Update(SEntityUpdateContext &ctx, int updateSlot)
{
	IActor *pClient = g_pGame->GetIGameFramework()->GetClientActor();
	if (pClient)
	{
		float dist2ToClient((pClient->GetEntity()->GetWorldPos() - GetEntity()->GetWorldPos()).len2());
		float maxRange(m_radius * m_radius);
		if (dist2ToClient<maxRange)
		{
			IView *pView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetViewByEntityId(pClient->GetEntityId());
			if (pView)
			{
				float strength = (1.0f - (dist2ToClient/maxRange)) * 0.5f;
				pView->SetViewShake(ZERO,Vec3(m_shake*strength,0,m_shake*strength),0.1f,0.0225f,1.5f,1);
			}
		}
	}
}
void EnterTransitionCoordinator::OnTakeSharedElements()
{
    if (!mIsReadyForTransition || mSharedElementsBundle == NULL) {
        return;
    }
    AutoPtr<IBundle> sharedElementState = mSharedElementsBundle;
    mSharedElementsBundle = NULL;
    AutoPtr<IViewGroup> vg;
    GetDecor((IViewGroup**)&vg);
    IView* decorView = IView::Probe(vg);
    if (decorView != NULL) {
        AutoPtr<IViewTreeObserver> vto;
        decorView->GetViewTreeObserver((IViewTreeObserver**)&vto);
        AutoPtr<IOnPreDrawListener> listener = new TakeSharedElementsOnPreDrawListener(
            this, decorView, sharedElementState);
        vto->AddOnPreDrawListener(listener);
        decorView->Invalidate();
    }
}
void CAddObjectController::onMouseMove(int x, int y)
{	
	IView *pView = getIView();

	// get position
	core::vector3df hit;
	bool b = getPickPosition( &hit );
	
	if ( b )
	{
		CGameObject *pObj = pView->getGameObjectOfCurrentTemplate();
		if ( pObj && pObj->isVisible() == false )
			pObj->setVisible( true );
		if ( pObj )
		{
			pObj->updateObject();
			pObj->setPosition( hit );			
		}
	}
}