aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Common/Configuration/AspectRatioExtensions.cs
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2020-12-16 03:19:07 +0100
committerGitHub <noreply@github.com>2020-12-15 23:19:07 -0300
commit11222516c4b5042cd8da6fdd72f53ee736139b66 (patch)
treea58a7870dbe3ac59a2b7fc4229dc507a753adbea /Ryujinx.Common/Configuration/AspectRatioExtensions.cs
parent808380690c684a7598efad791f560e02ce70bc82 (diff)
gui/gpu: Implement setting and toggle for Aspect Ratio (#1777)
* gui/gpu: Implement setting and toggle for Aspect Ratio * address gdkchan feedback and add 16:10 * fix config.json file * Fix rebase * Address gdkchan feedback * Address rip feedback * Fix aspectWidth
Diffstat (limited to 'Ryujinx.Common/Configuration/AspectRatioExtensions.cs')
-rw-r--r--Ryujinx.Common/Configuration/AspectRatioExtensions.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/Ryujinx.Common/Configuration/AspectRatioExtensions.cs b/Ryujinx.Common/Configuration/AspectRatioExtensions.cs
new file mode 100644
index 00000000..3d0be88e
--- /dev/null
+++ b/Ryujinx.Common/Configuration/AspectRatioExtensions.cs
@@ -0,0 +1,59 @@
+namespace Ryujinx.Common.Configuration
+{
+ 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
+ {
+ AspectRatio.Fixed4x3 => 4.0f,
+ AspectRatio.Fixed16x9 => 16.0f,
+ AspectRatio.Fixed16x10 => 16.0f,
+ AspectRatio.Fixed21x9 => 21.0f,
+ AspectRatio.Fixed32x9 => 32.0f,
+ _ => 16.0f
+ };
+ }
+
+ public static float ToFloatY(this AspectRatio aspectRatio)
+ {
+ return aspectRatio switch
+ {
+ AspectRatio.Fixed4x3 => 3.0f,
+ AspectRatio.Fixed16x9 => 9.0f,
+ AspectRatio.Fixed16x10 => 10.0f,
+ AspectRatio.Fixed21x9 => 9.0f,
+ AspectRatio.Fixed32x9 => 9.0f,
+ _ => 9.0f
+ };
+ }
+
+ public static string ToText(this AspectRatio aspectRatio)
+ {
+ return aspectRatio switch
+ {
+ AspectRatio.Fixed4x3 => "4:3",
+ AspectRatio.Fixed16x9 => "16:9",
+ AspectRatio.Fixed16x10 => "16:10",
+ AspectRatio.Fixed21x9 => "21:9",
+ AspectRatio.Fixed32x9 => "32:9",
+ _ => "Stretched"
+ };
+ }
+ }
+} \ No newline at end of file