fix: UI: Custom setting was reset to global when changed during gameplay. (ryubing/ryujinx!164)

See merge request ryubing/ryujinx!164
This commit is contained in:
Goodfeat 2025-11-19 20:33:35 -06:00 committed by GreemDev
parent e1c829f91d
commit 6126e3dc1e
2 changed files with 27 additions and 23 deletions

View file

@ -196,22 +196,26 @@ namespace Ryujinx.Ava
return gameDir; return gameDir;
} }
public static void ReloadConfig() public static void ReloadConfig(bool isRunGameWithCustomConfig = false)
{ {
string localConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ReleaseInformation.ConfigName); string localConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ReleaseInformation.ConfigName);
string appDataConfigurationPath = Path.Combine(AppDataManager.BaseDirPath, 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) if (ConfigurationPath == null)
{ {
// No configuration, we load the default values and save it to disk // No configuration, we load the default values and save it to disk

View file

@ -88,6 +88,11 @@ namespace Ryujinx.Ava.UI.ViewModels
get; get;
} }
public bool IsCustomConfig
{
get;
}
public bool IsGameTitleNotNull => !string.IsNullOrEmpty(GameTitle); public bool IsGameTitleNotNull => !string.IsNullOrEmpty(GameTitle);
public double PanelOpacity => IsGameTitleNotNull ? 0.5 : 1; public double PanelOpacity => IsGameTitleNotNull ? 0.5 : 1;
@ -459,7 +464,7 @@ namespace Ryujinx.Ava.UI.ViewModels
using MemoryStream ms = new(gameIconData); using MemoryStream ms = new(gameIconData);
GameIcon = new Bitmap(ms); GameIcon = new Bitmap(ms);
} }
IsCustomConfig = customConfig;
IsGameRunning = gameRunning; IsGameRunning = gameRunning;
GamePath = gamePath; GamePath = gamePath;
GameTitle = gameName; GameTitle = gameName;
@ -869,16 +874,11 @@ namespace Ryujinx.Ava.UI.ViewModels
GameListNeedsRefresh = false; GameListNeedsRefresh = false;
} }
private static void RevertIfNotSaved() private static void RevertIfNotSaved(bool isCustomConfig = false, bool isGameRunning = false)
{ {
/* // Restores settings for a custom configuration during a game, if the condition is met.
maybe this is an unnecessary check(all options need to be tested) // If the condition is not met (parameter is false), restores global (default) configuration instead.
if (string.IsNullOrEmpty(Program.GlobalConfigurationPath)) Program.ReloadConfig(isCustomConfig && isGameRunning);
{
Program.ReloadConfig();
}
*/
Program.ReloadConfig();
} }
public void ApplyButton() public void ApplyButton()
@ -895,14 +895,14 @@ namespace Ryujinx.Ava.UI.ViewModels
File.Delete(gameDir); File.Delete(gameDir);
} }
RevertIfNotSaved(); RevertIfNotSaved(IsCustomConfig, IsGameRunning);
CloseWindow?.Invoke(); CloseWindow?.Invoke();
} }
public void SaveUserConfig() public void SaveUserConfig()
{ {
SaveSettings(); SaveSettings();
RevertIfNotSaved(); // Revert global configuration after saving user configuration RevertIfNotSaved(IsCustomConfig, IsGameRunning); // Revert global or custom configuration after saving user configuration
CloseWindow?.Invoke(); CloseWindow?.Invoke();
} }
@ -934,7 +934,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public void CancelButton() public void CancelButton()
{ {
RevertIfNotSaved(); RevertIfNotSaved(IsCustomConfig, IsGameRunning);
CloseWindow?.Invoke(); CloseWindow?.Invoke();
} }
} }