- the Doom status bar has been partially virtualized to allow overriding specific parts of it, most notably the ammo display

# Conflicts:
#	wadsrc/static/zscript/ui/statusbar/doom_sbar.zs
#	wadsrc/static/zscript/ui/statusbar/harm_sbar.zs
This commit is contained in:
Christoph Oelckers 2019-07-17 00:36:38 +02:00 committed by drfrag
parent f95f0257b0
commit 9097f23286

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(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)
@ -124,6 +83,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 ()
{
Vector2 iconbox = (40, 20);
@ -167,6 +181,16 @@ class DoomStatusBar : BaseStatusBar
DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (-3, 1), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD);
}
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);
@ -189,9 +213,5 @@ class DoomStatusBar : BaseStatusBar
}
}
}
if (isInventoryBarVisible())
{
DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW);
}
}
}