mirror of https://github.com/AxioDL/metaforce.git
Make CVarManager a singleton
This commit is contained in:
parent
ee40f5217f
commit
e458d97a2a
|
@ -31,7 +31,12 @@ class CVarManager
|
|||
|
||||
HECL::Runtime::FileStoreManager& m_store;
|
||||
bool m_useBinary;
|
||||
static CVarManager* m_instance;
|
||||
public:
|
||||
CVarManager() = delete;
|
||||
CVarManager(const CVarManager&) = delete;
|
||||
CVarManager& operator=(const CVarManager&) = delete;
|
||||
CVarManager& operator=(const CVarManager&&) = delete;
|
||||
CVarManager(HECL::Runtime::FileStoreManager& store, bool useBinary = false);
|
||||
~CVarManager();
|
||||
|
||||
|
@ -56,6 +61,9 @@ public:
|
|||
|
||||
void deserialize(CVar* cvar);
|
||||
void serialize();
|
||||
|
||||
static CVarManager* instance();
|
||||
|
||||
private:
|
||||
bool suppressDeveloper();
|
||||
void restoreDeveloper(bool oldDeveloper);
|
||||
|
|
|
@ -12,11 +12,14 @@ CVar* com_developer = nullptr;
|
|||
CVar* com_configfile = nullptr;
|
||||
CVar* com_enableCheats = nullptr;
|
||||
|
||||
CVarManager* CVarManager::m_instance = nullptr;
|
||||
|
||||
LogVisor::LogModule CVarLog("CVarManager");
|
||||
CVarManager::CVarManager(HECL::Runtime::FileStoreManager& store, bool useBinary)
|
||||
: m_store(store),
|
||||
m_useBinary(useBinary)
|
||||
{
|
||||
m_instance = this;
|
||||
com_configfile = newCVar("config", "File to store configuration", std::string("config"), CVar::EFlags::System);
|
||||
com_developer = newCVar("developer", "Enables developer mode", false, (CVar::EFlags::System | CVar::EFlags::Cheat | CVar::EFlags::ReadOnly));
|
||||
com_enableCheats = newCVar("iamaweiner", "Enable cheats", false, (CVar::EFlags::System | CVar::EFlags::ReadOnly | CVar::EFlags::Hidden));
|
||||
|
@ -167,6 +170,11 @@ void CVarManager::serialize()
|
|||
}
|
||||
}
|
||||
|
||||
CVarManager* CVarManager::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
bool CVarManager::suppressDeveloper()
|
||||
{
|
||||
bool oldDeveloper = com_developer->toBoolean();
|
||||
|
|
Loading…
Reference in New Issue