#pragma once namespace Components { class Dvar : public Component { public: class Flag { public: Flag(Game::dvar_flag flag) : val(flag) {}; Flag(int flag) : Flag(static_cast(flag)) {}; Game::dvar_flag val; }; class Var { public: Var() : dvar(nullptr) {}; Var(const Var& obj) { this->dvar = obj.dvar; this->dvarName = obj.dvarName; }; Var(Game::dvar_t* _dvar) : dvar(_dvar), dvarName(_dvar->name) {}; Var(DWORD ppdvar) : Var(*reinterpret_cast(ppdvar)) {}; Var(const std::string& dvarName); void registerDvar(); template T get(); void set(const char* string); void set(const std::string& string); void set(int integer); void set(float value); void set(bool enabled); void setRaw(int integer); void setRaw(float value); void setRaw(bool enabled); private: std::string dvarName; Game::dvar_t* dvar; }; Dvar(); ~Dvar(); static void OnInit(Utils::Slot callback); // Only strings and bools use this type of declaration template static Var Register(const char* name, T value, Flag flag, const char* description); template static Var Register(const char* name, T value, T min, T max, Flag flag, const char* description); static void ResetDvarsValue(); private: static Utils::Signal RegistrationSignal; static const char* ArchiveDvarPath; static Game::dvar_t* RegisterName(const char* name, const char* defaultVal, Game::dvar_flag flag, const char* description); static void SetFromStringByNameExternal(const char* dvar, const char* value); static void SetFromStringByNameSafeExternal(const char* dvar, const char* value); static void SaveArchiveDvar(const Game::dvar_t* var); static void DvarSetFromStringByNameStub(const char* dvarName, const char* value); }; }