From b9038db433cc1773a65989b3ab16cc3c419344f6 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 21 Aug 2020 22:20:43 +1000 Subject: [PATCH] - remove all the discrete definitions of variables from alt HUDs in Duke/RR/SW. --- source/games/duke/src/sbar_d.cpp | 31 ++++++++++++------------ source/games/duke/src/sbar_r.cpp | 41 ++++++++++++++++++-------------- source/sw/src/sbar.cpp | 32 +++++++++++++------------ 3 files changed, 56 insertions(+), 48 deletions(-) diff --git a/source/games/duke/src/sbar_d.cpp b/source/games/duke/src/sbar_d.cpp index ec36c4a26..3a6ebacfb 100644 --- a/source/games/duke/src/sbar_d.cpp +++ b/source/games/duke/src/sbar_d.cpp @@ -116,16 +116,18 @@ public: void FullscreenHUD1(struct player_struct* p, int snum) { - double imgScale = (scale * numberFont.mFont->GetHeight()) * 0.7; + FString format; + FGameTexture* img; + double imgScale; + double baseScale = (scale * numberFont.mFont->GetHeight()) * 0.7; // // Health // - auto imgHealth = tileGetTexture(COLA); - auto healthScale = imgScale / imgHealth->GetDisplayHeight(); - DrawGraphic(imgHealth, 2, -1.5, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, healthScale, healthScale); + img = tileGetTexture(COLA); + imgScale = baseScale / img->GetDisplayHeight(); + DrawGraphic(img, 2, -1.5, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale); - FString format; if (!althud_flashing || p->last_extra > (max_player_health >> 2) || ((int)totalclock & 32) || (sprite[p->i].pal == 1 && p->last_extra < 2)) { int s = -8; @@ -140,9 +142,9 @@ public: // // Armor // - auto imgArmor = tileGetTexture(SHIELD); - auto armorScale = imgScale / imgArmor->GetDisplayHeight(); - DrawGraphic(imgArmor, 67.375, -1.5, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, armorScale, armorScale); + img = tileGetTexture(SHIELD); + imgScale = baseScale / img->GetDisplayHeight(); + DrawGraphic(img, 67.375, -1.5, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale); format.Format("%d", GetMoraleOrShield(p, snum)); SBar_DrawString(this, &numberFont, format, 85, -numberFont.mFont->GetHeight() + 4.5, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); @@ -157,8 +159,8 @@ public: if (wicon > 0) { format.Format("%d", p->ammo_amount[weapon]); - auto imgWeap = tileGetTexture(wicon); - auto weapScale = imgScale / imgWeap->GetDisplayHeight(); + img = tileGetTexture(wicon); + imgScale = baseScale / img->GetDisplayHeight(); auto imgX = 20.; auto strlen = format.Len(); @@ -172,13 +174,12 @@ public: SBar_DrawString(this, &numberFont, format, -3, -numberFont.mFont->GetHeight() + 4.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); } - DrawGraphic(imgWeap, -imgX, -1.5, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, weapScale, weapScale); + DrawGraphic(img, -imgX, -1.5, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale); } // // Selected inventory item // - unsigned icon = p->inven_icon; if (icon > 0) { @@ -186,9 +187,9 @@ public: if (icon < ICON_MAX) { - auto imgInv = tileGetTexture(item_icons[icon]); - auto invScale = imgScale / imgInv->GetDisplayHeight(); - DrawGraphic(imgInv, x, -1.5, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, invScale, invScale); + img = tileGetTexture(item_icons[icon]); + imgScale = baseScale / img->GetDisplayHeight(); + DrawGraphic(img, x, -1.5, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, imgScale, imgScale); } int percentv = getinvamount(p); diff --git a/source/games/duke/src/sbar_r.cpp b/source/games/duke/src/sbar_r.cpp index a0d2449d6..612508303 100644 --- a/source/games/duke/src/sbar_r.cpp +++ b/source/games/duke/src/sbar_r.cpp @@ -94,16 +94,18 @@ public: void FullscreenHUD1(struct player_struct* p, int snum) { - double imgScale = (scale * numberFont.mFont->GetHeight()) * 0.76; + FString format; + FGameTexture* img; + double imgScale; + double baseScale = (scale * numberFont.mFont->GetHeight()) * 0.76; // // Health // - auto imgHealth = tileGetTexture(SPINNINGNUKEICON+1); - auto healthScale = imgScale / imgHealth->GetDisplayHeight(); - DrawGraphic(imgHealth, 2, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, healthScale, healthScale); + img = tileGetTexture(SPINNINGNUKEICON+1); + imgScale = baseScale / img->GetDisplayHeight(); + DrawGraphic(img, 2, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale); - FString format; if (!althud_flashing || p->last_extra > (max_player_health >> 2) || ((int)totalclock & 32) || (sprite[p->i].pal == 1 && p->last_extra < 2)) { int s = -8; @@ -118,18 +120,18 @@ public: // // drink // - auto imgDrink = tileGetTexture(COLA); - auto drinkScale = imgScale / imgDrink->GetDisplayHeight(); - DrawGraphic(imgDrink, 74, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, drinkScale, drinkScale); + img = tileGetTexture(COLA); + imgScale = baseScale / img->GetDisplayHeight(); + DrawGraphic(img, 74, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale); format.Format("%d", p->drink_amt); SBar_DrawString(this, &numberFont, format, 86, -numberFont.mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); // // eat // - auto imgEat = tileGetTexture(JETPACK); - auto eatScale = imgScale / imgEat->GetDisplayHeight(); - DrawGraphic(imgEat, 133.5, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, eatScale, eatScale); + img = tileGetTexture(JETPACK); + imgScale = baseScale / img->GetDisplayHeight(); + DrawGraphic(img, 133.5, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale); format.Format("%d", p->eat); SBar_DrawString(this, &numberFont, format, 173, -numberFont.mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); @@ -143,8 +145,8 @@ public: if (wicon > 0) { format.Format("%d", p->ammo_amount[weapon]); - auto imgWeap = tileGetTexture(wicon); - auto weapScale = imgScale / imgWeap->GetDisplayHeight(); + img = tileGetTexture(wicon); + imgScale = baseScale / img->GetDisplayHeight(); auto imgX = 22.5; auto strlen = format.Len(); @@ -158,13 +160,12 @@ public: SBar_DrawString(this, &numberFont, format, -1, -numberFont.mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); } - DrawGraphic(imgWeap, -imgX, -2, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, weapScale, weapScale); + DrawGraphic(img, -imgX, -2, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale); } // // Selected inventory item // - unsigned icon = p->inven_icon; if (icon > 0) { @@ -172,9 +173,9 @@ public: if (icon < ICON_MAX) { - auto imgInv = tileGetTexture(item_icons[icon]); - auto invScale = imgScale / imgInv->GetDisplayHeight(); - DrawGraphic(imgInv, x, -2, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, invScale, invScale); + img = tileGetTexture(item_icons[icon]); + imgScale = baseScale / img->GetDisplayHeight(); + DrawGraphic(img, x, -2, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale); } int percentv = getinvamount(p); @@ -185,6 +186,10 @@ public: auto text = ontext(p); if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 20, -miniFont.mFont->GetHeight() * scale - 15, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); } + + // + // keys + // if (p->keys[1]) DrawGraphic(tileGetTexture(ACCESSCARD), -28.5, -32 , DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 0)); if (p->keys[3]) DrawGraphic(tileGetTexture(ACCESSCARD), -21.25, -28.375, DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 23)); if (p->keys[2]) DrawGraphic(tileGetTexture(ACCESSCARD), -14, -24.75 , DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 21)); diff --git a/source/sw/src/sbar.cpp b/source/sw/src/sbar.cpp index 77dbc65bc..aea5dc433 100644 --- a/source/sw/src/sbar.cpp +++ b/source/sw/src/sbar.cpp @@ -758,16 +758,18 @@ private: auto pp = Player + screenpeek; USERp u = User[pp->PlayerSprite]; - double imgScale = numberFont.mFont->GetHeight() * 0.9375; + FString format; + FGameTexture* img; + double imgScale; + double baseScale = numberFont.mFont->GetHeight() * 0.9375; // // Health // - auto imgHealth = tileGetTexture(ICON_SM_MEDKIT); - auto healthScale = imgScale / imgHealth->GetDisplayHeight(); - DrawGraphic(imgHealth, 1.5, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, healthScale, healthScale); + img = tileGetTexture(ICON_SM_MEDKIT); + imgScale = baseScale / img->GetDisplayHeight(); + DrawGraphic(img, 1.5, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale); - FString format; if (!althud_flashing || u->Health > (u->MaxHealth >> 2) || ((int)totalclock & 32)) { int s = -8; @@ -782,9 +784,9 @@ private: // // Armor // - auto imgArmor = tileGetTexture(ICON_ARMOR); - auto armorScale = imgScale / imgArmor->GetDisplayHeight(); - DrawGraphic(imgArmor, 80.75, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, armorScale, armorScale); + img = tileGetTexture(ICON_ARMOR); + imgScale = baseScale / img->GetDisplayHeight(); + DrawGraphic(img, 80.75, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale); format.Format("%d", pp->Armor); SBar_DrawString(this, &numberFont, format, 108.5, -numberFont.mFont->GetHeight(), DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); @@ -800,8 +802,8 @@ private: if (wicon > 0) { format.Format("%d", pp->WpnAmmo[weapon]); - auto imgWeap = tileGetTexture(wicon); - auto weapScale = imgScale / imgWeap->GetDisplayHeight(); + img = tileGetTexture(wicon); + imgScale = baseScale / img->GetDisplayHeight(); auto imgX = 21.125; auto strlen = format.Len(); @@ -815,16 +817,16 @@ private: SBar_DrawString(this, &numberFont, format, -1.5, -numberFont.mFont->GetHeight(), DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); } - DrawGraphic(imgWeap, -imgX, -1, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, weapScale, weapScale); + DrawGraphic(img, -imgX, -1, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale); } // // Selected inventory item // + img = tileGetTexture(icons[pp->InventoryNum]); + imgScale = baseScale / img->GetDisplayHeight(); int x = 165; - auto imgInv = tileGetTexture(icons[pp->InventoryNum]); - auto invScale = imgScale / imgInv->GetDisplayHeight(); - DrawGraphic(imgInv, x, -1, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, invScale, invScale); + DrawGraphic(img, x, -1, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, imgScale, imgScale); PlayerUpdateInventoryState(pp, x + 3.0, -18.0, 1, 1); PlayerUpdateInventoryPercent(pp, x + 3.5, -20.5, 1, 1); @@ -833,7 +835,7 @@ private: // keys // DisplayKeys(pp, -105, -18, 0.8625, 0.8625); - PrintLevelStats(int(imgScale + 4)); + PrintLevelStats(int(baseScale + 4)); }