From 7d9a5feccbedc32dfeec00478c3a67ffff26dc60 Mon Sep 17 00:00:00 2001 From: Emmanuel Hansen Date: Mon, 11 Jul 2022 22:25:33 +0000 Subject: [PATCH] Avalonia - Couple fixes and improvements (#3451) * fix updater check crash * remove line * reduce cheat window sizes * enable tiered compilation and r2r * remove warning on LaunchState * remove warnings related to tasks * addressed review * undo csproj indentation * fix tabs in axaml file * remove double line * remove R2R --- Ryujinx.Ava/Common/ApplicationHelper.cs | 30 +++++++---- Ryujinx.Ava/Modules/Updater/Updater.cs | 42 +++++++++++---- Ryujinx.Ava/Ryujinx.Ava.csproj | 2 - Ryujinx.Ava/Ui/Applet/AvaHostUiHandler.cs | 6 +-- .../Ui/Controls/ContentDialogHelper.cs | 8 +-- .../ViewModels/ControllerSettingsViewModel.cs | 10 ++-- .../Ui/ViewModels/MainWindowViewModel.cs | 53 +++++++++++-------- .../Ui/ViewModels/UserProfileViewModel.cs | 9 +++- Ryujinx.Ava/Ui/Windows/CheatWindow.axaml | 14 +++-- .../Ui/Windows/DlcManagerWindow.axaml.cs | 13 +++-- Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs | 13 +++-- .../Ui/Windows/TitleUpdateWindow.axaml.cs | 15 ++++-- .../Ryujinx.Headless.SDL2.csproj | 4 +- Ryujinx/Ryujinx.csproj | 2 - 14 files changed, 141 insertions(+), 80 deletions(-) diff --git a/Ryujinx.Ava/Common/ApplicationHelper.cs b/Ryujinx.Ava/Common/ApplicationHelper.cs index 7d28e7e25..d83ca2c11 100644 --- a/Ryujinx.Ava/Common/ApplicationHelper.cs +++ b/Ryujinx.Ava/Common/ApplicationHelper.cs @@ -23,6 +23,7 @@ using System; using System.Buffers; using System.IO; using System.Threading; +using System.Threading.Tasks; using static LibHac.Fs.ApplicationSaveDataManagement; using Path = System.IO.Path; @@ -77,8 +78,12 @@ namespace Ryujinx.Ava.Common if (result.IsFailure()) { - ContentDialogHelper.CreateErrorDialog(_owner, - string.Format(LocaleManager.Instance["DialogMessageCreateSaveErrorMessage"], result.ToStringWithName())); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateErrorDialog( + _owner, + string.Format(LocaleManager.Instance["DialogMessageCreateSaveErrorMessage"], result.ToStringWithName())); + }); return false; } @@ -94,8 +99,11 @@ namespace Ryujinx.Ava.Common return true; } - ContentDialogHelper.CreateErrorDialog(_owner, - string.Format(LocaleManager.Instance["DialogMessageFindSaveErrorMessage"], result.ToStringWithName())); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateErrorDialog(_owner, + string.Format(LocaleManager.Instance["DialogMessageFindSaveErrorMessage"], result.ToStringWithName())); + }); return false; } @@ -137,7 +145,7 @@ namespace Ryujinx.Ava.Common } } - public static async void ExtractSection(NcaSectionType ncaSectionType, string titleFilePath, + public static async Task ExtractSection(NcaSectionType ncaSectionType, string titleFilePath, int programIndex = 0) { OpenFolderDialog folderDialog = new() { Title = LocaleManager.Instance["FolderDialogExtractTitle"] }; @@ -222,9 +230,9 @@ namespace Ryujinx.Ava.Common { Logger.Error?.Print(LogClass.Application, "Extraction failure. The main NCA was not present in the selected file"); - Dispatcher.UIThread.InvokeAsync(() => + Dispatcher.UIThread.InvokeAsync(async () => { - ContentDialogHelper.CreateErrorDialog(_owner, LocaleManager.Instance["DialogNcaExtractionMainNcaNotFoundErrorMessage"]); + await ContentDialogHelper.CreateErrorDialog(_owner, LocaleManager.Instance["DialogNcaExtractionMainNcaNotFoundErrorMessage"]); }); return; } @@ -263,9 +271,9 @@ namespace Ryujinx.Ava.Common { Logger.Error?.Print(LogClass.Application, $"LibHac returned error code: {resultCode.Value.ErrorCode}"); - Dispatcher.UIThread.InvokeAsync(() => + Dispatcher.UIThread.InvokeAsync(async () => { - ContentDialogHelper.CreateErrorDialog(_owner, LocaleManager.Instance["DialogNcaExtractionCheckLogErrorMessage"]); + await ContentDialogHelper.CreateErrorDialog(_owner, LocaleManager.Instance["DialogNcaExtractionCheckLogErrorMessage"]); }); } else if (resultCode.Value.IsSuccess()) @@ -288,9 +296,9 @@ namespace Ryujinx.Ava.Common } catch (ArgumentException ex) { - Dispatcher.UIThread.InvokeAsync(() => + Dispatcher.UIThread.InvokeAsync(async () => { - ContentDialogHelper.CreateErrorDialog(_owner, ex.Message); + await ContentDialogHelper.CreateErrorDialog(_owner, ex.Message); }); } } diff --git a/Ryujinx.Ava/Modules/Updater/Updater.cs b/Ryujinx.Ava/Modules/Updater/Updater.cs index 708c2a08e..362435c87 100644 --- a/Ryujinx.Ava/Modules/Updater/Updater.cs +++ b/Ryujinx.Ava/Modules/Updater/Updater.cs @@ -73,8 +73,11 @@ namespace Ryujinx.Modules } catch { - ContentDialogHelper.CreateWarningDialog(mainWindow, LocaleManager.Instance["DialogUpdaterConvertFailedMessage"], LocaleManager.Instance["DialogUpdaterCancelUpdateMessage"]); Logger.Error?.Print(LogClass.Application, "Failed to convert the current Ryujinx version!"); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateWarningDialog(mainWindow, LocaleManager.Instance["DialogUpdaterConvertFailedMessage"], LocaleManager.Instance["DialogUpdaterCancelUpdateMessage"]); + }); return; } @@ -106,7 +109,10 @@ namespace Ryujinx.Modules { if (showVersionUpToDate) { - ContentDialogHelper.CreateUpdaterInfoDialog(mainWindow, LocaleManager.Instance["DialogUpdaterAlreadyOnLatestVersionMessage"], ""); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateUpdaterInfoDialog(mainWindow, LocaleManager.Instance["DialogUpdaterAlreadyOnLatestVersionMessage"], ""); + }); } return; @@ -121,7 +127,10 @@ namespace Ryujinx.Modules { if (showVersionUpToDate) { - ContentDialogHelper.CreateUpdaterInfoDialog(mainWindow, LocaleManager.Instance["DialogUpdaterAlreadyOnLatestVersionMessage"], ""); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateUpdaterInfoDialog(mainWindow, LocaleManager.Instance["DialogUpdaterAlreadyOnLatestVersionMessage"], ""); + }); } return; @@ -131,7 +140,10 @@ namespace Ryujinx.Modules catch (Exception exception) { Logger.Error?.Print(LogClass.Application, exception.Message); - ContentDialogHelper.CreateErrorDialog(mainWindow, LocaleManager.Instance["DialogUpdaterFailedToGetVersionMessage"]); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateErrorDialog(mainWindow, LocaleManager.Instance["DialogUpdaterFailedToGetVersionMessage"]); + }); return; } @@ -142,8 +154,11 @@ namespace Ryujinx.Modules } catch { - ContentDialogHelper.CreateWarningDialog(mainWindow, LocaleManager.Instance["DialogUpdaterConvertFailedGithubMessage"], LocaleManager.Instance["DialogUpdaterCancelUpdateMessage"]); Logger.Error?.Print(LogClass.Application, "Failed to convert the received Ryujinx version from Github!"); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateWarningDialog(mainWindow, LocaleManager.Instance["DialogUpdaterConvertFailedGithubMessage"], LocaleManager.Instance["DialogUpdaterCancelUpdateMessage"]); + }); return; } @@ -152,7 +167,10 @@ namespace Ryujinx.Modules { if (showVersionUpToDate) { - ContentDialogHelper.CreateUpdaterInfoDialog(mainWindow, LocaleManager.Instance["DialogUpdaterAlreadyOnLatestVersionMessage"], ""); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateUpdaterInfoDialog(mainWindow, LocaleManager.Instance["DialogUpdaterAlreadyOnLatestVersionMessage"], ""); + }); } Running = false; @@ -180,10 +198,12 @@ namespace Ryujinx.Modules _buildSize = -1; } } - - // Show a message asking the user if they want to update - UpdaterWindow updateDialog = new(mainWindow, newVersion, _buildUrl); - await updateDialog.ShowDialog(mainWindow); + Dispatcher.UIThread.Post(async () => + { + // Show a message asking the user if they want to update + UpdaterWindow updateDialog = new(mainWindow, newVersion, _buildUrl); + await updateDialog.ShowDialog(mainWindow); + }); } private static HttpClient ConstructHttpClient() @@ -522,6 +542,7 @@ namespace Ryujinx.Modules updateDialog.ButtonBox.IsVisible = true; } +#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed public static bool CanUpdate(bool showWarnings, StyleableWindow parent) { #if !DISABLE_UPDATER @@ -577,6 +598,7 @@ namespace Ryujinx.Modules return false; #endif } +#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed // NOTE: This method should always reflect the latest build layout.s private static IEnumerable EnumerateFilesToDelete() diff --git a/Ryujinx.Ava/Ryujinx.Ava.csproj b/Ryujinx.Ava/Ryujinx.Ava.csproj index 7474b85b8..19b66029e 100644 --- a/Ryujinx.Ava/Ryujinx.Ava.csproj +++ b/Ryujinx.Ava/Ryujinx.Ava.csproj @@ -5,8 +5,6 @@ Exe true 1.0.0-dirty - false - false $(DefineConstants);$(ExtraDefineConstants) Ryujinx.Ava Ryujinx.ico diff --git a/Ryujinx.Ava/Ui/Applet/AvaHostUiHandler.cs b/Ryujinx.Ava/Ui/Applet/AvaHostUiHandler.cs index e9a0bd51b..f129cd710 100644 --- a/Ryujinx.Ava/Ui/Applet/AvaHostUiHandler.cs +++ b/Ryujinx.Ava/Ui/Applet/AvaHostUiHandler.cs @@ -92,7 +92,7 @@ namespace Ryujinx.Ava.Ui.Applet } catch (Exception ex) { - ContentDialogHelper.CreateErrorDialog(_parent, string.Format(LocaleManager.Instance["DialogMessageDialogErrorExceptionMessage"], ex)); + await ContentDialogHelper.CreateErrorDialog(_parent, string.Format(LocaleManager.Instance["DialogMessageDialogErrorExceptionMessage"], ex)); dialogCloseEvent.Set(); } @@ -126,7 +126,7 @@ namespace Ryujinx.Ava.Ui.Applet catch (Exception ex) { error = true; - ContentDialogHelper.CreateErrorDialog(_parent, string.Format(LocaleManager.Instance["DialogSoftwareKeyboardErrorExceptionMessage"], ex)); + await ContentDialogHelper.CreateErrorDialog(_parent, string.Format(LocaleManager.Instance["DialogSoftwareKeyboardErrorExceptionMessage"], ex)); } finally { @@ -181,7 +181,7 @@ namespace Ryujinx.Ava.Ui.Applet catch (Exception ex) { dialogCloseEvent.Set(); - ContentDialogHelper.CreateErrorDialog(_parent, string.Format(LocaleManager.Instance["DialogErrorAppletErrorExceptionMessage"], ex)); + await ContentDialogHelper.CreateErrorDialog(_parent, string.Format(LocaleManager.Instance["DialogErrorAppletErrorExceptionMessage"], ex)); } }); diff --git a/Ryujinx.Ava/Ui/Controls/ContentDialogHelper.cs b/Ryujinx.Ava/Ui/Controls/ContentDialogHelper.cs index 8dd1afafa..cdc5de93e 100644 --- a/Ryujinx.Ava/Ui/Controls/ContentDialogHelper.cs +++ b/Ryujinx.Ava/Ui/Controls/ContentDialogHelper.cs @@ -235,7 +235,7 @@ namespace Ryujinx.Ava.Ui.Controls return new(mainText, secondaryText); } - internal static async void CreateUpdaterInfoDialog(StyleableWindow window, string primary, string secondaryText) + internal static async Task CreateUpdaterInfoDialog(StyleableWindow window, string primary, string secondaryText) { await ShowContentDialog( window, @@ -248,7 +248,7 @@ namespace Ryujinx.Ava.Ui.Controls (int)Symbol.Important); } - internal static async void ShowNotAvailableMessage(StyleableWindow window) + internal static async Task ShowNotAvailableMessage(StyleableWindow window) { // Temporary placeholder for features to be added await ShowContentDialog( @@ -262,7 +262,7 @@ namespace Ryujinx.Ava.Ui.Controls (int)Symbol.Important); } - internal static async void CreateWarningDialog(StyleableWindow window, string primary, string secondaryText) + internal static async Task CreateWarningDialog(StyleableWindow window, string primary, string secondaryText) { await ShowContentDialog( window, @@ -275,7 +275,7 @@ namespace Ryujinx.Ava.Ui.Controls (int)Symbol.Important); } - internal static async void CreateErrorDialog(StyleableWindow owner, string errorMessage, string secondaryErrorMessage = "") + internal static async Task CreateErrorDialog(StyleableWindow owner, string errorMessage, string secondaryErrorMessage = "") { Logger.Error?.Print(LogClass.Application, errorMessage); diff --git a/Ryujinx.Ava/Ui/ViewModels/ControllerSettingsViewModel.cs b/Ryujinx.Ava/Ui/ViewModels/ControllerSettingsViewModel.cs index 8811a3c5c..c570aa8da 100644 --- a/Ryujinx.Ava/Ui/ViewModels/ControllerSettingsViewModel.cs +++ b/Ryujinx.Ava/Ui/ViewModels/ControllerSettingsViewModel.cs @@ -658,7 +658,7 @@ namespace Ryujinx.Ava.Ui.ViewModels return config; } - public void LoadProfile() + public async void LoadProfile() { if (Device == 0) { @@ -700,9 +700,9 @@ namespace Ryujinx.Ava.Ui.ViewModels catch (JsonException) { } catch (InvalidOperationException) { - ContentDialogHelper.CreateErrorDialog(_owner.GetVisualRoot() as StyleableWindow, - String.Format(LocaleManager.Instance["DialogProfileInvalidProfileErrorMessage"], ProfileName)); Logger.Error?.Print(LogClass.Configuration, $"Profile {ProfileName} is incompatible with the current input configuration system."); + await ContentDialogHelper.CreateErrorDialog(_owner.GetVisualRoot() as StyleableWindow, + String.Format(LocaleManager.Instance["DialogProfileInvalidProfileErrorMessage"], ProfileName)); return; } @@ -736,7 +736,7 @@ namespace Ryujinx.Ava.Ui.ViewModels if (ProfileName == LocaleManager.Instance["ControllerSettingsProfileDefault"]) { - ContentDialogHelper.CreateErrorDialog(_owner.GetVisualRoot() as StyleableWindow, LocaleManager.Instance["DialogProfileDefaultProfileOverwriteErrorMessage"]); + await ContentDialogHelper.CreateErrorDialog(_owner.GetVisualRoot() as StyleableWindow, LocaleManager.Instance["DialogProfileDefaultProfileOverwriteErrorMessage"]); return; } @@ -769,7 +769,7 @@ namespace Ryujinx.Ava.Ui.ViewModels } else { - ContentDialogHelper.CreateErrorDialog(_owner.GetVisualRoot() as StyleableWindow, LocaleManager.Instance["DialogProfileInvalidProfileNameErrorMessage"]); + await ContentDialogHelper.CreateErrorDialog(_owner.GetVisualRoot() as StyleableWindow, LocaleManager.Instance["DialogProfileInvalidProfileNameErrorMessage"]); } } } diff --git a/Ryujinx.Ava/Ui/ViewModels/MainWindowViewModel.cs b/Ryujinx.Ava/Ui/ViewModels/MainWindowViewModel.cs index bc8e64508..a9bb38ee6 100644 --- a/Ryujinx.Ava/Ui/ViewModels/MainWindowViewModel.cs +++ b/Ryujinx.Ava/Ui/ViewModels/MainWindowViewModel.cs @@ -1047,8 +1047,11 @@ namespace Ryujinx.Ava.Ui.ViewModels if (!ulong.TryParse(selection.TitleId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong titleIdNumber)) { - ContentDialogHelper.CreateErrorDialog(_owner, - LocaleManager.Instance["DialogRyujinxErrorMessage"], LocaleManager.Instance["DialogInvalidTitleIdErrorMessage"]); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateErrorDialog(_owner, + LocaleManager.Instance["DialogRyujinxErrorMessage"], LocaleManager.Instance["DialogInvalidTitleIdErrorMessage"]); + }); return; } @@ -1155,7 +1158,7 @@ namespace Ryujinx.Ava.Ui.ViewModels } catch (Exception e) { - ContentDialogHelper.CreateErrorDialog(_owner, string.Format(LocaleManager.Instance["DialogPPTCDeletionErrorMessage"], file.Name, e)); + await ContentDialogHelper.CreateErrorDialog(_owner, string.Format(LocaleManager.Instance["DialogPPTCDeletionErrorMessage"], file.Name, e)); } } } @@ -1216,7 +1219,7 @@ namespace Ryujinx.Ava.Ui.ViewModels } catch (Exception e) { - ContentDialogHelper.CreateErrorDialog(_owner, string.Format(LocaleManager.Instance["DialogPPTCDeletionErrorMessage"], directory.Name, e)); + await ContentDialogHelper.CreateErrorDialog(_owner, string.Format(LocaleManager.Instance["DialogPPTCDeletionErrorMessage"], directory.Name, e)); } } } @@ -1229,7 +1232,7 @@ namespace Ryujinx.Ava.Ui.ViewModels } catch (Exception e) { - ContentDialogHelper.CreateErrorDialog(_owner, string.Format(LocaleManager.Instance["ShaderCachePurgeError"], file.Name, e)); + await ContentDialogHelper.CreateErrorDialog(_owner, string.Format(LocaleManager.Instance["ShaderCachePurgeError"], file.Name, e)); } } } @@ -1310,8 +1313,11 @@ namespace Ryujinx.Ava.Ui.ViewModels if (!ulong.TryParse(selection.TitleId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong titleIdNumber)) { - ContentDialogHelper.CreateErrorDialog(_owner, - LocaleManager.Instance["DialogRyujinxErrorMessage"], LocaleManager.Instance["DialogInvalidTitleIdErrorMessage"]); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateErrorDialog(_owner, + LocaleManager.Instance["DialogRyujinxErrorMessage"], LocaleManager.Instance["DialogInvalidTitleIdErrorMessage"]); + }); return; } @@ -1333,8 +1339,11 @@ namespace Ryujinx.Ava.Ui.ViewModels if (!ulong.TryParse(selection.TitleId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong titleIdNumber)) { - ContentDialogHelper.CreateErrorDialog(_owner, - LocaleManager.Instance["DialogRyujinxErrorMessage"], LocaleManager.Instance["DialogInvalidTitleIdErrorMessage"]); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateErrorDialog(_owner, + LocaleManager.Instance["DialogRyujinxErrorMessage"], LocaleManager.Instance["DialogInvalidTitleIdErrorMessage"]); + }); return; } @@ -1350,30 +1359,30 @@ namespace Ryujinx.Ava.Ui.ViewModels ApplicationHelper.OpenSaveDir(in filter, titleId, data.ControlHolder, data.TitleName); } - private void ExtractLogo() + private async void ExtractLogo() { var selection = SelectedApplication; if (selection != null) { - ApplicationHelper.ExtractSection(NcaSectionType.Logo, selection.Path); + await ApplicationHelper.ExtractSection(NcaSectionType.Logo, selection.Path); } } - private void ExtractRomFs() + private async void ExtractRomFs() { var selection = SelectedApplication; if (selection != null) { - ApplicationHelper.ExtractSection(NcaSectionType.Data, selection.Path); + await ApplicationHelper.ExtractSection(NcaSectionType.Data, selection.Path); } } - private void ExtractExeFs() + private async void ExtractExeFs() { var selection = SelectedApplication; if (selection != null) { - ApplicationHelper.ExtractSection(NcaSectionType.Code, selection.Path); + await ApplicationHelper.ExtractSection(NcaSectionType.Code, selection.Path); } } @@ -1382,7 +1391,7 @@ namespace Ryujinx.Ava.Ui.ViewModels _owner.Close(); } - private async void HandleFirmwareInstallation(string path) + private async Task HandleFirmwareInstallation(string path) { try { @@ -1392,7 +1401,7 @@ namespace Ryujinx.Ava.Ui.ViewModels if (firmwareVersion == null) { - ContentDialogHelper.CreateErrorDialog(_owner, string.Format(LocaleManager.Instance["DialogFirmwareInstallerFirmwareNotFoundErrorMessage"], filename)); + await ContentDialogHelper.CreateErrorDialog(_owner, string.Format(LocaleManager.Instance["DialogFirmwareInstallerFirmwareNotFoundErrorMessage"], filename)); return; } @@ -1457,11 +1466,11 @@ namespace Ryujinx.Ava.Ui.ViewModels } catch (Exception ex) { - Dispatcher.UIThread.InvokeAsync(() => + Dispatcher.UIThread.InvokeAsync(async () => { waitingDialog.Close(); - ContentDialogHelper.CreateErrorDialog(_owner, ex.Message); + await ContentDialogHelper.CreateErrorDialog(_owner, ex.Message); }); } finally @@ -1482,7 +1491,7 @@ namespace Ryujinx.Ava.Ui.ViewModels } catch (Exception ex) { - ContentDialogHelper.CreateErrorDialog(_owner, ex.Message); + await ContentDialogHelper.CreateErrorDialog(_owner, ex.Message); } } @@ -1497,7 +1506,7 @@ namespace Ryujinx.Ava.Ui.ViewModels if (file != null && file.Length > 0) { - HandleFirmwareInstallation(file[0]); + await HandleFirmwareInstallation(file[0]); } } @@ -1509,7 +1518,7 @@ namespace Ryujinx.Ava.Ui.ViewModels if (!string.IsNullOrWhiteSpace(folder)) { - HandleFirmwareInstallation(folder); + await HandleFirmwareInstallation(folder); } } } diff --git a/Ryujinx.Ava/Ui/ViewModels/UserProfileViewModel.cs b/Ryujinx.Ava/Ui/ViewModels/UserProfileViewModel.cs index d75f65b1f..66fa7e34d 100644 --- a/Ryujinx.Ava/Ui/ViewModels/UserProfileViewModel.cs +++ b/Ryujinx.Ava/Ui/ViewModels/UserProfileViewModel.cs @@ -1,3 +1,4 @@ +using Avalonia.Threading; using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.Ui.Controls; using Ryujinx.Ava.Ui.Windows; @@ -141,8 +142,12 @@ namespace Ryujinx.Ava.Ui.ViewModels if (profile == null) { - ContentDialogHelper.CreateErrorDialog(_owner, - LocaleManager.Instance["DialogUserProfileDeletionWarningMessage"]); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateErrorDialog(_owner, + LocaleManager.Instance["DialogUserProfileDeletionWarningMessage"]); + }); + return; } diff --git a/Ryujinx.Ava/Ui/Windows/CheatWindow.axaml b/Ryujinx.Ava/Ui/Windows/CheatWindow.axaml index 1685ee807..a5a4b0eeb 100644 --- a/Ryujinx.Ava/Ui/Windows/CheatWindow.axaml +++ b/Ryujinx.Ava/Ui/Windows/CheatWindow.axaml @@ -7,7 +7,6 @@ xmlns:model="clr-namespace:Ryujinx.Ava.Ui.Models" xmlns:window="clr-namespace:Ryujinx.Ava.Ui.Windows" mc:Ignorable="d" - SizeToContent="Height" Width="500" MinHeight="500" Height="500" WindowStartupLocation="CenterOwner" MinWidth="500"> @@ -45,6 +44,13 @@ VerticalAlignment="Stretch" Name="CheatsView" MinHeight="300"> + + + + + @@ -56,9 +62,9 @@ - - - + + + diff --git a/Ryujinx.Ava/Ui/Windows/DlcManagerWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/DlcManagerWindow.axaml.cs index cb2ed3240..7450c64fc 100644 --- a/Ryujinx.Ava/Ui/Windows/DlcManagerWindow.axaml.cs +++ b/Ryujinx.Ava/Ui/Windows/DlcManagerWindow.axaml.cs @@ -2,6 +2,7 @@ using Avalonia; using Avalonia.Collections; using Avalonia.Controls; using Avalonia.Markup.Xaml; +using Avalonia.Threading; using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Fsa; @@ -21,6 +22,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Text; +using System.Threading.Tasks; using Path = System.IO.Path; namespace Ryujinx.Ava.Ui.Windows @@ -125,15 +127,18 @@ namespace Ryujinx.Ava.Ui.Windows } catch (Exception ex) { - ContentDialogHelper.CreateErrorDialog(this, + Dispatcher.UIThread.InvokeAsync(async () => + { + await ContentDialogHelper.CreateErrorDialog(this, string.Format(LocaleManager.Instance[ "DialogDlcLoadNcaErrorMessage"], ex.Message, containerPath)); + }); } return null; } - private void AddDlc(string path) + private async Task AddDlc(string path) { if (!File.Exists(path) || Dlcs.FirstOrDefault(x => x.ContainerPath == path) != null) { @@ -175,7 +180,7 @@ namespace Ryujinx.Ava.Ui.Windows if (!containsDlc) { - ContentDialogHelper.CreateErrorDialog(this, LocaleManager.Instance["DialogDlcNoDlcErrorMessage"]); + await ContentDialogHelper.CreateErrorDialog(this, LocaleManager.Instance["DialogDlcNoDlcErrorMessage"]); } } } @@ -214,7 +219,7 @@ namespace Ryujinx.Ava.Ui.Windows { foreach (string file in files) { - AddDlc(file); + await AddDlc(file); } } } diff --git a/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs index bea84e3b5..2b5c10e20 100644 --- a/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs +++ b/Ryujinx.Ava/Ui/Windows/MainWindow.axaml.cs @@ -120,8 +120,6 @@ namespace Ryujinx.Ava.Ui.Windows InputManager = new InputManager(new AvaloniaKeyboardDriver(this), new SDL2GamepadDriver()); LoadGameList(); - - CheckLaunchState(); } _rendererWaitEvent = new AutoResetEvent(false); @@ -451,7 +449,7 @@ namespace Ryujinx.Ava.Ui.Windows RefreshFirmwareStatus(); } - protected async void CheckLaunchState() + protected void CheckLaunchState() { if (ShowKeyErrorOnLoad) { @@ -470,7 +468,7 @@ namespace Ryujinx.Ava.Ui.Windows if (ConfigurationState.Instance.CheckUpdatesOnStart.Value && Updater.CanUpdate(false, this)) { - await Updater.BeginParse(this, false).ContinueWith(task => + Updater.BeginParse(this, false).ContinueWith(task => { Logger.Error?.Print(LogClass.Application, $"Updater Error: {task.Exception}"); }, TaskContinuationOptions.OnlyOnFaulted); @@ -537,6 +535,13 @@ namespace Ryujinx.Ava.Ui.Windows LoadHotKeys(); } + protected override void OnOpened(EventArgs e) + { + base.OnOpened(e); + + CheckLaunchState(); + } + public static void UpdateGraphicsConfig() { int resScale = ConfigurationState.Instance.Graphics.ResScale; diff --git a/Ryujinx.Ava/Ui/Windows/TitleUpdateWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/TitleUpdateWindow.axaml.cs index edc1abcd9..e465dc6e8 100644 --- a/Ryujinx.Ava/Ui/Windows/TitleUpdateWindow.axaml.cs +++ b/Ryujinx.Ava/Ui/Windows/TitleUpdateWindow.axaml.cs @@ -24,6 +24,7 @@ using System.Text; using Path = System.IO.Path; using SpanHelpers = LibHac.Common.SpanHelpers; using LibHac.Tools.FsSystem; +using Avalonia.Threading; namespace Ryujinx.Ava.Ui.Windows { @@ -151,14 +152,20 @@ namespace Ryujinx.Ava.Ui.Windows } else { - ContentDialogHelper.CreateErrorDialog(this, - LocaleManager.Instance["DialogUpdateAddUpdateErrorMessage"]); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateErrorDialog(this, + LocaleManager.Instance["DialogUpdateAddUpdateErrorMessage"]); + }); } } catch (Exception ex) { - ContentDialogHelper.CreateErrorDialog(this, - string.Format(LocaleManager.Instance["DialogDlcLoadNcaErrorMessage"], ex.Message, path)); + Dispatcher.UIThread.Post(async () => + { + await ContentDialogHelper.CreateErrorDialog(this, + string.Format(LocaleManager.Instance["DialogDlcLoadNcaErrorMessage"], ex.Message, path)); + }); } } } diff --git a/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj b/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj index 0546c22e4..092ec3c22 100644 --- a/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj +++ b/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -6,8 +6,6 @@ Exe true 1.0.0-dirty - false - false $(DefineConstants);$(ExtraDefineConstants) diff --git a/Ryujinx/Ryujinx.csproj b/Ryujinx/Ryujinx.csproj index 5e14f74dd..ed2fa1c49 100644 --- a/Ryujinx/Ryujinx.csproj +++ b/Ryujinx/Ryujinx.csproj @@ -6,8 +6,6 @@ Exe true 1.0.0-dirty - false - false $(DefineConstants);$(ExtraDefineConstants) true