mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-09-25 17:57:55 +02:00
Add custom refresh rate mode to VSync option
This commit is contained in:
@@ -60,6 +60,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;
|
||||
@@ -75,7 +76,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;
|
||||
@@ -105,6 +106,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;
|
||||
@@ -131,6 +134,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
Volume = ConfigurationState.Instance.System.AudioVolume;
|
||||
}
|
||||
CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value;
|
||||
}
|
||||
|
||||
public void Initialize(
|
||||
@@ -420,17 +424,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;
|
||||
@@ -541,6 +615,17 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public string VSyncModeText
|
||||
{
|
||||
get => _vSyncModeText;
|
||||
set
|
||||
{
|
||||
_vSyncModeText = value;
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string DockedStatusText
|
||||
{
|
||||
get => _dockedStatusText;
|
||||
@@ -1255,17 +1340,18 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
Application.Current.Styles.TryGetResource(args.VSyncEnabled
|
||||
? "VsyncEnabled"
|
||||
: "VsyncDisabled",
|
||||
Application.Current.ActualThemeVariant,
|
||||
Application.Current.Styles.TryGetResource(args.VSyncMode,
|
||||
Avalonia.Application.Current.ActualThemeVariant,
|
||||
out object color);
|
||||
|
||||
if (color is not null)
|
||||
{
|
||||
VsyncColor = new SolidColorBrush((Color)color);
|
||||
VSyncModeColor = new SolidColorBrush((Color)color);
|
||||
}
|
||||
|
||||
VSyncModeText = args.VSyncMode == "Custom" ? "Custom" : "VSync";
|
||||
ShowCustomVSyncIntervalPicker =
|
||||
args.VSyncMode == VSyncMode.Custom.ToString();
|
||||
DockedStatusText = args.DockedMode;
|
||||
AspectRatioStatusText = args.AspectRatio;
|
||||
GameStatusText = args.GameStatus;
|
||||
@@ -1422,6 +1508,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 == WindowState.FullScreen)
|
||||
|
||||
@@ -50,6 +50,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
private int _graphicsBackendIndex;
|
||||
private int _scalingFilter;
|
||||
private int _scalingFilterLevel;
|
||||
private int _customVSyncInterval;
|
||||
private bool _enableCustomVSyncInterval;
|
||||
private int _customVSyncIntervalPercentageProxy;
|
||||
private VSyncMode _vSyncMode;
|
||||
|
||||
public event Action CloseWindow;
|
||||
public event Action SaveSettingsEvent;
|
||||
@@ -138,7 +142,74 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
public bool EnableDockedMode { get; set; }
|
||||
public bool EnableKeyboard { get; set; }
|
||||
public bool EnableMouse { get; set; }
|
||||
public bool EnableVsync { get; set; }
|
||||
public VSyncMode VSyncMode
|
||||
{
|
||||
get => _vSyncMode;
|
||||
set
|
||||
{
|
||||
if (value == VSyncMode.Custom ||
|
||||
value == VSyncMode.Switch ||
|
||||
value == VSyncMode.Unbounded)
|
||||
{
|
||||
_vSyncMode = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int CustomVSyncIntervalPercentageProxy
|
||||
{
|
||||
get => _customVSyncIntervalPercentageProxy;
|
||||
set
|
||||
{
|
||||
int newInterval = (int)((value / 100f) * 60);
|
||||
_customVSyncInterval = newInterval;
|
||||
_customVSyncIntervalPercentageProxy = value;
|
||||
OnPropertyChanged((nameof(CustomVSyncInterval)));
|
||||
OnPropertyChanged((nameof(CustomVSyncIntervalPercentageText)));
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomVSyncIntervalPercentageText
|
||||
{
|
||||
get
|
||||
{
|
||||
string text = CustomVSyncIntervalPercentageProxy.ToString() + "%";
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
public bool EnableCustomVSyncInterval
|
||||
{
|
||||
get => _enableCustomVSyncInterval;
|
||||
set
|
||||
{
|
||||
_enableCustomVSyncInterval = value;
|
||||
if (_vSyncMode == VSyncMode.Custom && !value)
|
||||
{
|
||||
VSyncMode = VSyncMode.Switch;
|
||||
}
|
||||
else if (value)
|
||||
{
|
||||
VSyncMode = VSyncMode.Custom;
|
||||
}
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public int CustomVSyncInterval
|
||||
{
|
||||
get => _customVSyncInterval;
|
||||
set
|
||||
{
|
||||
_customVSyncInterval = value;
|
||||
int newPercent = (int)((value / 60f) * 100);
|
||||
_customVSyncIntervalPercentageProxy = newPercent;
|
||||
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageProxy));
|
||||
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageText));
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public bool EnablePptc { get; set; }
|
||||
public bool EnableLowPowerPptc { get; set; }
|
||||
public bool EnableInternetAccess { get; set; }
|
||||
@@ -428,7 +499,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
CurrentDate = currentDateTime.Date;
|
||||
CurrentTime = currentDateTime.TimeOfDay;
|
||||
|
||||
EnableVsync = config.Graphics.EnableVsync;
|
||||
EnableCustomVSyncInterval = config.Graphics.EnableCustomVSyncInterval.Value;
|
||||
CustomVSyncInterval = config.Graphics.CustomVSyncInterval;
|
||||
VSyncMode = config.Graphics.VSyncMode;
|
||||
EnableFsIntegrityChecks = config.System.EnableFsIntegrityChecks;
|
||||
DramSize = config.System.DramSize;
|
||||
IgnoreMissingServices = config.System.IgnoreMissingServices;
|
||||
@@ -441,7 +514,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
// Graphics
|
||||
GraphicsBackendIndex = (int)config.Graphics.GraphicsBackend.Value;
|
||||
// Physical devices are queried asynchronously hence the prefered index config value is loaded in LoadAvailableGpus().
|
||||
// Physical devices are queried asynchronously hence the preferred index config value is loaded in LoadAvailableGpus().
|
||||
EnableShaderCache = config.Graphics.EnableShaderCache;
|
||||
EnableTextureRecompression = config.Graphics.EnableTextureRecompression;
|
||||
EnableMacroHLE = config.Graphics.EnableMacroHLE;
|
||||
@@ -524,7 +597,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
|
||||
config.System.SystemTimeOffset.Value = Convert.ToInt64((CurrentDate.ToUnixTimeSeconds() + CurrentTime.TotalSeconds) - DateTimeOffset.Now.ToUnixTimeSeconds());
|
||||
config.Graphics.EnableVsync.Value = EnableVsync;
|
||||
config.Graphics.VSyncMode.Value = VSyncMode;
|
||||
config.Graphics.EnableCustomVSyncInterval.Value = EnableCustomVSyncInterval;
|
||||
config.Graphics.CustomVSyncInterval.Value = CustomVSyncInterval;
|
||||
config.System.EnableFsIntegrityChecks.Value = EnableFsIntegrityChecks;
|
||||
config.System.DramSize.Value = DramSize;
|
||||
config.System.IgnoreMissingServices.Value = IgnoreMissingServices;
|
||||
@@ -591,6 +666,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
config.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
||||
|
||||
MainWindow.UpdateGraphicsConfig();
|
||||
MainWindow.MainWindowViewModel.VSyncModeSettingChanged();
|
||||
|
||||
SaveSettingsEvent?.Invoke();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user