2017-01-20 08:36:52 -05:00
|
|
|
#pragma once
|
|
|
|
|
2015-12-28 20:52:31 -05:00
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
class Component
|
|
|
|
{
|
|
|
|
public:
|
2022-06-13 11:32:45 -04:00
|
|
|
Component() = default;
|
|
|
|
virtual ~Component() = default;
|
2016-08-15 10:40:30 -04:00
|
|
|
|
2016-09-16 05:04:28 -04:00
|
|
|
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
|
2017-05-31 06:02:14 -04:00
|
|
|
virtual std::string getName()
|
|
|
|
{
|
|
|
|
std::string name = typeid(*this).name();
|
|
|
|
Utils::String::Replace(name, "class Components::", "");
|
|
|
|
return name;
|
|
|
|
};
|
2016-08-15 10:40:30 -04:00
|
|
|
#endif
|
|
|
|
|
2017-01-23 16:06:50 -05:00
|
|
|
// It's illegal to spawn threads in DLLMain, and apparently it causes problems if they are destroyed there as well.
|
|
|
|
// This method is called before DLLMain (if possible) and should to destroy threads.
|
|
|
|
// It's not 100% guaranteed that it's called outside DLLMain, as it depends on the game, but it's 100% guaranteed, that it is called at all.
|
2022-05-05 10:03:14 -04:00
|
|
|
virtual void preDestroy() {}
|
|
|
|
virtual bool unitTest() { return true; } // Unit testing entry
|
2015-12-28 20:52:31 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class Loader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void Initialize();
|
|
|
|
static void Uninitialize();
|
2017-01-23 16:06:50 -05:00
|
|
|
static void PreDestroy();
|
2017-02-24 07:30:31 -05:00
|
|
|
static void PreDestroyNoPostGame();
|
2016-02-04 15:58:49 -05:00
|
|
|
static bool PerformUnitTests();
|
2017-07-03 09:40:32 -04:00
|
|
|
static bool IsPerformingUnitTests();
|
2015-12-28 20:52:31 -05:00
|
|
|
static void Register(Component* component);
|
|
|
|
|
2016-09-03 09:52:40 -04:00
|
|
|
static bool IsPregame();
|
2017-02-24 07:30:31 -05:00
|
|
|
static bool IsPostgame();
|
2017-06-04 07:46:50 -04:00
|
|
|
static bool IsUninitializing();
|
2016-09-03 09:52:40 -04:00
|
|
|
|
2017-05-31 06:02:14 -04:00
|
|
|
template <typename T>
|
|
|
|
static T* GetInstance()
|
|
|
|
{
|
2022-12-25 12:23:53 -05:00
|
|
|
for (auto& component : Components)
|
2017-05-31 06:02:14 -04:00
|
|
|
{
|
|
|
|
if (typeid(*component) == typeid(T))
|
|
|
|
{
|
|
|
|
return reinterpret_cast<T*>(component);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-12-28 20:52:31 -05:00
|
|
|
private:
|
2016-09-03 09:52:40 -04:00
|
|
|
static bool Pregame;
|
2017-01-23 16:06:50 -05:00
|
|
|
static bool Postgame;
|
2017-06-04 07:46:50 -04:00
|
|
|
static bool Uninitializing;
|
2015-12-28 20:52:31 -05:00
|
|
|
static std::vector<Component*> Components;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-25 12:23:53 -05:00
|
|
|
// Priority
|
2017-01-20 08:36:52 -05:00
|
|
|
#include "Modules/Auth.hpp"
|
2022-12-25 12:23:53 -05:00
|
|
|
#include "Modules/Command.hpp"
|
2017-01-20 08:36:52 -05:00
|
|
|
#include "Modules/Dvar.hpp"
|
2022-12-25 12:23:53 -05:00
|
|
|
#include "Modules/Exception.hpp"
|
2017-01-20 08:36:52 -05:00
|
|
|
#include "Modules/Flags.hpp"
|
|
|
|
#include "Modules/Network.hpp"
|
|
|
|
#include "Modules/Logger.hpp"
|
2022-12-25 12:23:53 -05:00
|
|
|
#include "Modules/Singleton.hpp"
|
|
|
|
#include "Modules/UIScript.hpp"
|
|
|
|
#include "Modules/ZoneBuilder.hpp"
|
|
|
|
|
|
|
|
#include "Modules/ArenaLength.hpp"
|
|
|
|
#include "Modules/AssetHandler.hpp"
|
2017-01-20 08:36:52 -05:00
|
|
|
#include "Modules/Dedicated.hpp"
|
2022-12-25 12:23:53 -05:00
|
|
|
#include "Modules/Events.hpp"
|
|
|
|
#include "Modules/FileSystem.hpp"
|
|
|
|
#include "Modules/Friends.hpp"
|
|
|
|
#include "Modules/IPCPipe.hpp"
|
|
|
|
#include "Modules/Localization.hpp"
|
|
|
|
#include "Modules/Maps.hpp"
|
2017-01-20 08:36:52 -05:00
|
|
|
#include "Modules/Materials.hpp"
|
2022-12-25 12:23:53 -05:00
|
|
|
#include "Modules/Menus.hpp"
|
|
|
|
#include "Modules/ModList.hpp"
|
2017-01-20 08:36:52 -05:00
|
|
|
#include "Modules/ModelSurfs.hpp"
|
2022-12-25 12:23:53 -05:00
|
|
|
#include "Modules/Node.hpp"
|
|
|
|
#include "Modules/Renderer.hpp"
|
|
|
|
#include "Modules/Scheduler.hpp"
|
2021-09-04 20:25:24 -04:00
|
|
|
#include "Modules/TextRenderer.hpp"
|
2022-12-25 12:23:53 -05:00
|
|
|
#include "Modules/Toast.hpp"
|
|
|
|
#include "Modules/Window.hpp"
|
|
|
|
#include "Modules/Zones.hpp"
|
2022-07-06 11:48:40 -04:00
|
|
|
|
|
|
|
#include "Modules/GSC/GSC.hpp"
|