metaforce/Runtime/MP1/MP1.hpp

274 lines
8.2 KiB
C++
Raw Normal View History

2016-04-13 06:07:23 +00:00
#ifndef __URDE_MP1_HPP__
#define __URDE_MP1_HPP__
2015-08-27 00:23:46 +00:00
2016-04-15 20:42:40 +00:00
#define MP1_USE_BOO 0
2016-09-17 06:40:45 +00:00
#include "IMain.hpp"
2015-08-27 00:23:46 +00:00
#include "CTweaks.hpp"
#include "CPlayMovie.hpp"
#include "IOStreams.hpp"
2016-04-15 20:42:40 +00:00
#include "CBasics.hpp"
#include "CMemoryCardSys.hpp"
#include "CResFactory.hpp"
#include "CSimplePool.hpp"
#include "Character/CAssetFactory.hpp"
2016-04-16 23:48:29 +00:00
#include "World/CAi.hpp"
2016-04-15 20:42:40 +00:00
#include "CGameState.hpp"
#include "CInGameTweakManager.hpp"
#include "Particle/CElementGen.hpp"
#include "Character/CAnimData.hpp"
#include "Particle/CDecalManager.hpp"
#include "Particle/CGenDescription.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"
2016-09-14 05:54:09 +00:00
#include "GuiSys/CErrorOutputWindow.hpp"
2016-04-15 20:42:40 +00:00
#include "GuiSys/CTextParser.hpp"
#include "Audio/CAudioStateWin.hpp"
#include "GameGlobalObjects.hpp"
#include "CArchitectureQueue.hpp"
#include "CTimeProvider.hpp"
#include "GuiSys/CTextExecuteBuffer.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakGame.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
{
2016-04-15 20:42:40 +00:00
class IFactory;
class IObjectStore;
2015-08-27 00:23:46 +00:00
namespace MP1
{
class CMain;
2016-04-15 20:42:40 +00:00
class CGameGlobalObjects
{
2016-12-30 06:37:01 +00:00
friend class CMain;
std::unique_ptr<CMemoryCardSys> x0_memoryCardSys;
IFactory& x4_resFactory;
CSimplePool& xcc_simplePool;
CCharacterFactoryBuilder xec_charFactoryBuilder;
CAiFuncMap x110_aiFuncMap;
2016-12-29 21:38:59 +00:00
std::unique_ptr<CGameState> x134_gameState;
2016-12-14 22:56:59 +00:00
TLockedToken<CStringTable> x13c_mainStringTable;
CInGameTweakManager x150_tweakManager;
2016-04-15 20:42:40 +00:00
std::unique_ptr<CBooRenderer> m_renderer;
void LoadStringTable()
{
2016-12-14 22:56:59 +00:00
x13c_mainStringTable = g_SimplePool->GetObj("STRG_Main");
g_MainStringTable = x13c_mainStringTable.GetObj();
2016-04-15 20:42:40 +00:00
}
static CBooRenderer*
AllocateRenderer(IObjectStore& store, IFactory& resFactory)
{
g_Renderer = new CBooRenderer(store, resFactory);
return g_Renderer;
}
public:
CGameGlobalObjects(IFactory& resFactory,
CSimplePool& objStore)
: x4_resFactory(resFactory), xcc_simplePool(objStore)
2016-04-15 20:42:40 +00:00
{
g_ResFactory = &x4_resFactory;
g_SimplePool = &xcc_simplePool;
g_CharFactoryBuilder = &xec_charFactoryBuilder;
g_AiFuncMap = &x110_aiFuncMap;
2016-12-29 21:38:59 +00:00
x134_gameState.reset(new CGameState());
g_GameState = x134_gameState.get();
g_TweakManager = &x150_tweakManager;
2016-04-15 20:42:40 +00:00
}
void PostInitialize()
{
LoadStringTable();
m_renderer.reset(AllocateRenderer(xcc_simplePool, x4_resFactory));
2016-04-15 20:42:40 +00:00
}
void MemoryCardInitializePump()
{
if (!g_MemoryCardSys)
{
if (!x0_memoryCardSys)
x0_memoryCardSys.reset(new CMemoryCardSys());
if (x0_memoryCardSys->InitializePump())
g_MemoryCardSys = x0_memoryCardSys.get();
}
}
2016-12-29 21:38:59 +00:00
void ResetGameState()
{
x134_gameState.reset(new CGameState());
g_GameState = x134_gameState.get();
}
};
2016-04-15 20:42:40 +00:00
#if MP1_USE_BOO
class CGameArchitectureSupport : public boo::IWindowCallback
#else
class CGameArchitectureSupport
#endif
{
CMain& m_parent;
2016-12-29 21:38:59 +00:00
CArchitectureQueue x4_archQueue;
CAudioSys x0_audioSys;
CInputGenerator x30_inputGenerator;
CGuiSys x44_guiSys;
CIOWinManager x58_ioWinManager;
s32 x78_;
2016-04-15 20:42:40 +00:00
boo::SWindowRect m_windowRect;
bool m_rectIsDirty;
void mouseDown(const boo::SWindowCoord &coord, boo::EMouseButton button, boo::EModifierKey mods)
2016-12-29 21:38:59 +00:00
{ x30_inputGenerator.mouseDown(coord, button, mods); }
2016-04-15 20:42:40 +00:00
void mouseUp(const boo::SWindowCoord &coord, boo::EMouseButton button, boo::EModifierKey mods)
2016-12-29 21:38:59 +00:00
{ x30_inputGenerator.mouseUp(coord, button, mods); }
2016-04-15 20:42:40 +00:00
void mouseMove(const boo::SWindowCoord &coord)
2016-12-29 21:38:59 +00:00
{ x30_inputGenerator.mouseMove(coord); }
2016-04-15 20:42:40 +00:00
void scroll(const boo::SWindowCoord &coord, const boo::SScrollDelta &scroll)
2016-12-29 21:38:59 +00:00
{ x30_inputGenerator.scroll(coord, scroll); }
2016-04-15 20:42:40 +00:00
void charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat)
2016-12-29 21:38:59 +00:00
{ x30_inputGenerator.charKeyDown(charCode, mods, isRepeat); }
2016-04-15 20:42:40 +00:00
void charKeyUp(unsigned long charCode, boo::EModifierKey mods)
2016-12-29 21:38:59 +00:00
{ x30_inputGenerator.charKeyUp(charCode, mods); }
2016-04-15 20:42:40 +00:00
void specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat)
2016-12-29 21:38:59 +00:00
{ x30_inputGenerator.specialKeyDown(key, mods, isRepeat); }
2016-04-15 20:42:40 +00:00
void specialKeyUp(boo::ESpecialKey key, boo::EModifierKey mods)
2016-12-29 21:38:59 +00:00
{ x30_inputGenerator.specialKeyUp(key, mods); }
2016-04-15 20:42:40 +00:00
void modKeyDown(boo::EModifierKey mod, bool isRepeat)
2016-12-29 21:38:59 +00:00
{ x30_inputGenerator.modKeyDown(mod, isRepeat);}
2016-04-15 20:42:40 +00:00
void modKeyUp(boo::EModifierKey mod)
2016-12-29 21:38:59 +00:00
{ x30_inputGenerator.modKeyUp(mod); }
2016-04-15 20:42:40 +00:00
2016-12-29 21:38:59 +00:00
void destroyed() { x4_archQueue.Push(MakeMsg::CreateApplicationExit(EArchMsgTarget::ArchitectureSupport)); }
2016-04-15 20:42:40 +00:00
void resized(const boo::SWindowRect &rect)
{
m_windowRect = rect;
m_rectIsDirty = true;
}
public:
2016-12-14 22:56:59 +00:00
CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend);
void PreloadAudio();
2016-09-14 05:54:09 +00:00
bool Update();
void Draw();
2016-04-15 20:42:40 +00:00
bool isRectDirty() { return m_rectIsDirty; }
const boo::SWindowRect& getWindowRect()
{
m_rectIsDirty = false;
return m_windowRect;
}
};
#if MP1_USE_BOO
2016-09-17 06:40:45 +00:00
class CMain : public boo::IApplicationCallback, public IMain
2016-04-15 20:42:40 +00:00
#else
2016-09-17 06:40:45 +00:00
class CMain : public IMain
2016-04-15 20:42:40 +00:00
#endif
{
friend class CGameArchitectureSupport;
2016-04-15 20:42:40 +00:00
#if MP1_USE_BOO
boo::IWindow* mainWindow;
int appMain(boo::IApplication* app);
2015-08-28 00:11:31 +00:00
void appQuitting(boo::IApplication*)
{ xe8_b24_finished = true; }
2015-08-28 00:11:31 +00:00
void appFilesOpen(boo::IApplication*, const std::vector<std::string>& paths)
{
fprintf(stderr, "OPENING: ");
for (const std::string& path : paths)
fprintf(stderr, "%s ", path.c_str());
fprintf(stderr, "\n");
}
2016-04-15 20:42:40 +00:00
#endif
2016-08-15 20:58:07 +00:00
private:
2015-08-28 00:11:31 +00:00
struct BooSetter
{
BooSetter(boo::IGraphicsDataFactory* factory,
boo::IGraphicsCommandQueue* cmdQ,
boo::ITextureR* spareTex);
} m_booSetter;
2016-04-15 20:42:40 +00:00
//CMemorySys x6c_memSys;
2015-08-27 00:23:46 +00:00
CTweaks x70_tweaks;
EGameplayResult xe4_gameplayResult;
2015-09-17 19:50:43 +00:00
bool xe8_b24_finished = false;
2015-08-28 00:11:31 +00:00
2016-04-15 20:42:40 +00:00
/* urde addition: these are simply initialized along with everything else */
2016-08-15 20:58:07 +00:00
CGameGlobalObjects x128_globalObjects;
std::unique_ptr<CGameArchitectureSupport> m_archSupport;
2016-04-15 20:42:40 +00:00
2016-09-17 06:40:45 +00:00
EFlowState x12c_flowState = EFlowState::Five;
2016-08-15 20:58:07 +00:00
u32 x130_[10] = { 1000000 };
union
{
struct
{
bool x160_24_ : 1;
bool x160_25_ : 1;
bool x160_26_ : 1;
bool x160_27_ : 1;
2016-12-30 06:37:01 +00:00
bool x160_28_manageCard : 1;
2016-08-15 20:58:07 +00:00
bool x160_29_ : 1;
bool x160_30_ : 1;
2016-12-24 05:23:50 +00:00
bool x160_31_cardBusy : 1;
2016-08-15 20:58:07 +00:00
bool x161_24_ : 1;
};
u16 _dummy = 0;
};
u32 x164_ = 0;
2016-12-14 22:56:59 +00:00
void InitializeSubsystems(const hecl::Runtime::FileStoreManager& storeMgr);
2016-04-15 20:42:40 +00:00
2015-08-27 00:23:46 +00:00
public:
CMain(IFactory& resFactory, CSimplePool& resStore,
boo::IGraphicsDataFactory* gfxFactory,
boo::IGraphicsCommandQueue* cmdQ,
boo::ITextureR* spareTex);
2015-08-27 00:23:46 +00:00
void RegisterResourceTweaks();
void ResetGameState();
2016-12-30 06:37:01 +00:00
void StreamNewGameState(CBitStreamReader&, u32 idx);
2015-08-27 00:23:46 +00:00
void CheckTweakManagerDebugOptions() {}
2016-04-15 20:42:40 +00:00
//int RsMain(int argc, const boo::SystemChar* argv[]);
void Init(const hecl::Runtime::FileStoreManager& storeMgr,
boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend);
2016-04-15 20:42:40 +00:00
bool Proc();
2016-09-14 05:54:09 +00:00
void Draw();
2016-04-15 20:42:40 +00:00
void Shutdown();
2016-09-17 06:40:45 +00:00
bool CheckReset() { return false; }
2016-12-30 06:37:01 +00:00
bool CheckTerminate() { return false; }
2016-09-17 06:40:45 +00:00
void DrawDebugMetrics(double, CStopWatch&) {}
2015-08-27 00:23:46 +00:00
void DoPredrawMetrics() {}
void FillInAssetIDs();
void LoadAudio();
2016-09-17 06:40:45 +00:00
void ShutdownSubsystems() {}
2016-12-30 06:37:01 +00:00
EGameplayResult GetGameplayResult() const { return xe4_gameplayResult; }
void SetGameplayResult(EGameplayResult wl) { xe4_gameplayResult = wl; }
void SetManageCard(bool v) { x160_28_manageCard = v; }
bool GetBardBusy() const { return x160_31_cardBusy; }
void SetCardBusy(bool v) { x160_31_cardBusy = v; }
2016-08-15 20:58:07 +00:00
2016-09-17 06:40:45 +00:00
EFlowState GetFlowState() const { return x12c_flowState; }
2015-08-27 00:23:46 +00:00
};
}
}
2016-04-13 06:07:23 +00:00
#endif // __URDE_MP1_HPP__