diff --git a/src/Ryujinx.Ava/AppHost.cs b/src/Ryujinx.Ava/AppHost.cs index dd77a08af..47fa1c32e 100644 --- a/src/Ryujinx.Ava/AppHost.cs +++ b/src/Ryujinx.Ava/AppHost.cs @@ -58,10 +58,10 @@ using IRenderer = Ryujinx.Graphics.GAL.IRenderer; using Key = Ryujinx.Input.Key; using MouseButton = Ryujinx.Input.MouseButton; -using PresentIntervalState = Ryujinx.Common.Configuration.PresentIntervalState; using ScalingFilter = Ryujinx.Common.Configuration.ScalingFilter; using Size = Avalonia.Size; using Switch = Ryujinx.HLE.Switch; +using VSyncMode = Ryujinx.Common.Configuration.VSyncMode; namespace Ryujinx.Ava { @@ -190,9 +190,9 @@ public AppHost( ConfigurationState.Instance.Graphics.ScalingFilter.Event += UpdateScalingFilter; ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event += UpdateScalingFilterLevel; ConfigurationState.Instance.Graphics.EnableColorSpacePassthrough.Event += UpdateColorSpacePassthrough; - ConfigurationState.Instance.Graphics.PresentIntervalState.Event += UpdatePresentIntervalState; - ConfigurationState.Instance.Graphics.CustomPresentInterval.Event += UpdateCustomPresentIntervalValue; - ConfigurationState.Instance.Graphics.EnableCustomPresentInterval.Event += UpdateCustomPresentIntervalEnabled; + ConfigurationState.Instance.Graphics.VSyncMode.Event += UpdateVSyncMode; + ConfigurationState.Instance.Graphics.CustomVSyncInterval.Event += UpdateCustomVSyncIntervalValue; + ConfigurationState.Instance.Graphics.EnableCustomVSyncInterval.Event += UpdateCustomVSyncIntervalEnabled; ConfigurationState.Instance.System.EnableInternetAccess.Event += UpdateEnableInternetAccessState; ConfigurationState.Instance.Multiplayer.LanInterfaceId.Event += UpdateLanInterfaceIdState; @@ -240,34 +240,66 @@ private void UpdateColorSpacePassthrough(object sender, ReactiveEventArgs _renderer.Window?.SetColorSpacePassthrough((bool)ConfigurationState.Instance.Graphics.EnableColorSpacePassthrough.Value); } - private void UpdatePresentIntervalState(object sender, ReactiveEventArgs e) + public void UpdateVSyncMode(object sender, ReactiveEventArgs e) { if (Device != null) { - Device.PresentIntervalState = e.NewValue; - Device.UpdatePresentInterval(); + Device.VSyncMode = e.NewValue; + Device.UpdateVSyncInterval(); } //vulkan present mode may change in response, so recreate the swapchain - _renderer.Window?.ChangePresentIntervalState((Ryujinx.Graphics.GAL.PresentIntervalState)e.NewValue); - ConfigurationState.Instance.Graphics.PresentIntervalState.Value = e.NewValue; + _renderer.Window?.ChangeVSyncMode((Ryujinx.Graphics.GAL.VSyncMode)e.NewValue); + + _viewModel.ShowCustomVSyncIntervalPicker = (e.NewValue == VSyncMode.Custom); + + ConfigurationState.Instance.Graphics.VSyncMode.Value = e.NewValue; ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath); } - private void UpdateCustomPresentIntervalValue(object sender, ReactiveEventArgs e) + public void VSyncModeToggle() + { + VSyncMode oldVSyncMode = Device.VSyncMode; + VSyncMode newVSyncMode = VSyncMode.Switch; + bool customVSyncIntervalEnabled = ConfigurationState.Instance.Graphics.EnableCustomVSyncInterval.Value; + + switch (oldVSyncMode) + { + case VSyncMode.Switch: + newVSyncMode = VSyncMode.Unbounded; + break; + case VSyncMode.Unbounded: + if (customVSyncIntervalEnabled) + { + newVSyncMode = VSyncMode.Custom; + } + else + { + newVSyncMode = VSyncMode.Switch; + } + + break; + case VSyncMode.Custom: + newVSyncMode = VSyncMode.Switch; + break; + } + UpdateVSyncMode(this, new ReactiveEventArgs(oldVSyncMode, newVSyncMode)); + } + + private void UpdateCustomVSyncIntervalValue(object sender, ReactiveEventArgs e) { if (Device != null) { - Device.TargetPresentInterval = e.NewValue; - Device.UpdatePresentInterval(); + Device.TargetVSyncInterval = e.NewValue; + Device.UpdateVSyncInterval(); } } - private void UpdateCustomPresentIntervalEnabled(object sender, ReactiveEventArgs e) + private void UpdateCustomVSyncIntervalEnabled(object sender, ReactiveEventArgs e) { if (Device != null) { - Device.CustomPresentIntervalEnabled = e.NewValue; - Device.UpdatePresentInterval(); + Device.CustomVSyncIntervalEnabled = e.NewValue; + Device.UpdateVSyncInterval(); } } @@ -550,12 +582,6 @@ private void HideCursorState_Changed(object sender, ReactiveEventArgs(oldState, presentIntervalState)); - } - public async Task LoadGuestApplication() { InitializeSwitchInstance(); @@ -819,7 +845,7 @@ private void InitializeSwitchInstance() _viewModel.UiHandler, (SystemLanguage)ConfigurationState.Instance.System.Language.Value, (RegionCode)ConfigurationState.Instance.System.Region.Value, - ConfigurationState.Instance.Graphics.PresentIntervalState, + ConfigurationState.Instance.Graphics.VSyncMode, ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.System.EnablePtc, ConfigurationState.Instance.System.EnableInternetAccess, @@ -834,7 +860,7 @@ private void InitializeSwitchInstance() ConfigurationState.Instance.System.UseHypervisor, ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value, ConfigurationState.Instance.Multiplayer.Mode, - ConfigurationState.Instance.Graphics.CustomPresentInterval.Value); + ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value); Device = new Switch(configuration); } @@ -960,7 +986,7 @@ private void RenderLoop() Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token); Translator.IsReadyForTranslation.Set(); - _renderer.Window.ChangePresentIntervalState((Ryujinx.Graphics.GAL.PresentIntervalState)Device.PresentIntervalState); + _renderer.Window.ChangeVSyncMode((Ryujinx.Graphics.GAL.VSyncMode)Device.VSyncMode); while (_isActive) { @@ -1008,7 +1034,7 @@ public void UpdateStatus() { // Run a status update only when a frame is to be drawn. This prevents from updating the ui and wasting a render when no frame is queued. string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? LocaleManager.Instance[LocaleKeys.Docked] : LocaleManager.Instance[LocaleKeys.Handheld]; - string presentIntervalState = Device.PresentIntervalState.ToString(); + string vSyncMode = Device.VSyncMode.ToString(); if (GraphicsConfig.ResScale != 1) { @@ -1016,7 +1042,7 @@ public void UpdateStatus() } StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs( - presentIntervalState, + vSyncMode, LocaleManager.Instance[LocaleKeys.VolumeShort] + $": {(int)(Device.GetVolume() * 100)}%", ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan ? "Vulkan" : "OpenGL", dockedMode, @@ -1108,40 +1134,16 @@ private bool UpdateFrame() { switch (currentHotkeyState) { - //todo default - case KeyboardHotkeyState.TogglePresentIntervalState: - PresentIntervalState oldState = Device.PresentIntervalState; - PresentIntervalState newState; - if (oldState == PresentIntervalState.Switch) - { - newState = PresentIntervalState.Unbounded; - } - else if (oldState == PresentIntervalState.Unbounded) - { - if (ConfigurationState.Instance.Graphics.EnableCustomPresentInterval) - { - newState = PresentIntervalState.Custom; - } - else - { - newState = PresentIntervalState.Switch; - } - } - else - { - newState = PresentIntervalState.Switch; - } - UpdatePresentIntervalState(this, new ReactiveEventArgs(oldState, newState)); - _viewModel.ShowCustomPresentIntervalPicker = - (newState == PresentIntervalState.Custom); + case KeyboardHotkeyState.ToggleVSyncMode: + VSyncModeToggle(); break; - case KeyboardHotkeyState.CustomPresentIntervalDecrement: - Device.DecrementCustomPresentInterval(); - _viewModel.CustomPresentInterval -= 1; + case KeyboardHotkeyState.CustomVSyncIntervalDecrement: + Device.DecrementCustomVSyncInterval(); + _viewModel.CustomVSyncInterval -= 1; break; - case KeyboardHotkeyState.CustomPresentIntervalIncrement: - Device.IncrementCustomPresentInterval(); - _viewModel.CustomPresentInterval += 1; + case KeyboardHotkeyState.CustomVSyncIntervalIncrement: + Device.IncrementCustomVSyncInterval(); + _viewModel.CustomVSyncInterval += 1; break; case KeyboardHotkeyState.Screenshot: ScreenshotRequested = true; @@ -1228,9 +1230,9 @@ private KeyboardHotkeyState GetHotkeyState() { KeyboardHotkeyState state = KeyboardHotkeyState.None; - if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.PresentIntervalState)) + if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.VSyncMode)) { - state = KeyboardHotkeyState.TogglePresentIntervalState; + state = KeyboardHotkeyState.ToggleVSyncMode; } else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Screenshot)) { @@ -1264,13 +1266,13 @@ private KeyboardHotkeyState GetHotkeyState() { state = KeyboardHotkeyState.VolumeDown; } - else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.CustomPresentIntervalIncrement)) + else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.CustomVSyncIntervalIncrement)) { - state = KeyboardHotkeyState.CustomPresentIntervalIncrement; + state = KeyboardHotkeyState.CustomVSyncIntervalIncrement; } - else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.CustomPresentIntervalDecrement)) + else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.CustomVSyncIntervalDecrement)) { - state = KeyboardHotkeyState.CustomPresentIntervalDecrement; + state = KeyboardHotkeyState.CustomVSyncIntervalDecrement; } return state; diff --git a/src/Ryujinx.Ava/Assets/Locales/en_US.json b/src/Ryujinx.Ava/Assets/Locales/en_US.json index 849604577..1d80f5161 100644 --- a/src/Ryujinx.Ava/Assets/Locales/en_US.json +++ b/src/Ryujinx.Ava/Assets/Locales/en_US.json @@ -126,17 +126,17 @@ "SettingsTabSystemSystemLanguageTraditionalChinese": "Traditional Chinese", "SettingsTabSystemSystemTimeZone": "System Time Zone:", "SettingsTabSystemSystemTime": "System Time:", - "SettingsTabSystemPresentIntervalState": "VSync:", - "SettingsTabSystemEnableCustomPresentInterval": "Enable custom refresh rate (Experimental)", - "SettingsTabSystemPresentIntervalStateSwitch": "On", - "SettingsTabSystemPresentIntervalStateUnbounded": "Off", - "SettingsTabSystemPresentIntervalStateCustom": "Custom Refresh Rate", - "SettingsTabSystemPresentIntervalStateTooltip": "Emulated Vertical Sync. 'On' emulates the Switch's refresh rate of 60Hz. 'Off' is an unbounded refresh rate.", - "SettingsTabSystemPresentIntervalStateTooltipCustom": "Emulated Vertical Sync. 'On' emulates the Switch's refresh rate of 60Hz. 'Off' is an unbounded refresh rate. 'Custom' emulates the specified custom refresh rate.", - "SettingsTabSystemEnableCustomPresentIntervalTooltip": "Allows the user to specify an emulated refresh rate. In some titles, this may speed up or slow down the rate of gameplay logic. In other titles, it may allow for capping FPS at some multiple of the refresh rate, or lead to unpredictable behavior. This is an experimental feature, with no guarantees for how gameplay will be affected. \n\nLeave OFF if unsure.", - "SettingsTabSystemCustomPresentIntervalValueTooltip": "The custom refresh rate target value.", - "SettingsTabSystemCustomPresentIntervalSliderTooltip": "The custom refresh rate, as a percentage of the normal Switch refresh rate.", - "SettingsTabSystemCustomPresentIntervalValue": "Custom Refresh Rate Value:", + "SettingsTabSystemVSyncMode": "VSync:", + "SettingsTabSystemEnableCustomVSyncInterval": "Enable custom refresh rate (Experimental)", + "SettingsTabSystemVSyncModeSwitch": "On", + "SettingsTabSystemVSyncModeUnbounded": "Off", + "SettingsTabSystemVSyncModeCustom": "Custom Refresh Rate", + "SettingsTabSystemVSyncModeTooltip": "Emulated Vertical Sync. 'On' emulates the Switch's refresh rate of 60Hz. 'Off' is an unbounded refresh rate.", + "SettingsTabSystemVSyncModeTooltipCustom": "Emulated Vertical Sync. 'On' emulates the Switch's refresh rate of 60Hz. 'Off' is an unbounded refresh rate. 'Custom' emulates the specified custom refresh rate.", + "SettingsTabSystemEnableCustomVSyncIntervalTooltip": "Allows the user to specify an emulated refresh rate. In some titles, this may speed up or slow down the rate of gameplay logic. In other titles, it may allow for capping FPS at some multiple of the refresh rate, or lead to unpredictable behavior. This is an experimental feature, with no guarantees for how gameplay will be affected. \n\nLeave OFF if unsure.", + "SettingsTabSystemCustomVSyncIntervalValueTooltip": "The custom refresh rate target value.", + "SettingsTabSystemCustomVSyncIntervalSliderTooltip": "The custom refresh rate, as a percentage of the normal Switch refresh rate.", + "SettingsTabSystemCustomVSyncIntervalValue": "Custom Refresh Rate Value:", "SettingsTabSystemEnablePptc": "PPTC (Profiled Persistent Translation Cache)", "SettingsTabSystemEnableFsIntegrityChecks": "FS Integrity Checks", "SettingsTabSystemAudioBackend": "Audio Backend:", @@ -144,7 +144,7 @@ "SettingsTabSystemAudioBackendOpenAL": "OpenAL", "SettingsTabSystemAudioBackendSoundIO": "SoundIO", "SettingsTabSystemAudioBackendSDL2": "SDL2", - "SettingsTabSystemCustomPresentInterval": "Interval", + "SettingsTabSystemCustomVSyncInterval": "Interval", "SettingsTabSystemHacks": "Hacks", "SettingsTabSystemHacksNote": "May cause instability", "SettingsTabSystemExpandDramSize": "Use alternative memory layout (Developers)", @@ -585,13 +585,13 @@ "RyujinxUpdater": "Ryujinx Updater", "SettingsTabHotkeys": "Keyboard Hotkeys", "SettingsTabHotkeysHotkeys": "Keyboard Hotkeys", - "SettingsTabHotkeysTogglePresentIntervalStateHotkey": "Toggle Present Interval state:", + "SettingsTabHotkeysToggleVSyncModeHotkey": "Toggle VSync mode:", "SettingsTabHotkeysScreenshotHotkey": "Screenshot:", "SettingsTabHotkeysShowUiHotkey": "Show UI:", "SettingsTabHotkeysPauseHotkey": "Pause:", "SettingsTabHotkeysToggleMuteHotkey": "Mute:", - "SettingsTabHotkeysIncrementCustomPresentIntervalHotkey": "Raise custom refresh interval", - "SettingsTabHotkeysDecrementCustomPresentIntervalHotkey": "Lower custom refresh interval", + "SettingsTabHotkeysIncrementCustomVSyncIntervalHotkey": "Raise custom refresh rate", + "SettingsTabHotkeysDecrementCustomVSyncIntervalHotkey": "Lower custom refresh rate", "ControllerMotionTitle": "Motion Control Settings", "ControllerRumbleTitle": "Rumble Settings", "SettingsSelectThemeFileDialogTitle": "Select Theme File", diff --git a/src/Ryujinx.Ava/Common/KeyboardHotkeyState.cs b/src/Ryujinx.Ava/Common/KeyboardHotkeyState.cs index 6429dda05..5c5507ffc 100644 --- a/src/Ryujinx.Ava/Common/KeyboardHotkeyState.cs +++ b/src/Ryujinx.Ava/Common/KeyboardHotkeyState.cs @@ -3,7 +3,7 @@ namespace Ryujinx.Ava.Common public enum KeyboardHotkeyState { None, - TogglePresentIntervalState, + ToggleVSyncMode, Screenshot, ShowUi, Pause, @@ -12,7 +12,7 @@ public enum KeyboardHotkeyState ResScaleDown, VolumeUp, VolumeDown, - CustomPresentIntervalIncrement, - CustomPresentIntervalDecrement, + CustomVSyncIntervalIncrement, + CustomVSyncIntervalDecrement, } } diff --git a/src/Ryujinx.Ava/UI/Models/StatusUpdatedEventArgs.cs b/src/Ryujinx.Ava/UI/Models/StatusUpdatedEventArgs.cs index ce975f8c5..e14bff25e 100644 --- a/src/Ryujinx.Ava/UI/Models/StatusUpdatedEventArgs.cs +++ b/src/Ryujinx.Ava/UI/Models/StatusUpdatedEventArgs.cs @@ -4,7 +4,7 @@ namespace Ryujinx.Ava.UI.Models { internal class StatusUpdatedEventArgs : EventArgs { - public string PresentIntervalState { get; } + public string VSyncMode { get; } public string VolumeStatus { get; } public string GpuBackend { get; } public string AspectRatio { get; } @@ -13,9 +13,9 @@ internal class StatusUpdatedEventArgs : EventArgs public string GameStatus { get; } public string GpuName { get; } - public StatusUpdatedEventArgs(string presentIntervalState, string volumeStatus, string gpuBackend, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, string gpuName) + public StatusUpdatedEventArgs(string vSyncMode, string volumeStatus, string gpuBackend, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, string gpuName) { - PresentIntervalState = presentIntervalState; + VSyncMode = vSyncMode; VolumeStatus = volumeStatus; GpuBackend = gpuBackend; DockedMode = dockedMode; diff --git a/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs index e34eb72b8..ec0bb3fc5 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs @@ -59,7 +59,7 @@ public class MainWindowViewModel : BaseModel private string _searchText; private Timer _searchTimer; private string _dockedStatusText; - private string _presentIntervalStateText; + private string _vSyncModeText; private string _fifoStatusText; private string _gameStatusText; private string _volumeStatusText; @@ -75,7 +75,7 @@ public class MainWindowViewModel : BaseModel private bool _showStatusSeparator; private Brush _progressBarForegroundColor; private Brush _progressBarBackgroundColor; - private Brush _presentIntervalStateColor; + private Brush _vSyncModeColor; private byte[] _selectedIcon; private bool _isAppletMenuActive; private int _statusBarProgressMaximum; @@ -103,8 +103,8 @@ public class MainWindowViewModel : BaseModel private WindowState _windowState; private double _windowWidth; private double _windowHeight; - private int _customPresentInterval; - private int _customPresentIntervalPercentageProxy; + private int _customVSyncInterval; + private int _customVSyncIntervalPercentageProxy; @@ -133,7 +133,7 @@ public MainWindowViewModel() Volume = ConfigurationState.Instance.System.AudioVolume; } - CustomPresentInterval = ConfigurationState.Instance.Graphics.CustomPresentInterval.Value; + CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value; } public void Initialize( @@ -410,25 +410,25 @@ public Brush ProgressBarForegroundColor } } - public Brush PresentIntervalStateColor + public Brush VSyncModeColor { - get => _presentIntervalStateColor; + get => _vSyncModeColor; set { - _presentIntervalStateColor = value; + _vSyncModeColor = value; OnPropertyChanged(); } } - public bool ShowCustomPresentIntervalPicker + public bool ShowCustomVSyncIntervalPicker { get { if (_isGameRunning) { - return AppHost.Device.PresentIntervalState == - PresentIntervalState.Custom; + return AppHost.Device.VSyncMode == + VSyncMode.Custom; } else { @@ -441,30 +441,30 @@ public bool ShowCustomPresentIntervalPicker } } - public int CustomPresentIntervalPercentageProxy + public int CustomVSyncIntervalPercentageProxy { - get => _customPresentIntervalPercentageProxy; + get => _customVSyncIntervalPercentageProxy; set { int newInterval = (int)(((decimal)value / 100) * 60); - _customPresentInterval = newInterval; - _customPresentIntervalPercentageProxy = value; - ConfigurationState.Instance.Graphics.CustomPresentInterval.Value = newInterval; + _customVSyncInterval = newInterval; + _customVSyncIntervalPercentageProxy = value; + ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value = newInterval; if (_isGameRunning) { - AppHost.Device.CustomPresentInterval = newInterval; - AppHost.Device.UpdatePresentInterval(); + AppHost.Device.CustomVSyncInterval = newInterval; + AppHost.Device.UpdateVSyncInterval(); } - OnPropertyChanged((nameof(CustomPresentInterval))); - OnPropertyChanged((nameof(CustomPresentIntervalPercentageText))); + OnPropertyChanged((nameof(CustomVSyncInterval))); + OnPropertyChanged((nameof(CustomVSyncIntervalPercentageText))); } } - public string CustomPresentIntervalPercentageText + public string CustomVSyncIntervalPercentageText { get { - string text = CustomPresentIntervalPercentageProxy.ToString() + "%"; + string text = CustomVSyncIntervalPercentageProxy.ToString() + "%"; return text; } set @@ -473,22 +473,22 @@ public string CustomPresentIntervalPercentageText } } - public int CustomPresentInterval + public int CustomVSyncInterval { - get => _customPresentInterval; + get => _customVSyncInterval; set { - _customPresentInterval = value; + _customVSyncInterval = value; int newPercent = (int)(((decimal)value / 60) * 100); - _customPresentIntervalPercentageProxy = newPercent; - ConfigurationState.Instance.Graphics.CustomPresentInterval.Value = value; + _customVSyncIntervalPercentageProxy = newPercent; + ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value = value; if (_isGameRunning) { - AppHost.Device.CustomPresentInterval = value; - AppHost.Device.UpdatePresentInterval(); + AppHost.Device.CustomVSyncInterval = value; + AppHost.Device.UpdateVSyncInterval(); } - OnPropertyChanged(nameof(CustomPresentIntervalPercentageProxy)); - OnPropertyChanged(nameof(CustomPresentIntervalPercentageText)); + OnPropertyChanged(nameof(CustomVSyncIntervalPercentageProxy)); + OnPropertyChanged(nameof(CustomVSyncIntervalPercentageText)); OnPropertyChanged(); } } @@ -581,12 +581,12 @@ public string BackendText } } - public string PresentIntervalStateText + public string VSyncModeText { - get => _presentIntervalStateText; + get => _vSyncModeText; set { - _presentIntervalStateText = value; + _vSyncModeText = value; OnPropertyChanged(); } @@ -1286,18 +1286,18 @@ private void Update_StatusBar(object sender, StatusUpdatedEventArgs args) { Dispatcher.UIThread.InvokeAsync(() => { - Application.Current.Styles.TryGetResource(args.PresentIntervalState, + Application.Current.Styles.TryGetResource(args.VSyncMode, Avalonia.Application.Current.ActualThemeVariant, out object color); if (color is not null) { - PresentIntervalStateColor = new SolidColorBrush((Color)color); + VSyncModeColor = new SolidColorBrush((Color)color); } - PresentIntervalStateText = args.PresentIntervalState == "Custom" ? "Custom" : "VSync"; - ShowCustomPresentIntervalPicker = - args.PresentIntervalState == PresentIntervalState.Custom.ToString(); + VSyncModeText = args.VSyncMode == "Custom" ? "Custom" : "VSync"; + ShowCustomVSyncIntervalPicker = + args.VSyncMode == VSyncMode.Custom.ToString(); DockedStatusText = args.DockedMode; AspectRatioStatusText = args.AspectRatio; GameStatusText = args.GameStatus; @@ -1456,55 +1456,25 @@ public void ToggleDockMode() } } - public void UpdatePresentIntervalState() + public void UpdateVSyncMode() { - PresentIntervalState oldPresentInterval = AppHost.Device.PresentIntervalState; - PresentIntervalState newPresentInterval = PresentIntervalState.Switch; - bool customPresentIntervalEnabled = ConfigurationState.Instance.Graphics.EnableCustomPresentInterval.Value; - - switch (oldPresentInterval) - { - case PresentIntervalState.Switch: - newPresentInterval = PresentIntervalState.Unbounded; - break; - case PresentIntervalState.Unbounded: - if (customPresentIntervalEnabled) - { - newPresentInterval = PresentIntervalState.Custom; - } - else - { - newPresentInterval = PresentIntervalState.Switch; - } - break; - case PresentIntervalState.Custom: - newPresentInterval = PresentIntervalState.Switch; - break; - } - - ConfigurationState.Instance.Graphics.PresentIntervalState.Value = newPresentInterval; - - if (_isGameRunning) - { - AppHost.UpdatePresentInterval(newPresentInterval); - } - - OnPropertyChanged(nameof(ShowCustomPresentIntervalPicker)); + AppHost.VSyncModeToggle(); + OnPropertyChanged(nameof(ShowCustomVSyncIntervalPicker)); } - public void PresentIntervalStateSettingChanged() + public void VSyncModeSettingChanged() { if (_isGameRunning) { - AppHost.Device.CustomPresentInterval = ConfigurationState.Instance.Graphics.CustomPresentInterval.Value; - AppHost.Device.UpdatePresentInterval(); + AppHost.Device.CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value; + AppHost.Device.UpdateVSyncInterval(); } - CustomPresentInterval = ConfigurationState.Instance.Graphics.CustomPresentInterval.Value; - OnPropertyChanged(nameof(ShowCustomPresentIntervalPicker)); - OnPropertyChanged(nameof(CustomPresentIntervalPercentageProxy)); - OnPropertyChanged(nameof(CustomPresentIntervalPercentageText)); - OnPropertyChanged(nameof(CustomPresentInterval)); + CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value; + OnPropertyChanged(nameof(ShowCustomVSyncIntervalPicker)); + OnPropertyChanged(nameof(CustomVSyncIntervalPercentageProxy)); + OnPropertyChanged(nameof(CustomVSyncIntervalPercentageText)); + OnPropertyChanged(nameof(CustomVSyncInterval)); } public async Task ExitCurrentState() diff --git a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs index 5ff1871bd..4333f4974 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs @@ -52,10 +52,10 @@ public class SettingsViewModel : BaseModel private string _customThemePath; private int _scalingFilter; private int _scalingFilterLevel; - private int _customPresentInterval; - private bool _enableCustomPresentInterval; - private int _customPresentIntervalPercentageProxy; - private PresentIntervalState _presentIntervalState; + private int _customVSyncInterval; + private bool _enableCustomVSyncInterval; + private int _customVSyncIntervalPercentageProxy; + private VSyncMode _vSyncMode; public event Action CloseWindow; public event Action SaveSettingsEvent; @@ -142,39 +142,39 @@ public bool DirectoryChanged public bool EnableDockedMode { get; set; } public bool EnableKeyboard { get; set; } public bool EnableMouse { get; set; } - public PresentIntervalState PresentIntervalState + public VSyncMode VSyncMode { - get => _presentIntervalState; + get => _vSyncMode; set { - if (value == PresentIntervalState.Custom || - value == PresentIntervalState.Switch || - value == PresentIntervalState.Unbounded) + if (value == VSyncMode.Custom || + value == VSyncMode.Switch || + value == VSyncMode.Unbounded) { - _presentIntervalState = value; + _vSyncMode = value; OnPropertyChanged(); } } } - public int CustomPresentIntervalPercentageProxy + public int CustomVSyncIntervalPercentageProxy { - get => _customPresentIntervalPercentageProxy; + get => _customVSyncIntervalPercentageProxy; set { int newInterval = (int)(((decimal)value / 100) * 60); - _customPresentInterval = newInterval; - _customPresentIntervalPercentageProxy = value; - OnPropertyChanged((nameof(CustomPresentInterval))); - OnPropertyChanged((nameof(CustomPresentIntervalPercentageText))); + _customVSyncInterval = newInterval; + _customVSyncIntervalPercentageProxy = value; + OnPropertyChanged((nameof(CustomVSyncInterval))); + OnPropertyChanged((nameof(CustomVSyncIntervalPercentageText))); } } - public string CustomPresentIntervalPercentageText + public string CustomVSyncIntervalPercentageText { get { - string text = CustomPresentIntervalPercentageProxy.ToString() + "%"; + string text = CustomVSyncIntervalPercentageProxy.ToString() + "%"; return text; } set @@ -183,34 +183,34 @@ public string CustomPresentIntervalPercentageText } } - public bool EnableCustomPresentInterval + public bool EnableCustomVSyncInterval { - get => _enableCustomPresentInterval; + get => _enableCustomVSyncInterval; set { - _enableCustomPresentInterval = value; - if (_presentIntervalState == PresentIntervalState.Custom && value == false) + _enableCustomVSyncInterval = value; + if (_vSyncMode == VSyncMode.Custom && value == false) { - PresentIntervalState = PresentIntervalState.Switch; + VSyncMode = VSyncMode.Switch; } else if (value) { - PresentIntervalState = PresentIntervalState.Custom; + VSyncMode = VSyncMode.Custom; } OnPropertyChanged(); } } - public int CustomPresentInterval + public int CustomVSyncInterval { - get => _customPresentInterval; + get => _customVSyncInterval; set { - _customPresentInterval = value; + _customVSyncInterval = value; int newPercent = (int)(((decimal)value / 60) * 100); - _customPresentIntervalPercentageProxy = newPercent; - OnPropertyChanged(nameof(CustomPresentIntervalPercentageProxy)); - OnPropertyChanged(nameof(CustomPresentIntervalPercentageText)); + _customVSyncIntervalPercentageProxy = newPercent; + OnPropertyChanged(nameof(CustomVSyncIntervalPercentageProxy)); + OnPropertyChanged(nameof(CustomVSyncIntervalPercentageText)); OnPropertyChanged(); } } @@ -524,9 +524,9 @@ public void LoadCurrentConfiguration() CurrentDate = currentDateTime.Date; CurrentTime = currentDateTime.TimeOfDay.Add(TimeSpan.FromSeconds(config.System.SystemTimeOffset)); - EnableCustomPresentInterval = config.Graphics.EnableCustomPresentInterval.Value; - CustomPresentInterval = config.Graphics.CustomPresentInterval; - PresentIntervalState = config.Graphics.PresentIntervalState; + EnableCustomVSyncInterval = config.Graphics.EnableCustomVSyncInterval.Value; + CustomVSyncInterval = config.Graphics.CustomVSyncInterval; + VSyncMode = config.Graphics.VSyncMode; EnableFsIntegrityChecks = config.System.EnableFsIntegrityChecks; ExpandDramSize = config.System.ExpandRam; IgnoreMissingServices = config.System.IgnoreMissingServices; @@ -615,9 +615,9 @@ public void SaveSettings() } config.System.SystemTimeOffset.Value = Convert.ToInt64((CurrentDate.ToUnixTimeSeconds() + CurrentTime.TotalSeconds) - DateTimeOffset.Now.ToUnixTimeSeconds()); - config.Graphics.PresentIntervalState.Value = PresentIntervalState; - config.Graphics.EnableCustomPresentInterval.Value = EnableCustomPresentInterval; - config.Graphics.CustomPresentInterval.Value = CustomPresentInterval; + config.Graphics.VSyncMode.Value = VSyncMode; + config.Graphics.EnableCustomVSyncInterval.Value = EnableCustomVSyncInterval; + config.Graphics.CustomVSyncInterval.Value = CustomVSyncInterval; config.System.EnableFsIntegrityChecks.Value = EnableFsIntegrityChecks; config.System.ExpandRam.Value = ExpandDramSize; config.System.IgnoreMissingServices.Value = IgnoreMissingServices; @@ -683,7 +683,7 @@ public void SaveSettings() config.ToFileFormat().SaveConfig(Program.ConfigurationPath); MainWindow.UpdateGraphicsConfig(); - MainWindow.MainWindowViewModel.PresentIntervalStateSettingChanged(); + MainWindow.MainWindowViewModel.VSyncModeSettingChanged(); SaveSettingsEvent?.Invoke(); diff --git a/src/Ryujinx.Ava/UI/Views/Main/MainStatusBarView.axaml b/src/Ryujinx.Ava/UI/Views/Main/MainStatusBarView.axaml index c53281c2a..4bc5130f2 100644 --- a/src/Ryujinx.Ava/UI/Views/Main/MainStatusBarView.axaml +++ b/src/Ryujinx.Ava/UI/Views/Main/MainStatusBarView.axaml @@ -80,18 +80,18 @@ MaxHeight="18" Orientation="Horizontal"> + PointerReleased="VSyncMode_PointerReleased" + Text="{Binding VSyncModeText}" + TextAlignment="Start"/>