diff options
| author | Ac_K <Acoustik666@gmail.com> | 2020-12-16 03:19:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-15 23:19:07 -0300 |
| commit | 11222516c4b5042cd8da6fdd72f53ee736139b66 (patch) | |
| tree | a58a7870dbe3ac59a2b7fc4229dc507a753adbea /Ryujinx.Common/Configuration | |
| parent | 808380690c684a7598efad791f560e02ce70bc82 (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')
| -rw-r--r-- | Ryujinx.Common/Configuration/AspectRatioExtensions.cs | 59 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/ConfigurationFileFormat.cs | 7 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/ConfigurationState.cs | 20 |
3 files changed, 84 insertions, 2 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 diff --git a/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs b/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs index 5618b228..cb7c3b7e 100644 --- a/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs +++ b/Ryujinx.Common/Configuration/ConfigurationFileFormat.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Configuration /// <summary> /// The current version of the file format /// </summary> - public const int CurrentVersion = 17; + public const int CurrentVersion = 18; public int Version { get; set; } @@ -34,6 +34,11 @@ namespace Ryujinx.Configuration public float MaxAnisotropy { get; set; } /// <summary> + /// Aspect Ratio applied to the renderer window. + /// </summary> + public AspectRatio AspectRatio { get; set; } + + /// <summary> /// Dumps shaders in this local directory /// </summary> public string GraphicsShadersDumpPath { get; set; } diff --git a/Ryujinx.Common/Configuration/ConfigurationState.cs b/Ryujinx.Common/Configuration/ConfigurationState.cs index 94c9ac0e..e822dcf6 100644 --- a/Ryujinx.Common/Configuration/ConfigurationState.cs +++ b/Ryujinx.Common/Configuration/ConfigurationState.cs @@ -279,6 +279,11 @@ namespace Ryujinx.Configuration public ReactiveObject<float> MaxAnisotropy { get; private set; } /// <summary> + /// Aspect Ratio applied to the renderer window. + /// </summary> + public ReactiveObject<AspectRatio> AspectRatio { get; private set; } + + /// <summary> /// Resolution Scale. An integer scale applied to applicable render targets. Values 1-4, or -1 to use a custom floating point scale instead. /// </summary> public ReactiveObject<int> ResScale { get; private set; } @@ -308,6 +313,7 @@ namespace Ryujinx.Configuration ResScale = new ReactiveObject<int>(); ResScaleCustom = new ReactiveObject<float>(); MaxAnisotropy = new ReactiveObject<float>(); + AspectRatio = new ReactiveObject<AspectRatio>(); ShadersDumpPath = new ReactiveObject<string>(); EnableVsync = new ReactiveObject<bool>(); EnableShaderCache = new ReactiveObject<bool>(); @@ -388,6 +394,7 @@ namespace Ryujinx.Configuration ResScale = Graphics.ResScale, ResScaleCustom = Graphics.ResScaleCustom, MaxAnisotropy = Graphics.MaxAnisotropy, + AspectRatio = Graphics.AspectRatio, GraphicsShadersDumpPath = Graphics.ShadersDumpPath, LoggingEnableDebug = Logger.EnableDebug, LoggingEnableStub = Logger.EnableStub, @@ -449,6 +456,7 @@ namespace Ryujinx.Configuration Graphics.ResScale.Value = 1; Graphics.ResScaleCustom.Value = 1.0f; Graphics.MaxAnisotropy.Value = -1.0f; + Graphics.AspectRatio.Value = AspectRatio.Fixed16x9; Graphics.ShadersDumpPath.Value = ""; Logger.EnableDebug.Value = false; Logger.EnableStub.Value = true; @@ -457,7 +465,7 @@ namespace Ryujinx.Configuration Logger.EnableError.Value = true; Logger.EnableGuest.Value = true; Logger.EnableFsAccessLog.Value = false; - Logger.FilteredClasses.Value = new LogClass[] { }; + Logger.FilteredClasses.Value = Array.Empty<LogClass>(); Logger.GraphicsDebugLevel.Value = GraphicsDebugLevel.None; Logger.EnableFileLog.Value = true; System.Language.Value = Language.AmericanEnglish; @@ -753,6 +761,15 @@ namespace Ryujinx.Configuration configurationFileUpdated = true; } + if (configurationFileFormat.Version < 18) + { + Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 18."); + + configurationFileFormat.AspectRatio = AspectRatio.Fixed16x9; + + configurationFileUpdated = true; + } + List<InputConfig> inputConfig = new List<InputConfig>(); inputConfig.AddRange(configurationFileFormat.ControllerConfig); inputConfig.AddRange(configurationFileFormat.KeyboardConfig); @@ -760,6 +777,7 @@ namespace Ryujinx.Configuration Graphics.ResScale.Value = configurationFileFormat.ResScale; Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom; Graphics.MaxAnisotropy.Value = configurationFileFormat.MaxAnisotropy; + Graphics.AspectRatio.Value = configurationFileFormat.AspectRatio; Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath; Logger.EnableDebug.Value = configurationFileFormat.LoggingEnableDebug; Logger.EnableStub.Value = configurationFileFormat.LoggingEnableStub; |
