diff --git a/src/Ryujinx/Systems/SetupWizard/SetupWizardPageBuilder.cs b/src/Ryujinx/Systems/SetupWizard/SetupWizardPageBuilder.cs index cc9f9ce55..d87e31e0c 100644 --- a/src/Ryujinx/Systems/SetupWizard/SetupWizardPageBuilder.cs +++ b/src/Ryujinx/Systems/SetupWizard/SetupWizardPageBuilder.cs @@ -2,6 +2,8 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Presenters; using Ryujinx.Ava.Common.Locale; +using Ryujinx.Ava.UI.Controls; +using Ryujinx.Ava.UI.ViewModels; using System.Threading.Tasks; namespace Ryujinx.Ava.Systems.SetupWizard @@ -52,6 +54,15 @@ namespace Ryujinx.Ava.Systems.SetupWizard return this; } + public SetupWizardPageBuilder WithContent(out TViewModel boundViewModel) + where TControl : RyujinxControl, new() + where TViewModel : BaseModel, new() + { + boundViewModel = new(); + + return WithContent(boundViewModel); + } + public SetupWizardPageBuilder WithActionContent(LocaleKeys content) => WithActionContent(LocaleManager.Instance[content]); diff --git a/src/Ryujinx/UI/SetupWizard/RyujinxSetupWizard.cs b/src/Ryujinx/UI/SetupWizard/RyujinxSetupWizard.cs index c645a5c7a..24494999c 100644 --- a/src/Ryujinx/UI/SetupWizard/RyujinxSetupWizard.cs +++ b/src/Ryujinx/UI/SetupWizard/RyujinxSetupWizard.cs @@ -49,10 +49,9 @@ namespace Ryujinx.Ava.UI.SetupWizard if (!mwvm.VirtualFileSystem.HasKeySet) { Retry: - SetupKeysPageViewModel kpvm = new(); bool result = await NextPage() .WithTitle(LocaleKeys.SetupWizardKeysPageTitle) - .WithContent(kpvm) + .WithContent(out SetupKeysPageViewModel kpvm) .Show(); if (!result) @@ -77,15 +76,14 @@ namespace Ryujinx.Ava.UI.SetupWizard { if (!mwvm.VirtualFileSystem.HasKeySet) { - NotificationHelper.ShowError("Keys still seem to not be installed. Are you sure they're in that folder?"); + NotificationHelper.ShowError("Keys still seem to not be installed. Please try again."); return false; } Retry: - SetupFirmwarePageViewModel fwvm = new(); bool result = await NextPage() .WithTitle(LocaleKeys.SetupWizardFirmwarePageTitle) - .WithContent(fwvm) + .WithContent(out SetupFirmwarePageViewModel fwvm) .Show(); if (!result) @@ -98,11 +96,22 @@ namespace Ryujinx.Ava.UI.SetupWizard { mwvm.ContentManager.InstallFirmware(fwvm.FirmwareSourcePath); SystemVersion installedFwVer = mwvm.ContentManager.GetCurrentFirmwareVersion(); - NotificationHelper.ShowInformation( - "Firmware installed", - $"Installed firmware version {installedFwVer.VersionString}." - ); - mwvm.RefreshFirmwareStatus(installedFwVer); + if (installedFwVer != null) + { + NotificationHelper.ShowInformation( + "Firmware installed", + $"Installed firmware version {installedFwVer.VersionString}." + ); + } + else + { + NotificationHelper.ShowError( + "Firmware not installed", + $"It seems some error occurred when trying to install the firmware at path '{fwvm.FirmwareSourcePath}'. " + + "\nPlease check the log or try again." + ); + } + mwvm.RefreshFirmwareStatus(installedFwVer, allowNullVersion: true); // Purge Applet Cache. diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index 6585d3903..dff600509 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -1758,11 +1758,19 @@ namespace Ryujinx.Ava.UI.ViewModels public static void UpdateGameMetadata(string titleId, TimeSpan playTime) => ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata => appMetadata.UpdatePostGame(playTime)); - public void RefreshFirmwareStatus(SystemVersion version = null) + /// + /// By default, this method will try to retrieve the installed FW version if the version parameter is null. + /// forces this method to accept null and not re-lookup + /// in the case you want to deliberately cause an update with a missing firmware version; + /// + /// i.e., in the setup wizard. + /// + public void RefreshFirmwareStatus(SystemVersion version = null, bool allowNullVersion = false) { try { - version ??= ContentManager.GetCurrentFirmwareVersion(); + if (!allowNullVersion) + version ??= ContentManager.GetCurrentFirmwareVersion(); } catch (Exception) {