From 9d1031f0ba7ee82927ab79af8a1f0f2740b3af8c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 20:01:57 +0200 Subject: [PATCH] - fixed ForcedScale handling in SBARINFO. Due to the setup it would miss setting it when changing between HUDs. --- src/g_statusbar/sbar.h | 2 +- src/g_statusbar/sbarinfo.cpp | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index 1cb0ffb7ff..2f3f7b202f 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -400,7 +400,7 @@ public: void BeginStatusBar(int resW, int resH, int relTop, bool forceScaled); void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false); - void ForceHUDScale(bool on) { ForcedScale = on; } // This is for SBARINFO which should not use BeginStatusBar or BeginHUD. + bool ForceHUDScale(bool on) { std::swap(ForcedScale, on); return on; } // This is for SBARINFO which should not use BeginStatusBar or BeginHUD. void StatusbarToRealCoords(double &x, double &y, double &w, double &h) const; int GetTopOfStatusbar() const { diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 9fcd0c48bd..2c9d962c4e 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -1030,10 +1030,7 @@ public: { hud = STBAR_NONE; } - if(script->huds[hud]->ForceScaled()) //scale the statusbar - { - wrapper->ForceHUDScale(true); - } + wrapper->ForceHUDScale(script->huds[hud]->ForceScaled()); if (CPlayer->ReadyWeapon != NULL) { @@ -1061,8 +1058,8 @@ public: { script->huds[hud]->Tick(NULL, this, true); // Restore scaling if need be. - wrapper->ForceHUDScale(false); } + wrapper->ForceHUDScale(script->huds[hud]->ForceScaled()); if(currentPopup != DBaseStatusBar::POP_None && !script->huds[hud]->FullScreenOffsets()) script->huds[hud]->Draw(NULL, this, script->popups[currentPopup-1].getXDisplacement(), script->popups[currentPopup-1].getYDisplacement(), 1.); @@ -1083,6 +1080,8 @@ public: else inventoryBar->DrawAux(NULL, this, 0, 0, 1.); } + // Reset hud scale + wrapper->ForceHUDScale(false); } // Handle popups @@ -1106,8 +1105,6 @@ public: else lastPopup = NULL; - // Reset hud scale - wrapper->ForceHUDScale(false); } void _NewGame () @@ -1473,9 +1470,9 @@ private: void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, double alpha) { // Popups can also be forced to scale - if(ForceScaled()) statusBar->wrapper->ForceHUDScale(true); + bool old = statusBar->wrapper->ForceHUDScale(ForceScaled()); Draw(block, statusBar, xOffset, yOffset, alpha); - statusBar->wrapper->ForceHUDScale(false); + statusBar->wrapper->ForceHUDScale(old); } #include "sbarinfo_commands.cpp"