metaforce/Runtime/MP1/CMainFlow.cpp

117 lines
3.4 KiB
C++
Raw Normal View History

2015-08-27 00:23:46 +00:00
#include "CMainFlow.hpp"
#include "MP1.hpp"
2015-08-27 00:23:46 +00:00
#include "CArchitectureQueue.hpp"
#include "CMFGame.hpp"
#include "CPlayMovie.hpp"
#include "CResFactory.hpp"
#include "CFrontEndUI.hpp"
#include "GameGlobalObjects.hpp"
2016-08-23 03:12:50 +00:00
#include "Character/CCharLayoutInfo.hpp"
2017-02-12 03:17:18 +00:00
#include "CSaveGameScreen.hpp"
#include "CCredits.hpp"
#include "CPreFrontEnd.hpp"
#include "CStateSetterFlow.hpp"
#include "CNESEmulator.hpp"
2017-02-12 03:17:18 +00:00
#include "CQuitGameScreen.hpp"
2015-08-27 00:23:46 +00:00
2016-03-04 23:04:53 +00:00
namespace urde
2015-08-27 00:23:46 +00:00
{
namespace MP1
{
2015-08-27 00:27:32 +00:00
void CMainFlow::AdvanceGameState(CArchitectureQueue& queue)
{
switch (x14_gameState)
{
case EClientFlowStates::Game:
2017-02-18 02:19:50 +00:00
SetGameState(EClientFlowStates::GameExit, queue);
break;
case EClientFlowStates::PreFrontEnd:
2017-02-18 02:19:50 +00:00
SetGameState(EClientFlowStates::FrontEnd, queue);
2016-09-16 20:18:03 +00:00
break;
2015-11-21 01:16:07 +00:00
case EClientFlowStates::FrontEnd:
2017-02-18 02:19:50 +00:00
SetGameState(EClientFlowStates::Game, queue);
2015-08-27 00:27:32 +00:00
break;
case EClientFlowStates::GameExit:
{
MP1::CMain* main = static_cast<MP1::CMain*>(g_Main);
if (main->GetFlowState() != EFlowState::None &&
main->GetFlowState() != EFlowState::StateSetter)
main->SetX30(true);
}
case EClientFlowStates::Unspecified:
2017-02-18 02:19:50 +00:00
SetGameState(EClientFlowStates::PreFrontEnd, queue);
2015-08-27 00:27:32 +00:00
break;
}
}
2015-08-27 00:23:46 +00:00
void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
{
x14_gameState = state;
MP1::CMain* main = static_cast<MP1::CMain*>(g_Main);
2015-08-27 00:23:46 +00:00
switch (state)
{
case EClientFlowStates::GameExit:
2015-08-27 00:23:46 +00:00
{
switch (main->GetFlowState())
2015-08-27 00:23:46 +00:00
{
case EFlowState::WinBad:
case EFlowState::WinGood:
case EFlowState::WinBest:
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11,
std::make_shared<CCredits>()));
2015-08-27 00:23:46 +00:00
break;
case EFlowState::LoseGame:
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
}
break;
}
case EClientFlowStates::PreFrontEnd:
2015-08-27 00:23:46 +00:00
{
if (main->GetFlowState() == EFlowState::None)
return;
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11,
std::make_shared<CPreFrontEnd>()));
2015-08-27 00:23:46 +00:00
break;
}
case EClientFlowStates::FrontEnd:
2015-08-27 00:23:46 +00:00
{
std::shared_ptr<CIOWin> nextIOWin;
switch (main->GetFlowState())
2015-08-27 00:23:46 +00:00
{
case EFlowState::StateSetter:
nextIOWin = std::make_shared<CStateSetterFlow>();
2015-08-27 00:23:46 +00:00
break;
case EFlowState::WinBad:
case EFlowState::WinGood:
case EFlowState::WinBest:
case EFlowState::LoseGame:
case EFlowState::Default:
nextIOWin = std::make_shared<CFrontEndUI>();
2015-08-27 00:23:46 +00:00
break;
default: return;
2015-08-27 00:23:46 +00:00
}
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::move(nextIOWin)));
break;
}
case EClientFlowStates::Game:
{
g_GameState->GameOptions().EnsureSettings();
main->SetFlowState(EFlowState::Default);
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 10, 1000,
std::make_shared<CMFGameLoader>()));
2015-08-27 00:23:46 +00:00
break;
}
default: break;
}
}
}
}