Finish initial CCredits implementation, merge EFlowStates with EClientFlowStates

This commit is contained in:
Phillip Stephens 2021-06-03 16:47:04 -07:00
parent 665dc5fd51
commit 99d363d5df
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
12 changed files with 50 additions and 49 deletions

View File

@ -4,7 +4,20 @@
namespace metaforce { 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 { class CMainFlowBase : public CIOWin {
protected: protected:

View File

@ -7,6 +7,7 @@
#include <boo/audiodev/IAudioVoiceEngine.hpp> #include <boo/audiodev/IAudioVoiceEngine.hpp>
#include <hecl/Runtime.hpp> #include <hecl/Runtime.hpp>
#include "DataSpec/DNACommon/MetaforceVersionInfo.hpp" #include "DataSpec/DNACommon/MetaforceVersionInfo.hpp"
#include "Runtime/CMainFlowBase.hpp"
namespace hecl { namespace hecl {
class Console; class Console;
@ -20,16 +21,6 @@ using EGame = DataSpec::EGame;
class CStopwatch; class CStopwatch;
enum class EGameplayResult { None, Win, Lose, Playing }; enum class EGameplayResult { None, Win, Lose, Playing };
enum class EFlowState {
None,
WinBad,
WinGood,
WinBest,
LoseGame,
Default,
StateSetter,
};
class IMain { class IMain {
public: public:
virtual ~IMain() = default; virtual ~IMain() = default;
@ -39,8 +30,8 @@ public:
virtual bool Proc(float dt) = 0; virtual bool Proc(float dt) = 0;
virtual void Shutdown() = 0; virtual void Shutdown() = 0;
virtual boo::IWindow* GetMainWindow() const = 0; virtual boo::IWindow* GetMainWindow() const = 0;
virtual EFlowState GetFlowState() const = 0; virtual EClientFlowStates GetFlowState() const = 0;
virtual void SetFlowState(EFlowState) = 0; virtual void SetFlowState(EClientFlowStates) = 0;
virtual size_t GetExpectedIdSize() const = 0; virtual size_t GetExpectedIdSize() const = 0;
virtual void WarmupShaders() = 0; virtual void WarmupShaders() = 0;
virtual hecl::Console* Console() const = 0; virtual hecl::Console* Console() const = 0;

View File

@ -100,7 +100,7 @@ static void Warp(const CAssetId worldId, TAreaId aId) {
aId = 0; aId = 0;
} }
g_GameState->CurrentWorldState().SetAreaId(aId); g_GameState->CurrentWorldState().SetAreaId(aId);
g_Main->SetFlowState(EFlowState::None); g_Main->SetFlowState(EClientFlowStates::None);
if (g_StateManager != nullptr) { if (g_StateManager != nullptr) {
g_StateManager->SetWarping(true); g_StateManager->SetWarping(true);
g_StateManager->SetShouldQuitGame(true); g_StateManager->SetShouldQuitGame(true);

View File

@ -18,7 +18,7 @@ CIOWin::EMessageReturn CAudioStateWin::OnMessage(const CArchitectureMessage& msg
CSfxManager::TurnOnChannel(CSfxManager::ESfxChannels::Game); CSfxManager::TurnOnChannel(CSfxManager::ESfxChannels::Game);
} else if (msgType == EArchMsgType::QuitGameplay) { } else if (msgType == EArchMsgType::QuitGameplay) {
if (g_GameState->GetWorldTransitionManager()->GetTransType() == CWorldTransManager::ETransType::Disabled || if (g_GameState->GetWorldTransitionManager()->GetTransType() == CWorldTransManager::ETransType::Disabled ||
m->GetFlowState() != EFlowState::None) { m->GetFlowState() != EClientFlowStates::None) {
CSfxManager::SetChannel(CSfxManager::ESfxChannels::Default); CSfxManager::SetChannel(CSfxManager::ESfxChannels::Default);
CSfxManager::KillAll(CSfxManager::ESfxChannels::Game); CSfxManager::KillAll(CSfxManager::ESfxChannels::Game);
} }

View File

@ -148,7 +148,7 @@ CIOWin::EMessageReturn CCredits::Update(float dt, CArchitectureQueue& queue) {
x5c_27_ = false; x5c_27_ = false;
x58_ = 0.f; x58_ = 0.f;
} else if (x5c_28_) { } else if (x5c_28_) {
x5c_28_ = true; x5c_25_ = true;
} }
} }

View File

@ -100,7 +100,7 @@ CIOWin::EMessageReturn CMFGame::OnMessage(const CArchitectureMessage& msg, CArch
} }
case EGameFlowState::SamusDied: { case EGameFlowState::SamusDied: {
if (x14_stateManager->GetPlayer().IsPlayerDeadEnough()) { if (x14_stateManager->GetPlayer().IsPlayerDeadEnough()) {
static_cast<CMain&>(*g_Main).SetFlowState(EFlowState::LoseGame); static_cast<CMain&>(*g_Main).SetFlowState(EClientFlowStates::LoseGame);
queue.Push(MakeMsg::CreateQuitGameplay(EArchMsgTarget::Game)); queue.Push(MakeMsg::CreateQuitGameplay(EArchMsgTarget::Game));
} else { } else {
x14_stateManager->SetActiveRandomToDefault(); x14_stateManager->SetActiveRandomToDefault();
@ -259,8 +259,8 @@ void CMFGame::EnterMapScreen() {
CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader") { CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader") {
auto* m = static_cast<CMain*>(g_Main); auto* m = static_cast<CMain*>(g_Main);
switch (m->GetFlowState()) { switch (m->GetFlowState()) {
case EFlowState::Default: case EClientFlowStates::Default:
case EFlowState::StateSetter: { case EClientFlowStates::StateSetter: {
CAssetId mlvlId = g_GameState->CurrentWorldAssetId(); CAssetId mlvlId = g_GameState->CurrentWorldAssetId();
if (g_MemoryCardSys->HasSaveWorldMemory(mlvlId)) { if (g_MemoryCardSys->HasSaveWorldMemory(mlvlId)) {
const CSaveWorldMemory& savwMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId); const CSaveWorldMemory& savwMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId);

View File

@ -31,13 +31,15 @@ void CMainFlow::AdvanceGameState(CArchitectureQueue& queue) {
break; break;
case EClientFlowStates::GameExit: { case EClientFlowStates::GameExit: {
MP1::CMain* main = static_cast<MP1::CMain*>(g_Main); MP1::CMain* main = static_cast<MP1::CMain*>(g_Main);
if (main->GetFlowState() != EFlowState::None && main->GetFlowState() != EFlowState::StateSetter) if (main->GetFlowState() != EClientFlowStates::None && main->GetFlowState() != EClientFlowStates::StateSetter)
main->SetX30(true); main->SetX30(true);
[[fallthrough]]; [[fallthrough]];
} }
case EClientFlowStates::Unspecified: case EClientFlowStates::Unspecified:
SetGameState(EClientFlowStates::PreFrontEnd, queue); SetGameState(EClientFlowStates::PreFrontEnd, queue);
break; break;
default:
break;
} }
} }
@ -48,12 +50,12 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
switch (state) { switch (state) {
case EClientFlowStates::GameExit: { case EClientFlowStates::GameExit: {
switch (main->GetFlowState()) { switch (main->GetFlowState()) {
case EFlowState::WinBad: case EClientFlowStates::WinBad:
case EFlowState::WinGood: case EClientFlowStates::WinGood:
case EFlowState::WinBest: case EClientFlowStates::WinBest:
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared<CCredits>())); queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared<CCredits>()));
break; break;
case EFlowState::LoseGame: case EClientFlowStates::LoseGame:
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11,
std::make_shared<CPlayMovie>(CPlayMovie::EWhichMovie::LoseGame))); std::make_shared<CPlayMovie>(CPlayMovie::EWhichMovie::LoseGame)));
break; break;
@ -63,7 +65,7 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
break; break;
} }
case EClientFlowStates::PreFrontEnd: { case EClientFlowStates::PreFrontEnd: {
if (main->GetFlowState() == EFlowState::None) if (main->GetFlowState() == EClientFlowStates::None)
return; return;
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared<CPreFrontEnd>())); queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared<CPreFrontEnd>()));
break; break;
@ -71,14 +73,14 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
case EClientFlowStates::FrontEnd: { case EClientFlowStates::FrontEnd: {
std::shared_ptr<CIOWin> nextIOWin; std::shared_ptr<CIOWin> nextIOWin;
switch (main->GetFlowState()) { switch (main->GetFlowState()) {
case EFlowState::StateSetter: case EClientFlowStates::StateSetter:
nextIOWin = std::make_shared<CStateSetterFlow>(); nextIOWin = std::make_shared<CStateSetterFlow>();
break; break;
case EFlowState::WinBad: case EClientFlowStates::WinBad:
case EFlowState::WinGood: case EClientFlowStates::WinGood:
case EFlowState::WinBest: case EClientFlowStates::WinBest:
case EFlowState::LoseGame: case EClientFlowStates::LoseGame:
case EFlowState::Default: case EClientFlowStates::Default:
nextIOWin = std::make_shared<CFrontEndUI>(); nextIOWin = std::make_shared<CFrontEndUI>();
break; break;
default: default:
@ -91,7 +93,7 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
case EClientFlowStates::Game: { case EClientFlowStates::Game: {
g_GameState->GameOptions().EnsureSettings(); g_GameState->GameOptions().EnsureSettings();
auto gameLoader = std::make_shared<CMFGameLoader>(); auto gameLoader = std::make_shared<CMFGameLoader>();
main->SetFlowState(EFlowState::Default); main->SetFlowState(EClientFlowStates::Default);
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 10, 1000, std::move(gameLoader))); queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 10, 1000, std::move(gameLoader)));
break; break;
} }

View File

@ -109,9 +109,6 @@ CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoi
CStreamAudioManager::SetMusicVolume(0x7f); CStreamAudioManager::SetMusicVolume(0x7f);
m->ResetGameState(); m->ResetGameState();
std::shared_ptr<CIOWin> credits = std::make_shared<CCredits>();
x58_ioWinManager.AddIOWin(credits, 1000, 10000);
/*
if (!g_tweakGame->GetSplashScreensDisabled()) { if (!g_tweakGame->GetSplashScreensDisabled()) {
std::shared_ptr<CIOWin> splash = std::make_shared<CSplashScreen>(CSplashScreen::ESplashScreen::Nintendo); std::shared_ptr<CIOWin> splash = std::make_shared<CSplashScreen>(CSplashScreen::ESplashScreen::Nintendo);
x58_ioWinManager.AddIOWin(splash, 1000, 10000); x58_ioWinManager.AddIOWin(splash, 1000, 10000);
@ -131,7 +128,6 @@ CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoi
g_GuiSys = &x44_guiSys; g_GuiSys = &x44_guiSys;
g_GameState->GameOptions().EnsureSettings(); g_GameState->GameOptions().EnsureSettings();
*/
} }
void CGameArchitectureSupport::UpdateTicks(float dt) { void CGameArchitectureSupport::UpdateTicks(float dt) {
@ -643,7 +639,7 @@ void CMain::Warp(hecl::Console* con, const std::vector<std::string>& args) {
} }
g_GameState->CurrentWorldState().SetAreaId(aId); g_GameState->CurrentWorldState().SetAreaId(aId);
g_Main->SetFlowState(EFlowState::None); g_Main->SetFlowState(EClientFlowStates::None);
g_StateManager->SetWarping(true); g_StateManager->SetWarping(true);
g_StateManager->SetShouldQuitGame(true); g_StateManager->SetShouldQuitGame(true);
} }
@ -855,7 +851,7 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana
++it; ++it;
} }
SetFlowState(EFlowState::StateSetter); SetFlowState(EClientFlowStates::StateSetter);
break; break;
} }
} }

View File

@ -219,7 +219,7 @@ private:
float x120_; float x120_;
float x124_; float x124_;
std::unique_ptr<CGameGlobalObjects> x128_globalObjects; std::unique_ptr<CGameGlobalObjects> x128_globalObjects;
EFlowState x12c_flowState = EFlowState::Default; EClientFlowStates x12c_flowState = EClientFlowStates::Default;
rstl::reserved_vector<u32, 10> x130_{{ rstl::reserved_vector<u32, 10> x130_{{
1000000, 1000000,
1000000, 1000000,
@ -307,8 +307,8 @@ public:
static void EnsureWorldPaksReady(); static void EnsureWorldPaksReady();
static void EnsureWorldPakReady(CAssetId mlvl); static void EnsureWorldPakReady(CAssetId mlvl);
EFlowState GetFlowState() const override { return x12c_flowState; } EClientFlowStates GetFlowState() const override { return x12c_flowState; }
void SetFlowState(EFlowState s) override { x12c_flowState = s; } void SetFlowState(EClientFlowStates s) override { x12c_flowState = s; }
void SetX30(bool v) { x160_30_ = v; } void SetX30(bool v) { x160_30_ = v; }

View File

@ -317,13 +317,13 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
if (msg == EScriptObjectMessage::Action) { if (msg == EScriptObjectMessage::Action) {
switch (GetSpecialEnding(mgr)) { switch (GetSpecialEnding(mgr)) {
case 0: case 0:
g_Main->SetFlowState(EFlowState::WinBad); g_Main->SetFlowState(EClientFlowStates::WinBad);
break; break;
case 1: case 1:
g_Main->SetFlowState(EFlowState::WinGood); g_Main->SetFlowState(EClientFlowStates::WinGood);
break; break;
case 2: case 2:
g_Main->SetFlowState(EFlowState::WinBest); g_Main->SetFlowState(EClientFlowStates::WinBest);
break; break;
} }
mgr.SetShouldQuitGame(true); mgr.SetShouldQuitGame(true);

View File

@ -80,7 +80,7 @@ void CScriptWorldTeleporter::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
StartTransition(mgr); StartTransition(mgr);
g_GameState->SetCurrentWorldId(x34_worldId); g_GameState->SetCurrentWorldId(x34_worldId);
g_GameState->CurrentWorldState().SetDesiredAreaAssetId(x38_areaId); g_GameState->CurrentWorldState().SetDesiredAreaAssetId(x38_areaId);
g_Main->SetFlowState(EFlowState::None); g_Main->SetFlowState(EClientFlowStates::None);
mgr.SetShouldQuitGame(true); mgr.SetShouldQuitGame(true);
} else { } else {
x40_25_inTransition = false; x40_25_inTransition = false;

View File

@ -193,9 +193,7 @@ int CDummyWorld::IGetAreaCount() const { return x18_areas.size(); }
const std::optional<CWorldLayers>& CDummyWorld::GetWorldLayers() const { return m_worldLayers; } const std::optional<CWorldLayers>& CDummyWorld::GetWorldLayers() const { return m_worldLayers; }
CWorld::CWorld(IObjectStore& objStore, IFactory& resFactory, CAssetId mlvlId) CWorld::CWorld(IObjectStore& objStore, IFactory& resFactory, CAssetId mlvlId)
: x8_mlvlId(mlvlId) : x8_mlvlId(mlvlId), x60_objectStore(objStore), x64_resFactory(resFactory) {
, x60_objectStore(objStore)
, x64_resFactory(resFactory) {
SObjectTag tag{FOURCC('MLVL'), mlvlId}; SObjectTag tag{FOURCC('MLVL'), mlvlId};
x44_bufSz = resFactory.ResourceSize(tag); x44_bufSz = resFactory.ResourceSize(tag);
x40_loadBuf.reset(new u8[x44_bufSz]); x40_loadBuf.reset(new u8[x44_bufSz]);
@ -204,7 +202,8 @@ CWorld::CWorld(IObjectStore& objStore, IFactory& resFactory, CAssetId mlvlId)
CWorld::~CWorld() { CWorld::~CWorld() {
StopSounds(); StopSounds();
if (g_GameState->GetWorldTransitionManager()->IsTransitionEnabled() && g_Main->GetFlowState() == EFlowState::None) if (g_GameState->GetWorldTransitionManager()->IsTransitionEnabled() &&
g_Main->GetFlowState() == EClientFlowStates::None)
CStreamAudioManager::StopOneShot(); CStreamAudioManager::StopOneShot();
else else
CStreamAudioManager::StopAll(); CStreamAudioManager::StopAll();