From 3ccd4aa0d1a3430c956f2fb219c1598ac37f40e3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 21 Apr 2017 18:08:30 +0200 Subject: [PATCH] - fixed: The powerup icons did not blink when expiring. --- src/g_shared/shared_hud.cpp | 42 ++++++++++++------- wadsrc/static/zscript/inventory/inventory.txt | 15 ------- wadsrc/static/zscript/inventory/powerups.txt | 6 ++- wadsrc/static/zscript/statusbar/statusbar.txt | 22 ++++++---- 4 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 8ac35da24..b3e9532d8 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -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; + } + } + } } } } diff --git a/wadsrc/static/zscript/inventory/inventory.txt b/wadsrc/static/zscript/inventory/inventory.txt index 43de6b527..750296565 100644 --- a/wadsrc/static/zscript/inventory/inventory.txt +++ b/wadsrc/static/zscript/inventory/inventory.txt @@ -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 diff --git a/wadsrc/static/zscript/inventory/powerups.txt b/wadsrc/static/zscript/inventory/powerups.txt index 8402588c5..078647a23 100644 --- a/wadsrc/static/zscript/inventory/powerups.txt +++ b/wadsrc/static/zscript/inventory/powerups.txt @@ -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; } diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index 82acfed9f..c5fd4a9ca 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -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; + } } } }