# Conflicts:
#	src/v_video.cpp
This commit is contained in:
raa-eruanna 2016-09-14 02:24:59 -04:00
commit 81545d9b4e
22 changed files with 365 additions and 194 deletions

View file

@ -1914,7 +1914,7 @@ class CommandAspectRatio : public SBarInfoCommandFlowControl
{
SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged);
SetTruth(ratioMap[CheckRatio(screen->GetWidth(), screen->GetHeight())] == ratio, block, statusBar);
SetTruth(ratioMap[FindRatio()] == ratio, block, statusBar);
}
protected:
enum Ratio
@ -1931,6 +1931,37 @@ class CommandAspectRatio : public SBarInfoCommandFlowControl
static Ratio ratioMap[5];
Ratio ratio;
private:
int FindRatio()
{
float aspect = ActiveRatio(screen->GetWidth(), screen->GetHeight());
static std::pair<float, int> ratioTypes[] =
{
{ 21 / 9.0f , ASPECTRATIO_16_9 },
{ 16 / 9.0f , ASPECTRATIO_16_9 },
{ 17 / 10.0f , ASPECTRATIO_17_10 },
{ 16 / 10.0f , ASPECTRATIO_16_10 },
{ 4 / 3.0f , ASPECTRATIO_4_3 },
{ 5 / 4.0f , ASPECTRATIO_5_4 },
{ 0.0f, 0 }
};
int ratio = ratioTypes[0].second;
float distance = fabs(ratioTypes[0].first - aspect);
for (int i = 1; ratioTypes[i].first != 0.0f; i++)
{
float d = fabs(ratioTypes[i].first - aspect);
if (d < distance)
{
ratio = ratioTypes[i].second;
distance = d;
}
}
return ratio;
}
};
CommandAspectRatio::Ratio CommandAspectRatio::ratioMap[5] = {ASPECTRATIO_4_3,ASPECTRATIO_16_9,ASPECTRATIO_16_10,ASPECTRATIO_16_10,ASPECTRATIO_5_4};

View file

@ -1108,13 +1108,13 @@ void DrawHUD()
}
else
{
if (WidescreenRatio == 4)
if (CheckRatio(SCREENWIDTH, SCREENHEIGHT) == 4)
{
hudheight = hudwidth * 30 / BaseRatioSizes[WidescreenRatio][3]; // BaseRatioSizes is inverted for this mode
hudheight = hudwidth * 30 / AspectMultiplier(WidescreenRatio); // BaseRatioSizes is inverted for this mode
}
else
{
hudheight = hudwidth * 30 / (48*48/BaseRatioSizes[WidescreenRatio][3]);
hudheight = hudwidth * 30 / (48*48/AspectMultiplier(WidescreenRatio));
}
}
}

View file

@ -299,14 +299,15 @@ void DBaseStatusBar::SetScaled (bool scale, bool force)
{
ST_X = 0;
ST_Y = VirticalResolution - RelTop;
if (CheckRatio(SCREENWIDTH, SCREENHEIGHT) != 4)
float aspect = ActiveRatio(SCREENWIDTH, SCREENHEIGHT);
if (!AspectTallerThanWide(aspect))
{ // Normal resolution
::ST_Y = Scale (ST_Y, SCREENHEIGHT, VirticalResolution);
}
else
{ // 5:4 resolution
::ST_Y = Scale(ST_Y - VirticalResolution/2, SCREENHEIGHT*3, Scale(VirticalResolution, BaseRatioSizes[4][1], 200)) + SCREENHEIGHT/2
+ (SCREENHEIGHT - SCREENHEIGHT * BaseRatioSizes[4][3] / 48) / 2;
::ST_Y = Scale(ST_Y - VirticalResolution/2, SCREENHEIGHT*3, Scale(VirticalResolution, AspectBaseHeight(aspect), 200)) + SCREENHEIGHT/2
+ (SCREENHEIGHT - SCREENHEIGHT * AspectMultiplier(aspect) / 48) / 2;
}
Displacement = 0;
}
@ -1035,10 +1036,10 @@ void DBaseStatusBar::DrSmallNumberOuter (int val, int x, int y, bool center) con
void DBaseStatusBar::RefreshBackground () const
{
int x, x2, y, ratio;
int x, x2, y;
ratio = CheckRatio (SCREENWIDTH, SCREENHEIGHT);
x = (!IsRatioWidescreen(ratio) || !Scaled) ? ST_X : SCREENWIDTH*(48-BaseRatioSizes[ratio][3])/(48*2);
float ratio = ActiveRatio (SCREENWIDTH, SCREENHEIGHT);
x = (ratio < 1.5f || !Scaled) ? ST_X : SCREENWIDTH*(48-AspectMultiplier(ratio))/(48*2);
y = x == ST_X && x > 0 ? ST_Y : ::ST_Y;
if(!CompleteBorder)
@ -1058,8 +1059,8 @@ void DBaseStatusBar::RefreshBackground () const
{
if(!CompleteBorder)
{
x2 = !IsRatioWidescreen(ratio) || !Scaled ? ST_X+HorizontalResolution :
SCREENWIDTH - (SCREENWIDTH*(48-BaseRatioSizes[ratio][3])+48*2-1)/(48*2);
x2 = ratio < 1.5f || !Scaled ? ST_X+HorizontalResolution :
SCREENWIDTH - (SCREENWIDTH*(48-AspectMultiplier(ratio))+48*2-1)/(48*2);
}
else
{