Show CVar's default value in addition to current

# Conflicts:
#	src/c_dispatch.cpp
This commit is contained in:
Nikolay Ambartsumov 2020-10-03 06:26:55 +03:00 committed by drfrag
parent 13a324dc7f
commit 493cc9af0d
3 changed files with 19 additions and 2 deletions

View file

@ -154,6 +154,11 @@ const char *FBaseCVar::GetHumanString(int precision) const
return GetGenericRep(CVAR_String).String;
}
const char *FBaseCVar::GetHumanStringDefault(int precision) const
{
return GetGenericRepDefault(CVAR_String).String;
}
void FBaseCVar::ForceSet (UCVarValue value, ECVarType type, bool nouserinfosend)
{
DoSet (value, type);
@ -874,6 +879,16 @@ const char *FFloatCVar::GetHumanString(int precision) const
return cstrbuf;
}
const char *FFloatCVar::GetHumanStringDefault(int precision) const
{
if (precision < 0)
{
precision = 6;
}
mysnprintf(cstrbuf, countof(cstrbuf), "%.*g", precision, DefaultValue);
return cstrbuf;
}
UCVarValue FFloatCVar::GetGenericRep (ECVarType type) const
{
return FromFloat (Value, type);

View file

@ -132,6 +132,7 @@ public:
virtual UCVarValue GetGenericRep (ECVarType type) const = 0;
virtual UCVarValue GetFavoriteRep (ECVarType *type) const = 0;
virtual const char *GetHumanStringDefault(int precision = -1) const;
virtual UCVarValue GetGenericRepDefault (ECVarType type) const = 0;
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const = 0;
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type) = 0;
@ -301,6 +302,7 @@ public:
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const;
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
const char *GetHumanString(int precision) const override;
const char *GetHumanStringDefault(int precision) const override;
float operator= (float floatval)
{ UCVarValue val; val.Float = floatval; SetGenericRep (val, CVAR_Float); return floatval; }

View file

@ -672,7 +672,8 @@ void C_DoCommand (const char *cmd, int keynum)
}
else
{ // Get the variable's value
Printf ("\"%s\" is \"%s\"\n", var->GetName(), var->GetHumanString());
Printf ("\"%s\" is \"%s\" ", var->GetName(), var->GetHumanString());
Printf ("(default: \"%s\")\n", var->GetHumanStringDefault());
}
}
else
@ -1681,4 +1682,3 @@ CCMD (pullin)
Printf (TEXTCOLOR_BOLD "Pullin" TEXTCOLOR_NORMAL " is only valid from .cfg\n"
"files and only when used at startup.\n");
}