2017-01-20 08:36:52 -05:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
class Dvar : public Component
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
class Var
|
|
|
|
{
|
|
|
|
public:
|
2022-08-10 17:03:26 -04:00
|
|
|
Var() : dvar_(nullptr) {}
|
|
|
|
Var(const Var& obj) { this->dvar_ = obj.dvar_; }
|
|
|
|
Var(Game::dvar_t* dvar) : dvar_(dvar) {}
|
2022-05-05 10:03:14 -04:00
|
|
|
Var(DWORD ppdvar) : Var(*reinterpret_cast<Game::dvar_t**>(ppdvar)) {}
|
2018-12-17 08:29:18 -05:00
|
|
|
Var(const std::string& dvarName);
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
template<typename T> T get();
|
|
|
|
|
|
|
|
void set(const char* string);
|
2018-12-17 08:29:18 -05:00
|
|
|
void set(const std::string& string);
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
void set(int integer);
|
|
|
|
void set(float value);
|
2021-08-29 11:41:21 -04:00
|
|
|
void set(bool enabled);
|
2017-01-19 16:23:59 -05:00
|
|
|
|
2021-09-10 05:40:30 -04:00
|
|
|
void setRaw(int integer);
|
|
|
|
void setRaw(float value);
|
|
|
|
void setRaw(bool enabled);
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
private:
|
2022-08-10 17:03:26 -04:00
|
|
|
Game::dvar_t* dvar_;
|
2017-01-19 16:23:59 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
Dvar();
|
|
|
|
|
|
|
|
// Only strings and bools use this type of declaration
|
2022-12-25 12:23:53 -05:00
|
|
|
template<typename T> static Var Register(const char* dvarName, T value, std::uint16_t flag, const char* description);
|
|
|
|
template<typename T> static Var Register(const char* dvarName, T value, T min, T max, std::uint16_t flag, const char* description);
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
private:
|
2022-11-02 09:40:45 -04:00
|
|
|
static Var Name;
|
2017-01-19 16:23:59 -05:00
|
|
|
|
2022-11-02 09:40:45 -04:00
|
|
|
static Game::dvar_t* Dvar_RegisterName(const char* name, const char* defaultVal, std::uint16_t flags, const char* description);
|
2017-02-18 05:39:01 -05:00
|
|
|
|
2022-11-02 09:40:45 -04:00
|
|
|
static void SetFromStringByNameExternal(const char* dvarName, const char* string);
|
|
|
|
static void SetFromStringByNameSafeExternal(const char* dvarName, const char* string);
|
2021-10-03 16:23:26 -04:00
|
|
|
|
2023-01-03 04:23:08 -05:00
|
|
|
static bool AreArchiveDvarsUnprotected();
|
2022-11-02 09:40:45 -04:00
|
|
|
static void DvarSetFromStringByName_Stub(const char* dvarName, const char* value);
|
2022-07-02 13:52:57 -04:00
|
|
|
|
|
|
|
static void OnRegisterVariant(Game::dvar_t* dvar);
|
|
|
|
static void Dvar_RegisterVariant_Stub();
|
2022-11-02 09:40:45 -04:00
|
|
|
|
|
|
|
static const char* Dvar_EnumToString_Stub(const Game::dvar_t* dvar);
|
2017-01-19 16:23:59 -05:00
|
|
|
};
|
|
|
|
}
|