From 394cbf36e0b85171d48b91bde8c5b329d6f81e4d Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 1 May 2017 18:00:38 -1000 Subject: [PATCH] Work on CPauseScreen --- Runtime/Input/ControlMapper.hpp | 2 + Runtime/MP1/CInGameGuiManager.cpp | 5 +- Runtime/MP1/CInventoryScreen.cpp | 30 +--- Runtime/MP1/CInventoryScreen.hpp | 6 +- Runtime/MP1/CLogBookScreen.cpp | 31 ++++ Runtime/MP1/CLogBookScreen.hpp | 25 +++ Runtime/MP1/COptionsScreen.cpp | 31 ++++ Runtime/MP1/COptionsScreen.hpp | 25 +++ Runtime/MP1/CPauseScreen.cpp | 282 +++++++++++++++++++++++++++++- Runtime/MP1/CPauseScreen.hpp | 29 ++- Runtime/MP1/CPauseScreenBase.cpp | 84 ++++++++- Runtime/MP1/CPauseScreenBase.hpp | 54 ++++-- Runtime/MP1/CPauseScreenBlur.cpp | 24 +++ 13 files changed, 576 insertions(+), 52 deletions(-) diff --git a/Runtime/Input/ControlMapper.hpp b/Runtime/Input/ControlMapper.hpp index 54589cfd5..ff5759e50 100644 --- a/Runtime/Input/ControlMapper.hpp +++ b/Runtime/Input/ControlMapper.hpp @@ -68,6 +68,8 @@ public: VisorDown, UseSheild=0x3B, ScanItem=0x3C, + PreviousPauseScreen=0x41, + NextPauseScreen=0x42, UNKNOWN, None, MAX diff --git a/Runtime/MP1/CInGameGuiManager.cpp b/Runtime/MP1/CInGameGuiManager.cpp index 3d078c5df..cdb46a522 100644 --- a/Runtime/MP1/CInGameGuiManager.cpp +++ b/Runtime/MP1/CInGameGuiManager.cpp @@ -179,9 +179,10 @@ void CInGameGuiManager::DoStateTransition(CStateManager& stateMgr) } } - int w1 = x1c0_nextState == EInGameGuiState::PauseLogBook ? 0 : 2; + CPauseScreen::ESubScreen screen = x1c0_nextState == EInGameGuiState::PauseLogBook ? + CPauseScreen::ESubScreen::LogBook : CPauseScreen::ESubScreen::Inventory; CDependencyGroup* suitGrp = x5c_pauseScreenDGRPs[suitResIdx].GetObj(); - x48_pauseScreen = std::make_unique(w1, *suitGrp, *suitGrp); + x48_pauseScreen = std::make_unique(screen, *suitGrp, *suitGrp); } case EInGameGuiState::MapScreen: diff --git a/Runtime/MP1/CInventoryScreen.cpp b/Runtime/MP1/CInventoryScreen.cpp index be578a634..92889e650 100644 --- a/Runtime/MP1/CInventoryScreen.cpp +++ b/Runtime/MP1/CInventoryScreen.cpp @@ -1,48 +1,30 @@ #include "CInventoryScreen.hpp" -#include "GameGlobalObjects.hpp" -#include "CSimplePool.hpp" -#include "Audio/CSfxManager.hpp" namespace urde { namespace MP1 { -CInventoryScreen::CInventoryScreen(const CStateManager& mgr, const CGuiFrame& frame, const CStringTable& pauseStrg, +CInventoryScreen::CInventoryScreen(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg, const CDependencyGroup& suitDgrp, const CDependencyGroup& ballDgrp) : CPauseScreenBase(mgr, frame, pauseStrg) { } -CPauseScreen::CPauseScreen(u32 w1, - const CDependencyGroup& suitDgrp, - const CDependencyGroup& ballDgrp) -: x0_w1(w1), x14_strgPauseScreen(g_SimplePool->GetObj("STRG_PauseScreen")), - x20_suitDgrp(suitDgrp), x24_ballDgrp(ballDgrp), - x28_pauseScreenInstructions(g_SimplePool->GetObj("FRME_PauseScreenInstructions")), - x54_frmePauseScreenId(g_ResFactory->GetResourceIdByName("FRME_PauseScreen")->id) +bool CInventoryScreen::VReady() const { - SObjectTag frmeTag(FOURCC('FRME'), x54_frmePauseScreenId); - x58_frmePauseScreenBufSz = g_ResFactory->ResourceSize(frmeTag); - ProjectResourceFactoryBase& resFac = static_cast(*g_ResFactory); - x60_loadTok = resFac.LoadResourceAsync(frmeTag, x5c_frmePauseScreenBuf); - CSfxManager::SfxStart(1435, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); + return true; } -void CPauseScreen::ProcessControllerInput(const CStateManager& mgr, const CFinalInput& input) +void CInventoryScreen::VActivate() const { } -void CPauseScreen::Update(float dt, CRandom16& rand, const CStateManager& mgr) +u32 CInventoryScreen::GetRightTableCount() const { - -} - -void CPauseScreen::PreDraw() -{ - + return 0; } } diff --git a/Runtime/MP1/CInventoryScreen.hpp b/Runtime/MP1/CInventoryScreen.hpp index 45e66d454..64ab51a63 100644 --- a/Runtime/MP1/CInventoryScreen.hpp +++ b/Runtime/MP1/CInventoryScreen.hpp @@ -16,8 +16,12 @@ class CInventoryScreen : public CPauseScreenBase { std::unique_ptr x19c_samusDoll; public: - CInventoryScreen(const CStateManager& mgr, const CGuiFrame& frame, const CStringTable& pauseStrg, + CInventoryScreen(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg, const CDependencyGroup& suitDgrp, const CDependencyGroup& ballDgrp); + + bool VReady() const; + void VActivate() const; + u32 GetRightTableCount() const; }; } diff --git a/Runtime/MP1/CLogBookScreen.cpp b/Runtime/MP1/CLogBookScreen.cpp index e69de29bb..0b7d79b81 100644 --- a/Runtime/MP1/CLogBookScreen.cpp +++ b/Runtime/MP1/CLogBookScreen.cpp @@ -0,0 +1,31 @@ +#include "CLogBookScreen.hpp" + +namespace urde +{ +namespace MP1 +{ + +CLogBookScreen::CLogBookScreen(const CStateManager& mgr, CGuiFrame& frame, + const CStringTable& pauseStrg) +: CPauseScreenBase(mgr, frame, pauseStrg) +{ + +} + +bool CLogBookScreen::VReady() const +{ + return true; +} + +void CLogBookScreen::VActivate() const +{ + +} + +u32 CLogBookScreen::GetRightTableCount() const +{ + return 0; +} + +} +} diff --git a/Runtime/MP1/CLogBookScreen.hpp b/Runtime/MP1/CLogBookScreen.hpp index e69de29bb..d42249b30 100644 --- a/Runtime/MP1/CLogBookScreen.hpp +++ b/Runtime/MP1/CLogBookScreen.hpp @@ -0,0 +1,25 @@ +#ifndef __URDE_CLOGBOOKSCREEN_HPP__ +#define __URDE_CLOGBOOKSCREEN_HPP__ + +#include "CInGameGuiManager.hpp" +#include "CPauseScreenBase.hpp" + +namespace urde +{ +namespace MP1 +{ + +class CLogBookScreen : public CPauseScreenBase +{ +public: + CLogBookScreen(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg); + + bool VReady() const; + void VActivate() const; + u32 GetRightTableCount() const; +}; + +} +} + +#endif // __URDE_CLOGBOOKSCREEN_HPP__ diff --git a/Runtime/MP1/COptionsScreen.cpp b/Runtime/MP1/COptionsScreen.cpp index e69de29bb..d948b9600 100644 --- a/Runtime/MP1/COptionsScreen.cpp +++ b/Runtime/MP1/COptionsScreen.cpp @@ -0,0 +1,31 @@ +#include "COptionsScreen.hpp" + +namespace urde +{ +namespace MP1 +{ + +COptionsScreen::COptionsScreen(const CStateManager& mgr, CGuiFrame& frame, + const CStringTable& pauseStrg) +: CPauseScreenBase(mgr, frame, pauseStrg) +{ + +} + +bool COptionsScreen::VReady() const +{ + return true; +} + +void COptionsScreen::VActivate() const +{ + +} + +u32 COptionsScreen::GetRightTableCount() const +{ + return 0; +} + +} +} diff --git a/Runtime/MP1/COptionsScreen.hpp b/Runtime/MP1/COptionsScreen.hpp index e69de29bb..28ba09d36 100644 --- a/Runtime/MP1/COptionsScreen.hpp +++ b/Runtime/MP1/COptionsScreen.hpp @@ -0,0 +1,25 @@ +#ifndef __URDE_COPTIONSSCREEN_HPP__ +#define __URDE_COPTIONSSCREEN_HPP__ + +#include "CInGameGuiManager.hpp" +#include "CPauseScreenBase.hpp" + +namespace urde +{ +namespace MP1 +{ + +class COptionsScreen : public CPauseScreenBase +{ +public: + COptionsScreen(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg); + + bool VReady() const; + void VActivate() const; + u32 GetRightTableCount() const; +}; + +} +} + +#endif // __URDE_COPTIONSSCREEN_HPP__ diff --git a/Runtime/MP1/CPauseScreen.cpp b/Runtime/MP1/CPauseScreen.cpp index 19ffdd11c..6e40589f8 100644 --- a/Runtime/MP1/CPauseScreen.cpp +++ b/Runtime/MP1/CPauseScreen.cpp @@ -1,23 +1,293 @@ -#include "CPauseScreenBlur.hpp" +#include "CPauseScreen.hpp" +#include "GameGlobalObjects.hpp" +#include "CSimplePool.hpp" +#include "Audio/CSfxManager.hpp" +#include "CLogBookScreen.hpp" +#include "COptionsScreen.hpp" +#include "GuiSys/CGuiSys.hpp" +#include "GuiSys/CGuiTextPane.hpp" +#include "GuiSys/CGuiWidgetDrawParms.hpp" +#include "Input/ControlMapper.hpp" namespace urde { namespace MP1 { -CPauseScreenBlur::CPauseScreenBlur() +CPauseScreen::CPauseScreen(ESubScreen subscreen, + const CDependencyGroup& suitDgrp, + const CDependencyGroup& ballDgrp) +: x0_initialSubScreen(subscreen), + x14_strgPauseScreen(g_SimplePool->GetObj("STRG_PauseScreen")), + x20_suitDgrp(suitDgrp), x24_ballDgrp(ballDgrp), + x28_pauseScreenInstructions(g_SimplePool->GetObj("FRME_PauseScreenInstructions")), + x54_frmePauseScreenId(g_ResFactory->GetResourceIdByName("FRME_PauseScreen")->id) { - + SObjectTag frmeTag(FOURCC('FRME'), x54_frmePauseScreenId); + x58_frmePauseScreenBufSz = g_ResFactory->ResourceSize(frmeTag); + ProjectResourceFactoryBase& resFac = static_cast(*g_ResFactory); + x60_loadTok = resFac.LoadResourceAsync(frmeTag, x5c_frmePauseScreenBuf); + CSfxManager::SfxStart(1435, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); } -bool CPauseScreenBlur::CheckLoadComplete() +std::unique_ptr CPauseScreen::BuildPauseSubScreen(ESubScreen subscreen, + const CStateManager& mgr, + CGuiFrame& frame) const { - return false; + switch (subscreen) + { + case ESubScreen::LogBook: + return std::make_unique(mgr, frame, *x14_strgPauseScreen); + case ESubScreen::Options: + return std::make_unique(mgr, frame, *x14_strgPauseScreen); + case ESubScreen::Inventory: + return std::make_unique(mgr, frame, *x14_strgPauseScreen, x20_suitDgrp, x24_ballDgrp); + default: + return {}; + } } -void CPauseScreenBlur::OnNewInGameGuiState(EInGameGuiState state, CStateManager& stateMgr) +void CPauseScreen::InitializeFrameGlue() { + x38_textpane_l1 = static_cast(x34_loadedPauseScreenInstructions->FindWidget("textpane_l1")); + x3c_textpane_r = static_cast(x34_loadedPauseScreenInstructions->FindWidget("textpane_r")); + x40_textpane_a = static_cast(x34_loadedPauseScreenInstructions->FindWidget("textpane_a")); + x44_textpane_b = static_cast(x34_loadedPauseScreenInstructions->FindWidget("textpane_b")); + x48_textpane_return = static_cast(x34_loadedPauseScreenInstructions->FindWidget("textpane_return")); + x4c_textpane_next = static_cast(x34_loadedPauseScreenInstructions->FindWidget("textpane_next")); + x50_textpane_back = static_cast(x34_loadedPauseScreenInstructions->FindWidget("textpane_back")); + x40_textpane_a->TextSupport()->SetText(x14_strgPauseScreen->GetString(7)); // OPTIONS + x40_textpane_a->TextSupport()->SetFontColor(g_tweakGuiColors->GetPauseItemAmberColor()); + x44_textpane_b->TextSupport()->SetText(x14_strgPauseScreen->GetString(6)); // LOG BOOK + x44_textpane_b->TextSupport()->SetFontColor(g_tweakGuiColors->GetPauseItemAmberColor()); + x40_textpane_a->SetColor(zeus::CColor::skClear); + x44_textpane_b->SetColor(zeus::CColor::skClear); + + if (CGuiWidget* deco = x34_loadedPauseScreenInstructions->FindWidget("basewidget_deco")) + { + zeus::CColor color = g_tweakGuiColors->GetPauseItemAmberColor(); + color.a *= 0.75f; + deco->SetColor(color); + } +} + +bool CPauseScreen::CheckLoadComplete(const CStateManager& mgr) +{ + if (x90_resourcesLoaded) + return true; + if (!x14_strgPauseScreen.IsLoaded()) + return false; + if (!x34_loadedPauseScreenInstructions) + { + if (!x28_pauseScreenInstructions.IsLoaded()) + return false; + if (!x28_pauseScreenInstructions->GetIsFinishedLoading()) + return false; + x34_loadedPauseScreenInstructions = x28_pauseScreenInstructions.GetObj(); + InitializeFrameGlue(); + } + if (x60_loadTok) + { + if (!x60_loadTok->m_complete) + return false; + for (int i=0 ; i<2 ; ++i) + { + CMemoryInStream s(x5c_frmePauseScreenBuf.get(), x58_frmePauseScreenBufSz); + x64_frameInsts.push_back(CGuiFrame::CreateFrame(x54_frmePauseScreenId, *g_GuiSys, s, g_SimplePool)); + } + x5c_frmePauseScreenBuf.reset(); + x60_loadTok.reset(); + } + if (!x64_frameInsts[0]->GetIsFinishedLoading() || !x64_frameInsts[1]->GetIsFinishedLoading()) + return false; + x90_resourcesLoaded = true; + StartTransition(FLT_EPSILON, mgr, x0_initialSubScreen, 2); + x91_initialTransition = true; + return true; +} + +void CPauseScreen::StartTransition(float time, const CStateManager& mgr, ESubScreen subscreen, int b) +{ + if (subscreen == xc_nextSubscreen) + return; + xc_nextSubscreen = subscreen; + x4_ = b; + std::unique_ptr& newScreenSlot = x7c_screens[x78_activeIdx]; + std::unique_ptr& newScreenInst = x64_frameInsts[x78_activeIdx]; + newScreenSlot = BuildPauseSubScreen(xc_nextSubscreen, mgr, *newScreenInst); + x7c_screens[1 - x78_activeIdx]->TransitioningAway(); + x91_initialTransition = false; +} + +bool CPauseScreen::InputEnabled() const +{ + if (xc_nextSubscreen != x8_curSubscreen) + return false; + + if (const std::unique_ptr& screenSlot = x7c_screens[x78_activeIdx]) + if (screenSlot->InputDisabled()) + return false; + + if (const std::unique_ptr& screenSlot = x7c_screens[1 - x78_activeIdx]) + if (screenSlot->InputDisabled()) + return false; + + return true; +} + +CPauseScreen::ESubScreen CPauseScreen::GetPreviousSubscreen(ESubScreen screen) +{ + switch (screen) + { + case ESubScreen::Inventory: + return ESubScreen::Options; + case ESubScreen::Options: + return ESubScreen::LogBook; + case ESubScreen::LogBook: + return ESubScreen::Inventory; + default: + return ESubScreen::Invalid; + } +} + +CPauseScreen::ESubScreen CPauseScreen::GetNextSubscreen(ESubScreen screen) +{ + switch (screen) + { + case ESubScreen::Inventory: + return ESubScreen::LogBook; + case ESubScreen::Options: + return ESubScreen::Inventory; + case ESubScreen::LogBook: + return ESubScreen::Options; + default: + return ESubScreen::Invalid; + } +} + +void CPauseScreen::ProcessControllerInput(const CStateManager& mgr, const CFinalInput& input) +{ + if (!IsLoaded()) + return; + + if (x8_curSubscreen == ESubScreen::Invalid) + return; + + bool bExits = false; + if (std::unique_ptr& curScreen = x7c_screens[x78_activeIdx]) + { + if (curScreen->GetMode() == CPauseScreenBase::EMode::Zero) + bExits = true; + curScreen->ProcessControllerInput(input); + } + + if (InputEnabled()) + { + bool invalid = x8_curSubscreen == ESubScreen::Invalid; + 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); + } + else + { + if (ControlMapper::GetPressInput(ControlMapper::ECommands::PreviousPauseScreen, input)) + { + CSfxManager::SfxStart(1433, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); + StartTransition(0.5f, mgr, GetPreviousSubscreen(x8_curSubscreen), invalid ? 2 : 0); + } + else if (ControlMapper::GetPressInput(ControlMapper::ECommands::NextPauseScreen, input)) + { + CSfxManager::SfxStart(1433, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); + StartTransition(0.5f, mgr, GetNextSubscreen(x8_curSubscreen), invalid ? 2 : 1); + } + } + } + + x38_textpane_l1->TextSupport()->SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x74_lTrigger[input.DLTrigger()]))); + x3c_textpane_r->TextSupport()->SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x80_rTrigger[input.DRTrigger()]))); + x48_textpane_return->TextSupport()->SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x8c_startButton[input.DStart()]))); + x50_textpane_back->TextSupport()->SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x98_aButton[input.DA()]))); + x4c_textpane_next->TextSupport()->SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->xa4_bButton[input.DB()]))); +} + +void CPauseScreen::TransitionComplete() +{ + std::unique_ptr& curScreen = x7c_screens[x78_activeIdx]; + curScreen.reset(); + x78_activeIdx = 1 - x78_activeIdx; + x8_curSubscreen = xc_nextSubscreen; + x40_textpane_a->TextSupport()->SetText(x14_strgPauseScreen->GetString(int(GetPreviousSubscreen(x8_curSubscreen)) + 6)); + x44_textpane_b->TextSupport()->SetText(x14_strgPauseScreen->GetString(int(GetNextSubscreen(x8_curSubscreen)) + 6)); +} + +void CPauseScreen::Update(float dt, const CStateManager& mgr, CRandom16& rand, CArchitectureQueue& archQueue) +{ + if (!CheckLoadComplete(mgr)) + return; + + std::unique_ptr& curScreen = x7c_screens[x78_activeIdx]; + std::unique_ptr& otherScreen = x7c_screens[1 - x78_activeIdx]; + + if (x8_curSubscreen != xc_nextSubscreen) + { + x10_interp = std::max(0.f, x10_interp - dt); + if (!curScreen || !curScreen->InputDisabled()) + { + if (!otherScreen || otherScreen->IsReady()) + { + if (x10_interp == 0.f) + TransitionComplete(); + } + } + } + + if (std::unique_ptr& curScreen = x7c_screens[x78_activeIdx]) + { + curScreen->Update(dt, rand, archQueue); + zeus::CColor color = zeus::CColor::skWhite; + color.a = std::min(curScreen->GetAlpha(), x8_curSubscreen != xc_nextSubscreen ? x10_interp / 0.5f : 1.f); + x40_textpane_a->SetColor(color); + x44_textpane_b->SetColor(color); + } +} + +void CPauseScreen::PreDraw() +{ + if (!IsLoaded()) + return; + if (std::unique_ptr& curScreen = x7c_screens[x78_activeIdx]) + if (curScreen->CanDraw()) + curScreen->Touch(); +} + +void CPauseScreen::Draw() +{ + if (!IsLoaded()) + return; + + float totalAlpha = 0.f; + float yOff = 0.f; + std::unique_ptr& curScreen = x7c_screens[x78_activeIdx]; + if (curScreen && curScreen->CanDraw()) + { + float useInterp = x10_interp == 0.f ? 1.f : x10_interp / 0.5f; + float initInterp = std::min(curScreen->GetAlpha(), useInterp); + if (xc_nextSubscreen == ESubScreen::Invalid) + totalAlpha = useInterp; + else if (x91_initialTransition) + totalAlpha = initInterp; + else + totalAlpha = 1.f; + + curScreen->Draw(x8_curSubscreen != xc_nextSubscreen ? useInterp : 1.f, totalAlpha, 0.f); + yOff = curScreen->GetCameraYBias(); + } + + CGuiWidgetDrawParms parms(totalAlpha, zeus::CVector3f{0.f, 15.f * yOff, 0.f}); + x34_loadedPauseScreenInstructions->Draw(parms); } } diff --git a/Runtime/MP1/CPauseScreen.hpp b/Runtime/MP1/CPauseScreen.hpp index 54256c7b1..9e1525b2a 100644 --- a/Runtime/MP1/CPauseScreen.hpp +++ b/Runtime/MP1/CPauseScreen.hpp @@ -24,11 +24,11 @@ public: }; private: - u32 x0_w1; + ESubScreen x0_initialSubScreen; u32 x4_ = 2; - ESubScreen x8_ = ESubScreen::Invalid; - ESubScreen xc_ = ESubScreen::Invalid; - float x10_ = 0.f; + ESubScreen x8_curSubscreen = ESubScreen::Invalid; + ESubScreen xc_nextSubscreen = ESubScreen::Invalid; + float x10_interp = 0.f; TLockedToken x14_strgPauseScreen; const CDependencyGroup& x20_suitDgrp; const CDependencyGroup& x24_ballDgrp; @@ -37,6 +37,7 @@ private: CGuiTextPane* x38_textpane_l1 = nullptr; CGuiTextPane* x3c_textpane_r = nullptr; CGuiTextPane* x40_textpane_a = nullptr; + CGuiTextPane* x44_textpane_b = nullptr; CGuiTextPane* x48_textpane_return = nullptr; CGuiTextPane* x4c_textpane_next = nullptr; CGuiTextPane* x50_textpane_back = nullptr; @@ -44,17 +45,29 @@ private: u32 x58_frmePauseScreenBufSz; std::unique_ptr x5c_frmePauseScreenBuf; std::shared_ptr x60_loadTok; - rstl::reserved_vector, 2> x64_frames; + rstl::reserved_vector, 2> x64_frameInsts; u32 x78_activeIdx = 0; rstl::reserved_vector, 2> x7c_screens; bool x90_resourcesLoaded = false; - bool x91_inPauseScreen = true; + bool x91_initialTransition = true; + std::unique_ptr BuildPauseSubScreen(ESubScreen subscreen, + const CStateManager& mgr, + CGuiFrame& frame) const; + void StartTransition(float time, const CStateManager& mgr, ESubScreen subscreen, int); + bool CheckLoadComplete(const CStateManager& mgr); + void InitializeFrameGlue(); + bool InputEnabled() const; + static ESubScreen GetPreviousSubscreen(ESubScreen screen); + static ESubScreen GetNextSubscreen(ESubScreen screen); + void TransitionComplete(); public: - CPauseScreen(u32 w1, const CDependencyGroup& suitDgrp, const CDependencyGroup& ballDgrp); + CPauseScreen(ESubScreen subscreen, const CDependencyGroup& suitDgrp, const CDependencyGroup& ballDgrp); void ProcessControllerInput(const CStateManager& mgr, const CFinalInput& input); - void Update(float dt, CRandom16& rand, const CStateManager& mgr); + void Update(float dt, const CStateManager& mgr, CRandom16& rand, CArchitectureQueue& archQueue); void PreDraw(); + void Draw(); + bool IsLoaded() const { return x90_resourcesLoaded; } }; } diff --git a/Runtime/MP1/CPauseScreenBase.cpp b/Runtime/MP1/CPauseScreenBase.cpp index 373fba203..4688e60aa 100644 --- a/Runtime/MP1/CPauseScreenBase.cpp +++ b/Runtime/MP1/CPauseScreenBase.cpp @@ -5,6 +5,7 @@ #include "GuiSys/CGuiModel.hpp" #include "GuiSys/CGuiTextPane.hpp" #include "GuiSys/CAuiImagePane.hpp" +#include "GuiSys/CGuiWidgetDrawParms.hpp" #include "GameGlobalObjects.hpp" namespace urde @@ -12,7 +13,7 @@ namespace urde namespace MP1 { -CPauseScreenBase::CPauseScreenBase(const CStateManager& mgr, const CGuiFrame& frame, const CStringTable& pauseStrg) +CPauseScreenBase::CPauseScreenBase(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg) : x4_mgr(mgr), x8_frame(frame), xc_pauseStrg(pauseStrg) { InitializeFrameGlue(); @@ -69,6 +70,87 @@ void CPauseScreenBase::InitializeFrameGlue() x6c_basewidget_leftlog->SetColor(g_tweakGuiColors->GetPauseItemAmberColor()); } +bool CPauseScreenBase::IsReady() +{ + if (x198_24_ready) + return true; + x198_24_ready = VReady(); + if (x198_24_ready) + { + VActivate(); + Activate(EMode::Zero); + UpdateSideTable(x70_tablegroup_leftlog); + UpdateRightTable(); + return true; + } + return false; +} + +void CPauseScreenBase::Activate(EMode mode) +{ + +} + +void CPauseScreenBase::UpdateSideTable(CGuiTableGroup* table) +{ + +} + +void CPauseScreenBase::Update(float dt, CRandom16& rand, CArchitectureQueue& archQueue) +{ + x198_27_canDraw = true; + x8_frame.Update(dt); + x14_alpha = std::min(2.f * dt + x14_alpha, 1.f); + + u32 rightCount = GetRightTableCount(); + bool pulseRightUp = x10_mode == EMode::One && x18_ > 0; + bool pulseRightDown = x10_mode == EMode::One && x18_ + 5 < rightCount; + float rightUpT = pulseRightUp ? CGraphics::GetSecondsMod900() : 0.f; + float rightDownT = pulseRightDown ? CGraphics::GetSecondsMod900() : 0.f; + + zeus::CColor lowC = g_tweakGuiColors->GetPauseItemAmberColor(); + lowC.a = 0.2f; + xa0_model_scrollrightup->SetColor( + zeus::CColor::lerp(lowC, g_tweakGuiColors->GetPauseItemAmberColor(), + zeus::clamp(0.f, (std::sin(5.f * rightUpT - M_PIF / 2.f) + 1.f) * 0.5f, 1.f))); + xa4_model_scrollrightdown->SetColor( + zeus::CColor::lerp(lowC, g_tweakGuiColors->GetPauseItemAmberColor(), + zeus::clamp(0.f, (std::sin(5.f * rightDownT - M_PIF / 2.f) + 1.f) * 0.5f, 1.f))); + + float textUpT = x198_28_pulseTextArrowTop ? CGraphics::GetSecondsMod900() : 0.f; + float textDownT = x198_29_pulseTextArrowBottom ? CGraphics::GetSecondsMod900() : 0.f; + + x90_model_textarrowtop->SetColor( + zeus::CColor::lerp(lowC, g_tweakGuiColors->GetPauseItemAmberColor(), + zeus::clamp(0.f, (std::sin(5.f * textUpT - M_PIF / 2.f) + 1.f) * 0.5f, 1.f))); + x94_model_textarrowbottom->SetColor( + zeus::CColor::lerp(lowC, g_tweakGuiColors->GetPauseItemAmberColor(), + zeus::clamp(0.f, (std::sin(5.f * textDownT - M_PIF / 2.f) + 1.f) * 0.5f, 1.f))); +} + +void CPauseScreenBase::ProcessControllerInput(const CFinalInput& input) +{ + x198_25_handledInput = false; + x8_frame.ProcessUserInput(input); +} + +void CPauseScreenBase::Draw(float mainAlpha, float frameAlpha, float yOff) +{ + zeus::CColor color = zeus::CColor::skWhite; + color.a = mainAlpha * x14_alpha; + x60_basewidget_pivot->SetColor(color); + color.a = frameAlpha; + x64_basewidget_bgframe->SetColor(color); + + CGuiWidgetDrawParms parms(1.f, zeus::CVector3f{0.f, 15.f * yOff, 0.f}); + x8_frame.Draw(parms); +} + +void CPauseScreenBase::UpdateRightTable() +{ + +} + static const char* PaneSuffixes[] = { "0", diff --git a/Runtime/MP1/CPauseScreenBase.hpp b/Runtime/MP1/CPauseScreenBase.hpp index 46019324a..da8c86a49 100644 --- a/Runtime/MP1/CPauseScreenBase.hpp +++ b/Runtime/MP1/CPauseScreenBase.hpp @@ -15,16 +15,28 @@ class CGuiTextPane; class CGuiSliderGroup; class CAuiImagePane; class CStringTable; +class CRandom16; +class CArchitectureQueue; + namespace MP1 { class CPauseScreenBase { +public: + enum class EMode + { + Invalid = -1, + Zero = 0, + One = 1, + Two = 2 + }; +private: const CStateManager& x4_mgr; - const CGuiFrame& x8_frame; + CGuiFrame& x8_frame; const CStringTable& xc_pauseStrg; - ResId x10_ = -1; - float x14_ = 0.f; + EMode x10_mode = EMode::Invalid; + float x14_alpha = 0.f; u32 x18_ = 0; u32 x1c_ = 0; zeus::CVector3f x20_; @@ -70,19 +82,41 @@ class CPauseScreenBase { struct { - bool x198_24_ : 1; - bool x198_25_ : 1; - bool x198_26_ : 1; - bool x198_27_ : 1; - bool x198_28_ : 1; - bool x198_29_ : 1; + bool x198_24_ready : 1; + bool x198_25_handledInput : 1; + bool x198_26_exitPauseScreen : 1; + bool x198_27_canDraw : 1; + bool x198_28_pulseTextArrowTop : 1; + bool x198_29_pulseTextArrowBottom : 1; }; u32 _dummy = 0; }; void InitializeFrameGlue(); static std::string GetImagePaneName(u32 i); +protected: + void Activate(EMode mode); + void UpdateSideTable(CGuiTableGroup* table); public: - CPauseScreenBase(const CStateManager& mgr, const CGuiFrame& frame, const CStringTable& pauseStrg); + CPauseScreenBase(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg); + + bool ShouldExitPauseScreen() const { return x198_26_exitPauseScreen; } + bool IsReady(); + bool CanDraw() const { return x198_27_canDraw; } + EMode GetMode() const { return x10_mode; } + float GetAlpha() const { return x14_alpha; } + + virtual ~CPauseScreenBase() = default; + virtual bool InputDisabled() const { return false; } + virtual void TransitioningAway() {} + virtual void Update(float dt, CRandom16& rand, CArchitectureQueue& archQueue); + virtual void Touch() {} + virtual void ProcessControllerInput(const CFinalInput& input); + virtual void Draw(float transInterp, float totalAlpha, float yOff); + virtual float GetCameraYBias() const { return 0.f; } + virtual bool VReady() const=0; + virtual void VActivate() const=0; + virtual void UpdateRightTable(); + virtual u32 GetRightTableCount() const=0; }; } diff --git a/Runtime/MP1/CPauseScreenBlur.cpp b/Runtime/MP1/CPauseScreenBlur.cpp index e69de29bb..19ffdd11c 100644 --- a/Runtime/MP1/CPauseScreenBlur.cpp +++ b/Runtime/MP1/CPauseScreenBlur.cpp @@ -0,0 +1,24 @@ +#include "CPauseScreenBlur.hpp" + +namespace urde +{ +namespace MP1 +{ + +CPauseScreenBlur::CPauseScreenBlur() +{ + +} + +bool CPauseScreenBlur::CheckLoadComplete() +{ + return false; +} + +void CPauseScreenBlur::OnNewInGameGuiState(EInGameGuiState state, CStateManager& stateMgr) +{ + +} + +} +}