diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index abab3daca..4904b8464 100644 --- a/src/Ryujinx/Program.cs +++ b/src/Ryujinx/Program.cs @@ -196,22 +196,26 @@ namespace Ryujinx.Ava return gameDir; } - public static void ReloadConfig() + public static void ReloadConfig(bool isRunGameWithCustomConfig = false) { string localConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ReleaseInformation.ConfigName); string appDataConfigurationPath = Path.Combine(AppDataManager.BaseDirPath, ReleaseInformation.ConfigName); - // Now load the configuration as the other subsystems are now registered - if (File.Exists(localConfigurationPath)) - { - ConfigurationPath = localConfigurationPath; - } - else if (File.Exists(appDataConfigurationPath)) - { - ConfigurationPath = appDataConfigurationPath; - } + if (!isRunGameWithCustomConfig) // To return settings from the game folder if the user configuration exists + { + // Now load the configuration as the other subsystems are now registered + if (File.Exists(localConfigurationPath)) + { + ConfigurationPath = localConfigurationPath; + } + else if (File.Exists(appDataConfigurationPath)) + { + ConfigurationPath = appDataConfigurationPath; + } + } + if (ConfigurationPath == null) { // No configuration, we load the default values and save it to disk diff --git a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs index 233c30bad..d5d9b8218 100644 --- a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs @@ -88,6 +88,11 @@ namespace Ryujinx.Ava.UI.ViewModels get; } + public bool IsCustomConfig + { + get; + } + public bool IsGameTitleNotNull => !string.IsNullOrEmpty(GameTitle); public double PanelOpacity => IsGameTitleNotNull ? 0.5 : 1; @@ -459,7 +464,7 @@ namespace Ryujinx.Ava.UI.ViewModels using MemoryStream ms = new(gameIconData); GameIcon = new Bitmap(ms); } - + IsCustomConfig = customConfig; IsGameRunning = gameRunning; GamePath = gamePath; GameTitle = gameName; @@ -869,16 +874,11 @@ namespace Ryujinx.Ava.UI.ViewModels GameListNeedsRefresh = false; } - private static void RevertIfNotSaved() + private static void RevertIfNotSaved(bool isCustomConfig = false, bool isGameRunning = false) { - /* - maybe this is an unnecessary check(all options need to be tested) - if (string.IsNullOrEmpty(Program.GlobalConfigurationPath)) - { - Program.ReloadConfig(); - } - */ - Program.ReloadConfig(); + // Restores settings for a custom configuration during a game, if the condition is met. + // If the condition is not met (parameter is false), restores global (default) configuration instead. + Program.ReloadConfig(isCustomConfig && isGameRunning); } public void ApplyButton() @@ -895,14 +895,14 @@ namespace Ryujinx.Ava.UI.ViewModels File.Delete(gameDir); } - RevertIfNotSaved(); + RevertIfNotSaved(IsCustomConfig, IsGameRunning); CloseWindow?.Invoke(); } public void SaveUserConfig() { SaveSettings(); - RevertIfNotSaved(); // Revert global configuration after saving user configuration + RevertIfNotSaved(IsCustomConfig, IsGameRunning); // Revert global or custom configuration after saving user configuration CloseWindow?.Invoke(); } @@ -934,7 +934,7 @@ namespace Ryujinx.Ava.UI.ViewModels public void CancelButton() { - RevertIfNotSaved(); + RevertIfNotSaved(IsCustomConfig, IsGameRunning); CloseWindow?.Invoke(); } }