mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- Added ability to use a constant for the maximum comparator for health and armor drawbars.
SVN r3360 (trunk)
This commit is contained in:
parent
9ffb4c40ac
commit
25b73ac023
1 changed files with 63 additions and 37 deletions
|
@ -2235,8 +2235,8 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
{
|
||||
public:
|
||||
CommandDrawBar(SBarInfo *script) : SBarInfoCommand(script),
|
||||
border(0), horizontal(false), reverse(false), foreground(-1), background(-1),
|
||||
type(HEALTH), inventoryItem(NULL), interpolationSpeed(0), drawValue(0)
|
||||
border(0), horizontal(false), reverse(false), foreground(-1),
|
||||
background(-1), type(HEALTH), interpolationSpeed(0), drawValue(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -2297,28 +2297,12 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
if(sc.Compare("health"))
|
||||
{
|
||||
type = HEALTH;
|
||||
if(sc.CheckToken(TK_Identifier)) //comparing reference
|
||||
{
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem)) //must be a kind of inventory
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(AInventory);
|
||||
}
|
||||
}
|
||||
ParseComparator(sc);
|
||||
}
|
||||
else if(sc.Compare("armor"))
|
||||
{
|
||||
type = ARMOR;
|
||||
if(sc.CheckToken(TK_Identifier))
|
||||
{
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem)) //must be a kind of inventory
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(AInventory);
|
||||
}
|
||||
}
|
||||
ParseComparator(sc);
|
||||
}
|
||||
else if(sc.Compare("ammo1"))
|
||||
type = AMMO1;
|
||||
|
@ -2328,11 +2312,11 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
{
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
type = AMMO;
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(inventoryItem)) //must be a kind of ammo
|
||||
data.inventoryItem = PClass::FindClass(sc.String);
|
||||
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AAmmo)->IsAncestorOf(data.inventoryItem)) //must be a kind of ammo
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of ammo.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(AAmmo);
|
||||
data.inventoryItem = RUNTIME_CLASS(AAmmo);
|
||||
}
|
||||
}
|
||||
else if(sc.Compare("frags"))
|
||||
|
@ -2351,21 +2335,21 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
{
|
||||
type = POWERUPTIME;
|
||||
sc.MustGetToken(TK_Identifier);
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(APowerupGiver)->IsAncestorOf(inventoryItem))
|
||||
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);
|
||||
inventoryItem = RUNTIME_CLASS(APowerupGiver);
|
||||
data.inventoryItem = RUNTIME_CLASS(APowerupGiver);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
type = INVENTORY;
|
||||
inventoryItem = PClass::FindClass(sc.String);
|
||||
if(inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(inventoryItem))
|
||||
data.inventoryItem = PClass::FindClass(sc.String);
|
||||
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(data.inventoryItem))
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
|
||||
inventoryItem = RUNTIME_CLASS(AInventory);
|
||||
data.inventoryItem = RUNTIME_CLASS(AInventory);
|
||||
}
|
||||
}
|
||||
sc.MustGetToken(',');
|
||||
|
@ -2423,9 +2407,11 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
if(value < 0) //health shouldn't display negatives
|
||||
value = 0;
|
||||
|
||||
if(inventoryItem != NULL)
|
||||
if(data.useMaximumConstant)
|
||||
max = data.value;
|
||||
else if(data.inventoryItem != NULL)
|
||||
{
|
||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(inventoryItem); //max comparer
|
||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem); //max comparer
|
||||
if(item != NULL)
|
||||
max = item->Amount;
|
||||
else
|
||||
|
@ -2436,9 +2422,11 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
break;
|
||||
case ARMOR:
|
||||
value = statusBar->armor != NULL ? statusBar->armor->Amount : 0;
|
||||
if(inventoryItem != NULL)
|
||||
if(data.useMaximumConstant)
|
||||
max = data.value;
|
||||
else if(data.inventoryItem != NULL)
|
||||
{
|
||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(inventoryItem);
|
||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
||||
if(item != NULL)
|
||||
max = item->Amount;
|
||||
else
|
||||
|
@ -2469,7 +2457,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
break;
|
||||
case AMMO:
|
||||
{
|
||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(inventoryItem);
|
||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
||||
if(item != NULL)
|
||||
{
|
||||
value = item->Amount;
|
||||
|
@ -2497,7 +2485,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
break;
|
||||
case INVENTORY:
|
||||
{
|
||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(inventoryItem);
|
||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
||||
if(item != NULL)
|
||||
{
|
||||
value = item->Amount;
|
||||
|
@ -2514,7 +2502,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
case POWERUPTIME:
|
||||
{
|
||||
//Get the PowerupType and check to see if the player has any in inventory.
|
||||
APowerupGiver *powerupGiver = (APowerupGiver*) GetDefaultByType(inventoryItem);
|
||||
APowerupGiver *powerupGiver = (APowerupGiver*) GetDefaultByType(data.inventoryItem);
|
||||
const PClass *powerupType = powerupGiver->PowerupType;
|
||||
APowerup *powerup = (APowerup*) statusBar->CPlayer->mo->FindInventory(powerupType);
|
||||
if(powerup != NULL && powerupType != NULL && powerupGiver != NULL)
|
||||
|
@ -2566,6 +2554,29 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
drawValue = value;
|
||||
}
|
||||
protected:
|
||||
void ParseComparator(FScanner &sc)
|
||||
{
|
||||
bool extendedSyntax = sc.CheckToken('(');
|
||||
|
||||
if(sc.CheckToken(TK_Identifier)) //comparing reference
|
||||
{
|
||||
data.inventoryItem = PClass::FindClass(sc.String);
|
||||
if(data.inventoryItem == NULL || !RUNTIME_CLASS(AInventory)->IsAncestorOf(data.inventoryItem)) //must be a kind of inventory
|
||||
{
|
||||
sc.ScriptMessage("'%s' is not a type of inventory item.", sc.String);
|
||||
data.inventoryItem = RUNTIME_CLASS(AInventory);
|
||||
}
|
||||
}
|
||||
else if(extendedSyntax && sc.CheckToken(TK_IntConst))
|
||||
{
|
||||
data.useMaximumConstant = true;
|
||||
data.value = sc.Number;
|
||||
}
|
||||
|
||||
if(extendedSyntax)
|
||||
sc.MustGetToken(')');
|
||||
}
|
||||
|
||||
enum ValueType
|
||||
{
|
||||
HEALTH,
|
||||
|
@ -2584,13 +2595,28 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
SAVEPERCENT
|
||||
};
|
||||
|
||||
struct AdditionalData
|
||||
{
|
||||
public:
|
||||
AdditionalData() : useMaximumConstant(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool useMaximumConstant;
|
||||
union
|
||||
{
|
||||
const PClass *inventoryItem;
|
||||
int value;
|
||||
};
|
||||
};
|
||||
|
||||
unsigned int border;
|
||||
bool horizontal;
|
||||
bool reverse;
|
||||
int foreground;
|
||||
int background;
|
||||
ValueType type;
|
||||
const PClass *inventoryItem;
|
||||
AdditionalData data;
|
||||
SBarInfoCoordinate x;
|
||||
SBarInfoCoordinate y;
|
||||
|
||||
|
|
Loading…
Reference in a new issue