mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-31 04:50:48 +00:00
- reinstated the old clean scaling factor calculation just for the status bar.
Some mods took the lack of validation in this code for granted.
This commit is contained in:
parent
23412a4f28
commit
cd929e0c76
1 changed files with 42 additions and 1 deletions
|
@ -388,6 +388,47 @@ void DBaseStatusBar::SetSize(int reltop, int hres, int vres, int hhres, int hvre
|
||||||
SetDrawSize(reltop, hres, vres);
|
SetDrawSize(reltop, hres, vres);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ST_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany)
|
||||||
|
{
|
||||||
|
float ratio;
|
||||||
|
int cwidth;
|
||||||
|
int cheight;
|
||||||
|
int cx1, cy1, cx2, cy2;
|
||||||
|
|
||||||
|
ratio = ActiveRatio(realwidth, realheight);
|
||||||
|
if (AspectTallerThanWide(ratio))
|
||||||
|
{
|
||||||
|
cwidth = realwidth;
|
||||||
|
cheight = realheight * AspectMultiplier(ratio) / 48;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cwidth = realwidth * AspectMultiplier(ratio) / 48;
|
||||||
|
cheight = realheight;
|
||||||
|
}
|
||||||
|
// Use whichever pair of cwidth/cheight or width/height that produces less difference
|
||||||
|
// between CleanXfac and CleanYfac.
|
||||||
|
cx1 = MAX(cwidth / designwidth, 1);
|
||||||
|
cy1 = MAX(cheight / designheight, 1);
|
||||||
|
cx2 = MAX(realwidth / designwidth, 1);
|
||||||
|
cy2 = MAX(realheight / designheight, 1);
|
||||||
|
if (abs(cx1 - cy1) <= abs(cx2 - cy2) || MAX(cx1, cx2) >= 4)
|
||||||
|
{ // e.g. 640x360 looks better with this.
|
||||||
|
*cleanx = cx1;
|
||||||
|
*cleany = cy1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // e.g. 720x480 looks better with this.
|
||||||
|
*cleanx = cx2;
|
||||||
|
*cleany = cy2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*cleanx < *cleany)
|
||||||
|
*cleany = *cleanx;
|
||||||
|
else
|
||||||
|
*cleanx = *cleany;
|
||||||
|
}
|
||||||
|
|
||||||
void DBaseStatusBar::SetDrawSize(int reltop, int hres, int vres)
|
void DBaseStatusBar::SetDrawSize(int reltop, int hres, int vres)
|
||||||
{
|
{
|
||||||
ValidateResolution(hres, vres);
|
ValidateResolution(hres, vres);
|
||||||
|
@ -396,7 +437,7 @@ void DBaseStatusBar::SetDrawSize(int reltop, int hres, int vres)
|
||||||
HorizontalResolution = hres;
|
HorizontalResolution = hres;
|
||||||
VerticalResolution = vres;
|
VerticalResolution = vres;
|
||||||
int x, y;
|
int x, y;
|
||||||
V_CalcCleanFacs(hres, vres, SCREENWIDTH, SCREENHEIGHT, &x, &y);
|
ST_CalcCleanFacs(hres, vres, SCREENWIDTH, SCREENHEIGHT, &x, &y);
|
||||||
defaultScale = { (double)x, (double)y };
|
defaultScale = { (double)x, (double)y };
|
||||||
|
|
||||||
SetScale(); // recalculate positioning info.
|
SetScale(); // recalculate positioning info.
|
||||||
|
|
Loading…
Reference in a new issue