2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/MP1/CMainFlow.hpp"
|
|
|
|
|
|
|
|
#include "NESEmulator/CNESEmulator.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CArchitectureQueue.hpp"
|
|
|
|
#include "Runtime/CResFactory.hpp"
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/Character/CCharLayoutInfo.hpp"
|
|
|
|
#include "Runtime/MP1/CCredits.hpp"
|
|
|
|
#include "Runtime/MP1/CFrontEndUI.hpp"
|
|
|
|
#include "Runtime/MP1/CMFGame.hpp"
|
|
|
|
#include "Runtime/MP1/CPlayMovie.hpp"
|
|
|
|
#include "Runtime/MP1/CPreFrontEnd.hpp"
|
|
|
|
#include "Runtime/MP1/CQuitGameScreen.hpp"
|
|
|
|
#include "Runtime/MP1/CSaveGameScreen.hpp"
|
|
|
|
#include "Runtime/MP1/CStateSetterFlow.hpp"
|
|
|
|
#include "Runtime/MP1/MP1.hpp"
|
2015-08-27 00:23:46 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce::MP1 {
|
2015-08-27 00:23:46 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CMainFlow::AdvanceGameState(CArchitectureQueue& queue) {
|
|
|
|
switch (x14_gameState) {
|
|
|
|
case EClientFlowStates::Game:
|
|
|
|
SetGameState(EClientFlowStates::GameExit, queue);
|
|
|
|
break;
|
|
|
|
case EClientFlowStates::PreFrontEnd:
|
|
|
|
SetGameState(EClientFlowStates::FrontEnd, queue);
|
|
|
|
break;
|
|
|
|
case EClientFlowStates::FrontEnd:
|
|
|
|
SetGameState(EClientFlowStates::Game, queue);
|
|
|
|
break;
|
|
|
|
case EClientFlowStates::GameExit: {
|
|
|
|
MP1::CMain* main = static_cast<MP1::CMain*>(g_Main);
|
2021-06-03 23:47:04 +00:00
|
|
|
if (main->GetFlowState() != EClientFlowStates::None && main->GetFlowState() != EClientFlowStates::StateSetter)
|
2018-12-08 05:30:43 +00:00
|
|
|
main->SetX30(true);
|
2019-02-18 05:47:46 +00:00
|
|
|
[[fallthrough]];
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
case EClientFlowStates::Unspecified:
|
|
|
|
SetGameState(EClientFlowStates::PreFrontEnd, queue);
|
|
|
|
break;
|
2021-06-03 23:47:04 +00:00
|
|
|
default:
|
|
|
|
break;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2015-08-27 00:27:32 +00:00
|
|
|
}
|
2015-08-27 00:23:46 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue) {
|
|
|
|
x14_gameState = state;
|
|
|
|
MP1::CMain* main = static_cast<MP1::CMain*>(g_Main);
|
2017-01-17 01:23:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (state) {
|
|
|
|
case EClientFlowStates::GameExit: {
|
|
|
|
switch (main->GetFlowState()) {
|
2021-06-03 23:47:04 +00:00
|
|
|
case EClientFlowStates::WinBad:
|
|
|
|
case EClientFlowStates::WinGood:
|
|
|
|
case EClientFlowStates::WinBest:
|
2018-12-08 05:30:43 +00:00
|
|
|
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared<CCredits>()));
|
|
|
|
break;
|
2021-06-03 23:47:04 +00:00
|
|
|
case EClientFlowStates::LoseGame:
|
2018-12-08 05:30:43 +00:00
|
|
|
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11,
|
|
|
|
std::make_shared<CPlayMovie>(CPlayMovie::EWhichMovie::LoseGame)));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2015-08-27 00:23:46 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EClientFlowStates::PreFrontEnd: {
|
2021-06-03 23:47:04 +00:00
|
|
|
if (main->GetFlowState() == EClientFlowStates::None)
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
|
|
|
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared<CPreFrontEnd>()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EClientFlowStates::FrontEnd: {
|
|
|
|
std::shared_ptr<CIOWin> nextIOWin;
|
|
|
|
switch (main->GetFlowState()) {
|
2021-06-03 23:47:04 +00:00
|
|
|
case EClientFlowStates::StateSetter:
|
2018-12-08 05:30:43 +00:00
|
|
|
nextIOWin = std::make_shared<CStateSetterFlow>();
|
|
|
|
break;
|
2021-06-03 23:47:04 +00:00
|
|
|
case EClientFlowStates::WinBad:
|
|
|
|
case EClientFlowStates::WinGood:
|
|
|
|
case EClientFlowStates::WinBest:
|
|
|
|
case EClientFlowStates::LoseGame:
|
|
|
|
case EClientFlowStates::Default:
|
2018-12-08 05:30:43 +00:00
|
|
|
nextIOWin = std::make_shared<CFrontEndUI>();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
2015-08-27 00:23:46 +00:00
|
|
|
}
|
2017-01-17 01:23:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::move(nextIOWin)));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EClientFlowStates::Game: {
|
|
|
|
g_GameState->GameOptions().EnsureSettings();
|
2020-03-17 23:14:25 +00:00
|
|
|
auto gameLoader = std::make_shared<CMFGameLoader>();
|
2021-06-03 23:47:04 +00:00
|
|
|
main->SetFlowState(EClientFlowStates::Default);
|
2020-03-17 23:14:25 +00:00
|
|
|
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 10, 1000, std::move(gameLoader)));
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-08-27 00:23:46 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce::MP1
|