Reintroduce setRaw dvar methods
- Makes it possible to set the value of a dvar without using the game's way of first converting it to a string and checking all kinds of dvar flags
This commit is contained in:
parent
e8185a27b9
commit
cc39a7bbe5
@ -134,6 +134,36 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
void Dvar::Var::setRaw(int integer)
|
||||
{
|
||||
assert(this->dvar->type == Game::DVAR_TYPE_INT);
|
||||
if (this->dvar)
|
||||
{
|
||||
this->dvar->current.integer = integer;
|
||||
this->dvar->latched.integer = integer;
|
||||
}
|
||||
}
|
||||
|
||||
void Dvar::Var::setRaw(float value)
|
||||
{
|
||||
assert(this->dvar->type == Game::DVAR_TYPE_FLOAT);
|
||||
if (this->dvar)
|
||||
{
|
||||
this->dvar->current.value = value;
|
||||
this->dvar->latched.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
void Dvar::Var::setRaw(bool enabled)
|
||||
{
|
||||
assert(this->dvar->type == Game::DVAR_TYPE_BOOL);
|
||||
if (this->dvar)
|
||||
{
|
||||
this->dvar->current.enabled = enabled;
|
||||
this->dvar->latched.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
template<> static Dvar::Var Dvar::Register(const char* name, bool value, Dvar::Flag flag, const char* description)
|
||||
{
|
||||
return Game::Dvar_RegisterBool(name, value, flag.val, description);
|
||||
|
@ -33,6 +33,10 @@ namespace Components
|
||||
void set(float value);
|
||||
void set(bool enabled);
|
||||
|
||||
void setRaw(int integer);
|
||||
void setRaw(float value);
|
||||
void setRaw(bool enabled);
|
||||
|
||||
private:
|
||||
Game::dvar_t* dvar;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user