- 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.
This commit is contained in:
Christoph Oelckers 2019-07-17 00:36:38 +02:00
parent 8dbad9b530
commit c64aedb262
6 changed files with 93 additions and 199 deletions

View file

@ -267,7 +267,6 @@ version "4.2"
#include "zscript/ui/statusbar/alt_hud.zs" #include "zscript/ui/statusbar/alt_hud.zs"
#include "zscript/ui/statusbar/doom_sbar.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/heretic_sbar.zs"
#include "zscript/ui/statusbar/hexen_sbar.zs" #include "zscript/ui/statusbar/hexen_sbar.zs"
#include "zscript/ui/statusbar/sbarinfowrapper.zs" #include "zscript/ui/statusbar/sbarinfowrapper.zs"

View file

@ -47,43 +47,8 @@ class DoomStatusBar : BaseStatusBar
DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (90, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW); 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); DrawString(mHUDFont, FormatNumber(GetArmorAmount(), 3), (221, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
bool locks[6]; DrawBarKeys();
String image; DrawBarAmmo();
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);
if (deathmatch || teamplay) if (deathmatch || teamplay)
{ {
@ -91,13 +56,7 @@ class DoomStatusBar : BaseStatusBar
} }
else else
{ {
DrawImage("STARMS", (104, 168), DI_ITEM_OFFSETS); DrawBarWeapons();
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) 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 () 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); 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. // 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); Vector2 keypos = (-10, 2);
int rowc = 0; int rowc = 0;
@ -185,9 +209,5 @@ class DoomStatusBar : BaseStatusBar
} }
} }
} }
if (isInventoryBarVisible())
{
DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW);
}
} }
} }

View file

@ -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);
}
}
}

View file

@ -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;
}
}

View file

@ -0,0 +1,2 @@
version "4.2"
#include "zscript/harm_sbar.zs"

View file

@ -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);
}
}