mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 23:32:04 +00:00
Merge branch 'master' of https://github.com/rheit/zdoom
This commit is contained in:
commit
4eda5f841e
1 changed files with 75 additions and 2 deletions
|
@ -3464,6 +3464,78 @@ class CommandIfWaterLevel : public SBarInfoNegatableFlowControl
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CommandIfCVarInt : public SBarInfoNegatableFlowControl
|
||||
{
|
||||
public:
|
||||
CommandIfCVarInt(SBarInfo *script) : SBarInfoNegatableFlowControl(script),
|
||||
equalcomp(false)
|
||||
{
|
||||
}
|
||||
|
||||
void ParseNegatable(FScanner &sc, bool fullScreenOffsets)
|
||||
{
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
{
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
}
|
||||
|
||||
cvarname = sc.String;
|
||||
cvar = FindCVar(cvarname, nullptr);
|
||||
|
||||
if (cvar != nullptr)
|
||||
{
|
||||
ECVarType cvartype = cvar->GetRealType();
|
||||
|
||||
if (cvartype == CVAR_Bool || cvartype == CVAR_Int)
|
||||
{
|
||||
sc.MustGetToken(',');
|
||||
sc.MustGetToken(TK_IntConst);
|
||||
value = sc.Number;
|
||||
|
||||
if (sc.CheckToken(','))
|
||||
{
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
|
||||
if(sc.Compare("equal"))
|
||||
{
|
||||
equalcomp = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.ScriptError("Type mismatch: console variable '%s' is not of type 'bool' or 'int'.", cvarname);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.ScriptError("Unknown console variable '%s'.", cvarname);
|
||||
}
|
||||
}
|
||||
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
||||
{
|
||||
SBarInfoNegatableFlowControl::Tick(block, statusBar, hudChanged);
|
||||
|
||||
bool result = false;
|
||||
cvar = GetCVar(statusBar->CPlayer->mo, cvarname);
|
||||
|
||||
if (cvar != nullptr)
|
||||
{
|
||||
int cvarvalue = cvar->GetGenericRep(CVAR_Int).Int;
|
||||
result = equalcomp ? cvarvalue == value : cvarvalue >= value;
|
||||
}
|
||||
|
||||
SetTruth(result, block, statusBar);
|
||||
}
|
||||
protected:
|
||||
FString cvarname;
|
||||
FBaseCVar *cvar;
|
||||
int value;
|
||||
bool equalcomp;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const char *SBarInfoCommandNames[] =
|
||||
{
|
||||
"drawimage", "drawnumber", "drawswitchableimage",
|
||||
|
@ -3474,7 +3546,7 @@ static const char *SBarInfoCommandNames[] =
|
|||
"isselected", "usesammo", "usessecondaryammo",
|
||||
"hasweaponpiece", "inventorybarnotvisible",
|
||||
"weaponammo", "ininventory", "alpha", "ifhealth",
|
||||
"ifinvulnerable", "ifwaterlevel",
|
||||
"ifinvulnerable", "ifwaterlevel", "ifcvarint",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -3488,7 +3560,7 @@ enum SBarInfoCommands
|
|||
SBARINFO_ISSELECTED, SBARINFO_USESAMMO, SBARINFO_USESSECONDARYAMMO,
|
||||
SBARINFO_HASWEAPONPIECE, SBARINFO_INVENTORYBARNOTVISIBLE,
|
||||
SBARINFO_WEAPONAMMO, SBARINFO_ININVENTORY, SBARINFO_ALPHA, SBARINFO_IFHEALTH,
|
||||
SBARINFO_IFINVULNERABLE, SBARINFO_IFWATERLEVEL,
|
||||
SBARINFO_IFINVULNERABLE, SBARINFO_IFWATERLEVEL, SBARINFO_IFCVARINT,
|
||||
};
|
||||
|
||||
SBarInfoCommand *SBarInfoCommandFlowControl::NextCommand(FScanner &sc)
|
||||
|
@ -3524,6 +3596,7 @@ SBarInfoCommand *SBarInfoCommandFlowControl::NextCommand(FScanner &sc)
|
|||
case SBARINFO_IFHEALTH: return new CommandIfHealth(script);
|
||||
case SBARINFO_IFINVULNERABLE: return new CommandIfInvulnerable(script);
|
||||
case SBARINFO_IFWATERLEVEL: return new CommandIfWaterLevel(script);
|
||||
case SBARINFO_IFCVARINT: return new CommandIfCVarInt(script);
|
||||
}
|
||||
|
||||
sc.ScriptError("Unknown command '%s'.\n", sc.String);
|
||||
|
|
Loading…
Reference in a new issue