Fixed a ban where a custom setting was mistakenly created when starting the game if it did not exist.
Now when starting the game, if a custom setting was created, the current game will be displayed in the settings window. Code cleanup.
This commit is contained in:
parent
a92475b8fd
commit
5f5c76107c
@ -469,6 +469,8 @@ namespace Ryujinx.Ava
|
|||||||
|
|
||||||
_viewModel.IsGameRunning = true;
|
_viewModel.IsGameRunning = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Dispatcher.UIThread.InvokeAsync(() =>
|
Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
_viewModel.Title = TitleHelper.ActiveApplicationTitle(Device.Processes.ActiveApplication, Program.Version, !ConfigurationState.Instance.ShowTitleBar);
|
_viewModel.Title = TitleHelper.ActiveApplicationTitle(Device.Processes.ActiveApplication, Program.Version, !ConfigurationState.Instance.ShowTitleBar);
|
||||||
@ -582,8 +584,8 @@ namespace Ryujinx.Ava
|
|||||||
Rainbow.Disable();
|
Rainbow.Disable();
|
||||||
Rainbow.Reset();
|
Rainbow.Reset();
|
||||||
|
|
||||||
//Reload settings when the game is turned off
|
// Reload settings when the game is turned off
|
||||||
//(resets custom settings if there were any)
|
// (resets custom settings if there were any)
|
||||||
Program.ReloadConfig();
|
Program.ReloadConfig();
|
||||||
|
|
||||||
_isStopped = true;
|
_isStopped = true;
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
<ui:NumberBox Value="1" />
|
<ui:NumberBox Value="1" />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
IconSource="Settings"
|
|
||||||
Header="123 0000"
|
Header="123 0000"
|
||||||
ToolTip.Tip="What this"/>
|
ToolTip.Tip="What this"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -23,7 +23,6 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava
|
namespace Ryujinx.Ava
|
||||||
{
|
{
|
||||||
@ -157,13 +156,14 @@ namespace Ryujinx.Ava
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ReloadGameConfig(string gamedir)
|
public static bool FindGameConfig(string gameDir)
|
||||||
{
|
{
|
||||||
if (File.Exists(gamedir))
|
if (File.Exists(gameDir))
|
||||||
{
|
{
|
||||||
ConfigurationPath = gamedir;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetDirGameUserConfig(string gameId, bool rememberGlobalDir = false, bool changeFolderForGame = false)
|
public static string GetDirGameUserConfig(string gameId, bool rememberGlobalDir = false, bool changeFolderForGame = false)
|
||||||
|
@ -37,21 +37,6 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleUserControl_Click(object sender, RoutedEventArgs args)
|
|
||||||
{
|
|
||||||
if (sender is not MenuItem { DataContext: MainWindowViewModel { SelectedApplication: not null } viewModel })
|
|
||||||
return;
|
|
||||||
|
|
||||||
viewModel.SelectedApplication.Favorite = !viewModel.SelectedApplication.Favorite;
|
|
||||||
|
|
||||||
ApplicationLibrary.LoadAndSaveMetaData(viewModel.SelectedApplication.IdString, appMetadata =>
|
|
||||||
{
|
|
||||||
appMetadata.Favorite = viewModel.SelectedApplication.Favorite;
|
|
||||||
});
|
|
||||||
|
|
||||||
viewModel.RefreshView();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ToggleFavorite_Click(object sender, RoutedEventArgs args)
|
public void ToggleFavorite_Click(object sender, RoutedEventArgs args)
|
||||||
{
|
{
|
||||||
if (sender is not MenuItem { DataContext: MainWindowViewModel { SelectedApplication: not null } viewModel })
|
if (sender is not MenuItem { DataContext: MainWindowViewModel { SelectedApplication: not null } viewModel })
|
||||||
|
@ -43,19 +43,6 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
await CompatibilityList.Show((string)playabilityLabel.Tag);
|
await CompatibilityList.Show((string)playabilityLabel.Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void EditGameConfiguration_Click(object sender, RoutedEventArgs args)
|
|
||||||
{
|
|
||||||
if (sender is MenuItem { DataContext: MainWindowViewModel { SelectedApplication: not null } viewModel })
|
|
||||||
{
|
|
||||||
await new UserConfigWindows(viewModel).ShowDialog((Window)viewModel.TopLevel);
|
|
||||||
|
|
||||||
//viewModel.SelectedApplication.UserConfig = File.Exists(Program.GetDirGameUserConfig(viewModel.SelectedApplication.IdString));
|
|
||||||
|
|
||||||
viewModel.RefreshView();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void IdString_OnClick(object sender, RoutedEventArgs e)
|
private async void IdString_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (DataContext is not MainWindowViewModel mwvm)
|
if (DataContext is not MainWindowViewModel mwvm)
|
||||||
|
@ -7,6 +7,7 @@ using Avalonia.Media.Imaging;
|
|||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using DiscordRPC;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
@ -1540,13 +1541,12 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
#if RELEASE
|
#if RELEASE
|
||||||
await PerformanceCheck();
|
await PerformanceCheck();
|
||||||
#endif
|
#endif
|
||||||
// If a configuration is found in the "/games/xxxxxxxxxxxxxx" folder, the program will load the user setting.
|
|
||||||
string gameDir = Program.GetDirGameUserConfig(application.IdBaseString, true, true);
|
|
||||||
|
|
||||||
if (ConfigurationFileFormat.TryLoad(gameDir, out ConfigurationFileFormat configurationFileFormat))
|
// If a configuration is found in the "/games/xxxxxxxxxxxxxx" folder, the program will load the user setting.
|
||||||
|
if (ConfigurationFileFormat.TryLoad(Program.GetDirGameUserConfig(application.IdBaseString), out ConfigurationFileFormat configurationFileFormat))
|
||||||
{
|
{
|
||||||
//Program.GetDirGameUserConfig(application.IdBaseString, false);
|
// Loads the user configuration, having previously changed the global configuration to the user configuration
|
||||||
ConfigurationState.Instance.Load(configurationFileFormat, gameDir, application.IdBaseString);
|
ConfigurationState.Instance.Load(configurationFileFormat, Program.GetDirGameUserConfig(application.IdBaseString, true, true), application.IdBaseString);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.RestartTime();
|
Logger.RestartTime();
|
||||||
|
@ -4,7 +4,6 @@ using Avalonia.Media.Imaging;
|
|||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using Humanizer;
|
|
||||||
using LibHac.Tools.FsSystem;
|
using LibHac.Tools.FsSystem;
|
||||||
using Ryujinx.Audio.Backends.OpenAL;
|
using Ryujinx.Audio.Backends.OpenAL;
|
||||||
using Ryujinx.Audio.Backends.SDL2;
|
using Ryujinx.Audio.Backends.SDL2;
|
||||||
@ -70,11 +69,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
[ObservableProperty] private string _ldnServer;
|
[ObservableProperty] private string _ldnServer;
|
||||||
|
|
||||||
public SettingsHacksViewModel DirtyHacks { get; }
|
public SettingsHacksViewModel DirtyHacks { get; }
|
||||||
public string GamePath { get; }
|
|
||||||
public string GameName { get; }
|
|
||||||
|
|
||||||
private Bitmap _gameIcon;
|
private Bitmap _gameIcon;
|
||||||
|
|
||||||
private string _gameTitle;
|
private string _gameTitle;
|
||||||
private string _gameId;
|
private string _gameId;
|
||||||
public Bitmap GameIcon
|
public Bitmap GameIcon
|
||||||
@ -375,7 +371,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
|
|
||||||
public bool IsInvalidLdnPassphraseVisible { get; set; }
|
public bool IsInvalidLdnPassphraseVisible { get; set; }
|
||||||
|
|
||||||
public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this()
|
public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this(false)
|
||||||
{
|
{
|
||||||
_virtualFileSystem = virtualFileSystem;
|
_virtualFileSystem = virtualFileSystem;
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
@ -388,7 +384,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager, string gamePath, string gameName, string gameId, byte[] gameIconData) : this()
|
public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager, string gamePath, string gameName, string gameId, byte[] gameIconData, bool userDirFind) : this(userDirFind)
|
||||||
{
|
{
|
||||||
_virtualFileSystem = virtualFileSystem;
|
_virtualFileSystem = virtualFileSystem;
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
@ -404,12 +400,15 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
GameTitle = gameName;
|
GameTitle = gameName;
|
||||||
GameId = gameId;
|
GameId = gameId;
|
||||||
|
|
||||||
string gameDir = Program.GetDirGameUserConfig(gameId,false,true);
|
if (userDirFind)
|
||||||
|
{
|
||||||
|
string gameDir = Program.GetDirGameUserConfig(gameId, false, true);
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -419,7 +418,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SettingsViewModel()
|
public SettingsViewModel(bool noLoadGlobalConfig = false)
|
||||||
{
|
{
|
||||||
GameDirectories = [];
|
GameDirectories = [];
|
||||||
AutoloadDirectories = [];
|
AutoloadDirectories = [];
|
||||||
@ -434,7 +433,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
if (Program.PreviewerDetached)
|
if (Program.PreviewerDetached)
|
||||||
{
|
{
|
||||||
Task.Run(LoadAvailableGpus);
|
Task.Run(LoadAvailableGpus);
|
||||||
|
|
||||||
|
if (!noLoadGlobalConfig)
|
||||||
|
{
|
||||||
LoadCurrentConfiguration();
|
LoadCurrentConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
DirtyHacks = new SettingsHacksViewModel(this);
|
DirtyHacks = new SettingsHacksViewModel(this);
|
||||||
}
|
}
|
||||||
@ -545,6 +548,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
{
|
{
|
||||||
ConfigurationState config = ConfigurationState.Instance;
|
ConfigurationState config = ConfigurationState.Instance;
|
||||||
|
|
||||||
|
//It is necessary that the data is used from the global configuration file
|
||||||
if (string.IsNullOrEmpty(GameId))
|
if (string.IsNullOrEmpty(GameId))
|
||||||
{
|
{
|
||||||
// User Interface
|
// User Interface
|
||||||
@ -568,6 +572,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
"Dark" => 2,
|
"Dark" => 2,
|
||||||
_ => 0
|
_ => 0
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
|
@ -135,7 +135,23 @@ namespace Ryujinx.Ava.UI.Views.Main
|
|||||||
|
|
||||||
Rainbow.Enable();
|
Rainbow.Enable();
|
||||||
|
|
||||||
|
if (ViewModel.SelectedApplication is null)
|
||||||
|
{
|
||||||
await Window.SettingsWindow.ShowDialog(Window);
|
await Window.SettingsWindow.ShowDialog(Window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool userConfigExist = Program.FindGameConfig(Program.GetDirGameUserConfig(ViewModel.SelectedApplication.IdString, false, false));
|
||||||
|
|
||||||
|
if (!ViewModel.IsGameRunning || !userConfigExist)
|
||||||
|
{
|
||||||
|
await Window.SettingsWindow.ShowDialog(Window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await new UserConfigWindows(ViewModel, userConfigExist).ShowDialog((Window)ViewModel.TopLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rainbow.Disable();
|
Rainbow.Disable();
|
||||||
Rainbow.Reset();
|
Rainbow.Reset();
|
||||||
|
@ -28,7 +28,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
{
|
{
|
||||||
internal readonly SettingsViewModel ViewModel;
|
internal readonly SettingsViewModel ViewModel;
|
||||||
|
|
||||||
public UserConfigWindows(MainWindowViewModel viewModel)
|
public UserConfigWindows(MainWindowViewModel viewModel, bool findUserConfigDir = true)
|
||||||
{
|
{
|
||||||
Title = string.Format(LocaleManager.Instance[LocaleKeys.SettingsWithInfo], viewModel.SelectedApplication.Name, viewModel.SelectedApplication.IdString);
|
Title = string.Format(LocaleManager.Instance[LocaleKeys.SettingsWithInfo], viewModel.SelectedApplication.Name, viewModel.SelectedApplication.IdString);
|
||||||
|
|
||||||
@ -38,7 +38,8 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
viewModel.SelectedApplication.Path,
|
viewModel.SelectedApplication.Path,
|
||||||
viewModel.SelectedApplication.Name,
|
viewModel.SelectedApplication.Name,
|
||||||
viewModel.SelectedApplication.IdString,
|
viewModel.SelectedApplication.IdString,
|
||||||
viewModel.SelectedApplication.Icon);
|
viewModel.SelectedApplication.Icon,
|
||||||
|
findUserConfigDir);
|
||||||
|
|
||||||
ViewModel.CloseWindow += Close;
|
ViewModel.CloseWindow += Close;
|
||||||
ViewModel.SaveSettingsEvent += SaveSettings;
|
ViewModel.SaveSettingsEvent += SaveSettings;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user