add 21:9 and 9:16 to ConfAspectRatio in _fallback

This adds choices for 21:9 (Ultrawide) and 9:16 (widescreen display in
portrait mode) to the _fallback theme.  Previously, users would have to
manually edit Preferences.ini to achieve either of these.

Since "21:9" is the common marketing term for what is actually 64:27,
I've slightly extended GenChoices() in ConfAspectRatio() to use a "name"
string from the winFracs table is one is provided. If not, the original
behavior of generating user-facing choices from the raw values is
preserved.

See: https://wikipedia.org/wiki/21:9_aspect_ratio

I updated the global AspectRatios table in _fallback/02 Utilities.lua to
match.
This commit is contained in:
quietly-turning
2020-04-28 22:47:54 -04:00
parent 8650fc420e
commit 21eed3f235
2 changed files with 18 additions and 13 deletions
+9 -6
View File
@@ -94,14 +94,17 @@ end
-- TODO: here, I'm replicating the AspectRatios table from "02 Utilities.lua",
-- but in a friendly format
-- name can optionally be provided as a user-facing string for ConfAspectRatio
local winFracs = {
{n=3, d=4},
{n=1, d=1},
{n=5, d=4},
{n=4, d=3},
{n=3, d=4},
{n=1, d=1},
{n=5, d=4},
{n=4, d=3},
{n=16, d=10},
{n=16, d=9},
{n=8, d=3}
{n=8, d=3},
{n=64, d=27, name="21:9"},
{n=9, d=16},
}
-- Maximum distance between aspect ratios to be considered equivalent
-- (approximately half the distance between 16:9 and 16:10)
@@ -243,7 +246,7 @@ function ConfAspectRatio()
local vals = {}
foreach_ordered(ratios, function(v, f)
vals[#vals + 1] = f.n/f.d
choices[#choices + 1] = tostring(f.n) .. ':' .. tostring(f.d)
choices[#choices + 1] = (type(f.name)=="string" and f.name) or ("%d:%d"):format(f.n, f.d)
end)
self.Choices = choices
self.ChoiceVals = vals