mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- Fixed: Allow string constants in SBarInfo whenever an actor name is required. The only exception is drawing the inventory icon with drawimage since it would be ambiguous, so I would advise using valid identifiers for class names even if it isn't required. Parenthesized syntax is required to use this feature where applicable.
SVN r3677 (trunk)
This commit is contained in:
parent
ab737220f0
commit
9b7e44c026
1 changed files with 170 additions and 144 deletions
|
@ -315,31 +315,35 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
|||
}
|
||||
void Parse(FScanner &sc, bool fullScreenOffsets)
|
||||
{
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(sc.Compare("weaponslot"))
|
||||
{
|
||||
condition = WEAPONSLOT;
|
||||
sc.MustGetToken(TK_IntConst);
|
||||
conditionalValue[0] = sc.Number;
|
||||
}
|
||||
else if(sc.Compare("invulnerable"))
|
||||
{
|
||||
condition = INVULNERABILITY;
|
||||
}
|
||||
else if(sc.Compare("keyslot"))
|
||||
{
|
||||
condition = KEYSLOT;
|
||||
sc.MustGetToken(TK_IntConst);
|
||||
conditionalValue[0] = sc.Number;
|
||||
}
|
||||
else if(sc.Compare("armortype"))
|
||||
{
|
||||
condition = ARMORTYPE;
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
armorType[0] = FName(sc.String).GetIndex();
|
||||
GetOperation(sc, conditionalOperator[0], conditionalValue[0]);
|
||||
if(sc.TokenType == TK_Identifier)
|
||||
{
|
||||
if(sc.Compare("weaponslot"))
|
||||
{
|
||||
condition = WEAPONSLOT;
|
||||
sc.MustGetToken(TK_IntConst);
|
||||
conditionalValue[0] = sc.Number;
|
||||
}
|
||||
else if(sc.Compare("invulnerable"))
|
||||
{
|
||||
condition = INVULNERABILITY;
|
||||
}
|
||||
else if(sc.Compare("keyslot"))
|
||||
{
|
||||
condition = KEYSLOT;
|
||||
sc.MustGetToken(TK_IntConst);
|
||||
conditionalValue[0] = sc.Number;
|
||||
}
|
||||
else if(sc.Compare("armortype"))
|
||||
{
|
||||
condition = ARMORTYPE;
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
armorType[0] = FName(sc.String).GetIndex();
|
||||
GetOperation(sc, conditionalOperator[0], conditionalValue[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
if(condition == INVENTORY)
|
||||
{
|
||||
inventoryItem[0] = sc.String;
|
||||
const PClass* item = PClass::FindClass(sc.String);
|
||||
|
@ -905,119 +909,126 @@ class CommandDrawNumber : public CommandDrawString
|
|||
}
|
||||
else
|
||||
{
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(sc.Compare("health"))
|
||||
value = HEALTH;
|
||||
else if(sc.Compare("armor"))
|
||||
value = ARMOR;
|
||||
else if(sc.Compare("ammo1"))
|
||||
value = AMMO1;
|
||||
else if(sc.Compare("ammo2"))
|
||||
value = AMMO2;
|
||||
else if(sc.Compare("ammo1capacity"))
|
||||
value = AMMO1CAPACITY;
|
||||
else if(sc.Compare("ammo2capacity"))
|
||||
value = AMMO2CAPACITY;
|
||||
else if(sc.Compare("score"))
|
||||
value = SCORE;
|
||||
else if(sc.Compare("ammo")) //request the next string to be an ammo type
|
||||
{
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
value = AMMO;
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
|
||||
value = INVENTORY;
|
||||
if(sc.TokenType == TK_Identifier)
|
||||
{
|
||||
if(sc.Compare("health"))
|
||||
value = HEALTH;
|
||||
else if(sc.Compare("armor"))
|
||||
value = ARMOR;
|
||||
else if(sc.Compare("ammo1"))
|
||||
value = AMMO1;
|
||||
else if(sc.Compare("ammo2"))
|
||||
value = AMMO2;
|
||||
else if(sc.Compare("ammo1capacity"))
|
||||
value = AMMO1CAPACITY;
|
||||
else if(sc.Compare("ammo2capacity"))
|
||||
value = AMMO2CAPACITY;
|
||||
else if(sc.Compare("score"))
|
||||
value = SCORE;
|
||||
else if(sc.Compare("ammo")) //request the next string to be an ammo type
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(AAmmo);
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
value = AMMO;
|
||||
if(!parenthesized || !sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(AAmmo);
|
||||
}
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
}
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
}
|
||||
else if(sc.Compare("ammocapacity"))
|
||||
{
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
value = AMMOCAPACITY;
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
|
||||
else if(sc.Compare("ammocapacity"))
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(AAmmo);
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
value = AMMOCAPACITY;
|
||||
if(!parenthesized || !sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(AAmmo);
|
||||
}
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
}
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
}
|
||||
else if(sc.Compare("frags"))
|
||||
value = FRAGS;
|
||||
else if(sc.Compare("kills"))
|
||||
value = KILLS;
|
||||
else if(sc.Compare("monsters"))
|
||||
value = MONSTERS;
|
||||
else if(sc.Compare("items"))
|
||||
value = ITEMS;
|
||||
else if(sc.Compare("totalitems"))
|
||||
value = TOTALITEMS;
|
||||
else if(sc.Compare("secrets"))
|
||||
value = SECRETS;
|
||||
else if(sc.Compare("totalsecrets"))
|
||||
value = TOTALSECRETS;
|
||||
else if(sc.Compare("armorclass"))
|
||||
value = ARMORCLASS;
|
||||
else if(sc.Compare("savepercent"))
|
||||
value = SAVEPERCENT;
|
||||
else if(sc.Compare("airtime"))
|
||||
value = AIRTIME;
|
||||
else if(sc.Compare("accuracy"))
|
||||
value = ACCURACY;
|
||||
else if(sc.Compare("stamina"))
|
||||
value = STAMINA;
|
||||
else if(sc.Compare("keys"))
|
||||
value = KEYS;
|
||||
else if(sc.Compare("globalvar"))
|
||||
{
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
value = GLOBALVAR;
|
||||
sc.MustGetToken(TK_IntConst);
|
||||
if(sc.Number < 0 || sc.Number >= NUM_GLOBALVARS)
|
||||
sc.ScriptError("Global variable number out of range: %d", sc.Number);
|
||||
valueArgument = sc.Number;
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
}
|
||||
else if(sc.Compare("globalarray")) //acts like variable[playernumber()]
|
||||
{
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
value = GLOBALARRAY;
|
||||
sc.MustGetToken(TK_IntConst);
|
||||
if(sc.Number < 0 || sc.Number >= NUM_GLOBALVARS)
|
||||
sc.ScriptError("Global variable number out of range: %d", sc.Number);
|
||||
valueArgument = sc.Number;
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
}
|
||||
else if(sc.Compare("poweruptime"))
|
||||
{
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
value = POWERUPTIME;
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(inventoryItem))
|
||||
else if(sc.Compare("frags"))
|
||||
value = FRAGS;
|
||||
else if(sc.Compare("kills"))
|
||||
value = KILLS;
|
||||
else if(sc.Compare("monsters"))
|
||||
value = MONSTERS;
|
||||
else if(sc.Compare("items"))
|
||||
value = ITEMS;
|
||||
else if(sc.Compare("totalitems"))
|
||||
value = TOTALITEMS;
|
||||
else if(sc.Compare("secrets"))
|
||||
value = SECRETS;
|
||||
else if(sc.Compare("totalsecrets"))
|
||||
value = TOTALSECRETS;
|
||||
else if(sc.Compare("armorclass"))
|
||||
value = ARMORCLASS;
|
||||
else if(sc.Compare("savepercent"))
|
||||
value = SAVEPERCENT;
|
||||
else if(sc.Compare("airtime"))
|
||||
value = AIRTIME;
|
||||
else if(sc.Compare("accuracy"))
|
||||
value = ACCURACY;
|
||||
else if(sc.Compare("stamina"))
|
||||
value = STAMINA;
|
||||
else if(sc.Compare("keys"))
|
||||
value = KEYS;
|
||||
else if(sc.Compare("globalvar"))
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(APowerupGiver);
|
||||
}
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
value = GLOBALVAR;
|
||||
sc.MustGetToken(TK_IntConst);
|
||||
if(sc.Number < 0 || sc.Number >= NUM_GLOBALVARS)
|
||||
sc.ScriptError("Global variable number out of range: %d", sc.Number);
|
||||
valueArgument = sc.Number;
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
}
|
||||
else if(sc.Compare("globalarray")) //acts like variable[playernumber()]
|
||||
{
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
value = GLOBALARRAY;
|
||||
sc.MustGetToken(TK_IntConst);
|
||||
if(sc.Number < 0 || sc.Number >= NUM_GLOBALVARS)
|
||||
sc.ScriptError("Global variable number out of range: %d", sc.Number);
|
||||
valueArgument = sc.Number;
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
}
|
||||
else if(sc.Compare("poweruptime"))
|
||||
{
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
value = POWERUPTIME;
|
||||
if(!parenthesized || !sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(inventoryItem))
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(APowerupGiver);
|
||||
}
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
}
|
||||
}
|
||||
else
|
||||
if(value == INVENTORY)
|
||||
{
|
||||
value = INVENTORY;
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
|
||||
{
|
||||
|
@ -2369,7 +2380,8 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
{
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(!parenthesized || !sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
type = AMMO;
|
||||
data.inventoryItem = PClass::FindClass(sc.String);
|
||||
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(data.inventoryItem)) //must be a kind of ammo
|
||||
|
@ -2394,14 +2406,19 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
type = SAVEPERCENT;
|
||||
else if(sc.Compare("poweruptime"))
|
||||
{
|
||||
bool parenthesized = sc.CheckToken('(');
|
||||
|
||||
type = POWERUPTIME;
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(!parenthesized || !sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
data.inventoryItem = PClass::FindClass(sc.String);
|
||||
if(data.inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(data.inventoryItem))
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of PowerupGiver.", sc.String);
|
||||
data.inventoryItem = RUNTIME_CLASS(APowerupGiver);
|
||||
}
|
||||
|
||||
if(parenthesized) sc.MustGetToken(')');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2619,7 +2636,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
{
|
||||
bool extendedSyntax = sc.CheckToken('(');
|
||||
|
||||
if(sc.CheckToken(TK_Identifier)) //comparing reference
|
||||
if(sc.CheckToken(TK_Identifier) || (extendedSyntax && sc.CheckToken(TK_StringConst))) //comparing reference
|
||||
{
|
||||
data.inventoryItem = PClass::FindClass(sc.String);
|
||||
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(data.inventoryItem)) //must be a kind of inventory
|
||||
|
@ -2700,7 +2717,6 @@ class CommandIsSelected : public SBarInfoCommandFlowControl
|
|||
|
||||
void Parse(FScanner &sc, bool fullScreenOffsets)
|
||||
{
|
||||
//Using StringConst instead of Identifieres is deperecated!
|
||||
if(sc.CheckToken(TK_Identifier))
|
||||
{
|
||||
if(sc.Compare("not"))
|
||||
|
@ -2817,7 +2833,8 @@ class CommandPlayerType : public SBarInfoCommandFlowControl
|
|||
|
||||
void Parse(FScanner &sc, bool fullScreenOffsets)
|
||||
{
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
do
|
||||
{
|
||||
bool foundClass = false;
|
||||
|
@ -2834,7 +2851,7 @@ class CommandPlayerType : public SBarInfoCommandFlowControl
|
|||
if(!sc.CheckToken(','))
|
||||
break;
|
||||
}
|
||||
while(sc.CheckToken(TK_Identifier));
|
||||
while(sc.CheckToken(TK_Identifier) || sc.CheckToken(TK_StringConst));
|
||||
SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets);
|
||||
}
|
||||
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
||||
|
@ -2870,7 +2887,8 @@ class CommandHasWeaponPiece : public SBarInfoCommandFlowControl
|
|||
|
||||
void Parse(FScanner &sc, bool fullScreenOffsets)
|
||||
{
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
weapon = PClass::FindClass(sc.String);
|
||||
if(weapon == NULL || !RUNTIME_CLASS(AWeapon)->IsAncestorOf(weapon)) //must be a weapon
|
||||
{
|
||||
|
@ -3055,11 +3073,13 @@ class CommandWeaponAmmo : public SBarInfoCommandFlowControl
|
|||
|
||||
void Parse(FScanner &sc, bool fullScreenOffsets)
|
||||
{
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(sc.Compare("not"))
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(sc.Compare("not") && sc.TokenType == TK_Identifier)
|
||||
{
|
||||
negate = true;
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
}
|
||||
for(int i = 0;i < 2;i++)
|
||||
{
|
||||
|
@ -3073,12 +3093,14 @@ class CommandWeaponAmmo : public SBarInfoCommandFlowControl
|
|||
if(sc.CheckToken(TK_OrOr))
|
||||
{
|
||||
conditionAnd = false;
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
}
|
||||
else if(sc.CheckToken(TK_AndAnd))
|
||||
{
|
||||
conditionAnd = true;
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
@ -3158,11 +3180,13 @@ class CommandInInventory : public SBarInfoCommandFlowControl
|
|||
|
||||
void Parse(FScanner &sc, bool fullScreenOffsets)
|
||||
{
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(sc.Compare("not"))
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(sc.Compare("not") && sc.TokenType == TK_Identifier)
|
||||
{
|
||||
negate = true;
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
}
|
||||
for(int i = 0;i < 2;i++)
|
||||
{
|
||||
|
@ -3182,12 +3206,14 @@ class CommandInInventory : public SBarInfoCommandFlowControl
|
|||
if(sc.CheckToken(TK_OrOr))
|
||||
{
|
||||
conditionAnd = false;
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
}
|
||||
else if(sc.CheckToken(TK_AndAnd))
|
||||
{
|
||||
conditionAnd = true;
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
if(!sc.CheckToken(TK_StringConst))
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue