Added autorestart of the emulator if it is necessary to change the graphic multi-thread.

Code cleaning
This commit is contained in:
Vova
2025-02-11 14:06:31 +10:00
parent 0399af0ff9
commit 1ca5407c22
7 changed files with 192 additions and 11 deletions

View File

@@ -1523,10 +1523,16 @@ namespace Ryujinx.Ava.UI.ViewModels
}
}
public void InitializeUserConfig(ApplicationData application)
public bool InitializeUserConfig(ApplicationData application)
{
// Code where conditions will be met before loading the user configuration
// Code where conditions will be met before loading the user configuration (Global Config)
BackendThreading backendThreadingValue = ConfigurationState.Instance.Graphics.BackendThreading.Value;
string BackendThreadingInit = Program.BackendThreadingArg;
if (BackendThreadingInit is null)
{
BackendThreadingInit = ConfigurationState.Instance.Graphics.BackendThreading.Value.ToString();
}
// If a configuration is found in the "/games/xxxxxxxxxxxxxx" folder, the program will load the user setting.
string idGame = application.IdBaseString;
@@ -1537,19 +1543,29 @@ namespace Ryujinx.Ava.UI.ViewModels
}
// Code where conditions will be executed after loading user configuration
if (ConfigurationState.Instance.Graphics.BackendThreading != backendThreadingValue)
if (ConfigurationState.Instance.Graphics.BackendThreading.Value.ToString() != BackendThreadingInit)
{
/*
* The function to restart the emulator together with the selected game
Task.Run(async () => await Rebooter.RebootAppWithGame(application.Path));
*/
List<string> Arguments = new List<string>
{
"--bt", ConfigurationState.Instance.Graphics.BackendThreading.Value.ToString() // BackendThreading
};
Rebooter.RebootAppWithGame(application.Path, Arguments);
return true;
}
return false;
}
public async Task LoadApplication(ApplicationData application, bool startFullscreen = false, BlitStruct<ApplicationControlProperty>? customNacpData = null)
{
InitializeUserConfig(application);
if (InitializeUserConfig(application))
{
return;
}
if (AppHost != null)
{

View File

@@ -71,13 +71,14 @@ namespace Ryujinx.Ava.UI.ViewModels
public SettingsHacksViewModel DirtyHacks { get; }
private readonly bool _isGameRunning;
private Bitmap _gameIcon;
private string _gameTitle;
private string _gamePath;
private string _gameId;
private readonly bool _isGameRunning;
public bool IsGameRunning => _isGameRunning;
public Bitmap GameIcon => _gameIcon;
public string GamePath => _gamePath;
public string GameTitle => _gameTitle;
public string GameId => _gameId;
@@ -377,7 +378,8 @@ namespace Ryujinx.Ava.UI.ViewModels
}
_isGameRunning = gameRunning;
_gameTitle = gameName;
_gamePath = gamePath;
_gameTitle = gameName;
_gameId = gameId;
if (enableToLoadCustomConfig) // During the game. If there is no user config, then load the global config window