Skip to content

Commit 10671dd

Browse files
committed
[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)
1 parent 4313df2 commit 10671dd

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

sfall/HRP/Image.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ long Image::GetDarkColor(fo::PALETTE* palette) {
2828
return index;
2929
}
3030

31-
long Image::GetAspectSize(long sW, long sH, long* x, long* y, long &dW, long &dH) {
31+
void Image::GetAspectSize(long sW, long sH, long* x, long* y, long &dW, long &dH) {
3232
float sWf = (float)sW;
3333
float sHf = (float)sH;
3434

@@ -38,17 +38,17 @@ long Image::GetAspectSize(long sW, long sH, long* x, long* y, long &dW, long &dH
3838
float aspectS = sWf / sHf;
3939

4040
if (aspectD < aspectS) {
41-
dH = (long)((sHf / sWf) * dW); // set new height
41+
dH = (long)((dW / sWf) * sHf); // set new height
4242
long cy = (height - dH) / 2; // shift y-offset center
4343
if (y) *y = cy;
44-
return cy * width;
44+
//return cy * width;
4545
} else if (aspectD > aspectS) {
4646
dW = (long)((dH / sHf) * sWf); // set new width
4747
long cx = (width - dW) / 2; // shift x-offset center
4848
if (x) *x = cx;
49-
return cx;
49+
//return cx;
5050
}
51-
return 0;
51+
//return 0;
5252
}
5353

5454
// Resizes src image to dWidth/dHeight size

sfall/HRP/Image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Image {
1313
public:
1414
static long GetDarkColor(fo::PALETTE* palette);
1515

16-
static long GetAspectSize(long sW, long sH, long* x, long* y, long &dW, long &dH);
16+
static void GetAspectSize(long sW, long sH, long* x, long* y, long &dW, long &dH);
1717

1818
static void Scale(BYTE* src, long sWight, long sHeight, BYTE* dst, long dWight, long dHeight, long dPitch = 0, long sPitch = 0);
1919
static void ScaleText(BYTE* dst, const char* text, long txtWidth, long dstWidth, long colorFlags, float scaleFactor);

sfall/HRP/InterfaceBar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ static class Panels {
5555
BYTE* scr = frm->frameData[0].data;
5656

5757
// set the position to the right side
58-
if (!IFaceBar::IFACE_BAR_SIDES_ORI && win->wRect.left <= 0) scr += (frm->frameData[0].width - win->width);
59-
if (IFaceBar::IFACE_BAR_SIDES_ORI && win->wRect.left > xPosition) scr += (frm->frameData[0].width - win->width);
58+
if (!IFaceBar::IFACE_BAR_SIDES_ORI && win->wRect.left <= 0) scr += (frm->frameData[0].width - width);
59+
if (IFaceBar::IFACE_BAR_SIDES_ORI && win->wRect.left > xPosition) scr += (frm->frameData[0].width - width);
6060

6161
fo::func::cscale(scr, width, frm->frameData[0].height, frm->frameData[0].width, win->surface, win->width, win->height, win->width);
6262
}

0 commit comments

Comments
 (0)