From 11a68a204f4499e60fba899012c166bc23c732e9 Mon Sep 17 00:00:00 2001 From: Vova Date: Sat, 8 Feb 2025 20:16:38 +1000 Subject: [PATCH] Fixed bug crash due to incorrect System.SystemTimeOffset.Value, hotkeys should now also be read from the global configuration file --- src/Ryujinx/UI/ViewModels/SettingsViewModel.cs | 16 +++++++++------- .../ConfigurationState.Migration.cs | 18 +++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs index 9ab790714..0661bfd8f 100644 --- a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs @@ -405,9 +405,10 @@ namespace Ryujinx.Ava.UI.ViewModels string gameDir = Program.GetDirGameUserConfig(gameId, false, true); if (ConfigurationFileFormat.TryLoad(gameDir, out ConfigurationFileFormat configurationFileFormat)) { - ConfigurationState.Instance.Load(configurationFileFormat, gameDir, gameId); - LoadCurrentConfiguration(); // Needed to load custom configuration + ConfigurationState.Instance.Load(configurationFileFormat, gameDir, gameId); } + + LoadCurrentConfiguration(); // Needed to load custom configuration } if (Program.PreviewerDetached) @@ -547,6 +548,7 @@ namespace Ryujinx.Ava.UI.ViewModels public void LoadCurrentConfiguration() { ConfigurationState config = ConfigurationState.Instance; + bool userconfigIsNull = string.IsNullOrEmpty(GameId); //It is necessary that the data is used from the global configuration file if (string.IsNullOrEmpty(GameId)) @@ -593,7 +595,6 @@ namespace Ryujinx.Ava.UI.ViewModels DateTime currentDateTime = currentHostDateTime.Add(systemDateTimeOffset); CurrentDate = currentDateTime.Date; CurrentTime = currentDateTime.TimeOfDay; - MatchSystemTime = config.System.MatchSystemTime; EnableCustomVSyncInterval = config.Graphics.EnableCustomVSyncInterval; @@ -697,9 +698,9 @@ namespace Ryujinx.Ava.UI.ViewModels public void SaveSettings() { ConfigurationState config = ConfigurationState.Instance; + bool userConfigFile = string.IsNullOrEmpty(GameId); - - if (string.IsNullOrEmpty(GameId)) + if (userConfigFile) { // User Interface config.EnableDiscordIntegration.Value = EnableDiscordIntegration; @@ -734,7 +735,8 @@ namespace Ryujinx.Ava.UI.ViewModels config.Hid.EnableMouse.Value = EnableMouse; // Keyboard Hotkeys - config.Hid.Hotkeys.Value = KeyboardHotkey.GetConfig(); + config.Hid.Hotkeys.Value = userConfigFile ? KeyboardHotkey.GetConfig() : config.Hid.Hotkeys.Value; + // System config.System.Region.Value = (Region)Region; @@ -746,7 +748,7 @@ namespace Ryujinx.Ava.UI.ViewModels } config.System.MatchSystemTime.Value = MatchSystemTime; - config.System.SystemTimeOffset.Value = Convert.ToInt64((CurrentDate.ToUnixTimeSeconds() + CurrentTime.TotalSeconds) - DateTimeOffset.Now.ToUnixTimeSeconds()); + config.System.SystemTimeOffset.Value = config.System.SystemTimeOffset.Value; config.System.EnableFsIntegrityChecks.Value = EnableFsIntegrityChecks; config.System.DramSize.Value = DramSize; config.System.IgnoreMissingServices.Value = IgnoreMissingServices; diff --git a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs index 0a355a0ed..9fb56d03f 100644 --- a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs +++ b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs @@ -49,13 +49,13 @@ namespace Ryujinx.Ava.Utilities.Configuration configurationFileUpdated = true; } - EnableDiscordIntegration.Value = LoadSetting ? cff.EnableDiscordIntegration : EnableDiscordIntegration.Value; - CheckUpdatesOnStart.Value = LoadSetting ? cff.CheckUpdatesOnStart : CheckUpdatesOnStart.Value; - ShowConfirmExit.Value = LoadSetting ? cff.ShowConfirmExit : ShowConfirmExit.Value; - RememberWindowState.Value = LoadSetting ? cff.RememberWindowState : RememberWindowState.Value; - ShowTitleBar.Value = LoadSetting ? cff.ShowTitleBar : ShowTitleBar.Value; - EnableHardwareAcceleration.Value = LoadSetting ? cff.EnableHardwareAcceleration : EnableHardwareAcceleration.Value; - HideCursor.Value = LoadSetting ? cff.HideCursor : HideCursor.Value; + EnableDiscordIntegration.Value = LoadSetting ? cff.EnableDiscordIntegration : EnableDiscordIntegration.Value; // Get from global config only + CheckUpdatesOnStart.Value = LoadSetting ? cff.CheckUpdatesOnStart : CheckUpdatesOnStart.Value; // Get from global config only + ShowConfirmExit.Value = LoadSetting ? cff.ShowConfirmExit : ShowConfirmExit.Value; // Get from global config only + RememberWindowState.Value = LoadSetting ? cff.RememberWindowState : RememberWindowState.Value; // Get from global config only + ShowTitleBar.Value = LoadSetting ? cff.ShowTitleBar : ShowTitleBar.Value; // Get from global config only + EnableHardwareAcceleration.Value = LoadSetting ? cff.EnableHardwareAcceleration : EnableHardwareAcceleration.Value; // Get from global config only + HideCursor.Value = LoadSetting ? cff.HideCursor : HideCursor.Value; // Get from global config only Logger.EnableFileLog.Value = cff.EnableFileLog; Logger.EnableDebug.Value = cff.LoggingEnableDebug; @@ -91,7 +91,7 @@ namespace Ryujinx.Ava.Utilities.Configuration System.Language.Value = cff.SystemLanguage; System.Region.Value = cff.SystemRegion; System.TimeZone.Value = cff.SystemTimeZone; - System.SystemTimeOffset.Value = cff.SystemTimeOffset; + System.SystemTimeOffset.Value = LoadSetting ? cff.SystemTimeOffset : System.SystemTimeOffset.Value; // Get from global config only System.EnableDockedMode.Value = cff.DockedMode; System.EnablePtc.Value = cff.EnablePtc; System.EnableLowPowerPtc.Value = cff.EnableLowPowerPtc; @@ -145,7 +145,7 @@ namespace Ryujinx.Ava.Utilities.Configuration Hid.EnableKeyboard.Value = cff.EnableKeyboard; Hid.EnableMouse.Value = cff.EnableMouse; - Hid.Hotkeys.Value = cff.Hotkeys; + Hid.Hotkeys.Value = LoadSetting ? cff.Hotkeys: Hid.Hotkeys.Value; // Get from global config only Hid.InputConfig.Value = cff.InputConfig ?? []; Hid.RainbowSpeed.Value = cff.RainbowSpeed;