mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-28 08:56:24 +02:00
Add custom refresh rate mode to VSync option (#238)
Rebased @jcm93's refreshinterval branch: https://github.com/jcm93/Ryujinx/tree/refreshinterval The option is placed under System/Hacks. Disabled, it's the default Ryujinx behavior. Enabled, the behavior is shown in the attached screenshots. If a framerate is too high or low, you can adjust the value where you normally toggle VSync on and off. It will also cycle through the default on/off toggles. Also, in order to reduce clutter, I made an adjustment to remove the target FPS and only show the percentage. --------- Co-authored-by: jcm <6864788+jcm93@users.noreply.github.com>
This commit is contained in:
parent
7e16fccfc1
commit
2e6794e69b
34 changed files with 678 additions and 110 deletions
|
@ -63,6 +63,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
private string _searchText;
|
||||
private Timer _searchTimer;
|
||||
private string _dockedStatusText;
|
||||
private string _vSyncModeText;
|
||||
private string _fifoStatusText;
|
||||
private string _gameStatusText;
|
||||
private string _volumeStatusText;
|
||||
|
@ -80,7 +81,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
private bool _showStatusSeparator;
|
||||
private Brush _progressBarForegroundColor;
|
||||
private Brush _progressBarBackgroundColor;
|
||||
private Brush _vsyncColor;
|
||||
private Brush _vSyncModeColor;
|
||||
private byte[] _selectedIcon;
|
||||
private bool _isAppletMenuActive;
|
||||
private int _statusBarProgressMaximum;
|
||||
|
@ -111,6 +112,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
private WindowState _windowState;
|
||||
private double _windowWidth;
|
||||
private double _windowHeight;
|
||||
private int _customVSyncInterval;
|
||||
private int _customVSyncIntervalPercentageProxy;
|
||||
|
||||
private bool _isActive;
|
||||
private bool _isSubMenuOpen;
|
||||
|
@ -145,6 +148,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
|
||||
Volume = ConfigurationState.Instance.System.AudioVolume;
|
||||
}
|
||||
CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value;
|
||||
}
|
||||
|
||||
public void Initialize(
|
||||
|
@ -447,17 +451,87 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public Brush VsyncColor
|
||||
public Brush VSyncModeColor
|
||||
{
|
||||
get => _vsyncColor;
|
||||
get => _vSyncModeColor;
|
||||
set
|
||||
{
|
||||
_vsyncColor = value;
|
||||
_vSyncModeColor = value;
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowCustomVSyncIntervalPicker
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_isGameRunning)
|
||||
{
|
||||
return AppHost.Device.VSyncMode ==
|
||||
VSyncMode.Custom;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public int CustomVSyncIntervalPercentageProxy
|
||||
{
|
||||
get => _customVSyncIntervalPercentageProxy;
|
||||
set
|
||||
{
|
||||
int newInterval = (int)((value / 100f) * 60);
|
||||
_customVSyncInterval = newInterval;
|
||||
_customVSyncIntervalPercentageProxy = value;
|
||||
if (_isGameRunning)
|
||||
{
|
||||
AppHost.Device.CustomVSyncInterval = newInterval;
|
||||
AppHost.Device.UpdateVSyncInterval();
|
||||
}
|
||||
OnPropertyChanged((nameof(CustomVSyncInterval)));
|
||||
OnPropertyChanged((nameof(CustomVSyncIntervalPercentageText)));
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomVSyncIntervalPercentageText
|
||||
{
|
||||
get
|
||||
{
|
||||
string text = CustomVSyncIntervalPercentageProxy.ToString() + "%";
|
||||
return text;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int CustomVSyncInterval
|
||||
{
|
||||
get => _customVSyncInterval;
|
||||
set
|
||||
{
|
||||
_customVSyncInterval = value;
|
||||
int newPercent = (int)((value / 60f) * 100);
|
||||
_customVSyncIntervalPercentageProxy = newPercent;
|
||||
if (_isGameRunning)
|
||||
{
|
||||
AppHost.Device.CustomVSyncInterval = value;
|
||||
AppHost.Device.UpdateVSyncInterval();
|
||||
}
|
||||
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageProxy));
|
||||
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageText));
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] SelectedIcon
|
||||
{
|
||||
get => _selectedIcon;
|
||||
|
@ -578,6 +652,17 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public string VSyncModeText
|
||||
{
|
||||
get => _vSyncModeText;
|
||||
set
|
||||
{
|
||||
_vSyncModeText = value;
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string DockedStatusText
|
||||
{
|
||||
get => _dockedStatusText;
|
||||
|
@ -1292,17 +1377,18 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
Application.Current!.Styles.TryGetResource(args.VSyncEnabled
|
||||
? "VsyncEnabled"
|
||||
: "VsyncDisabled",
|
||||
Application.Current!.Styles.TryGetResource(args.VSyncMode,
|
||||
Application.Current.ActualThemeVariant,
|
||||
out object color);
|
||||
|
||||
if (color is Color clr)
|
||||
{
|
||||
VsyncColor = new SolidColorBrush(clr);
|
||||
VSyncModeColor = new SolidColorBrush(clr);
|
||||
}
|
||||
|
||||
VSyncModeText = args.VSyncMode == "Custom" ? "Custom" : "VSync";
|
||||
ShowCustomVSyncIntervalPicker =
|
||||
args.VSyncMode == VSyncMode.Custom.ToString();
|
||||
DockedStatusText = args.DockedMode;
|
||||
AspectRatioStatusText = args.AspectRatio;
|
||||
GameStatusText = args.GameStatus;
|
||||
|
@ -1495,6 +1581,27 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void ToggleVSyncMode()
|
||||
{
|
||||
AppHost.VSyncModeToggle();
|
||||
OnPropertyChanged(nameof(ShowCustomVSyncIntervalPicker));
|
||||
}
|
||||
|
||||
public void VSyncModeSettingChanged()
|
||||
{
|
||||
if (_isGameRunning)
|
||||
{
|
||||
AppHost.Device.CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value;
|
||||
AppHost.Device.UpdateVSyncInterval();
|
||||
}
|
||||
|
||||
CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value;
|
||||
OnPropertyChanged(nameof(ShowCustomVSyncIntervalPicker));
|
||||
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageProxy));
|
||||
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageText));
|
||||
OnPropertyChanged(nameof(CustomVSyncInterval));
|
||||
}
|
||||
|
||||
public async Task ExitCurrentState()
|
||||
{
|
||||
if (WindowState is WindowState.FullScreen)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue