mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-15 00:41:57 +00:00
08b3c38304
- got rid of the image list in the Doom status bar. The cost of the texture lookup is mostly irrelevant here so clearer and shorter code is preferrable. - moved the box fitting code from DrawTexture into the native function to have all coordinate calculations in one place which is necessary to implement proper alignment default handling. Without higher level functions altering positioning the default can be set to automatic alignment determination, i.e. the value's sign decides where something is placed. Of course for special cases this can be overridden. - use ANIMDEFS to animate the inventory arrow,
182 lines
No EOL
5.5 KiB
Text
182 lines
No EOL
5.5 KiB
Text
class DoomStatusBar : BaseStatusBar
|
|
{
|
|
HUDFont mHUDFont;
|
|
//DrawInventoryBarParms diparms;
|
|
|
|
|
|
override void Init()
|
|
{
|
|
Super.Init();
|
|
SetSize(32, 320, 200);
|
|
|
|
// set up the inventory bar drawer.
|
|
/*
|
|
diparms.SetDefaults(HX_SHADOW);
|
|
diparms.SetTextures("SELECTBO", "ARTIBOX", "INVGEML1", "INVGEMR1");
|
|
diparms.SetLeftArrow("INVGEML1");
|
|
diparms.SetRightArrow("INVGEMR1");
|
|
*/
|
|
|
|
// Create the font used for the fullscreen HUD
|
|
Font fnt = "HUDFONT_DOOM";
|
|
mHUDFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), true, 1, 1);
|
|
}
|
|
|
|
override void NewGame ()
|
|
{
|
|
if (CPlayer != NULL)
|
|
{
|
|
AttachToPlayer (CPlayer);
|
|
}
|
|
}
|
|
|
|
override void Draw (int state, double TicFrac)
|
|
{
|
|
Super.Draw (state, TicFrac);
|
|
|
|
if (state == HUD_StatusBar)
|
|
{
|
|
BeginStatusBar(320, 200, 32);
|
|
DrawMainBar (TicFrac);
|
|
}
|
|
else if (state == HUD_Fullscreen)
|
|
{
|
|
BeginHUD(320, 200, 1., false);
|
|
DrawFullScreenStuff ();
|
|
}
|
|
}
|
|
|
|
protected void DrawMainBar (double TicFrac)
|
|
{
|
|
//DrawTexture(Images[imgINVBACK], (0, 0), true, 1.0, itemAlign:ALIGN_OFFSETS);
|
|
//DrawTexture(Images[imgINVTOP], (0, -8), true, 1.0, itemAlign:ALIGN_OFFSETS);
|
|
|
|
// Health
|
|
//DrawString("Indexfont_Strife_Green", FormatNumber(CPlayer.health, 3, 5, 0), (86, -6), 1.0, Font.CR_UNTRANSLATED, TEXT_RIGHT, 0, 7, true, 1, 1);
|
|
}
|
|
|
|
protected void DrawFullScreenStuff ()
|
|
{
|
|
Vector2 iconbox = (40, 20);
|
|
// Draw health
|
|
let berserk = CPlayer.mo.FindInventory("PowerStrength");
|
|
DrawImage(berserk? "PSTRA0" : "MEDIA0", (20, -2));
|
|
DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (44, -20));
|
|
|
|
let armor = CPlayer.mo.FindInventory("BasicArmor");
|
|
if (armor != null)
|
|
{
|
|
DrawInventoryIcon(armor, (20, -22));
|
|
DrawString(mHUDFont, FormatNumber(armor.Amount, 3), (44, -40));
|
|
}
|
|
Inventory ammotype1, ammotype2;
|
|
[ammotype1, ammotype2] = GetCurrentAmmo();
|
|
int invY = -20;
|
|
if (ammotype1 != null)
|
|
{
|
|
DrawInventoryIcon(ammotype1, (-14, -4));
|
|
DrawString(mHUDFont, FormatNumber(ammotype1.Amount, 3), (-30, -20), DI_TEXT_ALIGN_RIGHT);
|
|
invY -= 20;
|
|
}
|
|
if (ammotype2 != null && ammotype2 != ammotype1)
|
|
{
|
|
DrawInventoryIcon(ammotype2, (-14, invY + 17));
|
|
DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);
|
|
invY -= 20;
|
|
}
|
|
if (CPlayer.inventorytics == 0 && 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.fragSum(), 3), (-3, 1), DI_TEXT_ALIGN_RIGHT);
|
|
}
|
|
|
|
// 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 (CPlayer.inventorytics != 0)
|
|
{
|
|
//DrawInventoryBar(diparms, (0, 0), 7, ALIGN_CENTER_BOTTOM, ALIGN_CENTER_BOTTOM);
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
statusbar normal // Standard Doom Status bar
|
|
{
|
|
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(Clip), 288, 173;
|
|
drawnumber 3, INDEXFONT_DOOM, untranslated, ammo(Shell), 288, 179;
|
|
drawnumber 3, INDEXFONT_DOOM, untranslated, ammo(RocketAmmo), 288, 185;
|
|
drawnumber 3, INDEXFONT_DOOM, untranslated, ammo(Cell), 288, 191;
|
|
|
|
drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(Clip), 314, 173;
|
|
drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(Shell), 314, 179;
|
|
drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(RocketAmmo), 314, 185;
|
|
drawnumber 3, INDEXFONT_DOOM, untranslated, ammocapacity(Cell), 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", 143, 169;
|
|
}
|
|
drawselectedinventory alternateonempty, INDEXFONT, 143, 168
|
|
{
|
|
drawmugshot "STF", 5, 143, 168;
|
|
}
|
|
}
|
|
|
|
statusbar inventory // Standard bar overlay (ZDoom Addition)
|
|
{
|
|
drawinventorybar Doom, 7, INDEXFONT, 50, 170;
|
|
}
|
|
|
|
statusbar inventoryfullscreen, fullscreenoffsets // ZDoom HUD overlay.
|
|
{
|
|
}
|
|
*/ |