[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)
This commit is contained in:
NovaRain
2025-09-28 10:08:11 +08:00
parent 4313df2e30
commit 10671ddf46
3 changed files with 8 additions and 8 deletions
+5 -5
View File
@@ -28,7 +28,7 @@ long Image::GetDarkColor(fo::PALETTE* palette) {
return index; 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 sWf = (float)sW;
float sHf = (float)sH; 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; float aspectS = sWf / sHf;
if (aspectD < aspectS) { 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 long cy = (height - dH) / 2; // shift y-offset center
if (y) *y = cy; if (y) *y = cy;
return cy * width; //return cy * width;
} else if (aspectD > aspectS) { } else if (aspectD > aspectS) {
dW = (long)((dH / sHf) * sWf); // set new width dW = (long)((dH / sHf) * sWf); // set new width
long cx = (width - dW) / 2; // shift x-offset center long cx = (width - dW) / 2; // shift x-offset center
if (x) *x = cx; if (x) *x = cx;
return cx; //return cx;
} }
return 0; //return 0;
} }
// Resizes src image to dWidth/dHeight size // Resizes src image to dWidth/dHeight size
+1 -1
View File
@@ -13,7 +13,7 @@ class Image {
public: public:
static long GetDarkColor(fo::PALETTE* palette); 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 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); static void ScaleText(BYTE* dst, const char* text, long txtWidth, long dstWidth, long colorFlags, float scaleFactor);
+2 -2
View File
@@ -55,8 +55,8 @@ static class Panels {
BYTE* scr = frm->frameData[0].data; BYTE* scr = frm->frameData[0].data;
// set the position to the right side // 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 <= 0) scr += (frm->frameData[0].width - 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 > 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); fo::func::cscale(scr, width, frm->frameData[0].height, frm->frameData[0].width, win->surface, win->width, win->height, win->width);
} }