mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-30 16:00:55 +00:00
Add ActiveRatio to be used where CheckRatio is used today
This commit is contained in:
parent
b003c47e3e
commit
5720634045
2 changed files with 58 additions and 25 deletions
|
@ -1603,6 +1603,59 @@ CUSTOM_CVAR (Int, vid_aspect, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper for ActiveRatio and CheckRatio. Returns the forced ratio type, or -1 if none.
|
||||||
|
int ActiveFakeRatio(int width, int height)
|
||||||
|
{
|
||||||
|
int fakeratio = -1;
|
||||||
|
if ((vid_aspect >= 1) && (vid_aspect <= 6))
|
||||||
|
{
|
||||||
|
// [SP] User wants to force aspect ratio; let them.
|
||||||
|
fakeratio = int(vid_aspect);
|
||||||
|
if (fakeratio == 3)
|
||||||
|
{
|
||||||
|
fakeratio = 0;
|
||||||
|
}
|
||||||
|
else if (fakeratio == 5)
|
||||||
|
{
|
||||||
|
fakeratio = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (vid_nowidescreen)
|
||||||
|
{
|
||||||
|
if (!vid_tft)
|
||||||
|
{
|
||||||
|
fakeratio = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fakeratio = (height * 5 / 4 == width) ? 4 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fakeratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Active screen ratio based on cvars and size
|
||||||
|
float ActiveRatio(int width, int height, float *trueratio)
|
||||||
|
{
|
||||||
|
static float forcedRatioTypes[] =
|
||||||
|
{
|
||||||
|
4 / 3.0f,
|
||||||
|
16 / 9.0f,
|
||||||
|
16 / 10.0f,
|
||||||
|
17 / 10.0f,
|
||||||
|
5 / 4.0f,
|
||||||
|
17 / 10.0f,
|
||||||
|
21 / 9.0f
|
||||||
|
};
|
||||||
|
|
||||||
|
float ratio = width / (float)height;
|
||||||
|
int fakeratio = ActiveFakeRatio(width, height);
|
||||||
|
|
||||||
|
if (trueratio)
|
||||||
|
*trueratio = ratio;
|
||||||
|
return (fakeratio != -1) ? forcedRatioTypes[fakeratio] : ratio;
|
||||||
|
}
|
||||||
|
|
||||||
// Tries to guess the physical dimensions of the screen based on the
|
// Tries to guess the physical dimensions of the screen based on the
|
||||||
// screen's pixel dimensions. Can return:
|
// screen's pixel dimensions. Can return:
|
||||||
// 0: 4:3
|
// 0: 4:3
|
||||||
|
@ -1639,31 +1692,9 @@ int CheckRatio (int width, int height, int *trueratio)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int fakeratio = ratio;
|
int fakeratio = ActiveFakeRatio(width, height);
|
||||||
if ((vid_aspect >= 1) && (vid_aspect <= 6))
|
if (fakeratio == -1)
|
||||||
{
|
fakeratio = ratio;
|
||||||
// [SP] User wants to force aspect ratio; let them.
|
|
||||||
fakeratio = int(vid_aspect);
|
|
||||||
if (fakeratio == 3)
|
|
||||||
{
|
|
||||||
fakeratio = 0;
|
|
||||||
}
|
|
||||||
else if (fakeratio == 5)
|
|
||||||
{
|
|
||||||
fakeratio = 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vid_nowidescreen)
|
|
||||||
{
|
|
||||||
if (!vid_tft)
|
|
||||||
{
|
|
||||||
fakeratio = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fakeratio = (height * 5 / 4 == width) ? 4 : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trueratio)
|
if (trueratio)
|
||||||
*trueratio = ratio;
|
*trueratio = ratio;
|
||||||
|
|
|
@ -516,6 +516,8 @@ extern "C" void ASM_PatchPitch (void);
|
||||||
|
|
||||||
int CheckRatio (int width, int height, int *trueratio=NULL);
|
int CheckRatio (int width, int height, int *trueratio=NULL);
|
||||||
static inline int CheckRatio (double width, double height) { return CheckRatio(int(width), int(height)); }
|
static inline int CheckRatio (double width, double height) { return CheckRatio(int(width), int(height)); }
|
||||||
|
float ActiveRatio (int width, int height, float *trueratio = NULL);
|
||||||
|
static inline double ActiveRatio (double width, double height) { return ActiveRatio(int(width), int(height)); }
|
||||||
extern const int BaseRatioSizes[7][4];
|
extern const int BaseRatioSizes[7][4];
|
||||||
|
|
||||||
inline bool IsRatioWidescreen(int ratio) {
|
inline bool IsRatioWidescreen(int ratio) {
|
||||||
|
|
Loading…
Reference in a new issue