From 8ffda1c9d13469d1ff83de13e4d2ded02eac6506 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Feb 2021 00:09:22 +0100 Subject: [PATCH] - Duke: Calculate the true font height of the numbers for alignment in the Statusbar. The original tiles are all 15 pixels tall, but depending on the games can vary in their true height, so use CheckRealHeight on them to get their true dimensions. Fixes #250 --- source/core/textures/hightile.cpp | 2 +- source/games/duke/src/sbar_d.cpp | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/source/core/textures/hightile.cpp b/source/core/textures/hightile.cpp index cfbbdd703..766ebf8ff 100644 --- a/source/core/textures/hightile.cpp +++ b/source/core/textures/hightile.cpp @@ -311,7 +311,7 @@ int tileSetSkybox(int picnum, int palnum, const char **facenames, int flags ) // //=========================================================================== -static bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick) +bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick) { if (!tex->isValid() || tex->GetTexelWidth() <= 0 || tex->GetTexelHeight() <= 0) return false; diff --git a/source/games/duke/src/sbar_d.cpp b/source/games/duke/src/sbar_d.cpp index 7c6883b8c..088b47148 100644 --- a/source/games/duke/src/sbar_d.cpp +++ b/source/games/duke/src/sbar_d.cpp @@ -44,6 +44,7 @@ source as it is released. #include "texturemanager.h" #include "dukeactor.h" +bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick); BEGIN_DUKE_NS @@ -57,6 +58,8 @@ BEGIN_DUKE_NS class DDukeStatusBar : public DDukeCommonStatusBar { DECLARE_CLASS(DDukeStatusBar, DDukeCommonStatusBar) + + int fontheight[2]; public: DDukeStatusBar() @@ -72,6 +75,27 @@ public: ammo_sprites = { -1, AMMO, SHOTGUNAMMO, BATTERYAMMO, RPGAMMO, HBOMBAMMO, CRYSTALAMMO, DEVISTATORAMMO, TRIPBOMBSPRITE, FREEZEAMMO + 1, HBOMBAMMO, GROWAMMO, FLAMETHROWERAMMO + 1 }; item_icons = { 0, FIRSTAID_ICON, STEROIDS_ICON, HOLODUKE_ICON, JETPACK_ICON, HEAT_ICON, AIRTANK_ICON, BOOT_ICON }; + + fontheight[1] = fontheight[0] = 0; + for (int i = 0; i < 9; i++) + { + auto zerotex = tileGetTexture(BIGALPHANUM - 10 + i); + if (zerotex) + { + int fh0 = zerotex->GetTexture()->CheckRealHeight(); + int fh1 = fh0; + TexturePick pick; + if (PickTexture(zerotex, TRANSLATION(Translation_Remap, 0), pick)) + { + int oheight = zerotex->GetTexelHeight(); + int dheight = pick.texture->GetTexelHeight(); + int dReal = pick.texture->CheckRealHeight(); + fh1 = Scale(dReal, oheight, dheight); + } + if (fh0 > fontheight[0]) fontheight[0] = fh0; + if (fh1 > fontheight[1]) fontheight[1] = fh1; + } + } } //========================================================================== @@ -120,11 +144,12 @@ public: void FullscreenHUD1(struct player_struct* p, int snum) { + int fh = fontheight[hw_hightile ? 1 : 0]; FString format; FGameTexture* img; double imgScale; - double baseScale = (scale * numberFont->mFont->GetHeight()) * (isNamWW2GI() ? 0.65 : !isPlutoPak() ? 0.75 : 0.7); - double texty = -numberFont->mFont->GetHeight() + (isNamWW2GI() ? 2.5 : !isPlutoPak() ? 3.5 : 4.5); + double baseScale = (scale * (fh+1)); + double texty = -fh - 2; // // Health