Show CVar's default value in addition to current

This commit is contained in:
Nikolay Ambartsumov 2020-10-03 06:26:55 +03:00 committed by Christoph Oelckers
parent 9fbfee3b2d
commit da97b51c35
3 changed files with 19 additions and 2 deletions

View file

@ -150,6 +150,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);
@ -653,6 +658,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

@ -161,6 +161,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;
@ -339,6 +340,7 @@ public:
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const override;
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type) override;
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

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