metaforce/Runtime/MP1/main.cpp

156 lines
4.1 KiB
C++
Raw Normal View History

2015-08-17 05:26:58 +00:00
#include <memory>
#include "COsContext.hpp"
#include "CBasics.hpp"
#include "CTweaks.hpp"
2015-08-17 20:33:58 +00:00
#include "CMemory.hpp"
2015-08-17 05:26:58 +00:00
#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-17 05:26:58 +00:00
namespace Retro
2015-08-17 05:26:58 +00:00
{
2015-08-18 05:54:43 +00:00
namespace Common
{
CMemoryCardSys* g_MemoryCardSys = nullptr;
CResFactory* g_ResFactory = nullptr;
CSimplePool* g_SimplePool = nullptr;
CCharacterFactoryBuilder* g_CharFactoryBuilder = nullptr;
CAiFuncMap* g_AiFuncMap = nullptr;
CGameState* g_GameState = nullptr;
CInGameTweakManager* g_TweakManager = nullptr;
CBooRenderer* g_Renderer = nullptr;
}
namespace MP1
{
2015-08-18 05:54:43 +00:00
class CGameGlobalObjects
{
Common::CMemoryCardSys m_memoryCardSys;
Common::CResFactory m_resFactory;
Common::CSimplePool m_simplePool;
2015-08-17 23:46:41 +00:00
Common::CCharacterFactoryBuilder m_charFactoryBuilder;
Common::CAiFuncMap m_aiFuncMap;
Common::CGameState m_gameState;
Common::CInGameTweakManager m_tweakManager;
2015-08-18 05:54:43 +00:00
std::unique_ptr<Common::CBooRenderer> m_renderer;
void AddPaksAndFactories()
{
}
void LoadStringTable()
{
}
static Common::CBooRenderer*
AllocateRenderer(Common::IObjectStore& store, Common::COsContext& osctx,
Common::CMemorySys& memSys, Common::CResFactory& resFactory)
{
Common::g_Renderer = new Common::CBooRenderer(store, osctx, memSys, resFactory);
return Common::g_Renderer;
}
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)
{
Common::g_MemoryCardSys = &m_memoryCardSys;
Common::g_ResFactory = &m_resFactory;
Common::g_SimplePool = &m_simplePool;
Common::g_CharFactoryBuilder = &m_charFactoryBuilder;
Common::g_AiFuncMap = &m_aiFuncMap;
Common::g_GameState = &m_gameState;
Common::g_TweakManager = &m_tweakManager;
}
void PostInitialize(Common::COsContext& osctx, Common::CMemorySys& memSys)
2015-08-18 05:54:43 +00:00
{
AddPaksAndFactories();
LoadStringTable();
m_renderer.reset(AllocateRenderer(m_simplePool, osctx, memSys, m_resFactory));
}
};
class CGameArchitectureSupport
{
Common::CAudioSys m_audioSys;
Common::CInputGenerator m_inputGenerator;
Common::CGuiSys m_guiSys;
Common::CIOWinManager m_ioWinManager;
Common::CSplashScreen m_splashScreen;
Common::CMainFlow m_mainFlow;
Common::CConsoleOutputWindow m_consoleWindow;
Common::CAudioStateWin m_audioStateWin;
public:
CGameArchitectureSupport(Common::COsContext& osctx)
: m_audioSys(0,0,0,0,0)
2015-08-17 20:33:58 +00:00
{
}
2015-08-17 05:26:58 +00:00
};
class CMain : public Common::COsContext
2015-08-17 05:26:58 +00:00
{
Common::CMemorySys m_memSys;
Common::CTweaks m_tweaks;
2015-08-17 20:33:58 +00:00
bool m_run = true;
2015-08-17 05:26:58 +00:00
public:
CMain()
: m_memSys(*this, Common::CMemorySys::GetGameAllocator())
2015-08-17 05:26:58 +00:00
{
OpenWindow("", 0, 0, 640, 480);
}
void InitializeSubsystems()
2015-08-18 05:54:43 +00:00
{
Common::CElementGen::Initialize();
Common::CAnimData::InitializeCache();
Common::CDecalManager::Initialize();
}
void AddWorldPaks()
{
}
void FillInAssetIDs()
2015-08-17 05:26:58 +00:00
{
}
int RsMain(int argc, const char* argv[])
{
2015-08-18 05:54:43 +00:00
Common::TOneStatic<CGameGlobalObjects> globalObjs;
2015-08-17 20:33:58 +00:00
InitializeSubsystems();
globalObjs->PostInitialize(*this, m_memSys);
2015-08-18 05:54:43 +00:00
m_tweaks.RegisterTweaks();
AddWorldPaks();
Common::g_TweakManager->ReadFromMemoryCard("AudioTweaks");
FillInAssetIDs();
Common::TOneStatic<CGameArchitectureSupport> archSupport(*this);
2015-08-17 20:33:58 +00:00
while (m_run)
{
}
2015-08-17 05:26:58 +00:00
return 0;
}
};
}
}
2015-08-17 05:26:58 +00:00
int main(int argc, const char* argv[])
{
Retro::MP1::CMain main;
2015-08-17 05:26:58 +00:00
return main.RsMain(argc, argv);
}