metaforce/Runtime/MP1/CInGameGuiManager.cpp

755 lines
27 KiB
C++
Raw Normal View History

2017-02-12 03:17:18 +00:00
#include "CInGameGuiManager.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
#include "World/CPlayer.hpp"
#include "CDependencyGroup.hpp"
#include "CSimplePool.hpp"
#include "GuiSys/CGuiFrame.hpp"
#include "GuiSys/CGuiCamera.hpp"
#include "GuiSys/CGuiModel.hpp"
#include "AutoMapper/CAutoMapper.hpp"
2017-02-12 04:43:33 +00:00
#include "Particle/CGenDescription.hpp"
2017-02-18 02:19:50 +00:00
#include "Audio/CSfxManager.hpp"
#include "CSamusHud.hpp"
#include "Input/CInputGenerator.hpp"
2017-05-18 19:27:21 +00:00
#include "TCastTo.hpp"
#include "Camera/CFirstPersonCamera.hpp"
2017-05-21 16:01:04 +00:00
#include "Graphics/CBooRenderer.hpp"
#include "GuiSys/CGuiWidgetDrawParms.hpp"
2017-02-12 03:17:18 +00:00
namespace urde
{
namespace MP1
{
static const char* InGameGuiDGRPs[] =
{
"InGameGui_DGRP",
"Ice_DGRP",
"Phazon_DGRP",
"Plasma_DGRP",
"Power_DGRP",
"Wave_DGRP",
"BallTransition_DGRP",
"GravitySuit_DGRP",
"Ice_Anim_DGRP",
"Plasma_Anim_DGRP",
"PowerSuit_DGRP",
"Power_Anim_DGRP",
"VariaSuit_DGRP",
"Wave_Anim_DGRP"
};
static const char* PauseScreenDGRPs[] =
{
"InventorySuitPower_DGRP",
"InventorySuitVaria_DGRP",
"InventorySuitGravity_DGRP",
"InventorySuitPhazon_DGRP",
"InventorySuitFusionPower_DGRP",
"InventorySuitFusionVaria_DGRP",
"InventorySuitFusionGravity_DGRP",
"InventorySuitFusionPhazon_DGRP",
"SamusBallANCS_DGRP",
"SamusSpiderBallANCS_DGRP",
"PauseScreenDontDump_DGRP",
"PauseScreenDontDump_NoARAM_DGRP",
"PauseScreenTokens_DGRP"
};
std::vector<TLockedToken<CDependencyGroup>> CInGameGuiManager::LockPauseScreenDependencies()
{
std::vector<TLockedToken<CDependencyGroup>> ret;
ret.reserve(13);
for (int i=0 ; i<13 ; ++i)
ret.push_back(g_SimplePool->GetObj(PauseScreenDGRPs[i]));
return ret;
}
bool CInGameGuiManager::CheckDGRPLoadComplete() const
{
for (const auto& dgrp : x5c_pauseScreenDGRPs)
if (!dgrp.IsLoaded())
return false;
for (const auto& dgrp : xc8_inGameGuiDGRPs)
if (!dgrp.IsLoaded())
return false;
return true;
}
void CInGameGuiManager::BeginStateTransition(EInGameGuiState state, CStateManager& stateMgr)
2017-02-18 02:19:50 +00:00
{
if (x1c0_nextState == state)
return;
x1bc_prevState = x1c0_nextState;
x1c0_nextState = state;
switch (state)
{
case EInGameGuiState::InGame:
{
CSfxManager::SetChannel(CSfxManager::ESfxChannels::Game);
x4c_saveUI.reset();
x38_autoMapper->UnmuteAllLoopedSounds();
break;
}
case EInGameGuiState::PauseHUDMessage:
{
x44_messageScreen = std::make_unique<CMessageScreen>(x124_pauseGameHudMessage, x128_pauseGameHudTime);
break;
}
case EInGameGuiState::PauseSaveGame:
{
x4c_saveUI = std::make_unique<CSaveGameScreen>(ESaveContext::InGame, g_GameState->GetCardSerial());
break;
}
default:
{
if (x1bc_prevState >= EInGameGuiState::Zero && x1bc_prevState <= EInGameGuiState::InGame)
x1f8_26_deferTransition = true;
break;
}
}
2017-04-26 06:43:48 +00:00
x3c_pauseScreenBlur->OnNewInGameGuiState(state, stateMgr);
2017-02-18 02:19:50 +00:00
if (!x1f8_26_deferTransition)
DoStateTransition(stateMgr);
}
void CInGameGuiManager::EnsureStates(CStateManager& stateMgr)
{
if (x1f8_26_deferTransition)
{
if (!x3c_pauseScreenBlur->IsGameDraw())
2017-02-18 02:19:50 +00:00
{
DestroyAreaTextures(stateMgr);
x1f8_26_deferTransition = false;
DoStateTransition(stateMgr);
}
}
}
void CInGameGuiManager::DoStateTransition(CStateManager& stateMgr)
{
x34_samusHud->OnNewInGameGuiState(x1c0_nextState, stateMgr);
x38_autoMapper->OnNewInGameGuiState(x1c0_nextState, stateMgr);
bool needsLock;
switch (x1c0_nextState)
{
case EInGameGuiState::PauseGame:
case EInGameGuiState::PauseLogBook:
2017-04-26 06:43:48 +00:00
if (!x48_pauseScreen)
2017-02-18 02:19:50 +00:00
{
auto pState = stateMgr.GetPlayerState();
CPlayerState::EPlayerSuit suit = pState->GetCurrentSuitRaw();
int suitResIdx;
if (pState->IsFusionEnabled())
{
switch (suit)
{
case CPlayerState::EPlayerSuit::Phazon:
suitResIdx = 7;
break;
case CPlayerState::EPlayerSuit::Gravity:
suitResIdx = 6;
break;
case CPlayerState::EPlayerSuit::Varia:
suitResIdx = 5;
break;
default:
suitResIdx = 4;
break;
}
}
else
{
switch (suit)
{
case CPlayerState::EPlayerSuit::Phazon:
suitResIdx = 3;
break;
case CPlayerState::EPlayerSuit::Gravity:
suitResIdx = 2;
break;
case CPlayerState::EPlayerSuit::Varia:
suitResIdx = 1;
break;
default:
suitResIdx = 0;
break;
}
}
2017-05-02 04:00:38 +00:00
CPauseScreen::ESubScreen screen = x1c0_nextState == EInGameGuiState::PauseLogBook ?
CPauseScreen::ESubScreen::LogBook : CPauseScreen::ESubScreen::Inventory;
2017-02-18 02:19:50 +00:00
CDependencyGroup* suitGrp = x5c_pauseScreenDGRPs[suitResIdx].GetObj();
2017-05-02 04:00:38 +00:00
x48_pauseScreen = std::make_unique<CPauseScreen>(screen, *suitGrp, *suitGrp);
2017-02-18 02:19:50 +00:00
}
case EInGameGuiState::MapScreen:
case EInGameGuiState::PauseSaveGame:
case EInGameGuiState::PauseHUDMessage:
needsLock = true;
break;
default:
needsLock = false;
break;
}
for (CToken& tok : xe8_pauseResources)
{
if (needsLock)
tok.Lock();
else
tok.Unlock();
}
}
void CInGameGuiManager::DestroyAreaTextures(CStateManager& stateMgr)
{
}
void CInGameGuiManager::TryReloadAreaTextures()
2017-02-12 03:17:18 +00:00
{
}
CInGameGuiManager::CInGameGuiManager(CStateManager& stateMgr,
CArchitectureQueue& archQueue)
: x0_iggmPreLoad(g_SimplePool->GetObj("PreLoadIGGM_DGRP")), x1c_rand(1234),
x20_faceplateDecor(stateMgr), x50_deathDot(g_SimplePool->GetObj("TXTR_DeathDot")),
x5c_pauseScreenDGRPs(LockPauseScreenDependencies())
{
x1e0_helmetVisMode = g_tweakGui->GetHelmetVisMode();
x1e4_enableTargetingManager = g_tweakGui->GetEnableTargetingManager();
x1e8_enableAutoMapper = g_tweakGui->GetEnableAutoMapper();
x1ec_hudVisMode = g_tweakGui->GetHudVisMode();
x1f0_enablePlayerVisor = g_tweakGui->GetEnablePlayerVisor();
2017-05-18 19:27:21 +00:00
x1f4_visorStaticAlpha = stateMgr.GetPlayer().GetVisorStaticAlpha();
2017-02-12 03:17:18 +00:00
2017-05-18 19:27:21 +00:00
x1f8_25_playerAlive = true;
x1f8_27_exitSaveUI = true;
2017-02-12 03:17:18 +00:00
xc8_inGameGuiDGRPs.reserve(14);
for (int i=0 ; i<14 ; ++i)
2017-03-20 05:09:53 +00:00
xc8_inGameGuiDGRPs.push_back(g_SimplePool->GetObj(InGameGuiDGRPs[i]));
2017-02-12 03:17:18 +00:00
}
bool CInGameGuiManager::CheckLoadComplete(CStateManager& stateMgr)
{
switch (x18_loadPhase)
{
case ELoadPhase::LoadDepsGroup:
{
if (!x0_iggmPreLoad.IsLoaded())
return false;
const auto& tags = x0_iggmPreLoad->GetObjectTagVector();
x8_preLoadDeps.reserve(tags.size());
for (const SObjectTag& tag : tags)
{
x8_preLoadDeps.push_back(g_SimplePool->GetObj(tag));
x8_preLoadDeps.back().Lock();
}
x0_iggmPreLoad.Unlock();
x18_loadPhase = ELoadPhase::PreLoadDeps;
}
case ELoadPhase::PreLoadDeps:
{
for (CToken& tok : x8_preLoadDeps)
if (!tok.IsLoaded())
return false;
x18_loadPhase = ELoadPhase::LoadDeps;
x30_playerVisor = std::make_unique<CPlayerVisor>(stateMgr);
x34_samusHud = std::make_unique<CSamusHud>(stateMgr);
x38_autoMapper = std::make_unique<CAutoMapper>(stateMgr);
2017-04-26 06:43:48 +00:00
x3c_pauseScreenBlur = std::make_unique<CPauseScreenBlur>();
2017-02-12 03:17:18 +00:00
x40_samusReflection = std::make_unique<CSamusFaceReflection>(stateMgr);
}
case ELoadPhase::LoadDeps:
{
if (!x38_autoMapper->CheckLoadComplete())
return false;
if (!x34_samusHud->CheckLoadComplete(stateMgr))
return false;
if (!x50_deathDot.IsLoaded())
return false;
if (!CheckDGRPLoadComplete())
return false;
x8_preLoadDeps.clear();
2017-04-02 03:03:37 +00:00
CGuiFrame& baseHud = *x34_samusHud->x274_loadedFrmeBaseHud;
2017-02-12 03:17:18 +00:00
x144_basewidget_automapper = baseHud.FindWidget("BaseWidget_AutoMapper");
x148_model_automapper = static_cast<CGuiModel*>(baseHud.FindWidget("Model_AutoMapper"));
x14c_basehud_camera = baseHud.GetFrameCamera();
x150_basewidget_functional = baseHud.FindWidget("BaseWidget_Functional");
2017-04-02 03:03:37 +00:00
x154_automapperRotate = zeus::CQuaternion(x144_basewidget_automapper->GetWorldTransform().basis);
2017-02-12 03:17:18 +00:00
x164_automapperOffset = x144_basewidget_automapper->GetLocalPosition();
x170_camRotate = zeus::CQuaternion::skNoRotation;
x180_camOffset = x14c_basehud_camera->GetLocalPosition() +
zeus::CVector3f(0.f, 2.f, g_tweakAutoMapper->GetCamVerticalOffset());
zeus::CMatrix3f mtx(x170_camRotate);
x18c_camXf = zeus::CTransform(mtx, x180_camOffset);
2017-02-18 02:19:50 +00:00
BeginStateTransition(EInGameGuiState::InGame, stateMgr);
2017-02-12 03:17:18 +00:00
x18_loadPhase = ELoadPhase::Done;
}
case ELoadPhase::Done:
{
x34_samusHud->Touch();
return true;
}
default:
return false;
}
}
2017-05-21 16:01:04 +00:00
void CInGameGuiManager::RefreshHudOptions()
{
x34_samusHud->RefreshHudOptions();
}
2017-05-18 19:27:21 +00:00
void CInGameGuiManager::OnNewPauseScreenState(CArchitectureQueue& archQueue)
{
2017-05-21 16:01:04 +00:00
if (x1c0_nextState != EInGameGuiState::PauseGame && x1c0_nextState != EInGameGuiState::PauseLogBook)
{
2017-11-16 08:05:10 +00:00
if (x48_pauseScreen && x48_pauseScreen->IsTransitioning())
2017-05-21 16:01:04 +00:00
return;
x48_pauseScreen.reset();
}
2017-05-18 19:27:21 +00:00
2017-05-21 16:01:04 +00:00
if (x1c0_nextState >= EInGameGuiState::Zero && x1c0_nextState <= EInGameGuiState::InGame)
{
if (x44_messageScreen)
x44_messageScreen.reset();
RefreshHudOptions();
}
x1bc_prevState = x1c0_nextState;
2017-05-18 19:27:21 +00:00
}
void CInGameGuiManager::UpdateAutoMapper(float dt, const CStateManager& stateMgr)
{
2017-05-21 16:01:04 +00:00
x38_autoMapper->Update(dt, stateMgr);
zeus::CTransform xf = x148_model_automapper->GetParent()->GetWorldTransform() *
x144_basewidget_automapper->GetTransform();
x154_automapperRotate = zeus::CQuaternion(xf.basis);
x164_automapperOffset = xf.origin;
x170_camRotate = zeus::CQuaternion(x14c_basehud_camera->GetWorldTransform().basis);
x180_camOffset = x14c_basehud_camera->GetWorldTransform().basis[1] * 2.f +
x14c_basehud_camera->GetWorldPosition() +
x14c_basehud_camera->GetWorldTransform().basis[2] * g_tweakAutoMapper->GetCamVerticalOffset();
float frameLength = std::tan(zeus::degToRad(x14c_basehud_camera->GetProjection().xbc_fov) / 2.f) / 0.7f;
float scaleX = frameLength * g_tweakAutoMapper->GetAutomapperScaleX();
float scaleZ = frameLength * g_tweakAutoMapper->GetAutomapperScaleZ();
if (x38_autoMapper->IsFullyOutOfMiniMapState())
{
x148_model_automapper->SetO2WTransform(
zeus::CTransform(x170_camRotate, x180_camOffset) * zeus::CTransform::Scale(scaleX, 1.f, scaleZ));
x18c_camXf = zeus::CTransform(x170_camRotate, x180_camOffset) *
zeus::CTransform::Scale(frameLength, 1.f, frameLength);
x148_model_automapper->SetColor(g_tweakAutoMapper->GetAutomapperWidgetColor());
}
else if (x38_autoMapper->IsFullyInMiniMapState())
{
x148_model_automapper->SetO2WTransform(zeus::CTransform(x154_automapperRotate, x164_automapperOffset));
x18c_camXf = x148_model_automapper->GetWorldTransform();
x148_model_automapper->SetColor(g_tweakAutoMapper->GetAutomapperWidgetMiniColor());
}
else
{
float t;
if (x38_autoMapper->GetNextState() != CAutoMapper::EAutoMapperState::MiniMap)
t = x38_autoMapper->GetInterp();
else
t = 1.f - x38_autoMapper->GetInterp();
float st = t * (frameLength - 1.f) + 1.f;
x148_model_automapper->SetO2WTransform(zeus::CTransform(
zeus::CQuaternion::slerp(x154_automapperRotate, x170_camRotate, t),
x164_automapperOffset * (1.f - t) + x180_camOffset * t) * zeus::CTransform::Scale(st, 1.f, st));
x148_model_automapper->SetColor(zeus::CColor::lerp(g_tweakAutoMapper->GetAutomapperWidgetMiniColor(),
g_tweakAutoMapper->GetAutomapperWidgetColor(), t));
}
2017-05-18 19:27:21 +00:00
}
void CInGameGuiManager::Update(CStateManager& stateMgr, float dt, CArchitectureQueue& archQueue, bool useHud)
2017-02-18 02:19:50 +00:00
{
EnsureStates(stateMgr);
2017-05-18 19:27:21 +00:00
if (x1d8_onScreenTexAlpha == 0.f)
x1dc_onScreenTexTok = TLockedToken<CTexture>();
if (x1c4_onScreenTex.x0_id != stateMgr.GetPendingScreenTex().x0_id)
{
if (!x1dc_onScreenTexTok)
{
x1c4_onScreenTex = stateMgr.GetPendingScreenTex();
2017-11-15 04:12:13 +00:00
if (x1c4_onScreenTex.x0_id.IsValid())
2017-05-18 19:27:21 +00:00
{
x1dc_onScreenTexTok = g_SimplePool->GetObj({FOURCC('TXTR'), x1c4_onScreenTex.x0_id});
x1d8_onScreenTexAlpha = FLT_EPSILON;
}
}
else
{
2017-11-15 04:12:13 +00:00
if (!stateMgr.GetPendingScreenTex().x0_id.IsValid() &&
2017-05-18 19:27:21 +00:00
stateMgr.GetPendingScreenTex().x4_origin == zeus::CVector2i(0, 0))
{
x1c4_onScreenTex.x4_origin = stateMgr.GetPendingScreenTex().x4_origin;
2017-11-15 04:12:13 +00:00
x1c4_onScreenTex.x0_id = {};
2017-05-18 19:27:21 +00:00
x1d8_onScreenTexAlpha = 0.f;
}
else
{
x1d8_onScreenTexAlpha = std::max(0.f, x1d8_onScreenTexAlpha - dt);
}
}
}
2017-11-15 04:12:13 +00:00
else if (x1c4_onScreenTex.x0_id.IsValid() && x1dc_onScreenTexTok.IsLoaded())
2017-05-18 19:27:21 +00:00
{
x1d8_onScreenTexAlpha = std::min(x1d8_onScreenTexAlpha + dt, 1.f);
}
if (useHud)
{
if (stateMgr.GetPlayer().GetVisorStaticAlpha() != x1f4_visorStaticAlpha)
{
2017-05-31 21:26:50 +00:00
if (TCastToPtr<CFirstPersonCamera>(stateMgr.GetCameraManager()->GetCurrentCamera(stateMgr)))
2017-05-18 19:27:21 +00:00
{
if (std::fabs(stateMgr.GetPlayer().GetVisorStaticAlpha() - x1f4_visorStaticAlpha) < 0.5f)
{
if (x1f4_visorStaticAlpha == 0.f)
CSfxManager::SfxStart(1401, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
else if (x1f4_visorStaticAlpha == 1.f)
CSfxManager::SfxStart(1400, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
}
}
x1f4_visorStaticAlpha = stateMgr.GetPlayer().GetVisorStaticAlpha();
x20_faceplateDecor.Update(dt, stateMgr);
x40_samusReflection->Update(dt, stateMgr, x1c_rand);
if (x1f0_enablePlayerVisor)
x30_playerVisor->Update(dt, stateMgr);
if (x1f8_25_playerAlive)
x34_samusHud->Update(dt, stateMgr, x1e0_helmetVisMode, x1ec_hudVisMode != EHudVisMode::Zero, x1e4_enableTargetingManager);
}
if (x1e8_enableAutoMapper)
UpdateAutoMapper(dt, stateMgr);
x3c_pauseScreenBlur->Update(dt, stateMgr, !x140_);
if (x4c_saveUI)
{
CIOWin::EMessageReturn ret = x4c_saveUI->Update(dt);
if (ret != CIOWin::EMessageReturn::Normal)
{
x1f8_27_exitSaveUI = ret == CIOWin::EMessageReturn::Exit;
BeginStateTransition(EInGameGuiState::InGame, stateMgr);
}
}
else if (x44_messageScreen)
{
if (!x44_messageScreen->Update(dt, x3c_pauseScreenBlur->GetBlurAmt()))
BeginStateTransition(EInGameGuiState::InGame, stateMgr);
}
if (x48_pauseScreen)
{
x48_pauseScreen->Update(dt, stateMgr, x1c_rand, archQueue);
if (x1bc_prevState == x1c0_nextState)
{
if (x48_pauseScreen->ShouldSwitchToMapScreen())
BeginStateTransition(EInGameGuiState::MapScreen, stateMgr);
else if (x48_pauseScreen->ShouldSwitchToInGame())
BeginStateTransition(EInGameGuiState::InGame, stateMgr);
}
}
x34_samusHud->Touch();
x30_playerVisor->Touch();
x34_samusHud->GetTargetingManager().Touch();
if (x1bc_prevState != x1c0_nextState)
{
if (x1c0_nextState == EInGameGuiState::Zero || x1c0_nextState == EInGameGuiState::InGame)
TryReloadAreaTextures();
2017-11-16 08:05:10 +00:00
if ((!x38_autoMapper->IsInMapperStateTransition() || !x1e8_enableAutoMapper) &&
2017-05-18 19:27:21 +00:00
x3c_pauseScreenBlur->IsNotTransitioning())
OnNewPauseScreenState(archQueue);
}
xf8_camFilter.Update(dt);
if (stateMgr.GetCameraManager()->IsInCinematicCamera())
{
stateMgr.SetViewportScale(zeus::CVector2f(1.f, 1.f));
}
else
{
stateMgr.SetViewportScale(zeus::CVector2f(
std::min(x30_playerVisor->GetDesiredViewportScaleX(stateMgr), x34_samusHud->GetViewportScale().x),
std::min(x30_playerVisor->GetDesiredViewportScaleY(stateMgr), x34_samusHud->GetViewportScale().y)));
}
x1f8_25_playerAlive = stateMgr.GetPlayerState()->IsPlayerAlive();
2017-02-18 02:19:50 +00:00
}
2017-04-15 05:32:25 +00:00
bool CInGameGuiManager::IsInGameStateNotTransitioning() const
{
return (x1bc_prevState >= EInGameGuiState::Zero && x1bc_prevState <= EInGameGuiState::InGame &&
x1c0_nextState >= EInGameGuiState::Zero && x1c0_nextState <= EInGameGuiState::InGame);
}
bool CInGameGuiManager::IsInPausedStateNotTransitioning() const
{
return (x1bc_prevState >= EInGameGuiState::MapScreen && x1bc_prevState <= EInGameGuiState::PauseHUDMessage &&
x1c0_nextState >= EInGameGuiState::MapScreen && x1c0_nextState <= EInGameGuiState::PauseHUDMessage);
}
2017-02-18 02:19:50 +00:00
void CInGameGuiManager::ProcessControllerInput(CStateManager& stateMgr, const CFinalInput& input,
CArchitectureQueue& archQueue)
{
2017-04-15 05:32:25 +00:00
if (input.ControllerIdx() == 0)
{
if (!IsInGameStateNotTransitioning())
{
if (IsInPausedStateNotTransitioning())
{
if (x1bc_prevState == EInGameGuiState::MapScreen)
{
if (x38_autoMapper->IsInMapperState(CAutoMapper::EAutoMapperState::MapScreen) ||
x38_autoMapper->IsInMapperState(CAutoMapper::EAutoMapperState::MapScreenUniverse))
{
x38_autoMapper->ProcessControllerInput(input, stateMgr);
if (x38_autoMapper->CanLeaveMapScreen(stateMgr))
BeginStateTransition(EInGameGuiState::InGame, stateMgr);
}
return;
}
if (x1bc_prevState == EInGameGuiState::PauseSaveGame)
{
x4c_saveUI->ProcessUserInput(input);
return;
}
if (x1bc_prevState == EInGameGuiState::PauseHUDMessage)
{
x44_messageScreen->ProcessControllerInput(input);
return;
}
2017-04-26 06:43:48 +00:00
if (x48_pauseScreen)
x48_pauseScreen->ProcessControllerInput(stateMgr, input);
2017-04-15 05:32:25 +00:00
}
}
else
{
x34_samusHud->ProcessControllerInput(input);
}
}
2017-02-18 02:19:50 +00:00
}
2017-04-26 06:43:48 +00:00
void CInGameGuiManager::PreDraw(CStateManager& stateMgr, bool cameraActive)
2017-02-18 02:19:50 +00:00
{
2017-04-26 06:43:48 +00:00
if (x48_pauseScreen)
x48_pauseScreen->PreDraw();
if (cameraActive)
x40_samusReflection->PreDraw(stateMgr);
2017-02-18 02:19:50 +00:00
}
void CInGameGuiManager::Draw(CStateManager& stateMgr)
{
2017-05-21 16:01:04 +00:00
//if (!GetIsGameDraw())
// g_Renderer->x318_26_requestRGBA6 = true;
if (x1d8_onScreenTexAlpha > 0.f && x1dc_onScreenTexTok.IsLoaded())
{
if (!m_onScreenQuad || m_onScreenQuad->GetTex().GetObj() != x1dc_onScreenTexTok.GetObj())
2017-06-01 05:34:24 +00:00
m_onScreenQuad.emplace(EFilterType::Blend, x1dc_onScreenTexTok);
2017-05-21 16:01:04 +00:00
// No depth read/write
// Alpha blend
int w = (g_Viewport.x0_left + (x1c4_onScreenTex.x4_origin.x - g_Viewport.x8_width) / 2 + x1c4_onScreenTex.xc_extent.x) -
x1c4_onScreenTex.x4_origin.x;
int h = (g_Viewport.x4_top + (x1c4_onScreenTex.x4_origin.y - g_Viewport.xc_height) / 2 - x1c4_onScreenTex.xc_extent.y) -
x1c4_onScreenTex.x4_origin.y;
zeus::CRectangle rect(x1c4_onScreenTex.x4_origin.x / float(g_Viewport.x8_width),
x1c4_onScreenTex.x4_origin.y / float(g_Viewport.xc_height),
w / float(g_Viewport.x8_width), h / float(g_Viewport.xc_height));
m_onScreenQuad->draw(zeus::CColor(1.f, x1d8_onScreenTexAlpha), 1.f, rect);
}
float staticAlpha = 0.f;
if (stateMgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed &&
stateMgr.GetPlayer().GetDeathTime() > 0.f)
staticAlpha = zeus::clamp(0.f, stateMgr.GetPlayer().GetDeathTime() / (0.3f * 2.5f), 1.f);
bool notInCine = !stateMgr.GetCameraManager()->IsInCinematicCamera();
bool drawVisor = false;
if (notInCine && (x1bc_prevState == EInGameGuiState::InGame || x1c0_nextState == EInGameGuiState::InGame))
drawVisor = true;
if (x3c_pauseScreenBlur->IsGameDraw())
2017-05-21 16:01:04 +00:00
{
x34_samusHud->GetTargetingManager().Draw(stateMgr, true);
CGraphics::SetDepthRange(0.015625f, 0.03125f);
bool scanVisor = stateMgr.GetPlayerState()->GetActiveVisor(stateMgr) == CPlayerState::EPlayerVisor::Scan;
if (drawVisor && x1f0_enablePlayerVisor)
{
2017-08-19 06:52:13 +00:00
if (stateMgr.GetPlayer().GetCameraState() == CPlayer::EPlayerCameraState::FirstPerson)
2017-05-21 16:01:04 +00:00
x20_faceplateDecor.Draw(stateMgr);
CTargetingManager* tgtMgr = nullptr;
if (scanVisor && x1e4_enableTargetingManager)
tgtMgr = &x34_samusHud->GetTargetingManager();
x30_playerVisor->Draw(stateMgr, tgtMgr);
}
x40_samusReflection->Draw(stateMgr);
if (drawVisor)
{
CGraphics::SetDepthRange(0.001953125f, 0.015625f);
if (staticAlpha > 0.f)
2017-06-01 05:34:24 +00:00
m_randomStatic.draw(zeus::CColor(1.f, staticAlpha), 1.f);
2017-05-21 16:01:04 +00:00
x34_samusHud->Draw(stateMgr, x1f4_visorStaticAlpha * (1.f - staticAlpha),
x1e0_helmetVisMode, x1ec_hudVisMode != EHudVisMode::Zero,
x1e4_enableTargetingManager && !scanVisor);
}
}
float preDrawBlur = true;
if (x1bc_prevState >= EInGameGuiState::Zero && x1bc_prevState <= EInGameGuiState::InGame)
if (x1bc_prevState != EInGameGuiState::MapScreen && x1c0_nextState != EInGameGuiState::MapScreen)
preDrawBlur = false;
if (preDrawBlur)
x3c_pauseScreenBlur->Draw(stateMgr);
2017-02-18 02:19:50 +00:00
2017-05-21 16:01:04 +00:00
if (notInCine && x1e8_enableAutoMapper &&
(x3c_pauseScreenBlur->IsGameDraw() || x1bc_prevState == EInGameGuiState::MapScreen ||
2017-05-21 16:01:04 +00:00
x1c0_nextState == EInGameGuiState::MapScreen))
{
float t;
if (stateMgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Combat)
t = stateMgr.GetPlayerState()->GetVisorTransitionFactor();
else
t = 0.f;
float mapAlpha;
if (g_tweakGui->GetShowAutomapperInMorphball())
mapAlpha = 1.f;
else if (stateMgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed)
mapAlpha = 1.f;
else
mapAlpha = 0.f;
x34_samusHud->GetBaseHudFrame()->GetFrameCamera()->Draw(CGuiWidgetDrawParms(0.f, zeus::CVector3f::skZero));
CGraphics::SetDepthRange(0.f, 0.001953125f);
x148_model_automapper->SetIsVisible(true);
x148_model_automapper->Draw(CGuiWidgetDrawParms(1.f, zeus::CVector3f::skZero));
// ZTest no write
2017-11-12 05:14:57 +00:00
x38_autoMapper->Draw(stateMgr, zeus::CTransform::Translate(0.f, 0.02f, 0.f) * x18c_camXf,
mapAlpha * x1f4_visorStaticAlpha * t);
2017-05-21 16:01:04 +00:00
// Zest and write
x148_model_automapper->SetIsVisible(false);
}
if (!preDrawBlur)
x3c_pauseScreenBlur->Draw(stateMgr);
if (x1e0_helmetVisMode != EHelmetVisMode::ReducedUpdate && notInCine)
{
float camYOff;
if (!x48_pauseScreen)
camYOff = 0.f;
else
camYOff = x48_pauseScreen->GetHelmetCamYOff();
x34_samusHud->DrawHelmet(stateMgr, camYOff);
}
if (x4c_saveUI)
x4c_saveUI->Draw();
if (x44_messageScreen)
x44_messageScreen->Draw();
if (x48_pauseScreen)
x48_pauseScreen->Draw();
xf8_camFilter.Draw();
if (stateMgr.GetPlayer().GetDeathTime() > 0.f)
{
float dieDur;
if (stateMgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed)
dieDur = 2.5f;
else
dieDur = 6.f;
float alpha = zeus::clamp(0.f, stateMgr.GetPlayer().GetDeathTime() / dieDur, 1.f);
2017-06-01 05:34:24 +00:00
m_deathWhiteout.draw(zeus::CColor(1.f, alpha));
2017-05-21 16:01:04 +00:00
float zStart = dieDur - 0.5f - 0.5f - 1.f;
float xStart = 0.5f - zStart;
float colStart = 0.5f - xStart;
if (stateMgr.GetPlayer().GetDeathTime() > zStart)
{
float zT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - zStart) / 0.5f, 1.f);
float xT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - xStart) / 0.5f, 1.f);
float colT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - colStart) / 0.5f, 1.f);
SClipScreenRect rect(g_Viewport);
CGraphics::ResolveSpareTexture(rect);
2017-06-01 05:34:24 +00:00
m_deathBlackout.draw(zeus::CColor::skBlack);
2017-05-21 16:01:04 +00:00
float z = 0.5f * (zT * zT * zT * zT * zT * (g_Viewport.xc_height - 12.f) + 12.f);
float x = 0.5f * (xT * (g_Viewport.x8_width - 12.f) + 12.f);
CTexturedQuadFilter::Vert verts[] =
{
{{-x, 0.f, z}, {0.f, 0.f}},
{{-x, 0.f, -z}, {0.f, 1.f}},
{{x, 0.f, z}, {1.f, 0.f}},
{{x, 0.f, -z}, {1.f, 1.f}}
};
if (!m_deathRenderTexQuad)
m_deathRenderTexQuad.emplace(EFilterType::Blend, CGraphics::g_SpareTexture.get());
2017-05-21 16:01:04 +00:00
m_deathRenderTexQuad->drawVerts(zeus::CColor(1.f, colT), verts);
if (!m_deathDotQuad)
2017-06-01 05:34:24 +00:00
m_deathDotQuad.emplace(EFilterType::Multiply, x50_deathDot);
2017-05-21 16:01:04 +00:00
m_deathDotQuad->drawVerts(zeus::CColor(1.f, colT), verts);
}
}
2017-02-18 02:19:50 +00:00
}
2017-08-13 05:26:14 +00:00
void CInGameGuiManager::ShowPauseGameHudMessage(CStateManager& stateMgr, CAssetId pauseMsg, float time)
2017-02-18 02:19:50 +00:00
{
x124_pauseGameHudMessage = pauseMsg;
x128_pauseGameHudTime = time;
PauseGame(stateMgr, EInGameGuiState::PauseHUDMessage);
}
void CInGameGuiManager::PauseGame(CStateManager& stateMgr, EInGameGuiState state)
{
g_InputGenerator->SetMotorState(EIOPort::Zero, EMotorState::Stop);
CSfxManager::SetChannel(CSfxManager::ESfxChannels::PauseScreen);
BeginStateTransition(state, stateMgr);
}
void CInGameGuiManager::StartFadeIn()
{
2017-06-01 05:34:24 +00:00
xf8_camFilter.SetFilter(EFilterType::Multiply,
EFilterShape::Fullscreen,
2017-05-21 16:01:04 +00:00
0.f, zeus::CColor::skBlack, -1);
xf8_camFilter.DisableFilter(0.5f);
2017-02-18 02:19:50 +00:00
}
bool CInGameGuiManager::GetIsGameDraw() const
{
return x3c_pauseScreenBlur->IsGameDraw();
2017-02-18 02:19:50 +00:00
}
2017-02-12 03:17:18 +00:00
}
}