- fixed: The powerup icons did not blink when expiring.

This commit is contained in:
Christoph Oelckers 2017-04-21 18:08:30 +02:00
parent 0ed3ee6267
commit 3ccd4aa0d1
4 changed files with 44 additions and 41 deletions

View file

@ -1088,23 +1088,35 @@ static void DrawPowerups(player_t *CPlayer)
for (item = CPlayer->mo->Inventory; item != NULL; item = item->Inventory)
{
IFVIRTUALPTR(item, AInventory, GetPowerupIcon)
if (item->IsKindOf(NAME_Powerup))
{
VMValue param[] = { item };
int rv;
VMReturn ret(&rv);
VMCall(func, param, 1, &ret, 1);
auto tex = FSetTextureID(rv);
if (!tex.isValid()) continue;
auto texture = TexMan(tex);
screen->DrawTexture(texture, x, y, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_CenterBottomOffset, true, TAG_DONE);
x -= POWERUPICONSIZE;
if (x < -hudwidth / 2)
IFVIRTUALPTRNAME(item, NAME_Powerup, GetPowerupIcon)
{
x = -20;
y += POWERUPICONSIZE * 3 / 2;
VMValue param[] = { item };
int rv;
VMReturn ret(&rv);
VMCall(func, param, 1, &ret, 1);
auto tex = FSetTextureID(rv);
if (!tex.isValid()) continue;
auto texture = TexMan(tex);
IFVIRTUALPTRNAME(item, NAME_Powerup, IsBlinking)
{
// Reuse the parameters from GetPowerupIcon
VMCall(func, param, 1, &ret, 1);
if (!rv)
{
screen->DrawTexture(texture, x, y, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_CenterBottomOffset, true, TAG_DONE);
x -= POWERUPICONSIZE;
if (x < -hudwidth / 2)
{
x = -20;
y += POWERUPICONSIZE * 3 / 2;
}
}
}
}
}
}

View file

@ -858,21 +858,6 @@ class Inventory : Actor native
virtual ui version("2.4") bool DrawPowerup(int x, int y) { return false; }
//===========================================================================
//
// AInventory :: GetPowerupIcon
//
// Returns the icon that should be drawn for an active powerup.
//
//===========================================================================
virtual clearscope version("2.5") TextureID GetPowerupIcon() const
{
TextureID id;
id.SetInvalid();
return id;
}
//===========================================================================
//
// AInventory :: AbsorbDamage

View file

@ -269,11 +269,13 @@ class Powerup : Inventory
//===========================================================================
//
// APowerup :: DrawPowerup
// AInventory :: GetPowerupIcon
//
// Returns the icon that should be drawn for an active powerup.
//
//===========================================================================
override TextureID GetPowerupIcon()
virtual clearscope version("2.5") TextureID GetPowerupIcon() const
{
return Icon;
}

View file

@ -813,18 +813,22 @@ class BaseStatusBar native ui
// that can obey AltHUD rules - which this cannot.
Vector2 pos = (-20, POWERUPICONSIZE * 5 / 4);
double maxpos = screen.GetWidth() / 2;
for (let item = CPlayer.mo.Inv; item != NULL; item = item.Inv)
for (let iitem = CPlayer.mo.Inv; iitem != NULL; iitem = iitem.Inv)
{
let icon = item.GetPowerupIcon();
if (icon.IsValid())
let item = Powerup(iitem);
if (item != null)
{
// Each icon gets a 32x32 block.
DrawTexture(icon, pos, DI_SCREEN_RIGHT_TOP, 1.0, (POWERUPICONSIZE, POWERUPICONSIZE));
pos.x -= POWERUPICONSIZE;
if (pos.x < -maxpos)
let icon = item.GetPowerupIcon();
if (icon.IsValid() && !item.IsBlinking())
{
pos.x = -20;
pos.y += POWERUPICONSIZE * 3 / 2;
// Each icon gets a 32x32 block.
DrawTexture(icon, pos, DI_SCREEN_RIGHT_TOP, 1.0, (POWERUPICONSIZE, POWERUPICONSIZE));
pos.x -= POWERUPICONSIZE;
if (pos.x < -maxpos)
{
pos.x = -20;
pos.y += POWERUPICONSIZE * 3 / 2;
}
}
}
}