//------------------------------------------------------------------------ IMPLEMENT_RMI(CWeapon, SvRequestSetZoomState) { CHECK_OWNER_REQUEST(); if (params.zoomed) StartZoom(m_owner.GetId(), 1); else StopZoom(m_owner.GetId()); CHANGED_NETWORK_STATE(this, ASPECT_STREAM); return true; }
//------------------------------------------------------------------------------ bool CWeapon::OnActionZoomXI(EntityId actorId, const ActionId& actionId, int activationMode, float value) { if (!AreAnyItemFlagsSet(eIF_Modifying)) { if (g_pGameCVars->hud_ctrlZoomMode) { if (activationMode == eAAM_OnPress) { if(m_fm && !m_fm->IsReloading()) { // The zoom code includes the aim assistance if (m_fm->AllowZoom()) { StartZoom(actorId,1); } else { m_fm->Cancel(); } } } else if (activationMode == eAAM_OnRelease) { if(m_fm && !m_fm->IsReloading()) { StopZoom(actorId); } } } else { if (activationMode == eAAM_OnPress && m_fm && !m_fm->IsReloading()) { if (m_fm->AllowZoom()) { StartZoom(actorId,1); } else { m_fm->Cancel(); } } } } return true; }
//------------------------------------------------------------------------------ bool CWeapon::OnActionZoomXI(EntityId actorId, const ActionId& actionId, int activationMode, float value) { COffHand * offHandWeapon = NULL; bool isOffHandSelected = false; GetOffHandInfo(this,isOffHandSelected,&offHandWeapon); if (!m_modifying && !isOffHandSelected && !IsWeaponRaised()) { bool isDualWield = false; CWeapon *dualWield = NULL; GetDualWieldInfo(this,isDualWield,&dualWield); if (m_useViewMode) { if (activationMode == eAAM_OnPress) IncrementViewmode(); } else if (g_pGameCVars->hud_ctrlZoomMode) { if (activationMode == eAAM_OnPress) { if (!isDualWield) { if(m_fm && !m_fm->IsReloading()) { // The zoom code includes the aim assistance if (m_fm->AllowZoom()) StartZoom(actorId,1); else m_fm->Cancel(); } } else { // If the view does not zoom, we need to force aim assistance AssistAiming(1, true); } } else if (activationMode == eAAM_OnRelease) { if (!isDualWield) { if(m_fm && !m_fm->IsReloading()) StopZoom(actorId); } } } else { if (activationMode == eAAM_OnPress && m_fm && !m_fm->IsReloading()) { if (!isDualWield) { if (m_fm->AllowZoom()) StartZoom(actorId,1); else m_fm->Cancel(); } else { // If the view does not zoom, we need to force aim assistance AssistAiming(1, true); } } } } return true; }
//------------------------------------------------------------------------ bool CIronSight::StartZoom(bool stayZoomed, bool fullZoomout, int zoomStep) { if(m_pWeapon->IsBusy() || (IsToggle() && IsZoomingInOrOut())) return false; CActor *pActor = m_pWeapon->GetOwnerActor(); CScreenEffects *pSE = pActor?pActor->GetScreenEffects():NULL; if(pSE) { pSE->EnableBlends(false, CScreenEffects::eSFX_GID_ZoomIn); pSE->EnableBlends(false, CScreenEffects::eSFX_GID_ZoomOut); pSE->EnableBlends(false, CScreenEffects::eSFX_GID_HitReaction); } if(!m_zoomed || stayZoomed) { EnterZoom(m_pShared->zoomParams.zoom_in_time, m_pShared->zoomParams.layer.c_str(), true, zoomStep); m_currentStep = zoomStep; m_pWeapon->AssistAiming(m_pShared->zoomParams.stages[m_currentStep-1], true); } else { int currentStep = m_currentStep; int nextStep = currentStep+1; if(nextStep > m_pShared->zoomParams.stages.size()) { if(!stayZoomed) { if(fullZoomout) { StopZoom(); } else { float oFoV = GetZoomFoVScale(currentStep); m_currentStep = 0; float tFoV = GetZoomFoVScale(m_currentStep); ZoomIn(m_pShared->zoomParams.stage_time, oFoV, tFoV, true); return true; } } } else { float oFoV = GetZoomFoVScale(currentStep); float tFoV = GetZoomFoVScale(nextStep); ZoomIn(m_pShared->zoomParams.stage_time, oFoV, tFoV, true); m_currentStep = nextStep; m_pWeapon->AssistAiming(m_pShared->zoomParams.stages[m_currentStep-1], true); return true; } } return false; }
//------------------------------------------------------------------------ void CThrowIndicator::ExitZoom(bool force) { StopZoom(); }
bool CWeapon::OnActionZoom(EntityId actorId, const ActionId& actionId, int activationMode, float value) { if (IsModifying()) { return false; } const bool zoomingIn = IsZoomingIn(); const bool zoomed = IsZoomed(); const bool toggleMode = (g_pGameCVars->cl_zoomToggle > 0); const bool toggleZoomOn = !(zoomingIn || zoomed); const bool buttonPressed = (activationMode == eAAM_OnPress); if (!toggleMode) { // Toggle mode is off, i.e. You have to hold to stay zoomed. if(buttonPressed || activationMode == eAAM_OnHold) { SetInputFlag(eWeaponAction_Zoom); } else { ClearInputFlag(eWeaponAction_Zoom); } } else { // Toggle mode is on. if(buttonPressed) { if (toggleZoomOn) { SetInputFlag(eWeaponAction_Zoom); } else { ClearInputFlag(eWeaponAction_Zoom); } } } //can ironsight while super jumping in MP const bool trumpZoom = !CanZoomInState(); if (!AreAnyItemFlagsSet(eIF_Modifying) && !trumpZoom) { if (!m_fm || !m_fm->IsReloading()) { if (buttonPressed && (!toggleMode || toggleZoomOn)) { if(m_fm && !m_fm->AllowZoom()) { if(IsTargetOn()) { m_fm->Cancel(); } else { return false; } } } else if ((!toggleMode && activationMode == eAAM_OnRelease) || // Not toggle mode and button is released (toggleMode && !toggleZoomOn && buttonPressed)) // Toggle mode, zoom is to be toggled off and button is pressed { StopZoom(actorId); } const bool shouldStartZoom = (!toggleMode && (buttonPressed || activationMode == eAAM_OnHold)) || (toggleMode && toggleZoomOn && buttonPressed); if (m_zm && shouldStartZoom) { const bool zoomingOut = m_zm->IsZoomingInOrOut() && !zoomingIn; if ((!zoomed && !zoomingIn) || zoomingOut) { StartZoom(actorId,1); } if (buttonPressed) { m_snapToTargetTimer = 0.5f; } } } else if( (!toggleMode && activationMode == eAAM_OnRelease) || (toggleMode && !toggleZoomOn && buttonPressed) ) { StopZoom(actorId); } } else if (trumpZoom) { StopZoom(actorId); } return true; }
//----------------------------------------------------------------------------- //! //----------------------------------------------------------------------------- tSteerPanel::tSteerPanel( int id, tSteerPanelWidgetBase& steerPanelWidget, const tMfdUiFactory& mfdUiFactory, tVesselsSettings& vesselSettings, tNavigationDataEngine& navigationDataEngine, QWidget* parent ) : tPanel(parent) , m_pPanelWidget ( &steerPanelWidget ) , m_pSetRouteAct ( 0 ) , m_pSetWptAct ( 0 ) , m_pSkipNavigationAct ( 0 ) , m_pCancelNavAct ( 0 ) , m_pXTEResetAct ( 0 ) , m_pNewWaypointAct ( 0 ) , m_pBlankSpaceAct ( 0 ) , m_mfdUiFactory ( mfdUiFactory ) , m_VesselsSettings( vesselSettings ) , m_pNavigationDataEngine( &navigationDataEngine ) , m_helpTimerID( 0 ) , m_PanelIsSmall( false ) { steerPanelWidget.setParent(this); //Reparent under this widget // Used by the panel manager to know which panel is specified to open QString str = QString("steerPanel%1").arg(id); setObjectName( str ); QGridLayout* pMainLayout = new QGridLayout( this ); pMainLayout->setContentsMargins( 0, 0, 0, 0 ); pMainLayout->setSpacing( 0 ); setLayout( pMainLayout ); //Add the widget to the layout pMainLayout->addWidget(m_pPanelWidget); CreateActions(); setMinimumSize( 100, 135 ); if( tProductSettings::Instance().UsbMouseWheelInversionAllowed() == true ) { // See tApplication::WheelEventFilter() for an explanation! setProperty( "InvertUsbMouseWheel", true ); } UpdateActions(); //Create the zoom buttons if ( tUiConfig::Instance()->HasZoomButton() ) { CreateZoomPanelButtons(); m_pZoomButton->setObjectName("ZoomButton"); m_pZoomButton->SetOverlayOnGL( true ); if( m_pPanelWidget != 0 ) { Connect( m_pZoomButton, SIGNAL( ZoomInClicked() ), m_pPanelWidget, SLOT( StartZoomIn() ) ); Connect( m_pZoomButton, SIGNAL( ZoomOutClicked() ), m_pPanelWidget, SLOT( StartZoomOut() ) ); Connect( m_pZoomButton, SIGNAL( ZoomButtonReleased() ), m_pPanelWidget, SLOT( StopZoom() ) ); } } }
//----------------------------------------------------------------------------- //! //----------------------------------------------------------------------------- void tSteerPanel::OnChartVendorChanged(unsigned int instance, const QString& /*type*/) { if (instance == 0) { SafeDelete(m_pPanelWidget); //Rebuild the panel widget RebuildPanelWidget(); layout()->addWidget( m_pPanelWidget ); //Connect the zoom buttons up to the new panel widget if ( ( m_pZoomButton != 0 ) && (m_pPanelWidget != 0) ) { Connect( m_pZoomButton, SIGNAL( ZoomInClicked() ), m_pPanelWidget, SLOT( StartZoomIn() ) ); Connect( m_pZoomButton, SIGNAL( ZoomOutClicked() ), m_pPanelWidget, SLOT( StartZoomOut() ) ); Connect( m_pZoomButton, SIGNAL( ZoomButtonReleased() ), m_pPanelWidget, SLOT( StopZoom() ) ); } } }