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
This commit is contained in:
parent
808380690c
commit
11222516c4
14 changed files with 264 additions and 57 deletions
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
"version": 17,
|
||||
"version": 18,
|
||||
"res_scale": 1,
|
||||
"res_scale_custom": 1,
|
||||
"max_anisotropy": -1,
|
||||
"aspect_ratio": "Fixed16x9",
|
||||
"graphics_shaders_dump_path": "",
|
||||
"logging_enable_debug": false,
|
||||
"logging_enable_stub": true,
|
||||
|
|
|
@ -5,16 +5,16 @@ using OpenTK;
|
|||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using OpenTK.Input;
|
||||
using Ryujinx.Configuration;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Configuration.Hid;
|
||||
using Ryujinx.Configuration;
|
||||
using Ryujinx.Graphics.OpenGL;
|
||||
using Ryujinx.HLE;
|
||||
using Ryujinx.HLE.HOS.Services.Hid;
|
||||
using Ryujinx.Motion;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Ryujinx.Motion;
|
||||
|
||||
namespace Ryujinx.Ui
|
||||
{
|
||||
|
@ -219,7 +219,6 @@ namespace Ryujinx.Ui
|
|||
{
|
||||
parent.Present();
|
||||
|
||||
|
||||
string titleNameSection = string.IsNullOrWhiteSpace(_device.Application.TitleName) ? string.Empty
|
||||
: $" - {_device.Application.TitleName}";
|
||||
|
||||
|
@ -419,6 +418,7 @@ namespace Ryujinx.Ui
|
|||
StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
|
||||
_device.EnableDeviceVsync,
|
||||
dockedMode,
|
||||
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
|
||||
$"Game: {_device.Statistics.GetGameFrameRate():00.00} FPS",
|
||||
$"FIFO: {_device.Statistics.GetFifoPercent():0.00} %",
|
||||
$"GPU: {_renderer.GpuVendor}"));
|
||||
|
@ -632,16 +632,18 @@ namespace Ryujinx.Ui
|
|||
// OpenTK always captures mouse events, even if out of focus, so check if window is focused.
|
||||
if (_isFocused && _mousePressed)
|
||||
{
|
||||
float aspectWidth = SwitchPanelHeight * ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat();
|
||||
|
||||
int screenWidth = AllocatedWidth;
|
||||
int screenHeight = AllocatedHeight;
|
||||
|
||||
if (AllocatedWidth > (AllocatedHeight * SwitchPanelWidth) / SwitchPanelHeight)
|
||||
if (AllocatedWidth > AllocatedHeight * aspectWidth / SwitchPanelHeight)
|
||||
{
|
||||
screenWidth = (AllocatedHeight * SwitchPanelWidth) / SwitchPanelHeight;
|
||||
screenWidth = (int)(AllocatedHeight * aspectWidth) / SwitchPanelHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
screenHeight = (AllocatedWidth * SwitchPanelHeight) / SwitchPanelWidth;
|
||||
screenHeight = (AllocatedWidth * SwitchPanelHeight) / (int)aspectWidth;
|
||||
}
|
||||
|
||||
int startX = (AllocatedWidth - screenWidth) >> 1;
|
||||
|
@ -659,7 +661,7 @@ namespace Ryujinx.Ui
|
|||
int screenMouseX = (int)_mouseX - startX;
|
||||
int screenMouseY = (int)_mouseY - startY;
|
||||
|
||||
int mX = (screenMouseX * SwitchPanelWidth) / screenWidth;
|
||||
int mX = (screenMouseX * (int)aspectWidth) / screenWidth;
|
||||
int mY = (screenMouseY * SwitchPanelHeight) / screenHeight;
|
||||
|
||||
TouchPoint currentPoint = new TouchPoint
|
||||
|
|
|
@ -72,6 +72,7 @@ namespace Ryujinx.Ui
|
|||
[GUI] CheckMenuItem _pathToggle;
|
||||
[GUI] CheckMenuItem _fileSizeToggle;
|
||||
[GUI] Label _dockedMode;
|
||||
[GUI] Label _aspectRatio;
|
||||
[GUI] Label _gameStatus;
|
||||
[GUI] TreeView _gameTable;
|
||||
[GUI] TreeSelection _gameTableSelection;
|
||||
|
@ -666,11 +667,12 @@ namespace Ryujinx.Ui
|
|||
|
||||
public static void UpdateGraphicsConfig()
|
||||
{
|
||||
int resScale = ConfigurationState.Instance.Graphics.ResScale;
|
||||
int resScale = ConfigurationState.Instance.Graphics.ResScale;
|
||||
float resScaleCustom = ConfigurationState.Instance.Graphics.ResScaleCustom;
|
||||
Graphics.Gpu.GraphicsConfig.ResScale = (resScale == -1) ? resScaleCustom : resScale;
|
||||
Graphics.Gpu.GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
|
||||
Graphics.Gpu.GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
|
||||
|
||||
Graphics.Gpu.GraphicsConfig.ResScale = (resScale == -1) ? resScaleCustom : resScale;
|
||||
Graphics.Gpu.GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
|
||||
Graphics.Gpu.GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
|
||||
Graphics.Gpu.GraphicsConfig.EnableShaderCache = ConfigurationState.Instance.Graphics.EnableShaderCache;
|
||||
}
|
||||
|
||||
|
@ -806,10 +808,11 @@ namespace Ryujinx.Ui
|
|||
{
|
||||
Application.Invoke(delegate
|
||||
{
|
||||
_gameStatus.Text = args.GameStatus;
|
||||
_fifoStatus.Text = args.FifoStatus;
|
||||
_gpuName.Text = args.GpuName;
|
||||
_dockedMode.Text = args.DockedMode;
|
||||
_gameStatus.Text = args.GameStatus;
|
||||
_fifoStatus.Text = args.FifoStatus;
|
||||
_gpuName.Text = args.GpuName;
|
||||
_dockedMode.Text = args.DockedMode;
|
||||
_aspectRatio.Text = args.AspectRatio;
|
||||
|
||||
if (args.VSyncEnabled)
|
||||
{
|
||||
|
@ -868,6 +871,13 @@ namespace Ryujinx.Ui
|
|||
ConfigurationState.Instance.System.EnableDockedMode.Value = !ConfigurationState.Instance.System.EnableDockedMode.Value;
|
||||
}
|
||||
|
||||
private void AspectRatio_Clicked(object sender, ButtonReleaseEventArgs args)
|
||||
{
|
||||
AspectRatio aspectRatio = ConfigurationState.Instance.Graphics.AspectRatio.Value;
|
||||
|
||||
ConfigurationState.Instance.Graphics.AspectRatio.Value = ((int)aspectRatio + 1) > Enum.GetNames(typeof(AspectRatio)).Length - 1 ? AspectRatio.Fixed4x3 : aspectRatio + 1;
|
||||
}
|
||||
|
||||
private void Row_Clicked(object sender, ButtonReleaseEventArgs args)
|
||||
{
|
||||
if (args.Event.Button != 3) return;
|
||||
|
|
|
@ -562,12 +562,20 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="_gameStatus">
|
||||
<object class="GtkEventBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_left">0</property>
|
||||
<signal name="button-release-event" handler="AspectRatio_Clicked" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkLabel" id="_aspectRatio">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -587,7 +595,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="_fifoStatus">
|
||||
<object class="GtkLabel" id="_gameStatus">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
|
@ -611,6 +619,31 @@
|
|||
<property name="position">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="_fifoStatus">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">9</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="_gpuName">
|
||||
<property name="visible">True</property>
|
||||
|
@ -621,7 +654,7 @@
|
|||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">8</property>
|
||||
<property name="position">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -71,6 +71,7 @@ namespace Ryujinx.Ui
|
|||
[GUI] Entry _addGameDirBox;
|
||||
[GUI] Entry _graphicsShadersDumpPath;
|
||||
[GUI] ComboBoxText _anisotropy;
|
||||
[GUI] ComboBoxText _aspectRatio;
|
||||
[GUI] ComboBoxText _resScaleCombo;
|
||||
[GUI] Entry _resScaleText;
|
||||
[GUI] ToggleButton _configureController1;
|
||||
|
@ -249,6 +250,7 @@ namespace Ryujinx.Ui
|
|||
_systemRegionSelect.SetActiveId(ConfigurationState.Instance.System.Region.Value.ToString());
|
||||
_resScaleCombo.SetActiveId(ConfigurationState.Instance.Graphics.ResScale.Value.ToString());
|
||||
_anisotropy.SetActiveId(ConfigurationState.Instance.Graphics.MaxAnisotropy.Value.ToString());
|
||||
_aspectRatio.SetActiveId(((int)ConfigurationState.Instance.Graphics.AspectRatio.Value).ToString());
|
||||
|
||||
_custThemePath.Buffer.Text = ConfigurationState.Instance.Ui.CustomThemePath;
|
||||
_resScaleText.Buffer.Text = ConfigurationState.Instance.Graphics.ResScaleCustom.Value.ToString();
|
||||
|
@ -408,6 +410,7 @@ namespace Ryujinx.Ui
|
|||
ConfigurationState.Instance.Ui.GameDirs.Value = gameDirs;
|
||||
ConfigurationState.Instance.System.FsGlobalAccessLogMode.Value = (int)_fsLogSpinAdjustment.Value;
|
||||
ConfigurationState.Instance.Graphics.MaxAnisotropy.Value = float.Parse(_anisotropy.ActiveId, CultureInfo.InvariantCulture);
|
||||
ConfigurationState.Instance.Graphics.AspectRatio.Value = Enum.Parse<AspectRatio>(_aspectRatio.ActiveId);
|
||||
ConfigurationState.Instance.Graphics.ResScale.Value = int.Parse(_resScaleCombo.ActiveId);
|
||||
ConfigurationState.Instance.Graphics.ResScaleCustom.Value = resScaleCustom;
|
||||
|
||||
|
@ -422,7 +425,7 @@ namespace Ryujinx.Ui
|
|||
}
|
||||
|
||||
//Events
|
||||
private void TimeZoneEntry_FocusOut(Object sender, FocusOutEventArgs e)
|
||||
private void TimeZoneEntry_FocusOut(object sender, FocusOutEventArgs e)
|
||||
{
|
||||
if (!_validTzRegions.Contains(_systemTimeZoneEntry.Text))
|
||||
{
|
||||
|
@ -439,7 +442,7 @@ namespace Ryujinx.Ui
|
|||
((string)compl.Model.GetValue(iter, 0)).Substring(3).StartsWith(key); // offset
|
||||
}
|
||||
|
||||
private void SystemTimeSpin_ValueChanged(Object sender, EventArgs e)
|
||||
private void SystemTimeSpin_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
int year = _systemTimeYearSpin.ValueAsInt;
|
||||
int month = _systemTimeMonthSpin.ValueAsInt;
|
||||
|
|
|
@ -1811,6 +1811,55 @@
|
|||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-top">5</property>
|
||||
<property name="margin-bottom">5</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="tooltip-text" translatable="yes">Aspect Ratio applied to the renderer window.</property>
|
||||
<property name="label" translatable="yes">Aspect Ratio:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">5</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="_aspectRatio">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="tooltip-text" translatable="yes">Aspect Ratio applied to the renderer window.</property>
|
||||
<property name="active-id">1</property>
|
||||
<items>
|
||||
<item id="0" translatable="yes">4:3</item>
|
||||
<item id="1" translatable="yes">16:9</item>
|
||||
<item id="2" translatable="yes">16:10</item>
|
||||
<item id="3" translatable="yes">21:9</item>
|
||||
<item id="4" translatable="yes">32:9</item>
|
||||
<item id="5" translatable="yes">Stretch to Fit Window</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">5</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
|
|
@ -6,14 +6,16 @@ namespace Ryujinx.Ui
|
|||
{
|
||||
public bool VSyncEnabled;
|
||||
public string DockedMode;
|
||||
public string AspectRatio;
|
||||
public string GameStatus;
|
||||
public string FifoStatus;
|
||||
public string GpuName;
|
||||
|
||||
public StatusUpdatedEventArgs(bool vSyncEnabled, string dockedMode, string gameStatus, string fifoStatus, string gpuName)
|
||||
public StatusUpdatedEventArgs(bool vSyncEnabled, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, string gpuName)
|
||||
{
|
||||
VSyncEnabled = vSyncEnabled;
|
||||
DockedMode = dockedMode;
|
||||
AspectRatio = aspectRatio;
|
||||
GameStatus = gameStatus;
|
||||
FifoStatus = fifoStatus;
|
||||
GpuName = gpuName;
|
||||
|
|
|
@ -941,6 +941,21 @@
|
|||
16
|
||||
]
|
||||
},
|
||||
"aspect_ratio": {
|
||||
"$id": "#/properties/aspect_ratio",
|
||||
"type": "string",
|
||||
"title": "Aspect Ratio applied to the renderer window.",
|
||||
"description": "Aspect Ratio applied to the renderer window.",
|
||||
"default": "Fixed16x9",
|
||||
"examples": [
|
||||
"Fixed4x3",
|
||||
"Fixed16x9",
|
||||
"Fixed16x10",
|
||||
"Fixed21x9",
|
||||
"Fixed32x9",
|
||||
"Stretched"
|
||||
]
|
||||
},
|
||||
"graphics_shaders_dump_path": {
|
||||
"$id": "#/properties/graphics_shaders_dump_path",
|
||||
"type": "string",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue