Fixed bug crash due to incorrect System.SystemTimeOffset.Value,

hotkeys should now also be read from the global configuration file
This commit is contained in:
Vova 2025-02-08 20:16:38 +10:00
parent 5f5c76107c
commit 11a68a204f
2 changed files with 18 additions and 16 deletions

View File

@ -406,8 +406,9 @@ namespace Ryujinx.Ava.UI.ViewModels
if (ConfigurationFileFormat.TryLoad(gameDir, out ConfigurationFileFormat configurationFileFormat)) if (ConfigurationFileFormat.TryLoad(gameDir, out ConfigurationFileFormat configurationFileFormat))
{ {
ConfigurationState.Instance.Load(configurationFileFormat, gameDir, gameId); ConfigurationState.Instance.Load(configurationFileFormat, gameDir, gameId);
LoadCurrentConfiguration(); // Needed to load custom configuration
} }
LoadCurrentConfiguration(); // Needed to load custom configuration
} }
if (Program.PreviewerDetached) if (Program.PreviewerDetached)
@ -547,6 +548,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public void LoadCurrentConfiguration() public void LoadCurrentConfiguration()
{ {
ConfigurationState config = ConfigurationState.Instance; ConfigurationState config = ConfigurationState.Instance;
bool userconfigIsNull = string.IsNullOrEmpty(GameId);
//It is necessary that the data is used from the global configuration file //It is necessary that the data is used from the global configuration file
if (string.IsNullOrEmpty(GameId)) if (string.IsNullOrEmpty(GameId))
@ -593,7 +595,6 @@ namespace Ryujinx.Ava.UI.ViewModels
DateTime currentDateTime = currentHostDateTime.Add(systemDateTimeOffset); DateTime currentDateTime = currentHostDateTime.Add(systemDateTimeOffset);
CurrentDate = currentDateTime.Date; CurrentDate = currentDateTime.Date;
CurrentTime = currentDateTime.TimeOfDay; CurrentTime = currentDateTime.TimeOfDay;
MatchSystemTime = config.System.MatchSystemTime; MatchSystemTime = config.System.MatchSystemTime;
EnableCustomVSyncInterval = config.Graphics.EnableCustomVSyncInterval; EnableCustomVSyncInterval = config.Graphics.EnableCustomVSyncInterval;
@ -697,9 +698,9 @@ namespace Ryujinx.Ava.UI.ViewModels
public void SaveSettings() public void SaveSettings()
{ {
ConfigurationState config = ConfigurationState.Instance; ConfigurationState config = ConfigurationState.Instance;
bool userConfigFile = string.IsNullOrEmpty(GameId);
if (userConfigFile)
if (string.IsNullOrEmpty(GameId))
{ {
// User Interface // User Interface
config.EnableDiscordIntegration.Value = EnableDiscordIntegration; config.EnableDiscordIntegration.Value = EnableDiscordIntegration;
@ -734,7 +735,8 @@ namespace Ryujinx.Ava.UI.ViewModels
config.Hid.EnableMouse.Value = EnableMouse; config.Hid.EnableMouse.Value = EnableMouse;
// Keyboard Hotkeys // Keyboard Hotkeys
config.Hid.Hotkeys.Value = KeyboardHotkey.GetConfig(); config.Hid.Hotkeys.Value = userConfigFile ? KeyboardHotkey.GetConfig() : config.Hid.Hotkeys.Value;
// System // System
config.System.Region.Value = (Region)Region; config.System.Region.Value = (Region)Region;
@ -746,7 +748,7 @@ namespace Ryujinx.Ava.UI.ViewModels
} }
config.System.MatchSystemTime.Value = MatchSystemTime; 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.EnableFsIntegrityChecks.Value = EnableFsIntegrityChecks;
config.System.DramSize.Value = DramSize; config.System.DramSize.Value = DramSize;
config.System.IgnoreMissingServices.Value = IgnoreMissingServices; config.System.IgnoreMissingServices.Value = IgnoreMissingServices;

View File

@ -49,13 +49,13 @@ namespace Ryujinx.Ava.Utilities.Configuration
configurationFileUpdated = true; configurationFileUpdated = true;
} }
EnableDiscordIntegration.Value = LoadSetting ? cff.EnableDiscordIntegration : EnableDiscordIntegration.Value; EnableDiscordIntegration.Value = LoadSetting ? cff.EnableDiscordIntegration : EnableDiscordIntegration.Value; // Get from global config only
CheckUpdatesOnStart.Value = LoadSetting ? cff.CheckUpdatesOnStart : CheckUpdatesOnStart.Value; CheckUpdatesOnStart.Value = LoadSetting ? cff.CheckUpdatesOnStart : CheckUpdatesOnStart.Value; // Get from global config only
ShowConfirmExit.Value = LoadSetting ? cff.ShowConfirmExit : ShowConfirmExit.Value; ShowConfirmExit.Value = LoadSetting ? cff.ShowConfirmExit : ShowConfirmExit.Value; // Get from global config only
RememberWindowState.Value = LoadSetting ? cff.RememberWindowState : RememberWindowState.Value; RememberWindowState.Value = LoadSetting ? cff.RememberWindowState : RememberWindowState.Value; // Get from global config only
ShowTitleBar.Value = LoadSetting ? cff.ShowTitleBar : ShowTitleBar.Value; ShowTitleBar.Value = LoadSetting ? cff.ShowTitleBar : ShowTitleBar.Value; // Get from global config only
EnableHardwareAcceleration.Value = LoadSetting ? cff.EnableHardwareAcceleration : EnableHardwareAcceleration.Value; EnableHardwareAcceleration.Value = LoadSetting ? cff.EnableHardwareAcceleration : EnableHardwareAcceleration.Value; // Get from global config only
HideCursor.Value = LoadSetting ? cff.HideCursor : HideCursor.Value; HideCursor.Value = LoadSetting ? cff.HideCursor : HideCursor.Value; // Get from global config only
Logger.EnableFileLog.Value = cff.EnableFileLog; Logger.EnableFileLog.Value = cff.EnableFileLog;
Logger.EnableDebug.Value = cff.LoggingEnableDebug; Logger.EnableDebug.Value = cff.LoggingEnableDebug;
@ -91,7 +91,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
System.Language.Value = cff.SystemLanguage; System.Language.Value = cff.SystemLanguage;
System.Region.Value = cff.SystemRegion; System.Region.Value = cff.SystemRegion;
System.TimeZone.Value = cff.SystemTimeZone; 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.EnableDockedMode.Value = cff.DockedMode;
System.EnablePtc.Value = cff.EnablePtc; System.EnablePtc.Value = cff.EnablePtc;
System.EnableLowPowerPtc.Value = cff.EnableLowPowerPtc; System.EnableLowPowerPtc.Value = cff.EnableLowPowerPtc;
@ -145,7 +145,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
Hid.EnableKeyboard.Value = cff.EnableKeyboard; Hid.EnableKeyboard.Value = cff.EnableKeyboard;
Hid.EnableMouse.Value = cff.EnableMouse; 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.InputConfig.Value = cff.InputConfig ?? [];
Hid.RainbowSpeed.Value = cff.RainbowSpeed; Hid.RainbowSpeed.Value = cff.RainbowSpeed;