From d500dc99ea58399d1d3392cd4577501754c60e98 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 6 Dec 2018 20:21:33 +0100 Subject: [PATCH] - handle the Harmony status bar icon scaling a bit more robustly. Considering that the physical texture size should be abstracted away from modding this needs to be done differently. Doing any calculations with physical texture sizes on the mod side is only going to cause errors so this had been changed to always return scaled size. --- wadsrc/static/zscript/statusbar/harm_sbar.txt | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/wadsrc/static/zscript/statusbar/harm_sbar.txt b/wadsrc/static/zscript/statusbar/harm_sbar.txt index 42a30f2fc..729df7cda 100644 --- a/wadsrc/static/zscript/statusbar/harm_sbar.txt +++ b/wadsrc/static/zscript/statusbar/harm_sbar.txt @@ -1,6 +1,6 @@ class HarmonyStatusBar : DoomStatusBar { - int scalestate; + double scaleFactor; override void Init() { @@ -10,22 +10,14 @@ class HarmonyStatusBar : DoomStatusBar let tex = TexMan.CheckForTexture("MEDIA0", TexMan.Type_Sprite); if (tex.isValid()) { - int size = TexMan.GetSize(tex); Vector2 ssize = TexMan.GetScaledSize(tex); - if (ssize.X ~== size) scalestate = 1; - else scalestate = 0; + Vector2 facs = (ssize.X / 31, ssize.Y / 18); + scaleFactor = min(facs.X, facs.Y, 1); } - else scalestate = 1; } override void Draw (int state, double TicFrac) { - if (!scalestate) - { - Super.Draw(state, TicFrac); - return; - } - BaseStatusBar.Draw (state, TicFrac); if (state == HUD_StatusBar) @@ -44,13 +36,13 @@ class HarmonyStatusBar : DoomStatusBar { Vector2 iconbox = (40, 20); // Draw health - DrawImage("MEDIA0", (20, -2), scale:(0.3, 0.3)); + DrawImage("MEDIA0", (20, -2), scale(scaleFactor, scaleFactor)); DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (44, -20)); let armor = CPlayer.mo.FindInventory("BasicArmor"); if (armor != null && armor.Amount > 0) { - DrawInventoryIcon(armor, (20, -22), scale:(0.3, 0.3)); + DrawInventoryIcon(armor, (20, -22), scale(scaleFactor, scaleFactor)); DrawString(mHUDFont, FormatNumber(armor.Amount, 3), (44, -40)); } Inventory ammotype1, ammotype2; @@ -58,13 +50,13 @@ class HarmonyStatusBar : DoomStatusBar int invY = -20; if (ammotype1 != null) { - DrawInventoryIcon(ammotype1, (-14, -4), scale:(0.3, 0.3)); + DrawInventoryIcon(ammotype1, (-14, -4), scale(scaleFactor, scaleFactor)); DrawString(mHUDFont, FormatNumber(ammotype1.Amount, 3), (-30, -20), DI_TEXT_ALIGN_RIGHT); invY -= 20; } if (ammotype2 != null && ammotype2 != ammotype1) { - DrawInventoryIcon(ammotype2, (-14, invY + 17), scale:(0.3, 0.3)); + DrawInventoryIcon(ammotype2, (-14, invY + 17), scale(scaleFactor, scaleFactor)); DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); invY -= 20; }