- added boolean CVar ZScript commands contributed by Nero: https://forum.zdoom.org/viewtopic.php?f=15&t=58050

This commit is contained in:
Rachael Alexanderson 2017-10-16 03:37:10 -04:00
parent 4f5b459703
commit 9d458c73df
2 changed files with 22 additions and 0 deletions

View file

@ -183,6 +183,14 @@ void FBaseCVar::SetGenericRep (UCVarValue value, ECVarType type)
}
}
// ADDED BY NERO
DEFINE_ACTION_FUNCTION(_CVar, GetBool)
{
PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar);
auto v = self->GetGenericRep(CVAR_Bool);
ACTION_RETURN_BOOL(v.Bool);
}
DEFINE_ACTION_FUNCTION(_CVar, GetInt)
{
PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar);
@ -204,6 +212,18 @@ DEFINE_ACTION_FUNCTION(_CVar, GetString)
ACTION_RETURN_STRING(v.String);
}
//ADDED BY NERO
DEFINE_ACTION_FUNCTION(_CVar, SetBool)
{
PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar);
if (!(self->GetFlags() & CVAR_MOD) && CurrentMenu == nullptr) return 0;
PARAM_BOOL(val);
UCVarValue v;
v.Bool = val;
self->SetGenericRep(v, CVAR_Bool);
return 0;
}
DEFINE_ACTION_FUNCTION(_CVar, SetInt)
{
// Only menus are allowed to change CVARs.

View file

@ -301,9 +301,11 @@ struct CVar native
native static CVar FindCVar(Name name);
native static CVar GetCVar(Name name, PlayerInfo player = null);
native bool GetBool();
native int GetInt();
native double GetFloat();
native String GetString();
native void SetBool(bool b);
native void SetInt(int v);
native void SetFloat(double v);
native void SetString(String s);