From 99d363d5df98e3819bc5884189750868ca7f4aef Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 3 Jun 2021 16:47:04 -0700 Subject: [PATCH] Finish initial CCredits implementation, merge EFlowStates with EClientFlowStates --- Runtime/CMainFlowBase.hpp | 15 ++++++++++++- Runtime/IMain.hpp | 15 +++---------- Runtime/ImGuiConsole.cpp | 2 +- Runtime/MP1/CAudioStateWin.cpp | 2 +- Runtime/MP1/CCredits.cpp | 2 +- Runtime/MP1/CMFGame.cpp | 6 ++--- Runtime/MP1/CMainFlow.cpp | 28 +++++++++++++----------- Runtime/MP1/MP1.cpp | 8 ++----- Runtime/MP1/MP1.hpp | 6 ++--- Runtime/World/CScriptSpecialFunction.cpp | 6 ++--- Runtime/World/CScriptWorldTeleporter.cpp | 2 +- Runtime/World/CWorld.cpp | 7 +++--- 12 files changed, 50 insertions(+), 49 deletions(-) diff --git a/Runtime/CMainFlowBase.hpp b/Runtime/CMainFlowBase.hpp index af874f924..3a7fdb59b 100644 --- a/Runtime/CMainFlowBase.hpp +++ b/Runtime/CMainFlowBase.hpp @@ -4,7 +4,20 @@ namespace metaforce { -enum class EClientFlowStates { Unspecified = -1, PreFrontEnd = 7, FrontEnd = 8, Game = 14, GameExit = 15 }; +enum class EClientFlowStates { + Unspecified = -1, + None = 0, + WinBad = 1, + WinGood = 2, + WinBest = 3, + LoseGame = 4, + Default = 5, + StateSetter = 6, + PreFrontEnd = 7, + FrontEnd = 8, + Game = 14, + GameExit = 15 +}; class CMainFlowBase : public CIOWin { protected: diff --git a/Runtime/IMain.hpp b/Runtime/IMain.hpp index c44456667..a4e5a2feb 100644 --- a/Runtime/IMain.hpp +++ b/Runtime/IMain.hpp @@ -7,6 +7,7 @@ #include #include #include "DataSpec/DNACommon/MetaforceVersionInfo.hpp" +#include "Runtime/CMainFlowBase.hpp" namespace hecl { class Console; @@ -20,16 +21,6 @@ using EGame = DataSpec::EGame; class CStopwatch; enum class EGameplayResult { None, Win, Lose, Playing }; -enum class EFlowState { - None, - WinBad, - WinGood, - WinBest, - LoseGame, - Default, - StateSetter, -}; - class IMain { public: virtual ~IMain() = default; @@ -39,8 +30,8 @@ public: virtual bool Proc(float dt) = 0; virtual void Shutdown() = 0; virtual boo::IWindow* GetMainWindow() const = 0; - virtual EFlowState GetFlowState() const = 0; - virtual void SetFlowState(EFlowState) = 0; + virtual EClientFlowStates GetFlowState() const = 0; + virtual void SetFlowState(EClientFlowStates) = 0; virtual size_t GetExpectedIdSize() const = 0; virtual void WarmupShaders() = 0; virtual hecl::Console* Console() const = 0; diff --git a/Runtime/ImGuiConsole.cpp b/Runtime/ImGuiConsole.cpp index e28796453..8d520c037 100644 --- a/Runtime/ImGuiConsole.cpp +++ b/Runtime/ImGuiConsole.cpp @@ -100,7 +100,7 @@ static void Warp(const CAssetId worldId, TAreaId aId) { aId = 0; } g_GameState->CurrentWorldState().SetAreaId(aId); - g_Main->SetFlowState(EFlowState::None); + g_Main->SetFlowState(EClientFlowStates::None); if (g_StateManager != nullptr) { g_StateManager->SetWarping(true); g_StateManager->SetShouldQuitGame(true); diff --git a/Runtime/MP1/CAudioStateWin.cpp b/Runtime/MP1/CAudioStateWin.cpp index fb18e3fd1..f8c2d1530 100644 --- a/Runtime/MP1/CAudioStateWin.cpp +++ b/Runtime/MP1/CAudioStateWin.cpp @@ -18,7 +18,7 @@ CIOWin::EMessageReturn CAudioStateWin::OnMessage(const CArchitectureMessage& msg CSfxManager::TurnOnChannel(CSfxManager::ESfxChannels::Game); } else if (msgType == EArchMsgType::QuitGameplay) { if (g_GameState->GetWorldTransitionManager()->GetTransType() == CWorldTransManager::ETransType::Disabled || - m->GetFlowState() != EFlowState::None) { + m->GetFlowState() != EClientFlowStates::None) { CSfxManager::SetChannel(CSfxManager::ESfxChannels::Default); CSfxManager::KillAll(CSfxManager::ESfxChannels::Game); } diff --git a/Runtime/MP1/CCredits.cpp b/Runtime/MP1/CCredits.cpp index 123b5f84f..b5207f13d 100644 --- a/Runtime/MP1/CCredits.cpp +++ b/Runtime/MP1/CCredits.cpp @@ -148,7 +148,7 @@ CIOWin::EMessageReturn CCredits::Update(float dt, CArchitectureQueue& queue) { x5c_27_ = false; x58_ = 0.f; } else if (x5c_28_) { - x5c_28_ = true; + x5c_25_ = true; } } diff --git a/Runtime/MP1/CMFGame.cpp b/Runtime/MP1/CMFGame.cpp index 4f8751872..a690ad0d7 100644 --- a/Runtime/MP1/CMFGame.cpp +++ b/Runtime/MP1/CMFGame.cpp @@ -100,7 +100,7 @@ CIOWin::EMessageReturn CMFGame::OnMessage(const CArchitectureMessage& msg, CArch } case EGameFlowState::SamusDied: { if (x14_stateManager->GetPlayer().IsPlayerDeadEnough()) { - static_cast(*g_Main).SetFlowState(EFlowState::LoseGame); + static_cast(*g_Main).SetFlowState(EClientFlowStates::LoseGame); queue.Push(MakeMsg::CreateQuitGameplay(EArchMsgTarget::Game)); } else { x14_stateManager->SetActiveRandomToDefault(); @@ -259,8 +259,8 @@ void CMFGame::EnterMapScreen() { CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader") { auto* m = static_cast(g_Main); switch (m->GetFlowState()) { - case EFlowState::Default: - case EFlowState::StateSetter: { + case EClientFlowStates::Default: + case EClientFlowStates::StateSetter: { CAssetId mlvlId = g_GameState->CurrentWorldAssetId(); if (g_MemoryCardSys->HasSaveWorldMemory(mlvlId)) { const CSaveWorldMemory& savwMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId); diff --git a/Runtime/MP1/CMainFlow.cpp b/Runtime/MP1/CMainFlow.cpp index 19643012a..450710a80 100644 --- a/Runtime/MP1/CMainFlow.cpp +++ b/Runtime/MP1/CMainFlow.cpp @@ -31,13 +31,15 @@ void CMainFlow::AdvanceGameState(CArchitectureQueue& queue) { break; case EClientFlowStates::GameExit: { MP1::CMain* main = static_cast(g_Main); - if (main->GetFlowState() != EFlowState::None && main->GetFlowState() != EFlowState::StateSetter) + if (main->GetFlowState() != EClientFlowStates::None && main->GetFlowState() != EClientFlowStates::StateSetter) main->SetX30(true); [[fallthrough]]; } case EClientFlowStates::Unspecified: SetGameState(EClientFlowStates::PreFrontEnd, queue); break; + default: + break; } } @@ -48,12 +50,12 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue) switch (state) { case EClientFlowStates::GameExit: { switch (main->GetFlowState()) { - case EFlowState::WinBad: - case EFlowState::WinGood: - case EFlowState::WinBest: + case EClientFlowStates::WinBad: + case EClientFlowStates::WinGood: + case EClientFlowStates::WinBest: queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared())); break; - case EFlowState::LoseGame: + case EClientFlowStates::LoseGame: queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared(CPlayMovie::EWhichMovie::LoseGame))); break; @@ -63,7 +65,7 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue) break; } case EClientFlowStates::PreFrontEnd: { - if (main->GetFlowState() == EFlowState::None) + if (main->GetFlowState() == EClientFlowStates::None) return; queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared())); break; @@ -71,14 +73,14 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue) case EClientFlowStates::FrontEnd: { std::shared_ptr nextIOWin; switch (main->GetFlowState()) { - case EFlowState::StateSetter: + case EClientFlowStates::StateSetter: nextIOWin = std::make_shared(); break; - case EFlowState::WinBad: - case EFlowState::WinGood: - case EFlowState::WinBest: - case EFlowState::LoseGame: - case EFlowState::Default: + case EClientFlowStates::WinBad: + case EClientFlowStates::WinGood: + case EClientFlowStates::WinBest: + case EClientFlowStates::LoseGame: + case EClientFlowStates::Default: nextIOWin = std::make_shared(); break; default: @@ -91,7 +93,7 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue) case EClientFlowStates::Game: { g_GameState->GameOptions().EnsureSettings(); auto gameLoader = std::make_shared(); - main->SetFlowState(EFlowState::Default); + main->SetFlowState(EClientFlowStates::Default); queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 10, 1000, std::move(gameLoader))); break; } diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 58e87b29a..b829043bd 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -109,9 +109,6 @@ CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoi CStreamAudioManager::SetMusicVolume(0x7f); m->ResetGameState(); - std::shared_ptr credits = std::make_shared(); - x58_ioWinManager.AddIOWin(credits, 1000, 10000); -/* if (!g_tweakGame->GetSplashScreensDisabled()) { std::shared_ptr splash = std::make_shared(CSplashScreen::ESplashScreen::Nintendo); x58_ioWinManager.AddIOWin(splash, 1000, 10000); @@ -131,7 +128,6 @@ CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoi g_GuiSys = &x44_guiSys; g_GameState->GameOptions().EnsureSettings(); - */ } void CGameArchitectureSupport::UpdateTicks(float dt) { @@ -643,7 +639,7 @@ void CMain::Warp(hecl::Console* con, const std::vector& args) { } g_GameState->CurrentWorldState().SetAreaId(aId); - g_Main->SetFlowState(EFlowState::None); + g_Main->SetFlowState(EClientFlowStates::None); g_StateManager->SetWarping(true); g_StateManager->SetShouldQuitGame(true); } @@ -855,7 +851,7 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana ++it; } - SetFlowState(EFlowState::StateSetter); + SetFlowState(EClientFlowStates::StateSetter); break; } } diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index b813d0aea..c9049617a 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -219,7 +219,7 @@ private: float x120_; float x124_; std::unique_ptr x128_globalObjects; - EFlowState x12c_flowState = EFlowState::Default; + EClientFlowStates x12c_flowState = EClientFlowStates::Default; rstl::reserved_vector x130_{{ 1000000, 1000000, @@ -307,8 +307,8 @@ public: static void EnsureWorldPaksReady(); static void EnsureWorldPakReady(CAssetId mlvl); - EFlowState GetFlowState() const override { return x12c_flowState; } - void SetFlowState(EFlowState s) override { x12c_flowState = s; } + EClientFlowStates GetFlowState() const override { return x12c_flowState; } + void SetFlowState(EClientFlowStates s) override { x12c_flowState = s; } void SetX30(bool v) { x160_30_ = v; } diff --git a/Runtime/World/CScriptSpecialFunction.cpp b/Runtime/World/CScriptSpecialFunction.cpp index a967ac74f..2f06d9595 100644 --- a/Runtime/World/CScriptSpecialFunction.cpp +++ b/Runtime/World/CScriptSpecialFunction.cpp @@ -317,13 +317,13 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId if (msg == EScriptObjectMessage::Action) { switch (GetSpecialEnding(mgr)) { case 0: - g_Main->SetFlowState(EFlowState::WinBad); + g_Main->SetFlowState(EClientFlowStates::WinBad); break; case 1: - g_Main->SetFlowState(EFlowState::WinGood); + g_Main->SetFlowState(EClientFlowStates::WinGood); break; case 2: - g_Main->SetFlowState(EFlowState::WinBest); + g_Main->SetFlowState(EClientFlowStates::WinBest); break; } mgr.SetShouldQuitGame(true); diff --git a/Runtime/World/CScriptWorldTeleporter.cpp b/Runtime/World/CScriptWorldTeleporter.cpp index 08914c9a4..c27fda842 100644 --- a/Runtime/World/CScriptWorldTeleporter.cpp +++ b/Runtime/World/CScriptWorldTeleporter.cpp @@ -80,7 +80,7 @@ void CScriptWorldTeleporter::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId StartTransition(mgr); g_GameState->SetCurrentWorldId(x34_worldId); g_GameState->CurrentWorldState().SetDesiredAreaAssetId(x38_areaId); - g_Main->SetFlowState(EFlowState::None); + g_Main->SetFlowState(EClientFlowStates::None); mgr.SetShouldQuitGame(true); } else { x40_25_inTransition = false; diff --git a/Runtime/World/CWorld.cpp b/Runtime/World/CWorld.cpp index b792968f7..f22b98010 100644 --- a/Runtime/World/CWorld.cpp +++ b/Runtime/World/CWorld.cpp @@ -193,9 +193,7 @@ int CDummyWorld::IGetAreaCount() const { return x18_areas.size(); } const std::optional& CDummyWorld::GetWorldLayers() const { return m_worldLayers; } CWorld::CWorld(IObjectStore& objStore, IFactory& resFactory, CAssetId mlvlId) -: x8_mlvlId(mlvlId) -, x60_objectStore(objStore) -, x64_resFactory(resFactory) { +: x8_mlvlId(mlvlId), x60_objectStore(objStore), x64_resFactory(resFactory) { SObjectTag tag{FOURCC('MLVL'), mlvlId}; x44_bufSz = resFactory.ResourceSize(tag); x40_loadBuf.reset(new u8[x44_bufSz]); @@ -204,7 +202,8 @@ CWorld::CWorld(IObjectStore& objStore, IFactory& resFactory, CAssetId mlvlId) CWorld::~CWorld() { StopSounds(); - if (g_GameState->GetWorldTransitionManager()->IsTransitionEnabled() && g_Main->GetFlowState() == EFlowState::None) + if (g_GameState->GetWorldTransitionManager()->IsTransitionEnabled() && + g_Main->GetFlowState() == EClientFlowStates::None) CStreamAudioManager::StopOneShot(); else CStreamAudioManager::StopAll();