- fixed ForcedScale handling in SBARINFO.

Due to the setup it would miss setting it when changing between HUDs.
This commit is contained in:
Christoph Oelckers 2017-03-29 20:01:57 +02:00
parent 401a1e80e8
commit 9d1031f0ba
2 changed files with 7 additions and 10 deletions

View file

@ -400,7 +400,7 @@ public:
void BeginStatusBar(int resW, int resH, int relTop, bool forceScaled); void BeginStatusBar(int resW, int resH, int relTop, bool forceScaled);
void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false); 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; void StatusbarToRealCoords(double &x, double &y, double &w, double &h) const;
int GetTopOfStatusbar() const int GetTopOfStatusbar() const
{ {

View file

@ -1030,10 +1030,7 @@ public:
{ {
hud = STBAR_NONE; hud = STBAR_NONE;
} }
if(script->huds[hud]->ForceScaled()) //scale the statusbar wrapper->ForceHUDScale(script->huds[hud]->ForceScaled());
{
wrapper->ForceHUDScale(true);
}
if (CPlayer->ReadyWeapon != NULL) if (CPlayer->ReadyWeapon != NULL)
{ {
@ -1061,8 +1058,8 @@ public:
{ {
script->huds[hud]->Tick(NULL, this, true); script->huds[hud]->Tick(NULL, this, true);
// Restore scaling if need be. // Restore scaling if need be.
wrapper->ForceHUDScale(false);
} }
wrapper->ForceHUDScale(script->huds[hud]->ForceScaled());
if(currentPopup != DBaseStatusBar::POP_None && !script->huds[hud]->FullScreenOffsets()) 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.); script->huds[hud]->Draw(NULL, this, script->popups[currentPopup-1].getXDisplacement(), script->popups[currentPopup-1].getYDisplacement(), 1.);
@ -1083,6 +1080,8 @@ public:
else else
inventoryBar->DrawAux(NULL, this, 0, 0, 1.); inventoryBar->DrawAux(NULL, this, 0, 0, 1.);
} }
// Reset hud scale
wrapper->ForceHUDScale(false);
} }
// Handle popups // Handle popups
@ -1106,8 +1105,6 @@ public:
else else
lastPopup = NULL; lastPopup = NULL;
// Reset hud scale
wrapper->ForceHUDScale(false);
} }
void _NewGame () void _NewGame ()
@ -1473,9 +1470,9 @@ private:
void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, double alpha) void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, double alpha)
{ {
// Popups can also be forced to scale // 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); Draw(block, statusBar, xOffset, yOffset, alpha);
statusBar->wrapper->ForceHUDScale(false); statusBar->wrapper->ForceHUDScale(old);
} }
#include "sbarinfo_commands.cpp" #include "sbarinfo_commands.cpp"