2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2015-08-27 00:23:46 +00:00
|
|
|
|
2020-04-15 07:56:59 +00:00
|
|
|
#include "Runtime/IMain.hpp"
|
|
|
|
#include "Runtime/MP1/CTweaks.hpp"
|
|
|
|
#include "Runtime/MP1/CPlayMovie.hpp"
|
2022-02-19 13:04:45 +00:00
|
|
|
#include "Runtime/Streams/IOStreams.hpp"
|
2020-04-15 07:56:59 +00:00
|
|
|
#include "Runtime/CBasics.hpp"
|
|
|
|
#include "Runtime/CMemoryCardSys.hpp"
|
|
|
|
#include "Runtime/CResFactory.hpp"
|
|
|
|
#include "Runtime/CSimplePool.hpp"
|
|
|
|
#include "Runtime/Character/CAssetFactory.hpp"
|
|
|
|
#include "Runtime/World/CAi.hpp"
|
|
|
|
#include "Runtime/CGameState.hpp"
|
2021-05-25 16:24:05 +00:00
|
|
|
#include "Runtime/ImGuiConsole.hpp"
|
2020-04-15 07:56:59 +00:00
|
|
|
#include "Runtime/MP1/CInGameTweakManager.hpp"
|
|
|
|
#include "Runtime/Particle/CElementGen.hpp"
|
|
|
|
#include "Runtime/Character/CAnimData.hpp"
|
|
|
|
#include "Runtime/Particle/CDecalManager.hpp"
|
|
|
|
#include "Runtime/Particle/CGenDescription.hpp"
|
2022-02-25 07:45:25 +00:00
|
|
|
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
2020-04-15 07:56:59 +00:00
|
|
|
#include "Runtime/Audio/CAudioSys.hpp"
|
|
|
|
#include "Runtime/Input/CInputGenerator.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiSys.hpp"
|
|
|
|
#include "Runtime/CIOWinManager.hpp"
|
|
|
|
#include "Runtime/GuiSys/CSplashScreen.hpp"
|
|
|
|
#include "Runtime/MP1/CMainFlow.hpp"
|
|
|
|
#include "Runtime/GuiSys/CConsoleOutputWindow.hpp"
|
|
|
|
#include "Runtime/GuiSys/CErrorOutputWindow.hpp"
|
|
|
|
#include "Runtime/GuiSys/CTextParser.hpp"
|
|
|
|
#include "Runtime/MP1/CAudioStateWin.hpp"
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/CArchitectureQueue.hpp"
|
|
|
|
#include "Runtime/CTimeProvider.hpp"
|
|
|
|
#include "Runtime/GuiSys/CTextExecuteBuffer.hpp"
|
2022-02-21 02:28:07 +00:00
|
|
|
#include "Runtime/MP1/Tweaks/CTweakPlayer.hpp"
|
|
|
|
#include "Runtime/MP1/Tweaks/CTweakGame.hpp"
|
|
|
|
#include "Runtime/ConsoleVariables/CVarCommons.hpp"
|
2015-08-27 00:23:46 +00:00
|
|
|
|
2018-05-25 06:39:38 +00:00
|
|
|
struct DiscordUser;
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-04-15 20:42:40 +00:00
|
|
|
class IFactory;
|
|
|
|
class IObjectStore;
|
2015-08-27 00:23:46 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace MP1 {
|
2016-09-30 22:43:19 +00:00
|
|
|
class CMain;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CGameGlobalObjects {
|
|
|
|
friend class CMain;
|
|
|
|
|
|
|
|
std::unique_ptr<CSimplePool> m_gameSimplePool;
|
|
|
|
std::unique_ptr<CResFactory> m_gameResFactory;
|
|
|
|
std::unique_ptr<CMemoryCardSys> x0_memoryCardSys;
|
|
|
|
IFactory* x4_resFactory;
|
|
|
|
CSimplePool* xcc_simplePool;
|
|
|
|
CCharacterFactoryBuilder xec_charFactoryBuilder;
|
|
|
|
CAiFuncMap x110_aiFuncMap;
|
|
|
|
std::unique_ptr<CGameState> x134_gameState;
|
|
|
|
TLockedToken<CStringTable> x13c_mainStringTable;
|
|
|
|
CInGameTweakManager x150_tweakManager;
|
|
|
|
std::unique_ptr<IRenderer> m_renderer;
|
2019-12-11 04:51:33 +00:00
|
|
|
TLockedToken<CTextureCache> m_textureCache;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
void LoadStringTable() {
|
|
|
|
x13c_mainStringTable = g_SimplePool->GetObj("STRG_Main");
|
|
|
|
g_MainStringTable = x13c_mainStringTable.GetObj();
|
|
|
|
}
|
2019-12-11 04:51:33 +00:00
|
|
|
void LoadTextureCache() {
|
|
|
|
m_textureCache = g_SimplePool->GetObj("TextureCache"sv);
|
|
|
|
g_TextureCache = m_textureCache.GetObj();
|
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
void AddPaksAndFactories();
|
|
|
|
static IRenderer* AllocateRenderer(IObjectStore& store, IFactory& resFactory) {
|
2022-02-25 07:45:25 +00:00
|
|
|
g_Renderer = new CCubeRenderer(store, resFactory);
|
2018-12-08 05:30:43 +00:00
|
|
|
return g_Renderer;
|
|
|
|
}
|
2016-04-15 20:42:40 +00:00
|
|
|
|
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CGameGlobalObjects(IFactory* resFactory, CSimplePool* objStore)
|
|
|
|
: x4_resFactory(resFactory), xcc_simplePool(objStore) {
|
|
|
|
if (!x4_resFactory) {
|
2019-09-12 03:50:38 +00:00
|
|
|
m_gameResFactory = std::make_unique<CResFactory>();
|
2018-12-08 05:30:43 +00:00
|
|
|
x4_resFactory = m_gameResFactory.get();
|
2016-12-29 21:38:59 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!xcc_simplePool) {
|
2019-09-12 03:50:38 +00:00
|
|
|
m_gameSimplePool = std::make_unique<CSimplePool>(*x4_resFactory);
|
2018-12-08 05:30:43 +00:00
|
|
|
xcc_simplePool = m_gameSimplePool.get();
|
2018-10-18 04:51:59 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
g_ResFactory = x4_resFactory;
|
|
|
|
g_SimplePool = xcc_simplePool;
|
|
|
|
g_CharFactoryBuilder = &xec_charFactoryBuilder;
|
|
|
|
g_AiFuncMap = &x110_aiFuncMap;
|
2019-09-12 03:50:38 +00:00
|
|
|
x134_gameState = std::make_unique<CGameState>();
|
2018-12-08 05:30:43 +00:00
|
|
|
g_GameState = x134_gameState.get();
|
|
|
|
g_TweakManager = &x150_tweakManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
~CGameGlobalObjects();
|
|
|
|
|
2020-04-15 07:56:59 +00:00
|
|
|
void PostInitialize();
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
void ResetGameState() {
|
2019-09-12 03:50:38 +00:00
|
|
|
x134_gameState = std::make_unique<CGameState>();
|
2018-12-08 05:30:43 +00:00
|
|
|
g_GameState = x134_gameState.get();
|
|
|
|
}
|
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
void StreamInGameState(CInputStream& stream, u32 saveIdx) {
|
2019-09-12 03:50:38 +00:00
|
|
|
x134_gameState = std::make_unique<CGameState>(stream, saveIdx);
|
2018-12-08 05:30:43 +00:00
|
|
|
g_GameState = x134_gameState.get();
|
|
|
|
}
|
2015-11-02 18:45:39 +00:00
|
|
|
};
|
|
|
|
|
2022-02-22 05:53:57 +00:00
|
|
|
class CGameArchitectureSupport {
|
2018-12-08 05:30:43 +00:00
|
|
|
friend class CMain;
|
|
|
|
CMain& m_parent;
|
|
|
|
CArchitectureQueue x4_archQueue;
|
|
|
|
CAudioSys x0_audioSys;
|
|
|
|
CInputGenerator x30_inputGenerator;
|
|
|
|
CGuiSys x44_guiSys;
|
|
|
|
CIOWinManager x58_ioWinManager;
|
2019-04-07 05:14:48 +00:00
|
|
|
s32 x78_gameFrameCount = 0;
|
2017-01-20 03:53:32 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EAudioLoadStatus { Loading, Loaded, Uninitialized };
|
|
|
|
EAudioLoadStatus x88_audioLoadStatus = EAudioLoadStatus::Uninitialized;
|
|
|
|
std::vector<TToken<CAudioGroupSet>> x8c_pendingAudioGroups;
|
2016-04-15 20:42:40 +00:00
|
|
|
|
2022-02-22 05:53:57 +00:00
|
|
|
aurora::WindowSize m_windowRect;
|
2020-04-15 11:27:06 +00:00
|
|
|
bool m_rectIsDirty = false;
|
2017-01-22 21:26:58 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void destroyed() { x4_archQueue.Push(MakeMsg::CreateRemoveAllIOWins(EArchMsgTarget::IOWinManager)); }
|
2017-01-22 21:26:58 +00:00
|
|
|
|
2022-02-22 05:53:57 +00:00
|
|
|
void resized(const aurora::WindowSize& rect) {
|
2018-12-08 05:30:43 +00:00
|
|
|
m_windowRect = rect;
|
|
|
|
m_rectIsDirty = true;
|
|
|
|
}
|
2017-02-06 03:21:58 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
public:
|
|
|
|
CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend);
|
|
|
|
~CGameArchitectureSupport();
|
|
|
|
|
2022-02-22 05:53:57 +00:00
|
|
|
void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) {
|
2022-03-22 19:04:57 +00:00
|
|
|
// x30_inputGenerator.mouseDown(coord, button, mods);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2022-02-22 05:53:57 +00:00
|
|
|
void mouseUp(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) {
|
2022-03-22 19:04:57 +00:00
|
|
|
// x30_inputGenerator.mouseUp(coord, button, mods);
|
|
|
|
}
|
|
|
|
void mouseMove(const SWindowCoord& coord) {
|
|
|
|
// x30_inputGenerator.mouseMove(coord);
|
|
|
|
}
|
|
|
|
void scroll(const SWindowCoord& coord, const SScrollDelta& scroll) {
|
|
|
|
// x30_inputGenerator.scroll(coord, scroll);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2022-02-22 05:53:57 +00:00
|
|
|
void charKeyDown(uint8_t charCode, aurora::ModifierKey mods, bool isRepeat);
|
2022-03-22 19:04:57 +00:00
|
|
|
void charKeyUp(uint8_t charCode, aurora::ModifierKey mods) {
|
|
|
|
// x30_inputGenerator.charKeyUp(charCode, mods);
|
|
|
|
}
|
2022-02-13 21:32:52 +00:00
|
|
|
void specialKeyDown(aurora::SpecialKey key, aurora::ModifierKey mods, bool isRepeat);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2022-02-13 21:32:52 +00:00
|
|
|
void specialKeyUp(aurora::SpecialKey key, aurora::ModifierKey mods);
|
2022-03-22 19:04:57 +00:00
|
|
|
void modKeyDown(aurora::ModifierKey mod, bool isRepeat) {
|
|
|
|
// x30_inputGenerator.modKeyDown(mod, isRepeat);
|
|
|
|
}
|
|
|
|
void modKeyUp(aurora::ModifierKey mod) {
|
|
|
|
// x30_inputGenerator.modKeyUp(mod);
|
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
void PreloadAudio();
|
|
|
|
bool LoadAudio();
|
|
|
|
void UnloadAudio();
|
2020-02-25 02:42:55 +00:00
|
|
|
void UpdateTicks(float dt);
|
|
|
|
void Update(float dt);
|
2018-12-08 05:30:43 +00:00
|
|
|
void Draw();
|
|
|
|
|
2019-08-14 10:04:11 +00:00
|
|
|
bool isRectDirty() const { return m_rectIsDirty; }
|
2022-02-22 05:53:57 +00:00
|
|
|
const aurora::WindowSize& getWindowRect() {
|
2018-12-08 05:30:43 +00:00
|
|
|
m_rectIsDirty = false;
|
|
|
|
return m_windowRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
CIOWinManager& GetIOWinManager() { return x58_ioWinManager; }
|
2016-04-15 20:42:40 +00:00
|
|
|
};
|
|
|
|
|
2022-02-22 05:53:57 +00:00
|
|
|
class CMain : public IMain {
|
2018-12-08 05:30:43 +00:00
|
|
|
friend class CGameArchitectureSupport;
|
2022-02-22 05:53:57 +00:00
|
|
|
|
2016-08-15 20:58:07 +00:00
|
|
|
private:
|
2020-05-08 03:20:23 +00:00
|
|
|
// COsContext x0_osContext;
|
2018-12-08 05:30:43 +00:00
|
|
|
// CMemorySys x6c_memSys;
|
|
|
|
CTweaks x70_tweaks;
|
|
|
|
EGameplayResult xe4_gameplayResult;
|
2020-05-08 03:20:23 +00:00
|
|
|
double xe8_;
|
|
|
|
rstl::reserved_vector<float, 4> xf0_;
|
|
|
|
rstl::reserved_vector<float, 4> x104_;
|
|
|
|
float x118_;
|
|
|
|
float x11c_;
|
|
|
|
float x120_;
|
|
|
|
float x124_;
|
|
|
|
std::unique_ptr<CGameGlobalObjects> x128_globalObjects;
|
2021-06-03 23:47:04 +00:00
|
|
|
EClientFlowStates x12c_flowState = EClientFlowStates::Default;
|
2020-05-08 03:20:23 +00:00
|
|
|
rstl::reserved_vector<u32, 10> x130_{{
|
|
|
|
1000000,
|
|
|
|
1000000,
|
|
|
|
1000000,
|
|
|
|
1000000,
|
|
|
|
1000000,
|
|
|
|
1000000,
|
|
|
|
1000000,
|
|
|
|
1000000,
|
|
|
|
1000000,
|
|
|
|
1000000,
|
|
|
|
}};
|
|
|
|
// u32 x15c_ = 0;
|
2020-04-21 07:22:41 +00:00
|
|
|
bool x160_24_finished : 1 = false;
|
|
|
|
bool x160_25_mfGameBuilt : 1 = false;
|
|
|
|
bool x160_26_screenFading : 1 = false;
|
|
|
|
bool x160_27_ : 1 = false;
|
|
|
|
bool x160_28_manageCard : 1 = false;
|
|
|
|
bool x160_29_ : 1 = false;
|
|
|
|
bool x160_30_ : 1 = false;
|
|
|
|
bool x160_31_cardBusy : 1 = false;
|
|
|
|
bool x161_24_gameFrameDrawn : 1 = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
std::unique_ptr<CGameArchitectureSupport> x164_archSupport;
|
2016-08-15 20:58:07 +00:00
|
|
|
|
2022-02-21 02:28:07 +00:00
|
|
|
CVarManager* m_cvarMgr = nullptr;
|
2019-03-09 08:58:27 +00:00
|
|
|
bool m_loadedPersistentResources = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
bool m_doQuit = false;
|
2021-05-25 16:24:05 +00:00
|
|
|
bool m_paused = false;
|
2022-02-21 02:28:07 +00:00
|
|
|
MetaforceVersionInfo m_version;
|
2020-02-25 02:42:55 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void InitializeSubsystems();
|
|
|
|
static void InitializeDiscord();
|
|
|
|
static void ShutdownDiscord();
|
|
|
|
static void HandleDiscordReady(const DiscordUser* request);
|
|
|
|
static void HandleDiscordDisconnected(int errorCode, const char* message);
|
|
|
|
static void HandleDiscordErrored(int errorCode, const char* message);
|
2016-04-15 20:42:40 +00:00
|
|
|
|
2015-08-27 00:23:46 +00:00
|
|
|
public:
|
2022-02-01 00:06:54 +00:00
|
|
|
CMain(IFactory* resFactory, CSimplePool* resStore);
|
2018-12-08 05:30:43 +00:00
|
|
|
void RegisterResourceTweaks();
|
|
|
|
void AddWorldPaks();
|
2019-11-21 15:37:08 +00:00
|
|
|
void AddOverridePaks();
|
2018-12-08 05:30:43 +00:00
|
|
|
void ResetGameState();
|
2022-02-18 07:37:54 +00:00
|
|
|
void StreamNewGameState(CInputStream&, u32 idx);
|
2018-12-08 05:30:43 +00:00
|
|
|
void RefreshGameState();
|
|
|
|
void CheckTweakManagerDebugOptions() {}
|
|
|
|
void SetMFGameBuilt(bool b) { x160_25_mfGameBuilt = b; }
|
|
|
|
void SetScreenFading(bool b) { x160_26_screenFading = b; }
|
|
|
|
bool GetScreenFading() const { return x160_26_screenFading; }
|
|
|
|
|
|
|
|
static void UpdateDiscordPresence(CAssetId worldSTRG = {});
|
|
|
|
|
2021-06-30 18:20:45 +00:00
|
|
|
// int RsMain(int argc, char** argv, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator&
|
2021-06-07 19:29:18 +00:00
|
|
|
// backend);
|
2022-02-22 05:53:57 +00:00
|
|
|
void Init(const FileStoreManager& storeMgr, CVarManager* cvarManager, boo::IAudioVoiceEngine* voiceEngine,
|
|
|
|
amuse::IBackendVoiceAllocator& backend) override;
|
2021-05-24 21:25:31 +00:00
|
|
|
bool Proc(float dt) override;
|
2019-08-09 19:46:49 +00:00
|
|
|
void Draw() override;
|
|
|
|
void Shutdown() override;
|
2022-03-22 19:04:57 +00:00
|
|
|
// boo::IWindow* GetMainWindow() const override;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
void MemoryCardInitializePump();
|
|
|
|
|
2019-08-14 10:04:11 +00:00
|
|
|
bool CheckReset() const { return m_doQuit; }
|
|
|
|
bool CheckTerminate() const { return m_doQuit; }
|
2018-12-08 05:30:43 +00:00
|
|
|
void DrawDebugMetrics(double, CStopwatch&) {}
|
|
|
|
void DoPredrawMetrics() {}
|
|
|
|
void FillInAssetIDs();
|
|
|
|
bool LoadAudio();
|
|
|
|
void ShutdownSubsystems();
|
|
|
|
EGameplayResult GetGameplayResult() const { return xe4_gameplayResult; }
|
|
|
|
void SetGameplayResult(EGameplayResult wl) { xe4_gameplayResult = wl; }
|
|
|
|
void SetManageCard(bool v) { x160_28_manageCard = v; }
|
|
|
|
bool GetCardBusy() const { return x160_31_cardBusy; }
|
|
|
|
void SetCardBusy(bool v) { x160_31_cardBusy = v; }
|
|
|
|
void SetGameFrameDrawn() { x161_24_gameFrameDrawn = true; }
|
|
|
|
static void EnsureWorldPaksReady();
|
|
|
|
static void EnsureWorldPakReady(CAssetId mlvl);
|
|
|
|
|
2021-06-03 23:47:04 +00:00
|
|
|
EClientFlowStates GetFlowState() const override { return x12c_flowState; }
|
|
|
|
void SetFlowState(EClientFlowStates s) override { x12c_flowState = s; }
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
void SetX30(bool v) { x160_30_ = v; }
|
|
|
|
|
|
|
|
CGameArchitectureSupport* GetArchSupport() const { return x164_archSupport.get(); }
|
|
|
|
|
2019-08-09 19:46:49 +00:00
|
|
|
size_t GetExpectedIdSize() const override { return sizeof(u32); }
|
2020-04-16 05:26:14 +00:00
|
|
|
bool IsPAL() const override { return m_version.region == ERegion::PAL; }
|
2022-02-23 06:28:35 +00:00
|
|
|
bool IsJapanese() const override { return m_version.region == ERegion::JPN; }
|
|
|
|
bool IsUSA() const override { return m_version.region == ERegion::USA; }
|
|
|
|
bool IsKorean() const override { return m_version.region == ERegion::KOR; }
|
|
|
|
bool IsTrilogy() const override { return m_version.game == EGame::MetroidPrimeTrilogy; }
|
2020-04-16 05:26:14 +00:00
|
|
|
ERegion GetRegion() const override { return m_version.region; }
|
|
|
|
EGame GetGame() const override { return m_version.game; }
|
2022-02-23 06:38:01 +00:00
|
|
|
std::string GetGameTitle() const override { return m_version.gameTitle; }
|
2020-05-08 03:20:23 +00:00
|
|
|
std::string_view GetVersionString() const override { return m_version.version; }
|
2021-05-25 16:24:05 +00:00
|
|
|
void Quit() override { m_doQuit = true; }
|
|
|
|
bool IsPaused() const override { return m_paused; }
|
|
|
|
void SetPaused(bool b) override { m_paused = b; }
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
int m_warpWorldIdx = -1;
|
|
|
|
TAreaId m_warpAreaId = 0;
|
|
|
|
u64 m_warpLayerBits = 0;
|
2019-02-10 04:41:35 +00:00
|
|
|
std::vector<TEditorId> m_warpMemoryRelays;
|
2015-08-27 00:23:46 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace MP1
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|