mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- Doom keybar is working.
I did not implement an equivalent to SBARINFO's DrawKeyBar. This is too limiting because it needs to consider any possibility. It really is easier to let a mod implement this itself and custom adjust it to its needs. - fixed some stuff, in particular use DrawInventoryIcon to get smarter icon lookup.
This commit is contained in:
parent
488fface50
commit
1c71d038dd
3 changed files with 58 additions and 79 deletions
|
@ -105,14 +105,14 @@ class DoomStatusBar : BaseStatusBar
|
|||
Vector2 iconbox = (40, 20);
|
||||
// Draw health
|
||||
let berserk = CPlayer.mo.FindInventory("PowerStrength");
|
||||
DrawTexture(Images[berserk? imgPSTRA0 : imgMEDIA0], (20, -2), false, 1.0, ALIGN_BOTTOM|ALIGN_LEFT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(CPlayer.health, 3, 0, 0), (44, -20), 1., Font.CR_UNTRANSLATED, TEXT_LEFT, ALIGN_LEFT|ALIGN_BOTTOM, HUdFontSpacing, true, 2, 2);
|
||||
DrawTexture(Images[berserk? imgPSTRA0 : imgMEDIA0], (20, -2), true, 1.0, ALIGN_BOTTOM|ALIGN_LEFT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(CPlayer.health, 3, 0, 0), (44, -20), 1., Font.CR_UNTRANSLATED, TEXT_LEFT, ALIGN_LEFT|ALIGN_BOTTOM, HUdFontSpacing, true, 1, 1);
|
||||
|
||||
let armor = CPlayer.mo.FindInventory("BasicArmor");
|
||||
if (armor != null)
|
||||
{
|
||||
DrawTexture(armor.Icon, (20, -22), false, 1.0, ALIGN_BOTTOM|ALIGN_LEFT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(armor.Amount, 3, 0, 0), (44, -40), 1., Font.CR_UNTRANSLATED, TEXT_LEFT, ALIGN_LEFT|ALIGN_BOTTOM, HUdFontSpacing, true, 2, 2);
|
||||
DrawInventoryIcon(armor, (20, -22), true, 1.0, ALIGN_BOTTOM|ALIGN_LEFT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(armor.Amount, 3, 0, 0), (44, -40), 1., Font.CR_UNTRANSLATED, TEXT_LEFT, ALIGN_LEFT|ALIGN_BOTTOM, HUdFontSpacing, true, 1, 1);
|
||||
}
|
||||
Inventory ammotype1, ammotype2;
|
||||
int ammoamount1, ammoamount2;
|
||||
|
@ -120,26 +120,53 @@ class DoomStatusBar : BaseStatusBar
|
|||
int invY = -20;
|
||||
if (ammotype1 != null)
|
||||
{
|
||||
DrawTexture(ammotype1.Icon, (-14, -4), false, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(ammoamount1, 3, 0, 0), (-25, -20), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_BOTTOM, HUdFontSpacing, true, 2, 2);
|
||||
DrawInventoryIcon(ammotype1, (-14, -4), true, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(ammoamount1, 3, 0, 0), (-25, -20), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_BOTTOM, HUdFontSpacing, true, 1, 1);
|
||||
invY -= 20;
|
||||
}
|
||||
if (ammotype2 != null && ammotype2 != ammotype1)
|
||||
{
|
||||
DrawTexture(ammotype2.Icon, (-14, invY + 17), false, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(ammoamount2, 3, 0, 0), (-25, invY), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_BOTTOM, HUdFontSpacing, true, 2, 2);
|
||||
DrawInventoryIcon(ammotype2, (-14, invY + 17), true, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(ammoamount2, 3, 0, 0), (-25, invY), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_BOTTOM, HUdFontSpacing, true, 1, 1);
|
||||
invY -= 20;
|
||||
}
|
||||
if (CPlayer.inventorytics == 0 && CPlayer.mo.InvSel != null)
|
||||
{
|
||||
DrawTexture(CPlayer.mo.InvSel.Icon, (-14, invY + 17), false, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(CPlayer.mo.InvSel.Amount, 3, 0, 0), (-25, invY), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_BOTTOM, HUdFontSpacing, true, 2, 2);
|
||||
DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17), true, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, iconbox, ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(CPlayer.mo.InvSel.Amount, 3, 0, 0), (-25, invY), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_BOTTOM, HUdFontSpacing, true, 1, 1);
|
||||
}
|
||||
if (deathmatch)
|
||||
{
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(CPlayer.fragSum(), 3, 0, 0), (-3, -1), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_TOP, HUdFontSpacing, true, 2, 2);
|
||||
DrawString("HUDFONT_DOOM", FormatNumber(CPlayer.fragSum(), 3, 0, 0), (-3, -1), 1., Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_RIGHT|ALIGN_TOP, HUdFontSpacing, true, 1, 1);
|
||||
}
|
||||
|
||||
// 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, true, 1., ALIGN_TOP|ALIGN_RIGHT, (-1,-1), ALIGN_TOP|ALIGN_LEFT);
|
||||
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("A
|
||||
//drawinventorybar Doom, translucent, 7, INDEXFONT, -106+center, -31;
|
||||
}
|
||||
//drawkeybar 100, vertical, reverserows, auto, -10, 2, 0, 3, auto;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,6 +225,5 @@ statusbar inventory // Standard bar overlay (ZDoom Addition)
|
|||
|
||||
statusbar inventoryfullscreen, fullscreenoffsets // ZDoom HUD overlay.
|
||||
{
|
||||
drawinventorybar Doom, translucent, 7, INDEXFONT, -106+center, -31;
|
||||
}
|
||||
*/
|
|
@ -235,7 +235,7 @@ class BaseStatusBar native ui
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
TextureID, Vector2 GetIcon(Inventory item, int flags, bool showdepleted = false)
|
||||
TextureID, Vector2 GetIcon(Inventory item, int flags, bool showdepleted = true)
|
||||
{
|
||||
TextureID icon;
|
||||
Vector2 scale = (1,1);
|
||||
|
@ -245,12 +245,12 @@ class BaseStatusBar native ui
|
|||
bool applyscale;
|
||||
[icon, applyscale] = GetInventoryIcon(item, flags);
|
||||
|
||||
if (item.Amount == 0 && !showdepleted) return icon;
|
||||
if (item.Amount == 0 && !showdepleted) return icon, scale;
|
||||
|
||||
if (applyscale)
|
||||
scale = item.Scale;
|
||||
}
|
||||
return icon;
|
||||
return icon, scale;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
@ -623,49 +623,6 @@ class BaseStatusBar native ui
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
void DrawIcon(int icontype, Vector2 pos, bool animated = false, double alpha = 1.0, int screenalign = ALIGN_TOP|ALIGN_LEFT, Vector2 boxsize = (-1, -1), int itemAlign = ALIGN_TOP|ALIGN_LEFT, int flags = 0)
|
||||
{
|
||||
TextureID texture;
|
||||
Vector2 applyscale = (1, 1);
|
||||
Inventory atype1, atype2;
|
||||
switch (icontype)
|
||||
{
|
||||
case ITYPE_PLAYERICON:
|
||||
texture = CPlayer.mo.ScoreIcon;
|
||||
break;
|
||||
|
||||
case ITYPE_AMMO1:
|
||||
case ITYPE_AMMO2:
|
||||
[atype1, atype2] = GetCurrentAmmo();
|
||||
[texture, applyscale] = GetIcon(icontype == ITYPE_AMMO1? atype1 : atype2, flags, true);
|
||||
break;
|
||||
|
||||
case ITYPE_ARMOR:
|
||||
[texture, applyscale] = GetIcon(CPlayer.mo.FindInventory("BasicArmor"), flags, false);
|
||||
break;
|
||||
|
||||
case ITYPE_WEAPON:
|
||||
[texture, applyscale] = GetIcon(CPlayer.ReadyWeapon, flags, false);
|
||||
break;
|
||||
|
||||
case ITYPE_SIGIL:
|
||||
[texture, applyscale] = GetIcon(CPlayer.mo.FindInventory("Sigil"), flags, false);
|
||||
break;
|
||||
|
||||
case ITYPE_SELECTEDINVENTORY:
|
||||
if (CPlayer.mo.InvSel != NULL)
|
||||
texture = CPlayer.mo.InvSel.Icon;
|
||||
break;
|
||||
}
|
||||
DrawTexture(texture, pos, animated, screenalign, alpha, boxsize, itemAlign, flags, applyscale);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void DrawHexenArmor(int armortype, String image, Vector2 pos, bool animated = false, double alpha = 1.0, int screenalign = ALIGN_TOP|ALIGN_LEFT, Vector2 boxsize = (-1, -1), int itemAlign = ALIGN_TOP|ALIGN_LEFT, int flags = 0)
|
||||
{
|
||||
let harmor = HexenArmor(statusBar.CPlayer.mo.FindInventory("HexenArmor"));
|
||||
|
@ -690,12 +647,14 @@ class BaseStatusBar native ui
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
void DrawInventoryIcon(class<Inventory> item, String image, Vector2 pos, bool animated = false, double alpha = 1.0, int screenalign = ALIGN_TOP|ALIGN_LEFT, Vector2 boxsize = (-1, -1), int itemAlign = ALIGN_TOP|ALIGN_LEFT, int flags = 0)
|
||||
void DrawInventoryIcon(Inventory item, Vector2 pos, bool animated = false, double alpha = 1.0, int screenalign = ALIGN_TOP|ALIGN_LEFT, Vector2 boxsize = (-1, -1), int itemAlign = ALIGN_TOP|ALIGN_LEFT, int flags = 0)
|
||||
{
|
||||
let texture = GetDefaultByType(item).Icon;
|
||||
TextureID texture;
|
||||
Vector2 applyscale = (1, 1);
|
||||
[texture, applyscale] = GetIcon(item, flags, false);
|
||||
if (texture.IsValid())
|
||||
{
|
||||
DrawTexture(texture, pos, animated, screenalign, alpha, boxsize, itemAlign, flags);
|
||||
DrawTexture(texture, pos, animated, alpha, screenalign, boxsize, itemAlign, flags, applyscale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -326,26 +326,23 @@ class StrifeStatusBar : BaseStatusBar
|
|||
item = CPlayer.mo.FindInventory('BasicArmor');
|
||||
if (item != NULL && item.Amount > 0)
|
||||
{
|
||||
DrawTexture(item.Icon, (2, 9), true, 1.0, itemAlign:ALIGN_OFFSETS);
|
||||
DrawInventoryIcon(item, (2, 9), true, 1.0, itemAlign:ALIGN_OFFSETS);
|
||||
DrawString("Indexfont_Strife_Yellow", FormatNumber(item.Amount, 3, 5, 0), (34, 23), 1.0, Font.CR_UNTRANSLATED, TEXT_RIGHT, 0, 7, true, 1, 1);
|
||||
}
|
||||
|
||||
// Ammo
|
||||
Inventory ammo1, ammo2;
|
||||
int ammocount1, ammocount2;
|
||||
|
||||
[ammo1, ammo2, ammocount1, ammocount2] = GetCurrentAmmo ();
|
||||
Inventory = GetCurrentAmmo ();
|
||||
if (ammo1 != NULL)
|
||||
{
|
||||
DrawString("Indexfont_Strife_Green", FormatNumber(ammo1.Amount, 3, 5, 0), (318, -6), 1.0, Font.CR_UNTRANSLATED, TEXT_RIGHT, 0, 7, true, 1, 1);
|
||||
DrawTexture (ammo1.Icon, (290, 13), true, 1.0, itemAlign:ALIGN_OFFSETS);
|
||||
DrawInventoryIcon (ammo1, (290, 13), true, 1.0, itemAlign:ALIGN_OFFSETS);
|
||||
}
|
||||
|
||||
// Sigil
|
||||
item = CPlayer.mo.FindInventory('Sigil');
|
||||
if (item != NULL)
|
||||
{
|
||||
DrawTexture (item.Icon, (253, 7), true, 1.0, itemAlign:ALIGN_OFFSETS);
|
||||
DrawInventoryIcon (item, (253, 7), true, 1.0, itemAlign:ALIGN_OFFSETS);
|
||||
}
|
||||
|
||||
// Inventory
|
||||
|
@ -356,12 +353,9 @@ class StrifeStatusBar : BaseStatusBar
|
|||
{
|
||||
if (item == CPlayer.mo.InvSel)
|
||||
{
|
||||
DrawTexture (item.Icon, (42 + 35*i, 12), true, 1. - ItemFlash, itemAlign:ALIGN_OFFSETS, item.Amount <= 0? DI_DIM : 0);
|
||||
}
|
||||
if (item.Icon.isValid())
|
||||
{
|
||||
DrawTexture (item.Icon, (48 + 35*i, 14), true, 1.0, itemAlign:ALIGN_OFFSETS, item.Amount <= 0? DI_DIM : 0);
|
||||
DrawTexture (Images[CursorImage], (42 + 35*i, 12), true, 1. - ItemFlash, itemAlign:ALIGN_OFFSETS, item.Amount <= 0? DI_DIM : 0);
|
||||
}
|
||||
DrawInventoryIcon (item, (48 + 35*i, 14), true, 1.0, itemAlign:ALIGN_OFFSETS, item.Amount <= 0? DI_DIM : 0);
|
||||
DrawString("Indexfont_Strife_Yellow", FormatNumber(item.Amount, 3, 5, 0), (81 + 35*i, 23), 1.0, Font.CR_UNTRANSLATED, TEXT_RIGHT, 0, 7, true, 1, 1);
|
||||
i++;
|
||||
}
|
||||
|
@ -379,7 +373,7 @@ class StrifeStatusBar : BaseStatusBar
|
|||
if (armor != NULL && armor.Amount != 0)
|
||||
{
|
||||
DrawString("Indexfont_Strife_Yellow", FormatNumber(armor.Amount, 3, 0, 0), (35, -10), 1., Font.CR_UNTRANSLATED, TEXT_LEFT, ALIGN_LEFT|ALIGN_BOTTOM, 7, true, 1, 1);
|
||||
DrawTexture(armor.Icon, (45, -17), false, 1.0, ALIGN_BOTTOM|ALIGN_LEFT, itemalign: ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawInventoryIcon(armor, (45, -17), false, 1.0, ALIGN_BOTTOM|ALIGN_LEFT, itemalign: ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
}
|
||||
|
||||
// Draw ammo
|
||||
|
@ -391,12 +385,12 @@ class StrifeStatusBar : BaseStatusBar
|
|||
{
|
||||
// Draw primary ammo in the bottom-right corner
|
||||
DrawString("Indexfont_Strife_Green", FormatNumber(ammo1.Amount, 3, 0, 0), (-23, -10), 1., Font.CR_UNTRANSLATED, TEXT_LEFT, ALIGN_RIGHT|ALIGN_BOTTOM, 7, true, 1, 1);
|
||||
DrawTexture(ammo1.Icon, (-14, -17), false, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, itemalign: ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawInventoryIcon(ammo1, (-14, -17), false, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, itemalign: ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
if (ammo2 != NULL && ammo1!=ammo2)
|
||||
{
|
||||
// Draw secondary ammo just above the primary ammo
|
||||
DrawString("Indexfont_Strife_Green", FormatNumber(ammo1.Amount, 3, 0, 0), (-23, -48), 1., Font.CR_UNTRANSLATED, TEXT_LEFT, ALIGN_RIGHT|ALIGN_BOTTOM, 7, true, 1, 1);
|
||||
DrawTexture(ammo1.Icon, (-14, -55), false, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, itemalign: ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
DrawInventoryIcon(ammo1, (-14, -55), false, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, itemalign: ALIGN_BOTTOM|ALIGN_HCENTER);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,7 +409,7 @@ class StrifeStatusBar : BaseStatusBar
|
|||
DrawTexture(Images[CursorImage], (-28, -15), true, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, ItemAlign:ALIGN_BOTTOM|ALIGN_RIGHT);
|
||||
}
|
||||
DrawString("Indexfont_Strife_Yellow", FormatNumber(CPlayer.mo.InvSel.Amount, 3, 5, 0), (-23, -10), 1.0, Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_BOTTOM|ALIGN_RIGHT, 7, true, 1, 1);
|
||||
DrawTexture(CPlayer.mo.InvSel.Icon, (-42, -17), true, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, ItemAlign:ALIGN_BOTTOM|ALIGN_HCENTER, CPlayer.mo.InvSel.Amount > 0 ? 0 : DI_DIM);
|
||||
DrawInventoryIcon(CPlayer.mo.InvSel, (-42, -17), true, 1.0, ALIGN_BOTTOM|ALIGN_RIGHT, ItemAlign:ALIGN_BOTTOM|ALIGN_HCENTER, CPlayer.mo.InvSel.Amount > 0 ? 0 : DI_DIM);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -434,7 +428,7 @@ class StrifeStatusBar : BaseStatusBar
|
|||
}
|
||||
if (item.Icon.isValid())
|
||||
{
|
||||
DrawTexture(item.Icon, (-90+i*35, -5), true, 0.75, ALIGN_CENTER_BOTTOM, box, ALIGN_CENTER_BOTTOM, CPlayer.mo.InvSel.Amount > 0 ? 0 : DI_DIM);
|
||||
DrawInventoryIcon(item, (-90+i*35, -5), true, 0.75, ALIGN_CENTER_BOTTOM, box, ALIGN_CENTER_BOTTOM, CPlayer.mo.InvSel.Amount > 0 ? 0 : DI_DIM);
|
||||
}
|
||||
DrawString("Indexfont_Strife_Yellow", FormatNumber(item.Amount, 3, 5, 0), (-65 + i*35, -8), 1.0, Font.CR_UNTRANSLATED, TEXT_RIGHT, ALIGN_CENTER_BOTTOM, 7, true, 1, 1);
|
||||
++i;
|
||||
|
|
Loading…
Reference in a new issue