From c64aedb262f87a8379a9d7930409a710b0d19aa8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 17 Jul 2019 00:36:38 +0200 Subject: [PATCH] - reimplemented the Harmony status bar in ZScript * the Doom status bar has been partially virtualized to allow overriding specific parts of it, most notably the ammo display * the internal Harmony status bar has been removed because it only works with the now disabled Dehacked patch. * the SBARINFO definition has been removed, instead it uses a ZScript-based status bar now which overrides the ammo display to use the new ammo types instead. --- wadsrc/static/zscript.txt | 1 - .../static/zscript/ui/statusbar/doom_sbar.zs | 118 ++++++++++-------- .../static/zscript/ui/statusbar/harm_sbar.zs | 100 --------------- .../static/filter/harmony/sbarinfo.txt | 49 -------- .../static/filter/harmony/zscript.txt | 2 + .../filter/harmony/zscript/harm_sbar.zs | 22 ++++ 6 files changed, 93 insertions(+), 199 deletions(-) delete mode 100644 wadsrc/static/zscript/ui/statusbar/harm_sbar.zs delete mode 100644 wadsrc_extra/static/filter/harmony/sbarinfo.txt create mode 100644 wadsrc_extra/static/filter/harmony/zscript.txt create mode 100644 wadsrc_extra/static/filter/harmony/zscript/harm_sbar.zs diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index 8abb522f3..ccef58d1d 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -267,7 +267,6 @@ version "4.2" #include "zscript/ui/statusbar/alt_hud.zs" #include "zscript/ui/statusbar/doom_sbar.zs" -#include "zscript/ui/statusbar/harm_sbar.zs" #include "zscript/ui/statusbar/heretic_sbar.zs" #include "zscript/ui/statusbar/hexen_sbar.zs" #include "zscript/ui/statusbar/sbarinfowrapper.zs" diff --git a/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs b/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs index 4fc7347ca..0ea001a32 100644 --- a/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs @@ -47,43 +47,8 @@ class DoomStatusBar : BaseStatusBar DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (90, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW); DrawString(mHUDFont, FormatNumber(GetArmorAmount(), 3), (221, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW); - bool locks[6]; - String image; - for(int i = 0; i < 6; i++) locks[i] = CPlayer.mo.CheckKeys(i + 1, false, true); - // key 1 - if (locks[1] && locks[4]) image = "STKEYS6"; - else if (locks[1]) image = "STKEYS0"; - else if (locks[4]) image = "STKEYS3"; - DrawImage(image, (239, 171), DI_ITEM_OFFSETS); - // key 2 - if (locks[2] && locks[5]) image = "STKEYS7"; - else if (locks[2]) image = "STKEYS1"; - else if (locks[5]) image = "STKEYS4"; - else image = ""; - DrawImage(image, (239, 181), DI_ITEM_OFFSETS); - // key 3 - if (locks[0] && locks[3]) image = "STKEYS8"; - else if (locks[0]) image = "STKEYS2"; - else if (locks[3]) image = "STKEYS5"; - else image = ""; - DrawImage(image, (239, 191), DI_ITEM_OFFSETS); - - int amt1, maxamt; - [amt1, maxamt] = GetAmount("Clip"); - DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 173), DI_TEXT_ALIGN_RIGHT); - DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 173), DI_TEXT_ALIGN_RIGHT); - - [amt1, maxamt] = GetAmount("Shell"); - DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 179), DI_TEXT_ALIGN_RIGHT); - DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 179), DI_TEXT_ALIGN_RIGHT); - - [amt1, maxamt] = GetAmount("RocketAmmo"); - DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 185), DI_TEXT_ALIGN_RIGHT); - DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 185), DI_TEXT_ALIGN_RIGHT); - - [amt1, maxamt] = GetAmount("Cell"); - DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 191), DI_TEXT_ALIGN_RIGHT); - DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 191), DI_TEXT_ALIGN_RIGHT); + DrawBarKeys(); + DrawBarAmmo(); if (deathmatch || teamplay) { @@ -91,13 +56,7 @@ class DoomStatusBar : BaseStatusBar } else { - DrawImage("STARMS", (104, 168), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(2)? "STYSNUM2" : "STGNUM2", (111, 172), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(3)? "STYSNUM3" : "STGNUM3", (123, 172), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(4)? "STYSNUM4" : "STGNUM4", (135, 172), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(5)? "STYSNUM5" : "STGNUM5", (111, 182), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(6)? "STYSNUM6" : "STGNUM6", (123, 182), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(7)? "STYSNUM7" : "STGNUM7", (135, 182), DI_ITEM_OFFSETS); + DrawBarWeapons(); } if (multiplayer) @@ -123,6 +82,61 @@ class DoomStatusBar : BaseStatusBar } } + + protected virtual void DrawBarKeys() + { + bool locks[6]; + String image; + for(int i = 0; i < 6; i++) locks[i] = CPlayer.mo.CheckKeys(i + 1, false, true); + // key 1 + if (locks[1] && locks[4]) image = "STKEYS6"; + else if (locks[1]) image = "STKEYS0"; + else if (locks[4]) image = "STKEYS3"; + DrawImage(image, (239, 171), DI_ITEM_OFFSETS); + // key 2 + if (locks[2] && locks[5]) image = "STKEYS7"; + else if (locks[2]) image = "STKEYS1"; + else if (locks[5]) image = "STKEYS4"; + else image = ""; + DrawImage(image, (239, 181), DI_ITEM_OFFSETS); + // key 3 + if (locks[0] && locks[3]) image = "STKEYS8"; + else if (locks[0]) image = "STKEYS2"; + else if (locks[3]) image = "STKEYS5"; + else image = ""; + DrawImage(image, (239, 191), DI_ITEM_OFFSETS); + } + + protected virtual void DrawBarAmmo() + { + int amt1, maxamt; + [amt1, maxamt] = GetAmount("Clip"); + DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 173), DI_TEXT_ALIGN_RIGHT); + DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 173), DI_TEXT_ALIGN_RIGHT); + + [amt1, maxamt] = GetAmount("Shell"); + DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 179), DI_TEXT_ALIGN_RIGHT); + DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 179), DI_TEXT_ALIGN_RIGHT); + + [amt1, maxamt] = GetAmount("RocketAmmo"); + DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 185), DI_TEXT_ALIGN_RIGHT); + DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 185), DI_TEXT_ALIGN_RIGHT); + + [amt1, maxamt] = GetAmount("Cell"); + DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 191), DI_TEXT_ALIGN_RIGHT); + DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 191), DI_TEXT_ALIGN_RIGHT); + } + + protected virtual void DrawBarWeapons() + { + DrawImage("STARMS", (104, 168), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(2)? "STYSNUM2" : "STGNUM2", (111, 172), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(3)? "STYSNUM3" : "STGNUM3", (123, 172), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(4)? "STYSNUM4" : "STGNUM4", (135, 172), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(5)? "STYSNUM5" : "STGNUM5", (111, 182), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(6)? "STYSNUM6" : "STGNUM6", (123, 182), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(7)? "STYSNUM7" : "STGNUM7", (135, 182), DI_ITEM_OFFSETS); + } protected void DrawFullScreenStuff () { @@ -163,7 +177,17 @@ class DoomStatusBar : BaseStatusBar DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (-3, 1), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD); } - // Draw the keys. This does not use a special draw function like SBARINFO because the specifics will be different for each mod + DrawFullscreenKeys(); + + if (isInventoryBarVisible()) + { + DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW); + } + } + + protected virtual void DrawFullscreenKeys() + { + // Draw the keys. This does not use a special draw function like SBARINFO because the specifics will be different for each mod // so it's easier to copy or reimplement the following piece of code instead of trying to write a complicated all-encompassing solution. Vector2 keypos = (-10, 2); int rowc = 0; @@ -185,9 +209,5 @@ class DoomStatusBar : BaseStatusBar } } } - if (isInventoryBarVisible()) - { - DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW); - } } } diff --git a/wadsrc/static/zscript/ui/statusbar/harm_sbar.zs b/wadsrc/static/zscript/ui/statusbar/harm_sbar.zs deleted file mode 100644 index f640bd993..000000000 --- a/wadsrc/static/zscript/ui/statusbar/harm_sbar.zs +++ /dev/null @@ -1,100 +0,0 @@ -class HarmonyStatusBar : DoomStatusBar -{ - double scaleFactor; - - override void Init() - { - Super.Init(); - - // This is for detecting the DECORATEd version of the mod which sets proper scaling for the HUD related textures. - let tex = TexMan.CheckForTexture("MEDIA0", TexMan.Type_Sprite); - if (tex.isValid()) - { - Vector2 ssize = TexMan.GetScaledSize(tex); - Vector2 facs = (ssize.X / 31, ssize.Y / 18); - scaleFactor = min(facs.X, facs.Y, 1); - } - } - - override void Draw (int state, double TicFrac) - { - BaseStatusBar.Draw (state, TicFrac); - - if (state == HUD_StatusBar) - { - BeginStatusBar(); - DrawMainBar (TicFrac); - } - else if (state == HUD_Fullscreen) - { - BeginHUD(); - DrawFullScreenStuff (); - } - } - - protected void DrawFullScreenStuff () - { - Vector2 iconbox = (40, 20); - // Draw health - DrawImage("MEDIA0", (20, -2), scale:(scaleFactor, scaleFactor)); - DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (44, -20)); - - let armor = CPlayer.mo.FindInventory("BasicArmor"); - if (armor != null && armor.Amount > 0) - { - DrawInventoryIcon(armor, (20, -22), scale:(scaleFactor, scaleFactor)); - DrawString(mHUDFont, FormatNumber(armor.Amount, 3), (44, -40)); - } - Inventory ammotype1, ammotype2; - [ammotype1, ammotype2] = GetCurrentAmmo(); - int invY = -20; - if (ammotype1 != null) - { - DrawInventoryIcon(ammotype1, (-14, -4), scale:(scaleFactor, scaleFactor)); - DrawString(mHUDFont, FormatNumber(ammotype1.Amount, 3), (-30, -20), DI_TEXT_ALIGN_RIGHT); - invY -= 20; - } - if (ammotype2 != null && ammotype2 != ammotype1) - { - DrawInventoryIcon(ammotype2, (-14, invY + 17), scale:(scaleFactor, scaleFactor)); - DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); - invY -= 20; - } - if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null) - { - DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17)); - DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); - } - if (deathmatch) - { - DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (-3, 1), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD); - } - - // Draw the keys. This does not use a special draw function like SBARINFO because the specifics will be different for each mod - // so it's easier to copy or reimplement the following piece of code instead of trying to write a complicated all-encompassing solution. - Vector2 keypos = (-10, 2); - int rowc = 0; - double roww = 0; - for(let i = CPlayer.mo.Inv; i != null; i = i.Inv) - { - if (i is "Key" && i.Icon.IsValid()) - { - DrawTexture(i.Icon, keypos, DI_SCREEN_RIGHT_TOP|DI_ITEM_LEFT_TOP); - Vector2 size = TexMan.GetScaledSize(i.Icon); - keypos.Y += size.Y + 2; - roww = max(roww, size.X); - if (++rowc == 3) - { - keypos.Y = 2; - keypos.X -= roww + 2; - roww = 0; - rowc = 0; - } - } - } - if (isInventoryBarVisible()) - { - DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW); - } - } -} diff --git a/wadsrc_extra/static/filter/harmony/sbarinfo.txt b/wadsrc_extra/static/filter/harmony/sbarinfo.txt deleted file mode 100644 index 6953bccd5..000000000 --- a/wadsrc_extra/static/filter/harmony/sbarinfo.txt +++ /dev/null @@ -1,49 +0,0 @@ -base doom; - -statusbar normal // Standard Doom Status bar (should probably be redone in ZScript later) -{ - drawimage "STBAR", 0, 168; - drawimage "STTPRCNT", 90, 171; - drawimage "STTPRCNT", 221, 171; - drawnumber 3, HUDFONT_DOOM, untranslated, ammo1, 44, 171; - drawnumber 3, HUDFONT_DOOM, untranslated, health, 90, 171; - drawnumber 3, HUDFONT_DOOM, untranslated, armor, 221, 171; - - //keys - drawswitchableimage keyslot 2 && 5, "nullimage", "STKEYS0", "STKEYS3", "STKEYS6", 239, 171; - drawswitchableimage keyslot 3 && 6, "nullimage", "STKEYS1", "STKEYS4", "STKEYS7", 239, 181; - drawswitchableimage keyslot 1 && 4, "nullimage", "STKEYS2", "STKEYS5", "STKEYS8", 239, 191; - - drawnumber 3, INDEXFONT_DOOM, untranslated, ammo MinigunAmmo, 288, 173; - drawnumber 3, INDEXFONT_DOOM, untranslated, ammo Shells, 288, 179; - drawnumber 3, INDEXFONT_DOOM, untranslated, ammo TimeBombAmmo, 288, 185; - drawnumber 3, INDEXFONT_DOOM, untranslated, ammo ChaosBarsAmmo, 288, 191; - - drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity MinigunAmmo, 314, 173; - drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity Shells, 314, 179; - drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity TimeBombAmmo, 314, 185; - drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity ChaosBarsAmmo, 314, 191; - gamemode deathmatch, teamgame - { - drawnumber 2, HUDFONT_DOOM, untranslated, frags, 138, 171; - } - gamemode cooperative, singleplayer - { - drawimage "STARMS", 104, 168; - drawswitchableimage weaponslot 2, "STGNUM2", "STYSNUM2", 111, 172; - drawswitchableimage weaponslot 3, "STGNUM3", "STYSNUM3", 123, 172; - drawswitchableimage weaponslot 4, "STGNUM4", "STYSNUM4", 135, 172; - drawswitchableimage weaponslot 5, "STGNUM5", "STYSNUM5", 111, 182; - drawswitchableimage weaponslot 6, "STGNUM6", "STYSNUM6", 123, 182; - drawswitchableimage weaponslot 7, "STGNUM7", "STYSNUM7", 135, 182; - } - gamemode cooperative, deathmatch, teamgame - { - drawimage translatable "STFBANY", 144, 169; - } - drawselectedinventory alternateonempty, INDEXFONT, 143, 168 - { - drawmugshot "STF", 5, 143, 168; - } -} - diff --git a/wadsrc_extra/static/filter/harmony/zscript.txt b/wadsrc_extra/static/filter/harmony/zscript.txt new file mode 100644 index 000000000..339942ecb --- /dev/null +++ b/wadsrc_extra/static/filter/harmony/zscript.txt @@ -0,0 +1,2 @@ +version "4.2" +#include "zscript/harm_sbar.zs" \ No newline at end of file diff --git a/wadsrc_extra/static/filter/harmony/zscript/harm_sbar.zs b/wadsrc_extra/static/filter/harmony/zscript/harm_sbar.zs new file mode 100644 index 000000000..a271c26ab --- /dev/null +++ b/wadsrc_extra/static/filter/harmony/zscript/harm_sbar.zs @@ -0,0 +1,22 @@ +class HarmonyStatusBar : DoomStatusBar +{ + override void DrawBarAmmo() + { + int amt1, maxamt; + [amt1, maxamt] = GetAmount("MinigunAmmo"); + DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 173), DI_TEXT_ALIGN_RIGHT); + DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 173), DI_TEXT_ALIGN_RIGHT); + + [amt1, maxamt] = GetAmount("Shells"); + DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 179), DI_TEXT_ALIGN_RIGHT); + DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 179), DI_TEXT_ALIGN_RIGHT); + + [amt1, maxamt] = GetAmount("TimeBombAmmo"); + DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 185), DI_TEXT_ALIGN_RIGHT); + DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 185), DI_TEXT_ALIGN_RIGHT); + + [amt1, maxamt] = GetAmount("ChaosBarsAmmo"); + DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 191), DI_TEXT_ALIGN_RIGHT); + DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 191), DI_TEXT_ALIGN_RIGHT); + } +}