From 10671ddf46449d9333c9162f01dc5b0938afa017 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 28 Sep 2025 10:08:11 +0800 Subject: [PATCH] [HRP] Fixed a crash and a visual glitch in the interface bar * when the game width is greater than side panel graphics + iface bar. (closes #598) --- sfall/HRP/Image.cpp | 10 +++++----- sfall/HRP/Image.h | 2 +- sfall/HRP/InterfaceBar.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sfall/HRP/Image.cpp b/sfall/HRP/Image.cpp index 826634f6..9681c952 100644 --- a/sfall/HRP/Image.cpp +++ b/sfall/HRP/Image.cpp @@ -28,7 +28,7 @@ long Image::GetDarkColor(fo::PALETTE* palette) { return index; } -long Image::GetAspectSize(long sW, long sH, long* x, long* y, long &dW, long &dH) { +void Image::GetAspectSize(long sW, long sH, long* x, long* y, long &dW, long &dH) { float sWf = (float)sW; float sHf = (float)sH; @@ -38,17 +38,17 @@ long Image::GetAspectSize(long sW, long sH, long* x, long* y, long &dW, long &dH float aspectS = sWf / sHf; if (aspectD < aspectS) { - dH = (long)((sHf / sWf) * dW); // set new height + dH = (long)((dW / sWf) * sHf); // set new height long cy = (height - dH) / 2; // shift y-offset center if (y) *y = cy; - return cy * width; + //return cy * width; } else if (aspectD > aspectS) { dW = (long)((dH / sHf) * sWf); // set new width long cx = (width - dW) / 2; // shift x-offset center if (x) *x = cx; - return cx; + //return cx; } - return 0; + //return 0; } // Resizes src image to dWidth/dHeight size diff --git a/sfall/HRP/Image.h b/sfall/HRP/Image.h index 8f91190f..127829f3 100644 --- a/sfall/HRP/Image.h +++ b/sfall/HRP/Image.h @@ -13,7 +13,7 @@ class Image { public: static long GetDarkColor(fo::PALETTE* palette); - static long GetAspectSize(long sW, long sH, long* x, long* y, long &dW, long &dH); + static void GetAspectSize(long sW, long sH, long* x, long* y, long &dW, long &dH); static void Scale(BYTE* src, long sWight, long sHeight, BYTE* dst, long dWight, long dHeight, long dPitch = 0, long sPitch = 0); static void ScaleText(BYTE* dst, const char* text, long txtWidth, long dstWidth, long colorFlags, float scaleFactor); diff --git a/sfall/HRP/InterfaceBar.cpp b/sfall/HRP/InterfaceBar.cpp index 34a4115e..f2db3b40 100644 --- a/sfall/HRP/InterfaceBar.cpp +++ b/sfall/HRP/InterfaceBar.cpp @@ -55,8 +55,8 @@ static class Panels { BYTE* scr = frm->frameData[0].data; // set the position to the right side - if (!IFaceBar::IFACE_BAR_SIDES_ORI && win->wRect.left <= 0) scr += (frm->frameData[0].width - win->width); - if (IFaceBar::IFACE_BAR_SIDES_ORI && win->wRect.left > xPosition) scr += (frm->frameData[0].width - win->width); + if (!IFaceBar::IFACE_BAR_SIDES_ORI && win->wRect.left <= 0) scr += (frm->frameData[0].width - width); + if (IFaceBar::IFACE_BAR_SIDES_ORI && win->wRect.left > xPosition) scr += (frm->frameData[0].width - width); fo::func::cscale(scr, width, frm->frameData[0].height, frm->frameData[0].width, win->surface, win->width, win->height, win->width); }