2015-11-22 04:24:51 +00:00
|
|
|
#ifndef CVARMANAGER_HPP
|
|
|
|
#define CVARMANAGER_HPP
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
|
|
|
#include "CVar.hpp"
|
|
|
|
|
2015-11-22 06:51:25 +00:00
|
|
|
namespace HECL
|
|
|
|
{
|
|
|
|
namespace Runtime
|
|
|
|
{
|
|
|
|
class FileStoreManager;
|
|
|
|
}
|
|
|
|
}
|
2015-11-22 04:24:51 +00:00
|
|
|
namespace Retro
|
|
|
|
{
|
|
|
|
|
|
|
|
class CVarManager
|
|
|
|
{
|
2015-11-22 06:51:25 +00:00
|
|
|
using CVarContainer = DNACVAR::CVarContainer;
|
2015-11-22 04:24:51 +00:00
|
|
|
template <typename T>
|
2015-11-22 06:51:25 +00:00
|
|
|
CVar* _newCVar(const std::string& name, const std::string& help, const T& value, CVar::EFlags flags)
|
2015-11-22 04:24:51 +00:00
|
|
|
{
|
2015-11-22 06:51:25 +00:00
|
|
|
CVar* ret(new CVar(name, value, help, flags, *this));
|
2015-11-22 04:24:51 +00:00
|
|
|
if (registerCVar(ret))
|
2015-11-22 06:51:25 +00:00
|
|
|
{
|
2015-11-22 07:12:38 +00:00
|
|
|
if (ret->isArchive())
|
|
|
|
deserialize(ret);
|
2015-11-22 04:24:51 +00:00
|
|
|
return ret;
|
2015-11-22 06:51:25 +00:00
|
|
|
}
|
|
|
|
delete ret;
|
2015-11-22 04:24:51 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2015-11-22 06:51:25 +00:00
|
|
|
|
|
|
|
HECL::Runtime::FileStoreManager& m_store;
|
|
|
|
bool m_useBinary;
|
2015-11-22 04:24:51 +00:00
|
|
|
public:
|
2015-11-22 06:51:25 +00:00
|
|
|
CVarManager(HECL::Runtime::FileStoreManager& store, bool useBinary = false);
|
2015-11-22 04:24:51 +00:00
|
|
|
~CVarManager();
|
|
|
|
|
2015-11-22 07:12:38 +00:00
|
|
|
void update();
|
2015-11-22 06:51:25 +00:00
|
|
|
CVar* newCVar(const std::string& name, const std::string& help, const Zeus::CColor& value, CVar::EFlags flags)
|
2015-11-22 04:24:51 +00:00
|
|
|
{ return _newCVar<Zeus::CColor>(name, help, value, flags); }
|
2015-11-22 06:51:25 +00:00
|
|
|
CVar* newCVar(const std::string& name, const std::string& help, const std::string& value, CVar::EFlags flags)
|
2015-11-22 04:24:51 +00:00
|
|
|
{ return _newCVar<std::string>(name, help, value, flags); }
|
2015-11-22 06:51:25 +00:00
|
|
|
CVar* newCVar(const std::string& name, const std::string& help, bool value, CVar::EFlags flags)
|
2015-11-22 04:24:51 +00:00
|
|
|
{ return _newCVar<bool>(name, help, value, flags); }
|
2015-11-22 06:51:25 +00:00
|
|
|
CVar* newCVar(const std::string& name, const std::string& help, float value, CVar::EFlags flags)
|
2015-11-22 04:24:51 +00:00
|
|
|
{ return _newCVar<float>(name, help, value, flags); }
|
2015-11-22 06:51:25 +00:00
|
|
|
CVar* newCVar(const std::string& name, const std::string& help, int value, CVar::EFlags flags)
|
2015-11-22 04:24:51 +00:00
|
|
|
{ return _newCVar<int>(name, help, value, flags); }
|
|
|
|
|
2015-11-22 06:51:25 +00:00
|
|
|
bool registerCVar(CVar* cvar);
|
2015-11-22 04:24:51 +00:00
|
|
|
|
2015-11-22 08:01:51 +00:00
|
|
|
CVar* findCVar(std::string name);
|
2015-11-22 04:24:51 +00:00
|
|
|
|
2015-11-22 06:51:25 +00:00
|
|
|
std::vector<CVar*> archivedCVars() const;
|
|
|
|
std::vector<CVar*> cvars() const;
|
2015-11-22 04:24:51 +00:00
|
|
|
|
2015-11-22 06:51:25 +00:00
|
|
|
void deserialize(CVar* cvar);
|
|
|
|
void serialize();
|
2015-11-22 04:24:51 +00:00
|
|
|
private:
|
|
|
|
bool suppressDeveloper();
|
|
|
|
void restoreDeveloper(bool oldDeveloper);
|
|
|
|
|
2015-11-22 06:51:25 +00:00
|
|
|
std::unordered_map<std::string, CVar*> m_cvars;
|
2015-11-22 04:24:51 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CVARMANAGER_HPP
|