Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default cvar getters #2950

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/common/scripting/interface/vmnatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,27 @@ DEFINE_ACTION_FUNCTION(_CVar, GetString)
ACTION_RETURN_STRING(v.String);
}

DEFINE_ACTION_FUNCTION(_CVar, GetDefaultInt)
{
PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar);
auto v = self->GetGenericRepDefault(CVAR_Int);
ACTION_RETURN_INT(v.Int);
}

DEFINE_ACTION_FUNCTION(_CVar, GetDefaultFloat)
{
PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar);
auto v = self->GetGenericRepDefault(CVAR_Float);
ACTION_RETURN_FLOAT(v.Float);
}

DEFINE_ACTION_FUNCTION(_CVar, GetDefaultString)
{
PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar);
auto v = self->GetGenericRepDefault(CVAR_String);
ACTION_RETURN_STRING(v.String);
}

DEFINE_ACTION_FUNCTION(_CVar, SetInt)
{
// Only menus are allowed to change CVARs.
Expand Down
4 changes: 4 additions & 0 deletions wadsrc/static/zscript/engine/base.zs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ struct CVar native
native int GetInt();
native double GetFloat();
native String GetString();
bool GetDefaultBool() { return GetDefaultInt(); }
native int GetDefaultInt();
native double GetDefaultFloat();
native String GetDefaultString();
void SetBool(bool b) { SetInt(b); }
native void SetInt(int v);
native void SetFloat(double v);
Expand Down