metaforce/Runtime/MP1/main.cpp

185 lines
4.4 KiB
C++
Raw Normal View History

2015-08-31 03:44:42 +00:00
#if _WIN32
#include <objbase.h>
#endif
#include <clocale>
2015-08-17 05:26:58 +00:00
#include <memory>
2015-08-18 22:51:54 +00:00
#include <boo/boo.hpp>
2015-08-17 05:26:58 +00:00
#include "CBasics.hpp"
#include "CMemoryCardSys.hpp"
2015-08-17 20:33:58 +00:00
#include "CResFactory.hpp"
#include "CSimplePool.hpp"
2015-08-17 23:46:41 +00:00
#include "Character/CAssetFactory.hpp"
#include "CAi.hpp"
#include "CGameState.hpp"
#include "CInGameTweakManager.hpp"
2015-08-18 05:54:43 +00:00
#include "Particle/CElementGen.hpp"
#include "Character/CAnimData.hpp"
#include "Particle/CDecalManager.hpp"
#include "Graphics/CBooRenderer.hpp"
#include "Audio/CAudioSys.hpp"
#include "Input/CInputGenerator.hpp"
#include "GuiSys/CGuiSys.hpp"
#include "CIOWinManager.hpp"
#include "GuiSys/CSplashScreen.hpp"
#include "CMainFlow.hpp"
#include "GuiSys/CConsoleOutputWindow.hpp"
#include "Audio/CAudioStateWin.hpp"
#include "GameGlobalObjects.hpp"
2015-08-22 01:58:41 +00:00
#include "CArchitectureQueue.hpp"
2015-08-27 00:23:46 +00:00
#include "CMain.hpp"
2015-08-17 05:26:58 +00:00
2015-08-29 01:30:47 +00:00
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp"
namespace Retro
2015-08-17 05:26:58 +00:00
{
2015-08-18 05:54:43 +00:00
CMemoryCardSys* g_MemoryCardSys = nullptr;
CResFactory* g_ResFactory = nullptr;
CSimplePool* g_SimplePool = nullptr;
CCharacterFactoryBuilder* g_CharFactoryBuilder = nullptr;
CAiFuncMap* g_AiFuncMap = nullptr;
CGameState* g_GameState = nullptr;
2015-08-27 00:23:46 +00:00
CInGameTweakManagerBase* g_TweakManager = nullptr;
2015-08-18 05:54:43 +00:00
CBooRenderer* g_Renderer = nullptr;
namespace MP1
{
2015-08-27 00:23:46 +00:00
class CMain* g_main = nullptr;
2015-08-18 05:54:43 +00:00
class CGameGlobalObjects
{
2015-08-18 22:51:54 +00:00
CMemoryCardSys m_memoryCardSys;
CResFactory m_resFactory;
CSimplePool m_simplePool;
CCharacterFactoryBuilder m_charFactoryBuilder;
CAiFuncMap m_aiFuncMap;
CGameState m_gameState;
CInGameTweakManager m_tweakManager;
std::unique_ptr<CBooRenderer> m_renderer;
2015-08-18 05:54:43 +00:00
void AddPaksAndFactories()
{
}
void LoadStringTable()
{
}
2015-08-18 22:51:54 +00:00
static CBooRenderer*
2015-08-28 00:11:31 +00:00
AllocateRenderer(IObjectStore& store,
2015-08-18 22:51:54 +00:00
CMemorySys& memSys, CResFactory& resFactory)
2015-08-18 05:54:43 +00:00
{
2015-08-28 00:11:31 +00:00
g_Renderer = new CBooRenderer(store, memSys, resFactory);
2015-08-18 22:51:54 +00:00
return g_Renderer;
2015-08-18 05:54:43 +00:00
}
2015-08-17 23:46:41 +00:00
2015-08-17 05:26:58 +00:00
public:
2015-08-18 05:54:43 +00:00
CGameGlobalObjects()
: m_simplePool(m_resFactory)
{
2015-08-18 22:51:54 +00:00
g_MemoryCardSys = &m_memoryCardSys;
g_ResFactory = &m_resFactory;
g_SimplePool = &m_simplePool;
g_CharFactoryBuilder = &m_charFactoryBuilder;
g_AiFuncMap = &m_aiFuncMap;
g_GameState = &m_gameState;
g_TweakManager = &m_tweakManager;
2015-08-18 05:54:43 +00:00
}
2015-08-28 00:11:31 +00:00
void PostInitialize(CMemorySys& memSys)
2015-08-18 05:54:43 +00:00
{
AddPaksAndFactories();
LoadStringTable();
2015-08-28 00:11:31 +00:00
m_renderer.reset(AllocateRenderer(m_simplePool, memSys, m_resFactory));
2015-08-18 05:54:43 +00:00
}
};
class CGameArchitectureSupport
{
2015-08-20 02:52:07 +00:00
CArchitectureQueue m_archQueue;
2015-08-18 22:51:54 +00:00
CAudioSys m_audioSys;
CInputGenerator m_inputGenerator;
CGuiSys m_guiSys;
CIOWinManager m_ioWinManager;
CSplashScreen m_splashScreen;
CMainFlow m_mainFlow;
CConsoleOutputWindow m_consoleWindow;
CAudioStateWin m_audioStateWin;
2015-08-18 05:54:43 +00:00
public:
2015-08-28 00:11:31 +00:00
CGameArchitectureSupport()
2015-08-29 01:30:47 +00:00
: m_audioSys(0,0,0,0,0),
m_inputGenerator(g_tweakPlayer->GetLeftLogicalThreshold(),
g_tweakPlayer->GetRightLogicalThreshold())
2015-08-17 20:33:58 +00:00
{
}
2015-08-20 02:52:07 +00:00
bool Update()
{
bool finished = false;
return finished;
}
2015-08-17 05:26:58 +00:00
};
2015-08-27 00:23:46 +00:00
CMain::CMain()
2015-08-28 00:11:31 +00:00
: x6c_memSys(CMemorySys::GetGameAllocator())
2015-08-17 05:26:58 +00:00
{
2015-08-27 00:23:46 +00:00
g_main = this;
xe4_gameplayResult = GameplayResultPlaying;
}
void CMain::RegisterResourceTweaks()
{
}
void CMain::ResetGameState()
{
}
void CMain::InitializeSubsystems()
{
CElementGen::Initialize();
CAnimData::InitializeCache();
CDecalManager::Initialize();
}
void CMain::AddWorldPaks()
{
}
void CMain::FillInAssetIDs()
{
}
void CMain::LoadAudio()
{
}
2015-08-31 03:44:42 +00:00
int CMain::RsMain(int argc, const boo::SystemChar* argv[])
2015-08-27 00:23:46 +00:00
{
TOneStatic<CGameGlobalObjects> globalObjs;
InitializeSubsystems();
2015-08-28 00:11:31 +00:00
globalObjs->PostInitialize(x6c_memSys);
2015-08-27 00:23:46 +00:00
x70_tweaks.RegisterTweaks();
AddWorldPaks();
g_TweakManager->ReadFromMemoryCard("AudioTweaks");
FillInAssetIDs();
2015-08-28 00:11:31 +00:00
TOneStatic<CGameArchitectureSupport> archSupport;
2015-08-27 00:23:46 +00:00
while (!xe8_finished)
2015-08-17 05:26:58 +00:00
{
2015-08-27 00:23:46 +00:00
xe8_finished = archSupport->Update();
2015-08-17 05:26:58 +00:00
}
2015-08-27 00:23:46 +00:00
return 0;
}
2015-08-17 05:26:58 +00:00
}
}
2015-08-31 03:44:42 +00:00
#ifdef _WIN32
int wmain(int argc, const wchar_t* argv[])
#else
2015-08-17 05:26:58 +00:00
int main(int argc, const char* argv[])
2015-08-31 03:44:42 +00:00
#endif
2015-08-17 05:26:58 +00:00
{
2015-08-31 03:44:42 +00:00
#if _WIN32
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
#else
std::setlocale(LC_ALL, "en-US.UTF-8");
#endif
2015-08-28 00:11:31 +00:00
Retro::TOneStatic<Retro::MP1::CMain> main;
2015-08-18 22:51:54 +00:00
std::unique_ptr<boo::IApplication> app =
2015-08-28 00:11:31 +00:00
boo::ApplicationBootstrap(boo::IApplication::PLAT_AUTO, *main,
2015-08-31 03:44:42 +00:00
_S("mp1"), _S("MP1"), argc, argv);
2015-08-18 23:30:23 +00:00
return main->RsMain(argc, argv);
2015-08-17 05:26:58 +00:00
}