2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/MP1/CPauseScreenBlur.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CSimplePool.hpp"
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/Audio/CSfxManager.hpp"
|
2017-05-02 04:00:38 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce::MP1 {
|
2017-05-02 04:00:38 +00:00
|
|
|
|
2020-04-21 07:22:41 +00:00
|
|
|
CPauseScreenBlur::CPauseScreenBlur() : x4_mapLightQuarter(g_SimplePool->GetObj("TXTR_MapLightQuarter")) {}
|
2017-05-02 04:00:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
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;
|
|
|
|
}
|
2017-05-02 04:00:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPauseScreenBlur::SetState(EState state) {
|
|
|
|
if (x10_prevState == EState::InGame && state != EState::InGame) {
|
|
|
|
CSfxManager::SetChannel(CSfxManager::ESfxChannels::PauseScreen);
|
|
|
|
if (state == EState::HUDMessage)
|
|
|
|
CSfxManager::SfxStart(SFXui_into_hud_message, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
else if (state == EState::MapScreen)
|
|
|
|
CSfxManager::SfxStart(SFXui_into_map_screen, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
x18_blurAmt = FLT_EPSILON;
|
|
|
|
}
|
2017-05-02 04:00:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (state == EState::InGame && (x10_prevState != EState::InGame || x14_nextState != EState::InGame)) {
|
|
|
|
CSfxManager::SetChannel(CSfxManager::ESfxChannels::Game);
|
|
|
|
if (x10_prevState == EState::HUDMessage)
|
|
|
|
CSfxManager::SfxStart(SFXui_outof_hud_message, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
else if (x10_prevState == EState::MapScreen)
|
|
|
|
CSfxManager::SfxStart(SFXui_outof_map_screen, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
x18_blurAmt = -1.f;
|
|
|
|
}
|
2017-05-29 19:55:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x14_nextState = state;
|
2017-05-02 04:00:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
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;
|
2017-05-29 19:55:44 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPauseScreenBlur::Update(float dt, const CStateManager& stateMgr, bool b) {
|
|
|
|
if (x10_prevState == x14_nextState)
|
|
|
|
return;
|
2017-05-29 19:55:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
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);
|
2017-05-29 19:55:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x18_blurAmt == 0.f || x18_blurAmt == 1.f)
|
|
|
|
OnBlurComplete(b);
|
2017-05-18 19:27:21 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x18_blurAmt == 0.f && b) {
|
|
|
|
x1c_camBlur.DisableBlur(0.f);
|
|
|
|
} else {
|
2022-05-19 07:57:30 +00:00
|
|
|
x1c_camBlur.SetBlur(EBlurType::HiBlur, g_tweakGui->GetPauseBlurFactor() * std::fabs(x18_blurAmt), 0.f, true);
|
2018-12-08 05:30:43 +00:00
|
|
|
x50_24_blurring = true;
|
|
|
|
}
|
2017-05-18 19:27:21 +00:00
|
|
|
}
|
|
|
|
|
2020-03-16 01:38:25 +00:00
|
|
|
void CPauseScreenBlur::Draw(const CStateManager&) {
|
2019-07-21 08:42:52 +00:00
|
|
|
SCOPED_GRAPHICS_DEBUG_GROUP("CPauseScreenBlur::Draw", zeus::skPurple);
|
2020-03-16 01:38:25 +00:00
|
|
|
x1c_camBlur.Draw(true);
|
2022-05-24 00:26:35 +00:00
|
|
|
CGraphics::DisableAllLights();
|
|
|
|
CGraphics::SetAmbientColor(zeus::skWhite);
|
2020-03-16 01:38:25 +00:00
|
|
|
const float t = std::fabs(x18_blurAmt);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x1c_camBlur.GetCurrType() != EBlurType::NoBlur) {
|
2020-03-16 01:38:25 +00:00
|
|
|
const auto filterColor = zeus::CColor::lerp(zeus::skWhite, g_tweakGuiColors->GetPauseBlurFilterColor(), t);
|
2022-05-24 00:26:35 +00:00
|
|
|
CCameraFilterPass::DrawFilter(EFilterType::Multiply, EFilterShape::FullscreenQuarters, filterColor,
|
|
|
|
x4_mapLightQuarter.GetObj(), t);
|
2020-03-16 01:38:25 +00:00
|
|
|
const auto scanLinesColor = zeus::CColor::lerp(zeus::skWhite, zeus::CColor(0.75f, 1.f), t);
|
2022-05-24 00:26:35 +00:00
|
|
|
CCameraFilterPass::DrawFilter(EFilterType::Multiply, EFilterShape::ScanLinesEven, scanLinesColor, nullptr, t);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-05-21 16:01:04 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x50_24_blurring /*&& x1c_camBlur.x2d_noPersistentCopy*/) {
|
2020-03-16 01:38:25 +00:00
|
|
|
x50_24_blurring = false;
|
|
|
|
x50_25_gameDraw = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-05-21 16:01:04 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce::MP1
|