- change statusbar drawers to use the top left of the virtual screen as origin, not the top left of the actual status bar, to bring this in line with SBARINFO.

The Strife status bar which was still native code had it differently and that was used as the initial guideline.
This commit is contained in:
Christoph Oelckers 2017-03-27 09:52:30 +02:00
parent bc95e5180d
commit 0fdd118906
4 changed files with 51 additions and 60 deletions

View file

@ -1620,7 +1620,7 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla
if (!fullscreenOffsets) if (!fullscreenOffsets)
{ {
x += ST_X; x += ST_X;
y += ST_Y; //y += ST_Y;
// Todo: Allow other scaling values, too. // Todo: Allow other scaling values, too.
if (Scaled) if (Scaled)
@ -1835,7 +1835,7 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d
if (!fullscreenOffsets) if (!fullscreenOffsets)
{ {
rx += ST_X; rx += ST_X;
ry += ST_Y; //ry += ST_Y;
// Todo: Allow other scaling values, too. // Todo: Allow other scaling values, too.
if (Scaled) if (Scaled)

View file

@ -20,14 +20,6 @@ class DoomStatusBar : BaseStatusBar
diparms = InventoryBarState.Create(); diparms = InventoryBarState.Create();
} }
override void NewGame ()
{
if (CPlayer != NULL)
{
AttachToPlayer (CPlayer);
}
}
override void Draw (int state, double TicFrac) override void Draw (int state, double TicFrac)
{ {
Super.Draw (state, TicFrac); Super.Draw (state, TicFrac);
@ -46,16 +38,16 @@ class DoomStatusBar : BaseStatusBar
protected void DrawMainBar (double TicFrac) protected void DrawMainBar (double TicFrac)
{ {
DrawImage("STBAR", (0, 0), DI_ITEM_OFFSETS); DrawImage("STBAR", (0, 168), DI_ITEM_OFFSETS);
DrawImage("STTPRCNT", (90, 3), DI_ITEM_OFFSETS); DrawImage("STTPRCNT", (90, 171), DI_ITEM_OFFSETS);
DrawImage("STTPRCNT", (221, 3), DI_ITEM_OFFSETS); DrawImage("STTPRCNT", (221, 171), DI_ITEM_OFFSETS);
Inventory a1, a2; Inventory a1, a2;
int amt1; int amt1;
[a1, a2, amt1] = GetCurrentAmmo(); [a1, a2, amt1] = GetCurrentAmmo();
DrawString(mHUDFont, FormatNumber(amt1, 3), (44, 3), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW); DrawString(mHUDFont, FormatNumber(amt1, 3), (44, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (90, 3), 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, 3), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW); DrawString(mHUDFont, FormatNumber(GetArmorAmount(), 3), (221, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
bool locks[6]; bool locks[6];
String image; String image;
@ -64,72 +56,72 @@ class DoomStatusBar : BaseStatusBar
if (locks[1] && locks[4]) image = "STKEYS6"; if (locks[1] && locks[4]) image = "STKEYS6";
else if (locks[1]) image = "STKEYS0"; else if (locks[1]) image = "STKEYS0";
else if (locks[4]) image = "STKEYS3"; else if (locks[4]) image = "STKEYS3";
DrawImage(image, (239, 3), DI_ITEM_OFFSETS); DrawImage(image, (239, 171), DI_ITEM_OFFSETS);
// key 2 // key 2
if (locks[2] && locks[5]) image = "STKEYS7"; if (locks[2] && locks[5]) image = "STKEYS7";
else if (locks[2]) image = "STKEYS1"; else if (locks[2]) image = "STKEYS1";
else if (locks[5]) image = "STKEYS4"; else if (locks[5]) image = "STKEYS4";
else image = ""; else image = "";
DrawImage(image, (239, 13), DI_ITEM_OFFSETS); DrawImage(image, (239, 181), DI_ITEM_OFFSETS);
// key 3 // key 3
if (locks[0] && locks[3]) image = "STKEYS8"; if (locks[0] && locks[3]) image = "STKEYS8";
else if (locks[0]) image = "STKEYS2"; else if (locks[0]) image = "STKEYS2";
else if (locks[3]) image = "STKEYS5"; else if (locks[3]) image = "STKEYS5";
else image = ""; else image = "";
DrawImage(image, (239, 23), DI_ITEM_OFFSETS); DrawImage(image, (239, 191), DI_ITEM_OFFSETS);
int maxamt; int maxamt;
[amt1, maxamt] = GetAmount("Clip"); [amt1, maxamt] = GetAmount("Clip");
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 5), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 173), DI_TEXT_ALIGN_RIGHT);
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 5), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 173), DI_TEXT_ALIGN_RIGHT);
[amt1, maxamt] = GetAmount("Shell"); [amt1, maxamt] = GetAmount("Shell");
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 11), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 179), DI_TEXT_ALIGN_RIGHT);
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 11), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 179), DI_TEXT_ALIGN_RIGHT);
[amt1, maxamt] = GetAmount("RocketAmmo"); [amt1, maxamt] = GetAmount("RocketAmmo");
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 17), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 185), DI_TEXT_ALIGN_RIGHT);
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 17), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 185), DI_TEXT_ALIGN_RIGHT);
[amt1, maxamt] = GetAmount("Cell"); [amt1, maxamt] = GetAmount("Cell");
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 23), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 191), DI_TEXT_ALIGN_RIGHT);
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 23), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 191), DI_TEXT_ALIGN_RIGHT);
if (deathmatch || teamplay) if (deathmatch || teamplay)
{ {
DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (138, 3), DI_TEXT_ALIGN_RIGHT); DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (138, 171), DI_TEXT_ALIGN_RIGHT);
} }
else else
{ {
DrawImage("STARMS", (104, 0), DI_ITEM_OFFSETS); DrawImage("STARMS", (104, 168), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(2)? "STYSNUM2" : "STGNUM2", (111, 3), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(2)? "STYSNUM2" : "STGNUM2", (111, 171), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(3)? "STYSNUM3" : "STGNUM3", (123, 3), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(3)? "STYSNUM3" : "STGNUM3", (123, 171), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(4)? "STYSNUM4" : "STGNUM4", (135, 3), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(4)? "STYSNUM4" : "STGNUM4", (135, 171), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(5)? "STYSNUM5" : "STGNUM5", (111, 13), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(5)? "STYSNUM5" : "STGNUM5", (111, 181), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(6)? "STYSNUM6" : "STGNUM6", (123, 13), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(6)? "STYSNUM6" : "STGNUM6", (123, 181), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(7)? "STYSNUM7" : "STGNUM7", (135, 13), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(7)? "STYSNUM7" : "STGNUM7", (135, 181), DI_ITEM_OFFSETS);
} }
if (multiplayer) if (multiplayer)
{ {
DrawImage("STFBANY", (143, 0), DI_ITEM_OFFSETS|DI_TRANSLATABLE); DrawImage("STFBANY", (143, 168), DI_ITEM_OFFSETS|DI_TRANSLATABLE);
} }
if (CPlayer.mo.InvSel != null && !level.NoInventoryBar) if (CPlayer.mo.InvSel != null && !level.NoInventoryBar)
{ {
DrawInventoryIcon(CPlayer.mo.InvSel, (160, 30)); DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198));
if (CPlayer.mo.InvSel.Amount > 0) if (CPlayer.mo.InvSel.Amount > 0)
{ {
DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 30-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD); DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 198-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD);
} }
} }
else else
{ {
DrawTexture(GetMugShot(5), (143, 0), DI_ITEM_OFFSETS); DrawTexture(GetMugShot(5), (143, 168), DI_ITEM_OFFSETS);
} }
if (CPlayer.inventorytics != 0 && !level.NoInventoryBar) if (CPlayer.inventorytics != 0 && !level.NoInventoryBar)
{ {
DrawInventoryBar(diparms, (48, 1), 7, DI_ITEM_LEFT_TOP); DrawInventoryBar(diparms, (48, 169), 7, DI_ITEM_LEFT_TOP);
} }
} }

View file

@ -262,7 +262,7 @@ class BaseStatusBar native ui
virtual void FlashItem (class<Inventory> itemtype) {} virtual void FlashItem (class<Inventory> itemtype) {}
virtual void AttachToPlayer (PlayerInfo player) { CPlayer = player; } virtual void AttachToPlayer (PlayerInfo player) { CPlayer = player; }
virtual void FlashCrosshair () { CrosshairSize = XHAIRPICKUPSIZE; } virtual void FlashCrosshair () { CrosshairSize = XHAIRPICKUPSIZE; }
virtual void NewGame () {} virtual void NewGame () { if (CPlayer != null) AttachToPlayer(CPlayer); }
virtual void ShowPop (int popnum) { ShowLog = (popnum == POP_Log && !ShowLog); } virtual void ShowPop (int popnum) { ShowLog = (popnum == POP_Log && !ShowLog); }
virtual bool MustDrawLog(int state) { return true; } virtual bool MustDrawLog(int state) { return true; }
@ -805,14 +805,16 @@ class DynamicValueInterpolator : Object
{ {
int mCurrentValue; int mCurrentValue;
int mMinChange; int mMinChange;
int mMaxChange;
double mChangeFactor; double mChangeFactor;
static DynamicValueInterpolator Create(int startval, double changefactor, int minchange) static DynamicValueInterpolator Create(int startval, double changefactor, int minchange, int maxchange)
{ {
let v = new("DynamicValueInterpolator"); let v = new("DynamicValueInterpolator");
v.mCurrentValue = startval; v.mCurrentValue = startval;
v.mMinChange = minchange; v.mMinChange = minchange;
v.mMaxChange = maxchange;
v.mChangeFactor = changefactor; v.mChangeFactor = changefactor;
return v; return v;
} }
@ -821,7 +823,7 @@ class DynamicValueInterpolator : Object
// Do not call this in the Draw function because that may skip some frames! // Do not call this in the Draw function because that may skip some frames!
void Update(int destvalue) void Update(int destvalue)
{ {
int diff = int(max(abs(destvalue - mCurrentValue) * mChangeFactor, mMinChange)); int diff = int(clamp(abs(destvalue - mCurrentValue) * mChangeFactor, mMinChange, mMaxChange));
if (mCurrentValue > destvalue) if (mCurrentValue > destvalue)
{ {
mCurrentValue = max(destvalue, mCurrentValue - diff); mCurrentValue = max(destvalue, mCurrentValue - diff);

View file

@ -71,11 +71,8 @@ class StrifeStatusBar : BaseStatusBar
override void NewGame () override void NewGame ()
{ {
Super.NewGame();
Reset (); Reset ();
if (CPlayer != NULL)
{
AttachToPlayer (CPlayer);
}
} }
override void Draw (int state, double TicFrac) override void Draw (int state, double TicFrac)
@ -290,11 +287,11 @@ class StrifeStatusBar : BaseStatusBar
DrawPopScreen (Scaled ? (ST_Y - 8) * screen.GetHeight() / 200 : ST_Y - 8, TicFrac); DrawPopScreen (Scaled ? (ST_Y - 8) * screen.GetHeight() / 200 : ST_Y - 8, TicFrac);
} }
DrawImage("INVBACK", (0, 0), DI_ITEM_OFFSETS); DrawImage("INVBACK", (0, 168), DI_ITEM_OFFSETS);
DrawImage("INVTOP", (0, -8), DI_ITEM_OFFSETS); DrawImage("INVTOP", (0, 160), DI_ITEM_OFFSETS);
// Health // Health
DrawString(mGrnFont, FormatNumber(CPlayer.health, 3, 5), (79, -6), DI_TEXT_ALIGN_RIGHT); DrawString(mGrnFont, FormatNumber(CPlayer.health, 3, 5), (79, 162), DI_TEXT_ALIGN_RIGHT);
int points; int points;
if (CPlayer.cheats & CF_GODMODE) if (CPlayer.cheats & CF_GODMODE)
{ {
@ -304,30 +301,30 @@ class StrifeStatusBar : BaseStatusBar
{ {
points = min(CPlayer.health, 200); points = min(CPlayer.health, 200);
} }
DrawHealthBar (points, 49, 4); DrawHealthBar (points, 49, 172);
DrawHealthBar (points, 49, 7); DrawHealthBar (points, 49, 175);
// Armor // Armor
item = CPlayer.mo.FindInventory('BasicArmor'); item = CPlayer.mo.FindInventory('BasicArmor');
if (item != NULL && item.Amount > 0) if (item != NULL && item.Amount > 0)
{ {
DrawInventoryIcon(item, (2, 9), DI_ITEM_OFFSETS); DrawInventoryIcon(item, (2, 177), DI_ITEM_OFFSETS);
DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (27, 23), DI_TEXT_ALIGN_RIGHT); DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (27, 191), DI_TEXT_ALIGN_RIGHT);
} }
// Ammo // Ammo
Inventory ammo1 = GetCurrentAmmo (); Inventory ammo1 = GetCurrentAmmo ();
if (ammo1 != NULL) if (ammo1 != NULL)
{ {
DrawString(mGrnFont, FormatNumber(ammo1.Amount, 3, 5), (311, -6), DI_TEXT_ALIGN_RIGHT); DrawString(mGrnFont, FormatNumber(ammo1.Amount, 3, 5), (311, 162), DI_TEXT_ALIGN_RIGHT);
DrawInventoryIcon (ammo1, (290, 13), DI_ITEM_OFFSETS); DrawInventoryIcon (ammo1, (290, 181), DI_ITEM_OFFSETS);
} }
// Sigil // Sigil
item = CPlayer.mo.FindInventory('Sigil'); item = CPlayer.mo.FindInventory('Sigil');
if (item != NULL) if (item != NULL)
{ {
DrawInventoryIcon (item, (253, 7), DI_ITEM_OFFSETS); DrawInventoryIcon (item, (253, 175), DI_ITEM_OFFSETS);
} }
// Inventory // Inventory
@ -339,10 +336,10 @@ class StrifeStatusBar : BaseStatusBar
int flags = item.Amount <= 0? DI_ITEM_OFFSETS|DI_DIM : DI_ITEM_OFFSETS; int flags = item.Amount <= 0? DI_ITEM_OFFSETS|DI_DIM : DI_ITEM_OFFSETS;
if (item == CPlayer.mo.InvSel) if (item == CPlayer.mo.InvSel)
{ {
DrawTexture (Images[CursorImage], (42 + 35*i, 12), flags, 1. - ItemFlash); DrawTexture (Images[CursorImage], (42 + 35*i, 180), flags, 1. - ItemFlash);
} }
DrawInventoryIcon (item, (48 + 35*i, 14), flags); DrawInventoryIcon (item, (48 + 35*i, 182), flags);
DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (75 + 35*i, 23), DI_TEXT_ALIGN_RIGHT); DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (75 + 35*i, 191), DI_TEXT_ALIGN_RIGHT);
i++; i++;
} }
} }