1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
using Ryujinx.Common.Utilities;
using System.Text.Json.Serialization;
namespace Ryujinx.Common.Configuration
{
[JsonConverter(typeof(TypedStringEnumConverter<AspectRatio>))]
public enum AspectRatio
{
Fixed4x3,
Fixed16x9,
Fixed16x10,
Fixed21x9,
Fixed32x9,
Stretched,
}
public static class AspectRatioExtensions
{
public static float ToFloat(this AspectRatio aspectRatio)
{
return aspectRatio.ToFloatX() / aspectRatio.ToFloatY();
}
public static float ToFloatX(this AspectRatio aspectRatio)
{
return aspectRatio switch
{
#pragma warning disable IDE0055 // Disable formatting
AspectRatio.Fixed4x3 => 4.0f,
AspectRatio.Fixed16x9 => 16.0f,
AspectRatio.Fixed16x10 => 16.0f,
AspectRatio.Fixed21x9 => 21.0f,
AspectRatio.Fixed32x9 => 32.0f,
_ => 16.0f,
#pragma warning restore IDE0055
};
}
public static float ToFloatY(this AspectRatio aspectRatio)
{
return aspectRatio switch
{
#pragma warning disable IDE0055 // Disable formatting
AspectRatio.Fixed4x3 => 3.0f,
AspectRatio.Fixed16x9 => 9.0f,
AspectRatio.Fixed16x10 => 10.0f,
AspectRatio.Fixed21x9 => 9.0f,
AspectRatio.Fixed32x9 => 9.0f,
_ => 9.0f,
#pragma warning restore IDE0055
};
}
public static string ToText(this AspectRatio aspectRatio)
{
return aspectRatio switch
{
#pragma warning disable IDE0055 // Disable formatting
AspectRatio.Fixed4x3 => "4:3",
AspectRatio.Fixed16x9 => "16:9",
AspectRatio.Fixed16x10 => "16:10",
AspectRatio.Fixed21x9 => "21:9",
AspectRatio.Fixed32x9 => "32:9",
_ => "Stretched",
#pragma warning restore IDE0055
};
}
}
}
|