mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
Added INTCVAR to DrawNumber.
- Allows retrieval and displaying of an int/bool user/server cvar.
This commit is contained in:
parent
e84a7de390
commit
1620ff58c8
1 changed files with 52 additions and 1 deletions
|
@ -1021,7 +1021,7 @@ class CommandDrawNumber : public CommandDrawString
|
||||||
usePrefix(false), interpolationSpeed(0), drawValue(0), length(3),
|
usePrefix(false), interpolationSpeed(0), drawValue(0), length(3),
|
||||||
lowValue(-1), lowTranslation(CR_UNTRANSLATED), highValue(-1),
|
lowValue(-1), lowTranslation(CR_UNTRANSLATED), highValue(-1),
|
||||||
highTranslation(CR_UNTRANSLATED), value(CONSTANT),
|
highTranslation(CR_UNTRANSLATED), value(CONSTANT),
|
||||||
inventoryItem(NULL)
|
inventoryItem(NULL), cvarName(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1166,6 +1166,37 @@ class CommandDrawNumber : public CommandDrawString
|
||||||
|
|
||||||
if(parenthesized) sc.MustGetToken(')');
|
if(parenthesized) sc.MustGetToken(')');
|
||||||
}
|
}
|
||||||
|
else if (sc.Compare("intcvar"))
|
||||||
|
{
|
||||||
|
bool parenthesized = sc.CheckToken('(');
|
||||||
|
|
||||||
|
value = INTCVAR;
|
||||||
|
|
||||||
|
if (!parenthesized || !sc.CheckToken(TK_StringConst))
|
||||||
|
sc.MustGetToken(TK_Identifier);
|
||||||
|
|
||||||
|
cvarName = sc.String;
|
||||||
|
|
||||||
|
// We have a name, but make sure it exists. If not, send notification so modders
|
||||||
|
// are aware of the situation.
|
||||||
|
FBaseCVar *CVar = FindCVar(cvarName, nullptr);
|
||||||
|
|
||||||
|
if (CVar != nullptr)
|
||||||
|
{
|
||||||
|
ECVarType cvartype = CVar->GetRealType();
|
||||||
|
|
||||||
|
if (!(cvartype == CVAR_Bool || cvartype == CVAR_Int))
|
||||||
|
{
|
||||||
|
sc.ScriptMessage("CVar '%s' is not an int or bool", cvarName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sc.ScriptMessage("CVar '%s' does not exist", cvarName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parenthesized) sc.MustGetToken(')');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(value == INVENTORY)
|
if(value == INVENTORY)
|
||||||
{
|
{
|
||||||
|
@ -1444,6 +1475,24 @@ class CommandDrawNumber : public CommandDrawString
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case INTCVAR:
|
||||||
|
{
|
||||||
|
FBaseCVar *CVar = GetCVar(statusBar->CPlayer->mo, cvarName);
|
||||||
|
if (CVar != nullptr)
|
||||||
|
{
|
||||||
|
ECVarType cvartype = CVar->GetRealType();
|
||||||
|
|
||||||
|
if (cvartype == CVAR_Bool || cvartype == CVAR_Int)
|
||||||
|
{
|
||||||
|
num = CVar->GetGenericRep(CVAR_Int).Int;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback in case of bad cvar/type. Unset can remove a cvar at will.
|
||||||
|
num = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
if(interpolationSpeed != 0 && (!hudChanged || level.time == 1))
|
if(interpolationSpeed != 0 && (!hudChanged || level.time == 1))
|
||||||
|
@ -1522,6 +1571,7 @@ class CommandDrawNumber : public CommandDrawString
|
||||||
ACCURACY,
|
ACCURACY,
|
||||||
STAMINA,
|
STAMINA,
|
||||||
KEYS,
|
KEYS,
|
||||||
|
INTCVAR,
|
||||||
|
|
||||||
CONSTANT
|
CONSTANT
|
||||||
};
|
};
|
||||||
|
@ -1544,6 +1594,7 @@ class CommandDrawNumber : public CommandDrawString
|
||||||
PClassActor *inventoryItem;
|
PClassActor *inventoryItem;
|
||||||
|
|
||||||
FString prefixPadding;
|
FString prefixPadding;
|
||||||
|
FString cvarName;
|
||||||
|
|
||||||
friend class CommandDrawInventoryBar;
|
friend class CommandDrawInventoryBar;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue