Skip to content

Commit

Permalink
- reimplemented the Harmony status bar in ZScript
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
coelckers committed Jul 16, 2019
1 parent 8dbad9b commit c64aedb
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 197 deletions.
1 change: 0 additions & 1 deletion wadsrc/static/zscript.txt
Expand Up @@ -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"
Expand Down
114 changes: 67 additions & 47 deletions wadsrc/static/zscript/ui/statusbar/doom_sbar.zs
Expand Up @@ -47,6 +47,44 @@ 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);

DrawBarKeys();
DrawBarAmmo();

if (deathmatch || teamplay)
{
DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (138, 171), DI_TEXT_ALIGN_RIGHT);
}
else
{
DrawBarWeapons();
}

if (multiplayer)
{
DrawImage("STFBANY", (143, 168), DI_ITEM_OFFSETS|DI_TRANSLATABLE);
}

if (CPlayer.mo.InvSel != null && !Level.NoInventoryBar)
{
DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198));
if (CPlayer.mo.InvSel.Amount > 1)
{
DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 198-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD);
}
}
else
{
DrawTexture(GetMugShot(5), (143, 168), DI_ITEM_OFFSETS);
}
if (isInventoryBarVisible())
{
DrawInventoryBar(diparms, (48, 169), 7, DI_ITEM_LEFT_TOP);
}

}

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);
Expand All @@ -67,61 +105,37 @@ class DoomStatusBar : BaseStatusBar
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);

if (deathmatch || teamplay)
{
DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (138, 171), DI_TEXT_ALIGN_RIGHT);
}
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);
}

if (multiplayer)
{
DrawImage("STFBANY", (143, 168), DI_ITEM_OFFSETS|DI_TRANSLATABLE);
}

if (CPlayer.mo.InvSel != null && !Level.NoInventoryBar)
{
DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198));
if (CPlayer.mo.InvSel.Amount > 1)
{
DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 198-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD);
}
}
else
{
DrawTexture(GetMugShot(5), (143, 168), DI_ITEM_OFFSETS);
}
if (isInventoryBarVisible())
{
DrawInventoryBar(diparms, (48, 169), 7, DI_ITEM_LEFT_TOP);
}

}

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 ()
Expand Down Expand Up @@ -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;
Expand All @@ -185,9 +209,5 @@ class DoomStatusBar : BaseStatusBar
}
}
}
if (isInventoryBarVisible())
{
DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW);
}
}
}
100 changes: 0 additions & 100 deletions wadsrc/static/zscript/ui/statusbar/harm_sbar.zs

This file was deleted.

49 changes: 0 additions & 49 deletions wadsrc_extra/static/filter/harmony/sbarinfo.txt

This file was deleted.

2 changes: 2 additions & 0 deletions wadsrc_extra/static/filter/harmony/zscript.txt
@@ -0,0 +1,2 @@
version "4.2"
#include "zscript/harm_sbar.zs"
22 changes: 22 additions & 0 deletions 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);
}
}

0 comments on commit c64aedb

Please sign in to comment.