Implement CInGameGuiManager::Update()

This commit is contained in:
Jack Andersen 2017-05-18 09:27:21 -10:00
parent 1f25becf8e
commit 0459192951
22 changed files with 249 additions and 39 deletions

View File

@ -448,6 +448,8 @@ public:
TUniqueId GetBossId() const { return xf18_bossId; }
float GetTotalBossEnergy() const { return xf1c_totalBossEnergy; }
u32 GetBossStringIdx() const { return xf20_bossStringIdx; }
const SOnScreenTex& GetPendingScreenTex() const { return xef4_pendingScreenTex; }
void SetViewportScale(const zeus::CVector2f& scale) { xf2c_viewportScale = scale; }
static float g_EscapeShakeCountdown;
static bool g_EscapeShakeCountdownInit;

View File

@ -80,7 +80,7 @@ BOO_GLSL_BINDING_HEAD
"TBINDING0 uniform sampler2D tex;\n"
"void main()\n"
"{\n"
" colorOut = vtf.color * vec4(textureLod(tex, vtf.uv, lod).rgb, 1.0);\n"
" colorOut = vtf.color * vec4(texture(tex, vtf.uv, lod).rgb, 1.0);\n"
"}\n";
static const char* FSAlpha =
@ -98,7 +98,7 @@ BOO_GLSL_BINDING_HEAD
"TBINDING0 uniform sampler2D tex;\n"
"void main()\n"
"{\n"
" colorOut = vtf.color * textureLod(tex, vtf.uv, lod);\n"
" colorOut = vtf.color * texture(tex, vtf.uv, lod);\n"
"}\n";
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)

View File

@ -84,7 +84,7 @@ static const char* FS =
"\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n"
" return vtf.color * float4(tex.SampleLevel(samp, vtf.uv, vtf.lod).rgb, 1.0);\n"
" return vtf.color * float4(tex.SampleBias(samp, vtf.uv, vtf.lod).rgb, 1.0);\n"
"}\n";
static const char* FSAlpha =
@ -101,7 +101,7 @@ static const char* FSAlpha =
"\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n"
" return vtf.color * tex.SampleLevel(samp, vtf.uv, vtf.lod);\n"
" return vtf.color * tex.SampleBias(samp, vtf.uv, vtf.lod);\n"
"}\n";
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)

View File

@ -89,7 +89,7 @@ static const char* FS =
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> tex [[ texture(0) ]])\n"
"{\n"
" return vtf.color * float4(tex.sample(samp, vtf.uv, level(vtf.lod)).rgb, 1.0);\n"
" return vtf.color * float4(tex.sample(samp, vtf.uv, bias(vtf.lod)).rgb, 1.0);\n"
"}\n";
static const char* FSAlpha =
@ -106,7 +106,7 @@ static const char* FSAlpha =
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> tex [[ texture(0) ]])\n"
"{\n"
" return vtf.color * tex.sample(samp, vtf.uv, level(vtf.lod));\n"
" return vtf.color * tex.sample(samp, vtf.uv, bias(vtf.lod));\n"
"}\n";
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)

View File

@ -18,4 +18,14 @@ void CTargetingManager::Update(float dt, const CStateManager& stateMgr)
}
void CTargetingManager::Draw(const CStateManager& stateMgr) const
{
}
void CTargetingManager::Touch() const
{
}
}

View File

@ -11,10 +11,10 @@ class CTargetingManager
{
zeus::CQuaternion x0_rot;
public:
CTargetingManager(const CStateManager&);
CTargetingManager(const CStateManager& stateMgr);
bool CheckLoadComplete();
void Update(float, const CStateManager&);
void Draw(const CStateManager&) const;
void Update(float, const CStateManager& stateMgr);
void Draw(const CStateManager& stateMgr) const;
void Touch() const;
void SetRotation(const zeus::CQuaternion& rot) { x0_rot = rot; }
};

View File

@ -12,6 +12,8 @@
#include "Audio/CSfxManager.hpp"
#include "CSamusHud.hpp"
#include "Input/CInputGenerator.hpp"
#include "TCastTo.hpp"
#include "Camera/CFirstPersonCamera.hpp"
namespace urde
{
@ -226,10 +228,10 @@ CInGameGuiManager::CInGameGuiManager(CStateManager& stateMgr,
x1ec_hudVisMode = g_tweakGui->GetHudVisMode();
x1f0_enablePlayerVisor = g_tweakGui->GetEnablePlayerVisor();
x1f4_player74c = stateMgr.GetPlayer().Get74C();
x1f4_visorStaticAlpha = stateMgr.GetPlayer().GetVisorStaticAlpha();
x1f8_25_ = true;
x1f8_27_inSaveUI = true;
x1f8_25_playerAlive = true;
x1f8_27_exitSaveUI = true;
xc8_inGameGuiDGRPs.reserve(14);
for (int i=0 ; i<14 ; ++i)
@ -306,9 +308,136 @@ bool CInGameGuiManager::CheckLoadComplete(CStateManager& stateMgr)
}
}
void CInGameGuiManager::Update(CStateManager& stateMgr, float dt, CArchitectureQueue& archQueue, bool)
void CInGameGuiManager::OnNewPauseScreenState(CArchitectureQueue& archQueue)
{
}
void CInGameGuiManager::UpdateAutoMapper(float dt, const CStateManager& stateMgr)
{
}
void CInGameGuiManager::Update(CStateManager& stateMgr, float dt, CArchitectureQueue& archQueue, bool useHud)
{
EnsureStates(stateMgr);
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();
if (x1c4_onScreenTex.x0_id != -1)
{
x1dc_onScreenTexTok = g_SimplePool->GetObj({FOURCC('TXTR'), x1c4_onScreenTex.x0_id});
x1d8_onScreenTexAlpha = FLT_EPSILON;
}
}
else
{
if (stateMgr.GetPendingScreenTex().x0_id == -1 &&
stateMgr.GetPendingScreenTex().x4_origin == zeus::CVector2i(0, 0))
{
x1c4_onScreenTex.x4_origin = stateMgr.GetPendingScreenTex().x4_origin;
x1c4_onScreenTex.x0_id = -1;
x1d8_onScreenTexAlpha = 0.f;
}
else
{
x1d8_onScreenTexAlpha = std::max(0.f, x1d8_onScreenTexAlpha - dt);
}
}
}
else if (x1c4_onScreenTex.x0_id != -1 && x1dc_onScreenTexTok.IsLoaded())
{
x1d8_onScreenTexAlpha = std::min(x1d8_onScreenTexAlpha + dt, 1.f);
}
if (useHud)
{
if (stateMgr.GetPlayer().GetVisorStaticAlpha() != x1f4_visorStaticAlpha)
{
if (TCastToPtr<CFirstPersonCamera> fpCam = stateMgr.GetCameraManager()->GetCurrentCamera(stateMgr))
{
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();
if ((x1bc_prevState == x1c0_nextState || !x1e8_enableAutoMapper) &&
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();
}
bool CInGameGuiManager::IsInGameStateNotTransitioning() const

View File

@ -35,6 +35,11 @@ class CPauseScreen;
class CInGameGuiManager
{
public:
using EHelmetVisMode = DataSpec::ITweakGui::EHelmetVisMode;
using EHudVisMode = DataSpec::ITweakGui::EHudVisMode;
private:
enum class ELoadPhase
{
LoadDepsGroup = 0,
@ -83,23 +88,23 @@ class CInGameGuiManager
EInGameGuiState x1bc_prevState = EInGameGuiState::Zero;
EInGameGuiState x1c0_nextState = EInGameGuiState::Zero;
SOnScreenTex x1c4_onScreenTex;
float x1d8_ = 0.f;
float x1d8_onScreenTexAlpha = 0.f;
TLockedToken<CTexture> x1dc_onScreenTexTok; // Used to be heap-allocated
DataSpec::ITweakGui::EHelmetVisMode x1e0_helmetVisMode;
EHelmetVisMode x1e0_helmetVisMode;
bool x1e4_enableTargetingManager;
bool x1e8_enableAutoMapper;
DataSpec::ITweakGui::EHudVisMode x1ec_hudVisMode;
EHudVisMode x1ec_hudVisMode;
u32 x1f0_enablePlayerVisor;
float x1f4_player74c;
float x1f4_visorStaticAlpha;
union
{
struct
{
bool x1f8_24_ : 1;
bool x1f8_25_ : 1;
bool x1f8_25_playerAlive : 1;
bool x1f8_26_deferTransition : 1;
bool x1f8_27_inSaveUI : 1;
bool x1f8_27_exitSaveUI : 1;
};
u32 _dummy = 0;
};
@ -113,11 +118,13 @@ class CInGameGuiManager
void TryReloadAreaTextures();
bool IsInGameStateNotTransitioning() const;
bool IsInPausedStateNotTransitioning() const;
void UpdateAutoMapper(float dt, const CStateManager& stateMgr);
void OnNewPauseScreenState(CArchitectureQueue& archQueue);
public:
CInGameGuiManager(CStateManager& stateMgr, CArchitectureQueue& archQueue);
bool CheckLoadComplete(CStateManager& stateMgr);
void Update(CStateManager& stateMgr, float dt, CArchitectureQueue& archQueue, bool);
void Update(CStateManager& stateMgr, float dt, CArchitectureQueue& archQueue, bool useHud);
void ProcessControllerInput(CStateManager& stateMgr, const CFinalInput& input,
CArchitectureQueue& archQueue);
void PreDraw(CStateManager& stateMgr, bool cameraActive);
@ -127,7 +134,7 @@ public:
void StartFadeIn();
bool WasInGame() const { return x1bc_prevState >= EInGameGuiState::Zero && x1bc_prevState <= EInGameGuiState::InGame; }
bool IsInGame() const { return x1c0_nextState >= EInGameGuiState::Zero && x1c0_nextState <= EInGameGuiState::InGame; }
bool IsInSaveUI() const { return x1f8_27_inSaveUI; }
bool IsInSaveUI() const { return x1f8_27_exitSaveUI; }
bool GetIsGameDraw() const;
static std::string GetIdentifierForMidiEvent(ResId world, ResId area, const std::string& midiObj);
};

View File

@ -15,5 +15,10 @@ void CMessageScreen::ProcessControllerInput(const CFinalInput& input)
}
bool CMessageScreen::Update(float dt, float blurAmt)
{
return false;
}
}
}

View File

@ -15,6 +15,7 @@ class CMessageScreen
public:
CMessageScreen(ResId msg, float time);
void ProcessControllerInput(const CFinalInput& input);
bool Update(float dt, float blurAmt);
};
}

View File

@ -147,7 +147,7 @@ CPauseScreen::ESubScreen CPauseScreen::GetPreviousSubscreen(ESubScreen screen)
case ESubScreen::LogBook:
return ESubScreen::Inventory;
default:
return ESubScreen::Invalid;
return ESubScreen::ToGame;
}
}
@ -162,7 +162,7 @@ CPauseScreen::ESubScreen CPauseScreen::GetNextSubscreen(ESubScreen screen)
case ESubScreen::LogBook:
return ESubScreen::Options;
default:
return ESubScreen::Invalid;
return ESubScreen::ToGame;
}
}
@ -171,7 +171,7 @@ void CPauseScreen::ProcessControllerInput(const CStateManager& mgr, const CFinal
if (!IsLoaded())
return;
if (x8_curSubscreen == ESubScreen::Invalid)
if (x8_curSubscreen == ESubScreen::ToGame)
return;
bool bExits = false;
@ -184,12 +184,12 @@ void CPauseScreen::ProcessControllerInput(const CStateManager& mgr, const CFinal
if (InputEnabled())
{
bool invalid = x8_curSubscreen == ESubScreen::Invalid;
bool invalid = x8_curSubscreen == ESubScreen::ToGame;
if (input.PStart() || (input.PB() && bExits) ||
(x7c_screens[x78_activeIdx] && x7c_screens[x78_activeIdx]->ShouldExitPauseScreen()))
{
CSfxManager::SfxStart(1434, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
StartTransition(0.5f, mgr, ESubScreen::Invalid, 2);
StartTransition(0.5f, mgr, ESubScreen::ToGame, 2);
}
else
{
@ -275,7 +275,7 @@ void CPauseScreen::Draw()
{
float useInterp = x10_alphaInterp == 0.f ? 1.f : x10_alphaInterp / 0.5f;
float initInterp = std::min(curScreen->GetAlpha(), useInterp);
if (xc_nextSubscreen == ESubScreen::Invalid)
if (xc_nextSubscreen == ESubScreen::ToGame)
totalAlpha = useInterp;
else if (x91_initialTransition)
totalAlpha = initInterp;
@ -290,5 +290,15 @@ void CPauseScreen::Draw()
x34_loadedPauseScreenInstructions->Draw(parms);
}
bool CPauseScreen::ShouldSwitchToMapScreen() const
{
return IsLoaded() && x8_curSubscreen == ESubScreen::ToMap && xc_nextSubscreen == ESubScreen::ToMap;
}
bool CPauseScreen::ShouldSwitchToInGame() const
{
return IsLoaded() && x8_curSubscreen == ESubScreen::ToGame && xc_nextSubscreen == ESubScreen::ToGame;
}
}
}

View File

@ -20,14 +20,15 @@ public:
LogBook,
Options,
Inventory,
Invalid
ToGame,
ToMap
};
private:
ESubScreen x0_initialSubScreen;
u32 x4_ = 2;
ESubScreen x8_curSubscreen = ESubScreen::Invalid;
ESubScreen xc_nextSubscreen = ESubScreen::Invalid;
ESubScreen x8_curSubscreen = ESubScreen::ToGame;
ESubScreen xc_nextSubscreen = ESubScreen::ToGame;
float x10_alphaInterp = 0.f;
TLockedToken<CStringTable> x14_strgPauseScreen;
const CDependencyGroup& x20_suitDgrp;
@ -68,6 +69,8 @@ public:
void PreDraw();
void Draw();
bool IsLoaded() const { return x90_resourcesLoaded; }
bool ShouldSwitchToMapScreen() const;
bool ShouldSwitchToInGame() const;
};
}

View File

@ -20,5 +20,10 @@ void CPauseScreenBlur::OnNewInGameGuiState(EInGameGuiState state, CStateManager&
}
void CPauseScreenBlur::Update(float dt, const CStateManager& stateMgr, bool)
{
}
}
}

View File

@ -11,6 +11,9 @@ namespace MP1
class CPauseScreenBlur
{
u32 x10_ = 0;
u32 x14_ = 0;
float x18_blurAmt = 0.f;
union
{
struct
@ -25,6 +28,9 @@ public:
bool CheckLoadComplete();
void OnNewInGameGuiState(EInGameGuiState state, CStateManager& stateMgr);
bool GetX50_25() const { return x50_25_; }
void Update(float dt, const CStateManager& stateMgr, bool);
float GetBlurAmt() const { return std::fabs(x18_blurAmt); }
bool IsNotTransitioning() const { return x10_ == x14_; }
};
}

View File

@ -10,5 +10,25 @@ CPlayerVisor::CPlayerVisor(CStateManager& stateMgr)
}
void CPlayerVisor::Update(float dt, const CStateManager& stateMgr)
{
}
void CPlayerVisor::Touch()
{
}
float CPlayerVisor::GetDesiredViewportScaleX(const CStateManager& stateMgr) const
{
return 0.f;
}
float CPlayerVisor::GetDesiredViewportScaleY(const CStateManager& stateMgr) const
{
return 0.f;
}
}
}

View File

@ -12,6 +12,10 @@ class CPlayerVisor
{
public:
CPlayerVisor(CStateManager& stateMgr);
void Update(float dt, const CStateManager& stateMgr);
void Touch();
float GetDesiredViewportScaleX(const CStateManager& stateMgr) const;
float GetDesiredViewportScaleY(const CStateManager& stateMgr) const;
};
}

View File

@ -21,5 +21,10 @@ void CSamusFaceReflection::PreDraw(const CStateManager& stateMgr)
}
void CSamusFaceReflection::Update(float dt, const CStateManager& stateMgr, CRandom16& rand)
{
}
}
}

View File

@ -20,6 +20,7 @@ class CSamusFaceReflection
public:
CSamusFaceReflection(CStateManager& stateMgr);
void PreDraw(const CStateManager& stateMgr);
void Update(float dt, const CStateManager& stateMgr, CRandom16& rand);
};
}

View File

@ -1227,7 +1227,7 @@ EHudState CSamusHud::GetDesiredHudState(const CStateManager& mgr)
}
void CSamusHud::Update(float dt, const CStateManager& mgr,
DataSpec::ITweakGui::EHelmetVisMode helmetVis,
CInGameGuiManager::EHelmetVisMode helmetVis,
bool hudVis, bool targetingManager)
{
CPlayer& player = mgr.GetPlayer();
@ -1274,14 +1274,14 @@ void CSamusHud::Update(float dt, const CStateManager& mgr,
{
switch (helmetVis)
{
case DataSpec::ITweakGui::EHelmetVisMode::HelmetOnly:
case CInGameGuiManager::EHelmetVisMode::HelmetOnly:
helmetVisible = true;
break;
case DataSpec::ITweakGui::EHelmetVisMode::GlowHelmetDeco:
case CInGameGuiManager::EHelmetVisMode::GlowHelmetDeco:
glowVisible = true;
case DataSpec::ITweakGui::EHelmetVisMode::HelmetDeco:
case CInGameGuiManager::EHelmetVisMode::HelmetDeco:
helmetVisible = true;
case DataSpec::ITweakGui::EHelmetVisMode::Deco:
case CInGameGuiManager::EHelmetVisMode::Deco:
decoVisible = true;
default: break;
}

View File

@ -246,7 +246,7 @@ public:
CSamusHud(CStateManager& stateMgr);
~CSamusHud();
void Update(float dt, const CStateManager& mgr,
DataSpec::ITweakGui::EHelmetVisMode helmetVis,
CInGameGuiManager::EHelmetVisMode helmetVis,
bool hudVis, bool targetingManager);
void ProcessControllerInput(const CFinalInput& input);
void UpdateStateTransition(float time, const CStateManager& mgr);
@ -254,6 +254,8 @@ public:
void OnNewInGameGuiState(EInGameGuiState state, CStateManager& stateMgr);
void RefreshHudOptions();
void Touch();
CTargetingManager& GetTargetingManager() { return x8_targetingMgr; }
const zeus::CVector2f& GetViewportScale() const { return x500_viewportScale; }
static zeus::CTransform BuildFinalCameraTransform(const zeus::CQuaternion& rot,
const zeus::CVector3f& pos,
const zeus::CVector3f& camPos);

View File

@ -206,7 +206,7 @@ private:
float x740_ = 0.f;
float x744_ = 0.f;
float x748_ = 0.f;
float x74c_ = 1.f;
float x74c_visorStaticAlpha = 1.f;
float x750_ = 0.f;
u32 x754_ = 0;
float x758_ = 0.f;
@ -432,7 +432,7 @@ public:
float GetWeight() const;
float GetDampedClampedVelocityWR() const;
const CVisorSteam& GetVisorSteam() const { return x7a0_visorSteam; }
float Get74C() const { return x74c_; }
float GetVisorStaticAlpha() const { return x74c_visorStaticAlpha; }
float GetMapAlpha() const { return x494_mapAlpha; }
void UpdateCinematicState(CStateManager& mgr);
void SetCameraState(EPlayerCameraState camState, CStateManager& stateMgr);

@ -1 +1 @@
Subproject commit 2faf7c87ed0548cd9152de4d1acd0791ba118308
Subproject commit b1f6555cf27f8874da7460d8f6feed615c00e839