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;
|
||||
|
||||
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
_viewModel.Title = TitleHelper.ActiveApplicationTitle(Device.Processes.ActiveApplication, Program.Version, !ConfigurationState.Instance.ShowTitleBar);
|
||||
|
@ -44,7 +44,6 @@
|
||||
</Grid>
|
||||
<ui:NumberBox Value="1" />
|
||||
<MenuItem
|
||||
IconSource="Settings"
|
||||
Header="123 0000"
|
||||
ToolTip.Tip="What this"/>
|
||||
</StackPanel>
|
||||
|
@ -23,7 +23,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
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)
|
||||
|
@ -37,21 +37,6 @@ namespace Ryujinx.Ava.UI.Controls
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (DataContext is not MainWindowViewModel mwvm)
|
||||
|
@ -7,6 +7,7 @@ using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using DiscordRPC;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
@ -1540,13 +1541,12 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
#if RELEASE
|
||||
await PerformanceCheck();
|
||||
#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);
|
||||
ConfigurationState.Instance.Load(configurationFileFormat, gameDir, application.IdBaseString);
|
||||
// Loads the user configuration, having previously changed the global configuration to the user configuration
|
||||
ConfigurationState.Instance.Load(configurationFileFormat, Program.GetDirGameUserConfig(application.IdBaseString, true, true), application.IdBaseString);
|
||||
}
|
||||
|
||||
Logger.RestartTime();
|
||||
|
@ -4,7 +4,6 @@ using Avalonia.Media.Imaging;
|
||||
using Avalonia.Threading;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Humanizer;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using Ryujinx.Audio.Backends.OpenAL;
|
||||
using Ryujinx.Audio.Backends.SDL2;
|
||||
@ -70,11 +69,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
[ObservableProperty] private string _ldnServer;
|
||||
|
||||
public SettingsHacksViewModel DirtyHacks { get; }
|
||||
public string GamePath { get; }
|
||||
public string GameName { get; }
|
||||
|
||||
private Bitmap _gameIcon;
|
||||
|
||||
private string _gameTitle;
|
||||
private string _gameId;
|
||||
public Bitmap GameIcon
|
||||
@ -375,7 +371,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public bool IsInvalidLdnPassphraseVisible { get; set; }
|
||||
|
||||
public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this()
|
||||
public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this(false)
|
||||
{
|
||||
_virtualFileSystem = virtualFileSystem;
|
||||
_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;
|
||||
_contentManager = contentManager;
|
||||
@ -404,12 +400,15 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
GameTitle = gameName;
|
||||
GameId = gameId;
|
||||
|
||||
if (userDirFind)
|
||||
{
|
||||
string gameDir = Program.GetDirGameUserConfig(gameId, false, true);
|
||||
if (ConfigurationFileFormat.TryLoad(gameDir, out ConfigurationFileFormat configurationFileFormat))
|
||||
{
|
||||
ConfigurationState.Instance.Load(configurationFileFormat, gameDir, gameId);
|
||||
LoadCurrentConfiguration(); // Needed to load custom configuration
|
||||
}
|
||||
}
|
||||
|
||||
if (Program.PreviewerDetached)
|
||||
{
|
||||
@ -419,7 +418,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsViewModel()
|
||||
public SettingsViewModel(bool noLoadGlobalConfig = false)
|
||||
{
|
||||
GameDirectories = [];
|
||||
AutoloadDirectories = [];
|
||||
@ -434,7 +433,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
if (Program.PreviewerDetached)
|
||||
{
|
||||
Task.Run(LoadAvailableGpus);
|
||||
|
||||
if (!noLoadGlobalConfig)
|
||||
{
|
||||
LoadCurrentConfiguration();
|
||||
}
|
||||
|
||||
DirtyHacks = new SettingsHacksViewModel(this);
|
||||
}
|
||||
@ -545,6 +548,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
ConfigurationState config = ConfigurationState.Instance;
|
||||
|
||||
//It is necessary that the data is used from the global configuration file
|
||||
if (string.IsNullOrEmpty(GameId))
|
||||
{
|
||||
// User Interface
|
||||
@ -568,6 +572,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
"Dark" => 2,
|
||||
_ => 0
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Input
|
||||
|
@ -135,7 +135,23 @@ namespace Ryujinx.Ava.UI.Views.Main
|
||||
|
||||
Rainbow.Enable();
|
||||
|
||||
if (ViewModel.SelectedApplication is null)
|
||||
{
|
||||
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.Reset();
|
||||
|
@ -28,7 +28,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
{
|
||||
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);
|
||||
|
||||
@ -38,7 +38,8 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
viewModel.SelectedApplication.Path,
|
||||
viewModel.SelectedApplication.Name,
|
||||
viewModel.SelectedApplication.IdString,
|
||||
viewModel.SelectedApplication.Icon);
|
||||
viewModel.SelectedApplication.Icon,
|
||||
findUserConfigDir);
|
||||
|
||||
ViewModel.CloseWindow += Close;
|
||||
ViewModel.SaveSettingsEvent += SaveSettings;
|
||||
|
Loading…
x
Reference in New Issue
Block a user