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;
|
HECL::Runtime::FileStoreManager& m_store;
|
||||||
bool m_useBinary;
|
bool m_useBinary;
|
||||||
|
static CVarManager* m_instance;
|
||||||
public:
|
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(HECL::Runtime::FileStoreManager& store, bool useBinary = false);
|
||||||
~CVarManager();
|
~CVarManager();
|
||||||
|
|
||||||
|
@ -56,6 +61,9 @@ public:
|
||||||
|
|
||||||
void deserialize(CVar* cvar);
|
void deserialize(CVar* cvar);
|
||||||
void serialize();
|
void serialize();
|
||||||
|
|
||||||
|
static CVarManager* instance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool suppressDeveloper();
|
bool suppressDeveloper();
|
||||||
void restoreDeveloper(bool oldDeveloper);
|
void restoreDeveloper(bool oldDeveloper);
|
||||||
|
|
|
@ -12,11 +12,14 @@ CVar* com_developer = nullptr;
|
||||||
CVar* com_configfile = nullptr;
|
CVar* com_configfile = nullptr;
|
||||||
CVar* com_enableCheats = nullptr;
|
CVar* com_enableCheats = nullptr;
|
||||||
|
|
||||||
|
CVarManager* CVarManager::m_instance = nullptr;
|
||||||
|
|
||||||
LogVisor::LogModule CVarLog("CVarManager");
|
LogVisor::LogModule CVarLog("CVarManager");
|
||||||
CVarManager::CVarManager(HECL::Runtime::FileStoreManager& store, bool useBinary)
|
CVarManager::CVarManager(HECL::Runtime::FileStoreManager& store, bool useBinary)
|
||||||
: m_store(store),
|
: m_store(store),
|
||||||
m_useBinary(useBinary)
|
m_useBinary(useBinary)
|
||||||
{
|
{
|
||||||
|
m_instance = this;
|
||||||
com_configfile = newCVar("config", "File to store configuration", std::string("config"), CVar::EFlags::System);
|
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_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));
|
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 CVarManager::suppressDeveloper()
|
||||||
{
|
{
|
||||||
bool oldDeveloper = com_developer->toBoolean();
|
bool oldDeveloper = com_developer->toBoolean();
|
||||||
|
|
Loading…
Reference in New Issue