From 598523a1ded352283b426735315095831d61d1e8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 01:59:03 +0200 Subject: [PATCH] - moved all coordinate adjustment for the status bar mode into one function and use this function in all places where status bar related coordinate adjustments need to be performed, also in SBARINFO. - fixed unscaled status bar placement. - fixed inventory count display for Doom status bar. --- src/g_statusbar/sbar.h | 2 + src/g_statusbar/sbarinfo.cpp | 36 ++++----------- src/g_statusbar/shared_sbar.cpp | 46 +++++++++---------- wadsrc/static/zscript/statusbar/doom_sbar.txt | 2 +- 4 files changed, 33 insertions(+), 53 deletions(-) diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index d7c7717674..3ac2681f1d 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -402,6 +402,7 @@ public: void BeginStatusBar(int resW, int resH, int relTop, bool completeborder = false, 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. + void StatusbarToRealCoords(double &x, double &y, double &w, double &h) const; //protected: void DrawPowerups (); @@ -410,6 +411,7 @@ public: void RefreshBackground () const; public: + AInventory *ValidateInvFirst (int numVisible) const; void DrawCrosshair (); diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 9f069b831e..8c775dd84c 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -1200,10 +1200,6 @@ public: if(!fullScreenOffsets) { double tmp = 0; - int barW = wrapper->HorizontalResolution, barH = wrapper->VerticalResolution; - - dx += wrapper->ST_X; - dy += wrapper->ST_Y - (wrapper->Scaled ? barH : 200) + script->height; w = forceWidth < 0 ? texture->GetScaledWidthDouble() : forceWidth; h = forceHeight < 0 ? texture->GetScaledHeightDouble() : forceHeight; double dcx = clip[0] == 0 ? 0 : dx + clip[0] - texture->GetScaledLeftOffsetDouble(); @@ -1211,24 +1207,17 @@ public: double dcr = clip[2] == 0 ? INT_MAX : dx + w - clip[2] - texture->GetScaledLeftOffsetDouble(); double dcb = clip[3] == 0 ? INT_MAX : dy + h - clip[3] - texture->GetScaledTopOffsetDouble(); - if(wrapper->Scaled) + if(clip[0] != 0 || clip[1] != 0) { - if(clip[0] != 0 || clip[1] != 0) - { - screen->VirtualToRealCoords(dcx, dcy, tmp, tmp, barW, barH, true); - if (clip[0] == 0) dcx = 0; - if (clip[1] == 0) dcy = 0; - } - if(clip[2] != 0 || clip[3] != 0 || clearDontDraw) - screen->VirtualToRealCoords(dcr, dcb, tmp, tmp, barW, barH, true); - screen->VirtualToRealCoords(dx, dy, w, h, barW, barH, true); + wrapper->StatusbarToRealCoords(dcx, dcy, tmp, tmp); + if (clip[0] == 0) dcx = 0; + if (clip[1] == 0) dcy = 0; } - else + if (clip[2] != 0 || clip[3] != 0 || clearDontDraw) { - dy += 200 - barH; - dcy += 200 - barH; - dcb += 200 - barH; + wrapper->StatusbarToRealCoords(dcr, dcb, tmp, tmp); } + wrapper->StatusbarToRealCoords(dx, dy, w, h); if(clearDontDraw) screen->Clear(static_cast(MAX(dx, dcx)), static_cast(MAX(dy, dcy)), static_cast(MIN(dcr,w+MAX(dx, dcx))), static_cast(MIN(dcb,MAX(dy, dcy)+h)), GPalette.BlackIndex, 0); @@ -1424,16 +1413,7 @@ public: if(!fullScreenOffsets) { - - int barW = wrapper->HorizontalResolution, barH = wrapper->VerticalResolution; - rx += wrapper->ST_X; - ry += wrapper->ST_Y - (wrapper->Scaled ? barH : 200) + script->height; - if(wrapper->Scaled) - screen->VirtualToRealCoords(rx, ry, rw, rh, barW, barH, true); - else - { - ry += (200 - barH); - } + wrapper->StatusbarToRealCoords(rx, ry, rw, rh); } else { diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index b22b48cf2b..3bced97dc4 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -1564,6 +1564,25 @@ uint32_t DBaseStatusBar::GetTranslation() const // //============================================================================ +void DBaseStatusBar::StatusbarToRealCoords(double &x, double &y, double &w, double &h) const +{ + if (Scaled) + { + screen->VirtualToRealCoords(x, y, w, h, HorizontalResolution, VerticalResolution, true, true); + } + else + { + x += ST_X; + y += screen->GetHeight() - VerticalResolution; + } +} + +//============================================================================ +// +// draw stuff +// +//============================================================================ + void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY) { if (!texture.isValid()) @@ -1636,14 +1655,7 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla if (!fullscreenOffsets) { - x += ST_X; - //y += ST_Y; - - // Todo: Allow other scaling values, too. - if (Scaled) - { - screen->VirtualToRealCoords(x, y, boxwidth, boxheight, HorizontalResolution, VerticalResolution, true, true); - } + StatusbarToRealCoords(x, y, boxwidth, boxheight); } else { @@ -1853,14 +1865,7 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d if (!fullscreenOffsets) { - rx += ST_X; - //ry += ST_Y; - - // Todo: Allow other scaling values, too. - if (Scaled) - { - screen->VirtualToRealCoords(rx, ry, rw, rh, HorizontalResolution, VerticalResolution, true); - } + StatusbarToRealCoords(rx, ry, rw, rh); } else { @@ -1963,14 +1968,7 @@ void DBaseStatusBar::Fill(PalEntry color, double x, double y, double w, double h if (!fullscreenOffsets) { - x += ST_X; - //y += ST_Y; - - // Todo: Allow other scaling values, too. - if (Scaled) - { - screen->VirtualToRealCoords(x, y, w, h, HorizontalResolution, VerticalResolution, true, true); - } + StatusbarToRealCoords(x, y, w, h); } else { diff --git a/wadsrc/static/zscript/statusbar/doom_sbar.txt b/wadsrc/static/zscript/statusbar/doom_sbar.txt index 67ea2c620c..b1671889a8 100644 --- a/wadsrc/static/zscript/statusbar/doom_sbar.txt +++ b/wadsrc/static/zscript/statusbar/doom_sbar.txt @@ -110,7 +110,7 @@ class DoomStatusBar : BaseStatusBar if (CPlayer.mo.InvSel != null && !level.NoInventoryBar) { DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198)); - if (CPlayer.mo.InvSel.Amount > 0) + if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 198-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD); }