From 0fdd118906858a82e04b620c81ffdef4518b8da5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Mar 2017 09:52:30 +0200 Subject: [PATCH] - 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. --- src/g_statusbar/shared_sbar.cpp | 4 +- wadsrc/static/zscript/statusbar/doom_sbar.txt | 68 ++++++++----------- wadsrc/static/zscript/statusbar/statusbar.txt | 8 ++- .../static/zscript/statusbar/strife_sbar.txt | 31 ++++----- 4 files changed, 51 insertions(+), 60 deletions(-) diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index acb9c42952..919d678485 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -1620,7 +1620,7 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla if (!fullscreenOffsets) { x += ST_X; - y += ST_Y; + //y += ST_Y; // Todo: Allow other scaling values, too. if (Scaled) @@ -1835,7 +1835,7 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d if (!fullscreenOffsets) { rx += ST_X; - ry += ST_Y; + //ry += ST_Y; // Todo: Allow other scaling values, too. if (Scaled) diff --git a/wadsrc/static/zscript/statusbar/doom_sbar.txt b/wadsrc/static/zscript/statusbar/doom_sbar.txt index e9e96307cb..7cd2ae4615 100644 --- a/wadsrc/static/zscript/statusbar/doom_sbar.txt +++ b/wadsrc/static/zscript/statusbar/doom_sbar.txt @@ -20,14 +20,6 @@ class DoomStatusBar : BaseStatusBar diparms = InventoryBarState.Create(); } - override void NewGame () - { - if (CPlayer != NULL) - { - AttachToPlayer (CPlayer); - } - } - override void Draw (int state, double TicFrac) { Super.Draw (state, TicFrac); @@ -46,16 +38,16 @@ class DoomStatusBar : BaseStatusBar protected void DrawMainBar (double TicFrac) { - DrawImage("STBAR", (0, 0), DI_ITEM_OFFSETS); - DrawImage("STTPRCNT", (90, 3), DI_ITEM_OFFSETS); - DrawImage("STTPRCNT", (221, 3), DI_ITEM_OFFSETS); + DrawImage("STBAR", (0, 168), DI_ITEM_OFFSETS); + DrawImage("STTPRCNT", (90, 171), DI_ITEM_OFFSETS); + DrawImage("STTPRCNT", (221, 171), DI_ITEM_OFFSETS); Inventory a1, a2; int amt1; [a1, a2, amt1] = GetCurrentAmmo(); - DrawString(mHUDFont, FormatNumber(amt1, 3), (44, 3), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW); - DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (90, 3), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW); - DrawString(mHUDFont, FormatNumber(GetArmorAmount(), 3), (221, 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, 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; @@ -64,72 +56,72 @@ class DoomStatusBar : BaseStatusBar if (locks[1] && locks[4]) image = "STKEYS6"; else if (locks[1]) image = "STKEYS0"; else if (locks[4]) image = "STKEYS3"; - DrawImage(image, (239, 3), DI_ITEM_OFFSETS); + 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, 13), DI_ITEM_OFFSETS); + 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, 23), DI_ITEM_OFFSETS); + DrawImage(image, (239, 191), DI_ITEM_OFFSETS); int maxamt; [amt1, maxamt] = GetAmount("Clip"); - DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 5), DI_TEXT_ALIGN_RIGHT); - DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 5), DI_TEXT_ALIGN_RIGHT); + 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, 11), DI_TEXT_ALIGN_RIGHT); - DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 11), DI_TEXT_ALIGN_RIGHT); + 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, 17), DI_TEXT_ALIGN_RIGHT); - DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 17), DI_TEXT_ALIGN_RIGHT); + 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, 23), DI_TEXT_ALIGN_RIGHT); - DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 23), DI_TEXT_ALIGN_RIGHT); + 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) { - 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 { - DrawImage("STARMS", (104, 0), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(2)? "STYSNUM2" : "STGNUM2", (111, 3), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(3)? "STYSNUM3" : "STGNUM3", (123, 3), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(4)? "STYSNUM4" : "STGNUM4", (135, 3), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(5)? "STYSNUM5" : "STGNUM5", (111, 13), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(6)? "STYSNUM6" : "STGNUM6", (123, 13), DI_ITEM_OFFSETS); - DrawImage(CPlayer.HasWeaponsInSlot(7)? "STYSNUM7" : "STGNUM7", (135, 13), DI_ITEM_OFFSETS); + DrawImage("STARMS", (104, 168), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(2)? "STYSNUM2" : "STGNUM2", (111, 171), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(3)? "STYSNUM3" : "STGNUM3", (123, 171), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(4)? "STYSNUM4" : "STGNUM4", (135, 171), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(5)? "STYSNUM5" : "STGNUM5", (111, 181), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(6)? "STYSNUM6" : "STGNUM6", (123, 181), DI_ITEM_OFFSETS); + DrawImage(CPlayer.HasWeaponsInSlot(7)? "STYSNUM7" : "STGNUM7", (135, 181), DI_ITEM_OFFSETS); } 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) { - DrawInventoryIcon(CPlayer.mo.InvSel, (160, 30)); + DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198)); 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 { - DrawTexture(GetMugShot(5), (143, 0), DI_ITEM_OFFSETS); + DrawTexture(GetMugShot(5), (143, 168), DI_ITEM_OFFSETS); } if (CPlayer.inventorytics != 0 && !level.NoInventoryBar) { - DrawInventoryBar(diparms, (48, 1), 7, DI_ITEM_LEFT_TOP); + DrawInventoryBar(diparms, (48, 169), 7, DI_ITEM_LEFT_TOP); } } diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index 48bc73dd4e..e1bdf4d634 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -262,7 +262,7 @@ class BaseStatusBar native ui virtual void FlashItem (class itemtype) {} virtual void AttachToPlayer (PlayerInfo player) { CPlayer = player; } 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 bool MustDrawLog(int state) { return true; } @@ -805,14 +805,16 @@ class DynamicValueInterpolator : Object { int mCurrentValue; int mMinChange; + int mMaxChange; 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"); v.mCurrentValue = startval; v.mMinChange = minchange; + v.mMaxChange = maxchange; v.mChangeFactor = changefactor; return v; } @@ -821,7 +823,7 @@ class DynamicValueInterpolator : Object // Do not call this in the Draw function because that may skip some frames! 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) { mCurrentValue = max(destvalue, mCurrentValue - diff); diff --git a/wadsrc/static/zscript/statusbar/strife_sbar.txt b/wadsrc/static/zscript/statusbar/strife_sbar.txt index b90a30a76d..889842cc30 100644 --- a/wadsrc/static/zscript/statusbar/strife_sbar.txt +++ b/wadsrc/static/zscript/statusbar/strife_sbar.txt @@ -71,11 +71,8 @@ class StrifeStatusBar : BaseStatusBar override void NewGame () { + Super.NewGame(); Reset (); - if (CPlayer != NULL) - { - AttachToPlayer (CPlayer); - } } 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); } - DrawImage("INVBACK", (0, 0), DI_ITEM_OFFSETS); - DrawImage("INVTOP", (0, -8), DI_ITEM_OFFSETS); + DrawImage("INVBACK", (0, 168), DI_ITEM_OFFSETS); + DrawImage("INVTOP", (0, 160), DI_ITEM_OFFSETS); // 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; if (CPlayer.cheats & CF_GODMODE) { @@ -304,30 +301,30 @@ class StrifeStatusBar : BaseStatusBar { points = min(CPlayer.health, 200); } - DrawHealthBar (points, 49, 4); - DrawHealthBar (points, 49, 7); + DrawHealthBar (points, 49, 172); + DrawHealthBar (points, 49, 175); // Armor item = CPlayer.mo.FindInventory('BasicArmor'); if (item != NULL && item.Amount > 0) { - DrawInventoryIcon(item, (2, 9), DI_ITEM_OFFSETS); - DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (27, 23), DI_TEXT_ALIGN_RIGHT); + DrawInventoryIcon(item, (2, 177), DI_ITEM_OFFSETS); + DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (27, 191), DI_TEXT_ALIGN_RIGHT); } // Ammo Inventory ammo1 = GetCurrentAmmo (); if (ammo1 != NULL) { - DrawString(mGrnFont, FormatNumber(ammo1.Amount, 3, 5), (311, -6), DI_TEXT_ALIGN_RIGHT); - DrawInventoryIcon (ammo1, (290, 13), DI_ITEM_OFFSETS); + DrawString(mGrnFont, FormatNumber(ammo1.Amount, 3, 5), (311, 162), DI_TEXT_ALIGN_RIGHT); + DrawInventoryIcon (ammo1, (290, 181), DI_ITEM_OFFSETS); } // Sigil item = CPlayer.mo.FindInventory('Sigil'); if (item != NULL) { - DrawInventoryIcon (item, (253, 7), DI_ITEM_OFFSETS); + DrawInventoryIcon (item, (253, 175), DI_ITEM_OFFSETS); } // Inventory @@ -339,10 +336,10 @@ class StrifeStatusBar : BaseStatusBar int flags = item.Amount <= 0? DI_ITEM_OFFSETS|DI_DIM : DI_ITEM_OFFSETS; 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); - DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (75 + 35*i, 23), DI_TEXT_ALIGN_RIGHT); + DrawInventoryIcon (item, (48 + 35*i, 182), flags); + DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (75 + 35*i, 191), DI_TEXT_ALIGN_RIGHT); i++; } }