mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-13 07:57:51 +00:00
Add FBaseCVar::GetHumanString()
- For most cvars, this is equivalent to calling GetGenericRep() to get a string. - For float cvars, it uses %g instead of %H, because %H is generally more information than is needed.
This commit is contained in:
parent
fc54dd1ff0
commit
e96ed6bf8d
5 changed files with 24 additions and 9 deletions
|
@ -132,6 +132,11 @@ FBaseCVar::~FBaseCVar ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *FBaseCVar::GetHumanString(int precision) const
|
||||||
|
{
|
||||||
|
return GetGenericRep(CVAR_String).String;
|
||||||
|
}
|
||||||
|
|
||||||
void FBaseCVar::ForceSet (UCVarValue value, ECVarType type, bool nouserinfosend)
|
void FBaseCVar::ForceSet (UCVarValue value, ECVarType type, bool nouserinfosend)
|
||||||
{
|
{
|
||||||
DoSet (value, type);
|
DoSet (value, type);
|
||||||
|
@ -750,6 +755,16 @@ ECVarType FFloatCVar::GetRealType () const
|
||||||
return CVAR_Float;
|
return CVAR_Float;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *FFloatCVar::GetHumanString(int precision) const
|
||||||
|
{
|
||||||
|
if (precision < 0)
|
||||||
|
{
|
||||||
|
precision = 6;
|
||||||
|
}
|
||||||
|
mysnprintf(cstrbuf, countof(cstrbuf), "%.*g", precision, Value);
|
||||||
|
return cstrbuf;
|
||||||
|
}
|
||||||
|
|
||||||
UCVarValue FFloatCVar::GetGenericRep (ECVarType type) const
|
UCVarValue FFloatCVar::GetGenericRep (ECVarType type) const
|
||||||
{
|
{
|
||||||
return FromFloat (Value, type);
|
return FromFloat (Value, type);
|
||||||
|
@ -1675,7 +1690,7 @@ void FBaseCVar::ListVars (const char *filter, bool plain)
|
||||||
if (!(flags & CVAR_UNSETTABLE))
|
if (!(flags & CVAR_UNSETTABLE))
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
Printf ("%s : %s\n", var->GetName(), var->GetGenericRep(CVAR_String).String);
|
Printf ("%s : %s\n", var->GetName(), var->GetHumanString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1692,7 +1707,7 @@ void FBaseCVar::ListVars (const char *filter, bool plain)
|
||||||
flags & CVAR_MOD ? 'M' : ' ',
|
flags & CVAR_MOD ? 'M' : ' ',
|
||||||
flags & CVAR_IGNORE ? 'X' : ' ',
|
flags & CVAR_IGNORE ? 'X' : ' ',
|
||||||
var->GetName(),
|
var->GetName(),
|
||||||
var->GetGenericRep(CVAR_String).String);
|
var->GetHumanString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var = var->m_Next;
|
var = var->m_Next;
|
||||||
|
|
|
@ -108,6 +108,7 @@ public:
|
||||||
|
|
||||||
virtual ECVarType GetRealType () const = 0;
|
virtual ECVarType GetRealType () const = 0;
|
||||||
|
|
||||||
|
virtual const char *GetHumanString(int precision=-1) const;
|
||||||
virtual UCVarValue GetGenericRep (ECVarType type) const = 0;
|
virtual UCVarValue GetGenericRep (ECVarType type) const = 0;
|
||||||
virtual UCVarValue GetFavoriteRep (ECVarType *type) const = 0;
|
virtual UCVarValue GetFavoriteRep (ECVarType *type) const = 0;
|
||||||
|
|
||||||
|
@ -268,6 +269,7 @@ public:
|
||||||
virtual UCVarValue GetGenericRepDefault (ECVarType type) const;
|
virtual UCVarValue GetGenericRepDefault (ECVarType type) const;
|
||||||
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const;
|
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const;
|
||||||
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
|
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
|
||||||
|
const char *GetHumanString(int precision) const override;
|
||||||
|
|
||||||
float operator= (float floatval)
|
float operator= (float floatval)
|
||||||
{ UCVarValue val; val.Float = floatval; SetGenericRep (val, CVAR_Float); return floatval; }
|
{ UCVarValue val; val.Float = floatval; SetGenericRep (val, CVAR_Float); return floatval; }
|
||||||
|
|
|
@ -651,8 +651,7 @@ void C_DoCommand (const char *cmd, int keynum)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Get the variable's value
|
{ // Get the variable's value
|
||||||
UCVarValue val = var->GetGenericRep (CVAR_String);
|
Printf ("\"%s\" is \"%s\"\n", var->GetName(), var->GetHumanString());
|
||||||
Printf ("\"%s\" is \"%s\"\n", var->GetName(), val.String);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -993,8 +993,7 @@ CCMD (playerinfo)
|
||||||
if (pair->Key != NAME_Name && pair->Key != NAME_Team && pair->Key != NAME_Skin &&
|
if (pair->Key != NAME_Name && pair->Key != NAME_Team && pair->Key != NAME_Skin &&
|
||||||
pair->Key != NAME_Gender && pair->Key != NAME_PlayerClass)
|
pair->Key != NAME_Gender && pair->Key != NAME_PlayerClass)
|
||||||
{
|
{
|
||||||
UCVarValue val = pair->Value->GetGenericRep(CVAR_String);
|
Printf("%20s: %s\n", pair->Key.GetChars(), pair->Value->GetHumanString());
|
||||||
Printf("%20s: %s\n", pair->Key.GetChars(), val.String);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (argv.argc() > 2)
|
if (argv.argc() > 2)
|
||||||
|
|
|
@ -295,10 +295,10 @@ public:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UCVarValue cv = mCVar->GetGenericRep(CVAR_String);
|
const char *cv = mCVar->GetHumanString();
|
||||||
for(unsigned i = 0; i < (*opt)->mValues.Size(); i++)
|
for(unsigned i = 0; i < (*opt)->mValues.Size(); i++)
|
||||||
{
|
{
|
||||||
if ((*opt)->mValues[i].TextValue.CompareNoCase(cv.String) == 0)
|
if ((*opt)->mValues[i].TextValue.CompareNoCase(cv) == 0)
|
||||||
{
|
{
|
||||||
Selection = i;
|
Selection = i;
|
||||||
break;
|
break;
|
||||||
|
@ -995,7 +995,7 @@ public:
|
||||||
if ( mCVar == NULL )
|
if ( mCVar == NULL )
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
return mCVar->GetGenericRep( CVAR_String ).String;
|
return mCVar->GetHumanString();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual FString Represent()
|
virtual FString Represent()
|
||||||
|
|
Loading…
Reference in a new issue