mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-16 01:21:17 +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
d697d4dc2a
commit
a36aa185db
1 changed files with 42 additions and 1 deletions
|
@ -420,6 +420,47 @@ void DBaseStatusBar::SetSize(int reltop, int hres, int vres, int hhres, int hvre
|
|||
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)
|
||||
{
|
||||
ValidateResolution(hres, vres);
|
||||
|
@ -428,7 +469,7 @@ void DBaseStatusBar::SetDrawSize(int reltop, int hres, int vres)
|
|||
HorizontalResolution = hres;
|
||||
VerticalResolution = vres;
|
||||
int x, y;
|
||||
V_CalcCleanFacs(hres, vres, SCREENWIDTH, SCREENHEIGHT, &x, &y);
|
||||
ST_CalcCleanFacs(hres, vres, SCREENWIDTH, SCREENHEIGHT, &x, &y);
|
||||
defaultScale = { (double)x, (double)y };
|
||||
|
||||
SetScale(); // recalculate positioning info.
|
||||
|
|
Loading…
Reference in a new issue