From d14dc8f7a8fa418e48796a8f9eb2fad541f9842a Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 29 May 2017 09:55:44 -1000 Subject: [PATCH] Finish CPauseScreenBlur; work on CPlayerVisor --- DataSpec/DNACommon/Tweaks/ITweakGui.hpp | 6 + DataSpec/DNACommon/Tweaks/ITweakGuiColors.hpp | 3 +- DataSpec/DNAMP1/Tweaks/CTweakGui.hpp | 18 +- DataSpec/DNAMP1/Tweaks/CTweakGuiColors.hpp | 7 +- DataSpec/SpecMP2.cpp | 2 +- Runtime/Camera/CCameraFilter.hpp | 1 + Runtime/MP1/CInGameGuiManager.cpp | 8 +- Runtime/MP1/CPauseScreenBlur.cpp | 111 +++++- Runtime/MP1/CPauseScreenBlur.hpp | 32 +- Runtime/MP1/CPlayerVisor.cpp | 317 +++++++++++++++++- Runtime/MP1/CPlayerVisor.hpp | 75 +++++ Runtime/MP1/CSamusDoll.cpp | 2 +- hecl | 2 +- nod | 2 +- 14 files changed, 544 insertions(+), 42 deletions(-) diff --git a/DataSpec/DNACommon/Tweaks/ITweakGui.hpp b/DataSpec/DNACommon/Tweaks/ITweakGui.hpp index 86913c7b5..6d70162dd 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGui.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGui.hpp @@ -28,6 +28,7 @@ struct ITweakGui : ITweak }; virtual float GetMapAlphaInterpolant() const=0; + virtual float GetPauseBlurFactor() const=0; virtual float GetRadarXYRadius() const=0; virtual float GetRadarZRadius() const=0; virtual float GetRadarZCloseRadius() const=0; @@ -101,6 +102,11 @@ struct ITweakGui : ITweak virtual float GetScanPaneFadeInTime() const=0; virtual float GetScanPaneFadeOutTime() const=0; virtual float GetBallViewportYReduction() const=0; + virtual float GetScanWindowIdleWidth() const=0; + virtual float GetScanWindowIdleHeight() const=0; + virtual float GetScanWindowActiveWidth() const=0; + virtual float GetScanWindowActiveHeight() const=0; + virtual float GetScanWindowMagnification() const=0; virtual float GetScanSpeed(int idx) const=0; virtual float GetXrayBlurScaleLinear() const=0; virtual float GetXrayBlurScaleQuadratic() const=0; diff --git a/DataSpec/DNACommon/Tweaks/ITweakGuiColors.hpp b/DataSpec/DNACommon/Tweaks/ITweakGuiColors.hpp index 3a337ba0e..411eb32d9 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGuiColors.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGuiColors.hpp @@ -22,7 +22,7 @@ struct ITweakGuiColors : BigYAML const zeus::CColor& shadow; }; - virtual const zeus::CColor& GetInvPhazonSuitFilterMod() const=0; + virtual const zeus::CColor& GetPauseBlurFilterColor() const=0; virtual const zeus::CColor& GetRadarStuffColor() const=0; virtual const zeus::CColor& GetRadarPlayerPaintColor() const=0; virtual const zeus::CColor& GetRadarEnemyPaintColor() const=0; @@ -63,6 +63,7 @@ struct ITweakGuiColors : BigYAML virtual const zeus::CColor& GetMissileWarningOutline() const=0; virtual const zeus::CColor& GetDamageAmbientColor() const=0; virtual const zeus::CColor& GetScanVisorHudLightMultiply() const=0; + virtual const zeus::CColor& GetScanVisorScreenDimColor() const=0; virtual const zeus::CColor& GetThermalVisorHudLightMultiply() const=0; virtual const zeus::CColor& GetEnergyDrainFilterColor() const=0; virtual const zeus::CColor& GetDamageAmbientPulseColor() const=0; diff --git a/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp b/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp index 0b3eba034..3394f2d1e 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp @@ -12,7 +12,7 @@ struct CTweakGui : ITweakGui DECL_YAML Value x4_; Value x8_mapAlphaInterp; - Value xc_; + Value xc_pauseBlurFactor; Value x10_radarXYRadius; Value x14_; Value x18_; @@ -141,11 +141,11 @@ struct CTweakGui : ITweakGui Value x24c_scanPaneFadeInTime; Value x250_scanPaneFadeOutTime; Value x254_ballViewportYReduction; - Value x258_; - Value x25c_; - Value x260_; - Value x264_; - Value x268_; + Value x258_scanWindowIdleW; + Value x25c_scanWindowIdleH; + Value x260_scanWindowActiveW; + Value x264_scanWindowActiveH; + Value x268_scanWindowMagnification; Value x26c_; Value x270_scanSidesPositionStart; Value x274_showAutomapperInMorphball; @@ -190,6 +190,7 @@ struct CTweakGui : ITweakGui CTweakGui(athena::io::IStreamReader& r) { this->read(r); } float GetMapAlphaInterpolant() const { return x8_mapAlphaInterp; } + float GetPauseBlurFactor() const { return xc_pauseBlurFactor; } float GetRadarXYRadius() const { return x10_radarXYRadius; } float GetRadarZRadius() const { return x24_radarZRadius; } float GetRadarZCloseRadius() const { return x28_radarZCloseRadius; } @@ -277,6 +278,11 @@ struct CTweakGui : ITweakGui float GetScanPaneFadeInTime() const { return x24c_scanPaneFadeInTime; } float GetScanPaneFadeOutTime() const { return x250_scanPaneFadeOutTime; } float GetBallViewportYReduction() const { return x254_ballViewportYReduction; } + float GetScanWindowIdleWidth() const { return x258_scanWindowIdleW; } + float GetScanWindowIdleHeight() const { return x25c_scanWindowIdleH; } + float GetScanWindowActiveWidth() const { return x260_scanWindowActiveW; } + float GetScanWindowActiveHeight() const { return x264_scanWindowActiveH; } + float GetScanWindowMagnification() const { return x268_scanWindowMagnification; } float GetScanSidesPositionStart() const { return x270_scanSidesPositionStart; } bool GetShowAutomapperInMorphball() const { return x274_showAutomapperInMorphball; } bool GetLatchArticleText() const { return x275_latchArticleText; } diff --git a/DataSpec/DNAMP1/Tweaks/CTweakGuiColors.hpp b/DataSpec/DNAMP1/Tweaks/CTweakGuiColors.hpp index 7a24051ed..693c77773 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakGuiColors.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakGuiColors.hpp @@ -10,7 +10,7 @@ namespace DNAMP1 struct CTweakGuiColors : public ITweakGuiColors { DECL_YAML - DNAColor x4_invPhazonSuitFilterMod; + DNAColor x4_pauseBlurFilterColor; DNAColor x8_radarStuffColor; DNAColor xc_radarPlayerPaintColor; DNAColor x10_radarEnemyPaintColor; @@ -63,7 +63,7 @@ struct CTweakGuiColors : public ITweakGuiColors DNAColor xcc_; DNAColor xd0_; DNAColor xd4_scanVisorHudLightMultiply; - DNAColor xd8_; + DNAColor xd8_scanVisorScreenDimColor; DNAColor xdc_thermalVisorHudLightMultiply; DNAColor xe0_energyDrainFilterColor; DNAColor xe4_damageAmbientPulseColor; @@ -140,7 +140,7 @@ struct CTweakGuiColors : public ITweakGuiColors CTweakGuiColors() = default; CTweakGuiColors(athena::io::IStreamReader& r) { this->read(r); } - const zeus::CColor& GetInvPhazonSuitFilterMod() const { return x4_invPhazonSuitFilterMod; } + const zeus::CColor& GetPauseBlurFilterColor() const { return x4_pauseBlurFilterColor; } const zeus::CColor& GetRadarStuffColor() const { return x8_radarStuffColor; } const zeus::CColor& GetRadarPlayerPaintColor() const { return xc_radarPlayerPaintColor; } const zeus::CColor& GetRadarEnemyPaintColor() const { return x10_radarEnemyPaintColor; } @@ -181,6 +181,7 @@ struct CTweakGuiColors : public ITweakGuiColors const zeus::CColor& GetMissileWarningOutline() const { return xbc_missileWarningOutline; } const zeus::CColor& GetDamageAmbientColor() const { return xc4_damageAmbientColor; } const zeus::CColor& GetScanVisorHudLightMultiply() const { return xd4_scanVisorHudLightMultiply; } + const zeus::CColor& GetScanVisorScreenDimColor() const { return xd8_scanVisorScreenDimColor; } const zeus::CColor& GetThermalVisorHudLightMultiply() const { return xdc_thermalVisorHudLightMultiply; } const zeus::CColor& GetEnergyDrainFilterColor() const { return xe0_energyDrainFilterColor; } const zeus::CColor& GetDamageAmbientPulseColor() const { return xe4_damageAmbientPulseColor; } diff --git a/DataSpec/SpecMP2.cpp b/DataSpec/SpecMP2.cpp index 5e9e539ed..f6f0856f7 100644 --- a/DataSpec/SpecMP2.cpp +++ b/DataSpec/SpecMP2.cpp @@ -231,7 +231,7 @@ struct SpecMP2 : SpecBase int prog = 0; ctx.progressCB = [&](const std::string& name, float) { hecl::SystemStringView nameView(name); - progress(_S("MP2 Root"), nameView.c_str(), 3, prog / (float)m_nonPaks.size()); + progress(_S("MP2 Root"), nameView.c_str(), 3, prog); }; for (const nod::Node* node : m_nonPaks) { diff --git a/Runtime/Camera/CCameraFilter.hpp b/Runtime/Camera/CCameraFilter.hpp index e4d6eba33..8ebc3ed96 100644 --- a/Runtime/Camera/CCameraFilter.hpp +++ b/Runtime/Camera/CCameraFilter.hpp @@ -74,6 +74,7 @@ public: void Update(float dt); void SetBlur(EBlurType type, float amount, float duration); void DisableBlur(float duration); + EBlurType GetCurrType() const { return x10_curType; } }; } diff --git a/Runtime/MP1/CInGameGuiManager.cpp b/Runtime/MP1/CInGameGuiManager.cpp index d6368ce99..c581e4c55 100644 --- a/Runtime/MP1/CInGameGuiManager.cpp +++ b/Runtime/MP1/CInGameGuiManager.cpp @@ -122,7 +122,7 @@ void CInGameGuiManager::EnsureStates(CStateManager& stateMgr) { if (x1f8_26_deferTransition) { - if (!x3c_pauseScreenBlur->GetX50_25()) + if (!x3c_pauseScreenBlur->IsGameDraw()) { DestroyAreaTextures(stateMgr); x1f8_26_deferTransition = false; @@ -593,7 +593,7 @@ void CInGameGuiManager::Draw(CStateManager& stateMgr) if (notInCine && (x1bc_prevState == EInGameGuiState::InGame || x1c0_nextState == EInGameGuiState::InGame)) drawVisor = true; - if (x3c_pauseScreenBlur->GetX50_25()) + if (x3c_pauseScreenBlur->IsGameDraw()) { x34_samusHud->GetTargetingManager().Draw(stateMgr, true); CGraphics::SetDepthRange(0.015625f, 0.03125f); @@ -631,7 +631,7 @@ void CInGameGuiManager::Draw(CStateManager& stateMgr) x3c_pauseScreenBlur->Draw(stateMgr); if (notInCine && x1e8_enableAutoMapper && - (x3c_pauseScreenBlur->GetX50_25() || x1bc_prevState == EInGameGuiState::MapScreen || + (x3c_pauseScreenBlur->IsGameDraw() || x1bc_prevState == EInGameGuiState::MapScreen || x1c0_nextState == EInGameGuiState::MapScreen)) { float t; @@ -754,7 +754,7 @@ void CInGameGuiManager::StartFadeIn() bool CInGameGuiManager::GetIsGameDraw() const { - return x3c_pauseScreenBlur->GetX50_25(); + return x3c_pauseScreenBlur->IsGameDraw(); } } diff --git a/Runtime/MP1/CPauseScreenBlur.cpp b/Runtime/MP1/CPauseScreenBlur.cpp index e79d0deca..1b1fffd5a 100644 --- a/Runtime/MP1/CPauseScreenBlur.cpp +++ b/Runtime/MP1/CPauseScreenBlur.cpp @@ -1,4 +1,7 @@ #include "CPauseScreenBlur.hpp" +#include "CSimplePool.hpp" +#include "GameGlobalObjects.hpp" +#include "Audio/CSfxManager.hpp" namespace urde { @@ -7,27 +10,117 @@ namespace MP1 CPauseScreenBlur::CPauseScreenBlur() { - -} - -bool CPauseScreenBlur::CheckLoadComplete() -{ - return false; + x4_mapLightQuarter = g_SimplePool->GetObj("TXTR_MapLightQuarter"); + x50_25_gameDraw = true; } void CPauseScreenBlur::OnNewInGameGuiState(EInGameGuiState state, CStateManager& stateMgr) { - + switch (state) + { + case EInGameGuiState::Zero: + case EInGameGuiState::InGame: + SetState(EState::InGame); + break; + case EInGameGuiState::MapScreen: + SetState(EState::MapScreen); + break; + case EInGameGuiState::PauseSaveGame: + SetState(EState::SaveGame); + break; + case EInGameGuiState::PauseHUDMessage: + SetState(EState::HUDMessage); + break; + case EInGameGuiState::PauseGame: + case EInGameGuiState::PauseLogBook: + SetState(EState::Pause); + break; + default: break; + } } -void CPauseScreenBlur::Update(float dt, const CStateManager& stateMgr, bool) +void CPauseScreenBlur::SetState(EState state) { + if (x10_prevState == EState::InGame && state != EState::InGame) + { + CSfxManager::SetChannel(CSfxManager::ESfxChannels::PauseScreen); + if (state == EState::HUDMessage) + CSfxManager::SfxStart(1415, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); + else if (state == EState::MapScreen) + CSfxManager::SfxStart(1378, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); + x18_blurAmt = FLT_EPSILON; + } + if (state == EState::InGame && (x10_prevState != EState::InGame || x14_nextState != EState::InGame)) + { + CSfxManager::SetChannel(CSfxManager::ESfxChannels::Game); + if (x10_prevState == EState::HUDMessage) + CSfxManager::SfxStart(1416, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); + else if (x10_prevState == EState::MapScreen) + CSfxManager::SfxStart(1380, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); + x18_blurAmt = -1.f; + } + + x14_nextState = state; } -void CPauseScreenBlur::Draw(const CStateManager& stateMgr) const +void CPauseScreenBlur::OnBlurComplete(bool b) { + if (x14_nextState == EState::InGame && !b) + return; + x10_prevState = x14_nextState; + if (x10_prevState == EState::InGame) + x50_25_gameDraw = true; +} +void CPauseScreenBlur::Update(float dt, const CStateManager& stateMgr, bool b) +{ + if (x10_prevState == x14_nextState) + return; + + if (x18_blurAmt < 0.f) + x18_blurAmt = std::min(0.f, 2.f * dt + x18_blurAmt); + else + x18_blurAmt = std::min(1.f, 2.f * dt + x18_blurAmt); + + if (x18_blurAmt == 0.f || x18_blurAmt == 1.f) + OnBlurComplete(b); + + if (x18_blurAmt == 0.f && b) + { + x1c_camBlur.DisableBlur(0.f); + } + else + { + x1c_camBlur.SetBlur(CCameraBlurPass::EBlurType::HiBlur, + g_tweakGui->GetPauseBlurFactor() * std::fabs(x18_blurAmt), 0.f); + x50_24_blurring = true; + } +} + +void CPauseScreenBlur::Draw(const CStateManager&) const +{ + const_cast(x1c_camBlur).Draw(); + float t = std::fabs(x18_blurAmt); + if (x1c_camBlur.GetCurrType() != CCameraBlurPass::EBlurType::NoBlur) + { + zeus::CColor filterColor = + zeus::CColor::lerp(zeus::CColor::skWhite, g_tweakGuiColors->GetPauseBlurFilterColor(), t); + CCameraFilterPass::DrawFilter(CCameraFilterPass::EFilterType::Multiply, + CCameraFilterPass::EFilterShape::FullscreenQuarters, + filterColor, x4_mapLightQuarter.GetObj(), t); + zeus::CColor scanLinesColor = + zeus::CColor::lerp(zeus::CColor::skWhite, zeus::CColor(0.75f, 1.f), t); + CCameraFilterPass::DrawFilter(CCameraFilterPass::EFilterType::Multiply, + CCameraFilterPass::EFilterShape::ScanLinesEven, + scanLinesColor, nullptr, t); + } + + if (x50_24_blurring /*&& x1c_camBlur.x2d_noPersistentCopy*/) + { + const_cast(this)->x50_24_blurring = false; + const_cast(this)->x50_25_gameDraw = false; + } } } diff --git a/Runtime/MP1/CPauseScreenBlur.hpp b/Runtime/MP1/CPauseScreenBlur.hpp index ad6887162..5aa07001b 100644 --- a/Runtime/MP1/CPauseScreenBlur.hpp +++ b/Runtime/MP1/CPauseScreenBlur.hpp @@ -2,36 +2,54 @@ #define __URDE_CPAUSESCREENBLUR_HPP__ #include "CInGameGuiManagerCommon.hpp" +#include "CToken.hpp" +#include "Camera/CCameraFilter.hpp" namespace urde { class CStateManager; +class CTexture; + namespace MP1 { class CPauseScreenBlur { - u32 x10_ = 0; - u32 x14_ = 0; + enum class EState + { + InGame, + MapScreen, + SaveGame, + HUDMessage, + Pause + }; + + TLockedToken x4_mapLightQuarter; + EState x10_prevState = EState::InGame; + EState x14_nextState = EState::InGame; float x18_blurAmt = 0.f; + CCameraBlurPass x1c_camBlur; + union { struct { - bool x50_24_ : 1; - bool x50_25_ : 1; + bool x50_24_blurring : 1; + bool x50_25_gameDraw : 1; }; u32 _dummy = 0; }; + void OnBlurComplete(bool); + void SetState(EState state); + public: CPauseScreenBlur(); - bool CheckLoadComplete(); void OnNewInGameGuiState(EInGameGuiState state, CStateManager& stateMgr); - bool GetX50_25() const { return x50_25_; } + bool IsGameDraw() const { return x50_25_gameDraw; } void Update(float dt, const CStateManager& stateMgr, bool); void Draw(const CStateManager& stateMgr) const; float GetBlurAmt() const { return std::fabs(x18_blurAmt); } - bool IsNotTransitioning() const { return x10_ == x14_; } + bool IsNotTransitioning() const { return x10_prevState == x14_nextState; } }; } diff --git a/Runtime/MP1/CPlayerVisor.cpp b/Runtime/MP1/CPlayerVisor.cpp index 2040f1c20..8cab5ac55 100644 --- a/Runtime/MP1/CPlayerVisor.cpp +++ b/Runtime/MP1/CPlayerVisor.cpp @@ -1,38 +1,339 @@ #include "CPlayerVisor.hpp" +#include "CSimplePool.hpp" +#include "GameGlobalObjects.hpp" +#include "Graphics/CModel.hpp" +#include "CStateManager.hpp" +#include "World/CPlayer.hpp" namespace urde { namespace MP1 { -CPlayerVisor::CPlayerVisor(CStateManager& stateMgr) +CPlayerVisor::CPlayerVisor(CStateManager&) +{ + x25_24_visorTransitioning = false; + x25_25_ = false; + xcc_scanFrameCorner = g_SimplePool->GetObj("CMDL_ScanFrameCorner"); + xd8_scanFrameCenterSide = g_SimplePool->GetObj("CMDL_ScanFrameCenterSide"); + xe4_scanFrameCenterTop = g_SimplePool->GetObj("CMDL_ScanFrameCenterTop"); + xf0_scanFrameStretchSide = g_SimplePool->GetObj("CMDL_ScanFrameStretchSide"); + xfc_scanFrameStretchTop = g_SimplePool->GetObj("CMDL_ScanFrameStretchTop"); + x108_newScanPane = g_SimplePool->GetObj("CMDL_NewScanPane"); + x114_scanShield = g_SimplePool->GetObj("CMDL_ScanShield"); + x124_scanIconNoncritical = g_SimplePool->GetObj("CMDL_ScanIconNoncritical"); + x130_scanIconCritical = g_SimplePool->GetObj("CMDL_ScanIconCritical"); + x13c_scanTargets.resize(64); + x540_xrayPalette = g_SimplePool->GetObj("TXTR_XRayPalette"); + x0_scanWindowSizes.push_back({}); + x0_scanWindowSizes.push_back({g_tweakGui->GetScanWindowIdleWidth(), g_tweakGui->GetScanWindowIdleHeight()}); + x0_scanWindowSizes.push_back({g_tweakGui->GetScanWindowActiveWidth(), g_tweakGui->GetScanWindowActiveHeight()}); +} + +CPlayerVisor::~CPlayerVisor() +{ + CSfxManager::SfxStop(x5c_visorLoopSfx); + CSfxManager::SfxStop(x60_); +} + +int CPlayerVisor::FindEmptyInactiveScanTarget() const +{ + for (int i=0 ; i 0.f) + return i; + } + return -1; +} + +void CPlayerVisor::DrawScanObjectIndicators(const CStateManager& mgr) const { } -void CPlayerVisor::Update(float dt, const CStateManager& stateMgr) +void CPlayerVisor::UpdateScanObjectIndicators(const CStateManager& mgr) { } -void CPlayerVisor::Draw(const CStateManager& stateMgr, const CTargetingManager* tgtManager) const +void CPlayerVisor::UpdateScanWindow(float dt, const CStateManager& mgr) +{ + +} + +CPlayerVisor::EScanWindowState +CPlayerVisor::GetDesiredScanWindowState(const CStateManager& mgr) const +{ + if (mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan) + { + switch (mgr.GetPlayer().GetScanningState()) + { + case CPlayer::EPlayerScanState::Scanning: + case CPlayer::EPlayerScanState::ScanComplete: + return EScanWindowState::Scan; + default: + return EScanWindowState::Idle; + } + } + return EScanWindowState::NotInScanVisor; +} + +void CPlayerVisor::LockUnlockAssets() +{ + +} + +void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, const CTargetingManager* tgtMgr) const +{ + +} + +void CPlayerVisor::DrawXRayEffect(const CStateManager&) const +{ + const_cast(x90_xrayBlur).Draw(); +} + +void CPlayerVisor::DrawThermalEffect(const CStateManager&) const +{ + // Empty +} + +void CPlayerVisor::UpdateCurrentVisor(float transFactor) +{ + switch (x1c_curVisor) + { + case CPlayerState::EPlayerVisor::XRay: + x90_xrayBlur.SetBlur(CCameraBlurPass::EBlurType::Xray, 36.f * transFactor, 0.f); + break; + case CPlayerState::EPlayerVisor::Scan: + { + zeus::CColor dimColor = zeus::CColor::lerp(g_tweakGuiColors->GetScanVisorHudLightMultiply(), + zeus::CColor::skWhite, 1.f - transFactor); + x64_scanDim.SetFilter(CCameraFilterPass::EFilterType::Multiply, + CCameraFilterPass::EFilterShape::Fullscreen, + 0.f, dimColor, -1); + break; + } + default: break; + } +} + +void CPlayerVisor::FinishTransitionIn() +{ + switch (x1c_curVisor) + { + case CPlayerState::EPlayerVisor::Combat: + x90_xrayBlur.DisableBlur(0.f); + break; + case CPlayerState::EPlayerVisor::XRay: + x90_xrayBlur.SetBlur(CCameraBlurPass::EBlurType::Xray, 36.f, 0.f); + if (!x5c_visorLoopSfx) + x5c_visorLoopSfx = CSfxManager::SfxStart(1384, x24_visorSfxVol, 0.f, false, 0x7f, true, kInvalidAreaId); + break; + case CPlayerState::EPlayerVisor::Scan: + { + zeus::CColor dimColor = zeus::CColor::lerp(g_tweakGuiColors->GetScanVisorScreenDimColor(), + g_tweakGuiColors->GetScanVisorHudLightMultiply(), + x2c_scanDimInterp); + x64_scanDim.SetFilter(CCameraFilterPass::EFilterType::Multiply, + CCameraFilterPass::EFilterShape::Fullscreen, + 0.f, dimColor, -1); + if (!x5c_visorLoopSfx) + x5c_visorLoopSfx = CSfxManager::SfxStart(1404, x24_visorSfxVol, 0.f, false, 0x7f, true, kInvalidAreaId); + break; + } + case CPlayerState::EPlayerVisor::Thermal: + if (!x5c_visorLoopSfx) + x5c_visorLoopSfx = CSfxManager::SfxStart(1388, x24_visorSfxVol, 0.f, false, 0x7f, true, kInvalidAreaId); + break; + default: break; + } +} + +void CPlayerVisor::BeginTransitionIn(const CStateManager&) +{ + switch (x1c_curVisor) + { + case CPlayerState::EPlayerVisor::XRay: + x90_xrayBlur.SetBlur(CCameraBlurPass::EBlurType::Xray, 0.f, 0.f); + xc4_vpScaleX = 0.9f; + xc8_vpScaleY = 0.9f; + CSfxManager::SfxStart(1383, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); + break; + case CPlayerState::EPlayerVisor::Scan: + CSfxManager::SfxStart(1383, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); + x64_scanDim.SetFilter(CCameraFilterPass::EFilterType::Multiply, + CCameraFilterPass::EFilterShape::Fullscreen, + 0.f, zeus::CColor::skWhite, -1); + break; + case CPlayerState::EPlayerVisor::Thermal: + CSfxManager::SfxStart(1383, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); + break; + default: break; + } +} + +void CPlayerVisor::FinishTransitionOut(const CStateManager&) +{ + switch (x1c_curVisor) + { + case CPlayerState::EPlayerVisor::XRay: + x90_xrayBlur.DisableBlur(0.f); + xc4_vpScaleX = 1.f; + xc8_vpScaleY = 1.f; + break; + case CPlayerState::EPlayerVisor::Scan: + x64_scanDim.DisableFilter(0.f); + x34_ = 0; + x30_ = 0; + break; + case CPlayerState::EPlayerVisor::Thermal: + x90_xrayBlur.DisableBlur(0.f); + break; + default: break; + } +} + +void CPlayerVisor::BeginTransitionOut() +{ + if (x5c_visorLoopSfx) + { + CSfxManager::SfxStop(x5c_visorLoopSfx); + x5c_visorLoopSfx.reset(); + } + + switch (x1c_curVisor) + { + case CPlayerState::EPlayerVisor::XRay: + CSfxManager::SfxStart(1382, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); + break; + case CPlayerState::EPlayerVisor::Scan: + if (x60_) + { + CSfxManager::SfxStop(x60_); + x60_.reset(); + } + CSfxManager::SfxStart(1382, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); + break; + case CPlayerState::EPlayerVisor::Thermal: + CSfxManager::SfxStart(1382, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); + break; + default: break; + } +} + +void CPlayerVisor::Update(float dt, const CStateManager& mgr) +{ + x90_xrayBlur.Update(dt); + + CPlayerState& playerState = *mgr.GetPlayerState(); + CPlayerState::EPlayerVisor activeVisor = playerState.GetActiveVisor(mgr); + CPlayerState::EPlayerVisor curVisor = playerState.GetCurrentVisor(); + CPlayerState::EPlayerVisor transVisor = playerState.GetTransitioningVisor(); + bool visorTransitioning = playerState.GetIsVisorTransitioning(); + + UpdateScanWindow(dt, mgr); + + if (x20_nextVisor != transVisor) + x20_nextVisor = transVisor; + + LockUnlockAssets(); + + if (mgr.GetPlayer().GetScanningState() == CPlayer::EPlayerScanState::ScanComplete) + x2c_scanDimInterp = std::max(0.f, x2c_scanDimInterp - 2.f * dt); + else + x2c_scanDimInterp = std::min(x2c_scanDimInterp + 2.f * dt, 1.f); + + if (visorTransitioning) + { + if (!x25_24_visorTransitioning) + BeginTransitionOut(); + if (x1c_curVisor != curVisor) + { + FinishTransitionOut(mgr); + x1c_curVisor = curVisor; + BeginTransitionIn(mgr); + } + UpdateCurrentVisor(playerState.GetVisorTransitionFactor()); + } + else + { + if (x25_24_visorTransitioning) + { + FinishTransitionIn(); + } + else if (curVisor == CPlayerState::EPlayerVisor::Scan) + { + zeus::CColor dimColor = zeus::CColor::lerp(g_tweakGuiColors->GetScanVisorScreenDimColor(), + g_tweakGuiColors->GetScanVisorHudLightMultiply(), + x2c_scanDimInterp); + x64_scanDim.SetFilter(CCameraFilterPass::EFilterType::Multiply, + CCameraFilterPass::EFilterShape::Fullscreen, + 0.f, dimColor, -1); + } + } + + x25_24_visorTransitioning = visorTransitioning; + + if (x1c_curVisor != activeVisor) + { + if (x24_visorSfxVol != 0.f) + { + x24_visorSfxVol = 0.f; + CSfxManager::SfxVolume(x5c_visorLoopSfx, x24_visorSfxVol); + CSfxManager::SfxVolume(x60_, x24_visorSfxVol); + } + } + else + { + if (x24_visorSfxVol != 1.f) + { + x24_visorSfxVol = 1.f; + CSfxManager::SfxVolume(x5c_visorLoopSfx, x24_visorSfxVol); + CSfxManager::SfxVolume(x60_, x24_visorSfxVol); + } + } + + float scanMag = g_tweakGui->GetScanWindowMagnification(); + if (x58_scanMagInterp < scanMag) + x58_scanMagInterp = std::min(x58_scanMagInterp + 2.f * dt, scanMag); + else + x58_scanMagInterp = std::max(x58_scanMagInterp - 2.f * dt, scanMag); +} + +void CPlayerVisor::Draw(const CStateManager& mgr, const CTargetingManager* tgtManager) const { } void CPlayerVisor::Touch() { - + if (x124_scanIconNoncritical.IsLoaded()) + x124_scanIconNoncritical->Touch(0); + if (x130_scanIconCritical.IsLoaded()) + x130_scanIconCritical->Touch(0); } -float CPlayerVisor::GetDesiredViewportScaleX(const CStateManager& stateMgr) const +float CPlayerVisor::GetDesiredViewportScaleX(const CStateManager& mgr) const { - return 0.f; + return mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Combat ? 1.f : xc4_vpScaleX; } -float CPlayerVisor::GetDesiredViewportScaleY(const CStateManager& stateMgr) const +float CPlayerVisor::GetDesiredViewportScaleY(const CStateManager& mgr) const { - return 0.f; + return mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Combat ? 1.f : xc8_vpScaleY; } } diff --git a/Runtime/MP1/CPlayerVisor.hpp b/Runtime/MP1/CPlayerVisor.hpp index abddb37ef..32cdeec03 100644 --- a/Runtime/MP1/CPlayerVisor.hpp +++ b/Runtime/MP1/CPlayerVisor.hpp @@ -1,18 +1,93 @@ #ifndef __URDE_CPLAYERVISOR_HPP__ #define __URDE_CPLAYERVISOR_HPP__ +#include "RetroTypes.hpp" +#include "Camera/CCameraFilter.hpp" +#include "zeus/CVector2f.hpp" +#include "Audio/CSfxManager.hpp" +#include "CPlayerState.hpp" + namespace urde { class CStateManager; class CTargetingManager; +class CModel; namespace MP1 { class CPlayerVisor { + struct SScanTarget + { + TUniqueId x0_objId = kInvalidUniqueId; + float x4_ = 0.f; + float x8_ = 0.f; + bool xc_ = false; + }; + + enum class EScanWindowState + { + NotInScanVisor, + Idle, + Scan + }; + + rstl::reserved_vector x0_scanWindowSizes; + CPlayerState::EPlayerVisor x1c_curVisor = CPlayerState::EPlayerVisor::Combat; + CPlayerState::EPlayerVisor x20_nextVisor = CPlayerState::EPlayerVisor::Combat; + float x24_visorSfxVol = 1.f; // used to be u8 + bool x25_24_visorTransitioning : 1; + bool x25_25_ : 1; + float x28_ = 0.f; + float x2c_scanDimInterp = 1.f; + u32 x30_ = 0; + u32 x34_ = 0; + float x38_ = 0.f; + float x3c_ = 0.f; + zeus::CVector2f x40_; + zeus::CVector2f x48_; + zeus::CVector2f x50_; + float x58_scanMagInterp = 1.f; + CSfxHandle x5c_visorLoopSfx; + CSfxHandle x60_; + CCameraFilterPass x64_scanDim; + CCameraBlurPass x90_xrayBlur; + float xc4_vpScaleX = 1.f; + float xc8_vpScaleY = 1.f; + TLockedToken xcc_scanFrameCorner; + TLockedToken xd8_scanFrameCenterSide; + TLockedToken xe4_scanFrameCenterTop; + TLockedToken xf0_scanFrameStretchSide; + TLockedToken xfc_scanFrameStretchTop; + TLockedToken x108_newScanPane; + TLockedToken x114_scanShield; + TLockedToken x124_scanIconNoncritical; + TLockedToken x130_scanIconCritical; + rstl::reserved_vector x13c_scanTargets; + TLockedToken x540_xrayPalette; + float x54c_ = 0.f; + float x550_ = 0.f; + + int FindEmptyInactiveScanTarget() const; + int FindCachedInactiveScanTarget(TUniqueId uid) const; + void DrawScanObjectIndicators(const CStateManager& mgr) const; + void UpdateScanObjectIndicators(const CStateManager& mgr); + void UpdateScanWindow(float dt, const CStateManager& mgr); + EScanWindowState GetDesiredScanWindowState(const CStateManager& mgr) const; + void LockUnlockAssets(); + void DrawScanEffect(const CStateManager& mgr, const CTargetingManager* tgtMgr) const; + void DrawXRayEffect(const CStateManager& mgr) const; + void DrawThermalEffect(const CStateManager& mgr) const; + void UpdateCurrentVisor(float transFactor); + void FinishTransitionIn(); + void BeginTransitionIn(const CStateManager& mgr); + void FinishTransitionOut(const CStateManager& mgr); + void BeginTransitionOut(); + public: CPlayerVisor(CStateManager& stateMgr); + ~CPlayerVisor(); void Update(float dt, const CStateManager& stateMgr); void Draw(const CStateManager& stateMgr, const CTargetingManager* tgtManager) const; void Touch(); diff --git a/Runtime/MP1/CSamusDoll.cpp b/Runtime/MP1/CSamusDoll.cpp index 0b6cce70b..9f1c36872 100644 --- a/Runtime/MP1/CSamusDoll.cpp +++ b/Runtime/MP1/CSamusDoll.cpp @@ -580,7 +580,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) { float radius = zeus::clamp(0.2f, (10.f - (xc0_userZoom >= 0.f ? xc0_userZoom : -xc0_userZoom)) / 20.f, 1.f); float offset = std::sin(x260_phazonOffsetAngle); - zeus::CColor color = g_tweakGuiColors->GetInvPhazonSuitFilterMod(); + zeus::CColor color = g_tweakGuiColors->GetPauseBlurFilterColor(); color.a = alpha; g_Renderer->DrawPhazonSuitIndirectEffect(zeus::CColor(0.1f, alpha), x250_phazonIndirectTexture, color, radius, 0.1f, offset, offset); diff --git a/hecl b/hecl index b7e8c42c0..1c87c8048 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit b7e8c42c02313e4a9a86aa9de072888c8ec576e7 +Subproject commit 1c87c80483c0a38063edbb3517ba287220e57068 diff --git a/nod b/nod index e494dbba9..7260012be 160000 --- a/nod +++ b/nod @@ -1 +1 @@ -Subproject commit e494dbba9f29634ccbd2b9af203b86d11d5466d5 +Subproject commit 7260012be57607149e312ac8565bc2fae9c7c972