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 {
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:

View File

@ -7,6 +7,7 @@
#include <boo/audiodev/IAudioVoiceEngine.hpp>
#include <hecl/Runtime.hpp>
#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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -100,7 +100,7 @@ CIOWin::EMessageReturn CMFGame::OnMessage(const CArchitectureMessage& msg, CArch
}
case EGameFlowState::SamusDied: {
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));
} else {
x14_stateManager->SetActiveRandomToDefault();
@ -259,8 +259,8 @@ void CMFGame::EnterMapScreen() {
CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader") {
auto* m = static_cast<CMain*>(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);

View File

@ -31,13 +31,15 @@ void CMainFlow::AdvanceGameState(CArchitectureQueue& queue) {
break;
case EClientFlowStates::GameExit: {
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);
[[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<CCredits>()));
break;
case EFlowState::LoseGame:
case EClientFlowStates::LoseGame:
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11,
std::make_shared<CPlayMovie>(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<CPreFrontEnd>()));
break;
@ -71,14 +73,14 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
case EClientFlowStates::FrontEnd: {
std::shared_ptr<CIOWin> nextIOWin;
switch (main->GetFlowState()) {
case EFlowState::StateSetter:
case EClientFlowStates::StateSetter:
nextIOWin = std::make_shared<CStateSetterFlow>();
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<CFrontEndUI>();
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<CMFGameLoader>();
main->SetFlowState(EFlowState::Default);
main->SetFlowState(EClientFlowStates::Default);
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 10, 1000, std::move(gameLoader)));
break;
}

View File

@ -109,9 +109,6 @@ CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoi
CStreamAudioManager::SetMusicVolume(0x7f);
m->ResetGameState();
std::shared_ptr<CIOWin> credits = std::make_shared<CCredits>();
x58_ioWinManager.AddIOWin(credits, 1000, 10000);
/*
if (!g_tweakGame->GetSplashScreensDisabled()) {
std::shared_ptr<CIOWin> splash = std::make_shared<CSplashScreen>(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<std::string>& 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;
}
}

View File

@ -219,7 +219,7 @@ private:
float x120_;
float x124_;
std::unique_ptr<CGameGlobalObjects> x128_globalObjects;
EFlowState x12c_flowState = EFlowState::Default;
EClientFlowStates x12c_flowState = EClientFlowStates::Default;
rstl::reserved_vector<u32, 10> 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; }

View File

@ -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);

View File

@ -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;

View File

@ -193,9 +193,7 @@ int CDummyWorld::IGetAreaCount() const { return x18_areas.size(); }
const std::optional<CWorldLayers>& 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();