mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-12 07:36:59 +00:00
content & viewmodel object creation helper with out param, touch up firmware install step
This commit is contained in:
parent
fa3a0c11ce
commit
beb697b7f7
3 changed files with 40 additions and 12 deletions
|
|
@ -2,6 +2,8 @@ using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Presenters;
|
using Avalonia.Controls.Presenters;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
using Ryujinx.Ava.UI.Controls;
|
||||||
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Systems.SetupWizard
|
namespace Ryujinx.Ava.Systems.SetupWizard
|
||||||
|
|
@ -52,6 +54,15 @@ namespace Ryujinx.Ava.Systems.SetupWizard
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SetupWizardPageBuilder WithContent<TControl, TViewModel>(out TViewModel boundViewModel)
|
||||||
|
where TControl : RyujinxControl<TViewModel>, new()
|
||||||
|
where TViewModel : BaseModel, new()
|
||||||
|
{
|
||||||
|
boundViewModel = new();
|
||||||
|
|
||||||
|
return WithContent<TControl>(boundViewModel);
|
||||||
|
}
|
||||||
|
|
||||||
public SetupWizardPageBuilder WithActionContent(LocaleKeys content) =>
|
public SetupWizardPageBuilder WithActionContent(LocaleKeys content) =>
|
||||||
WithActionContent(LocaleManager.Instance[content]);
|
WithActionContent(LocaleManager.Instance[content]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,9 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
||||||
if (!mwvm.VirtualFileSystem.HasKeySet)
|
if (!mwvm.VirtualFileSystem.HasKeySet)
|
||||||
{
|
{
|
||||||
Retry:
|
Retry:
|
||||||
SetupKeysPageViewModel kpvm = new();
|
|
||||||
bool result = await NextPage()
|
bool result = await NextPage()
|
||||||
.WithTitle(LocaleKeys.SetupWizardKeysPageTitle)
|
.WithTitle(LocaleKeys.SetupWizardKeysPageTitle)
|
||||||
.WithContent<SetupKeysPage>(kpvm)
|
.WithContent<SetupKeysPage, SetupKeysPageViewModel>(out SetupKeysPageViewModel kpvm)
|
||||||
.Show();
|
.Show();
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
|
|
@ -77,15 +76,14 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
||||||
{
|
{
|
||||||
if (!mwvm.VirtualFileSystem.HasKeySet)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Retry:
|
Retry:
|
||||||
SetupFirmwarePageViewModel fwvm = new();
|
|
||||||
bool result = await NextPage()
|
bool result = await NextPage()
|
||||||
.WithTitle(LocaleKeys.SetupWizardFirmwarePageTitle)
|
.WithTitle(LocaleKeys.SetupWizardFirmwarePageTitle)
|
||||||
.WithContent<SetupFirmwarePage>(fwvm)
|
.WithContent<SetupFirmwarePage, SetupFirmwarePageViewModel>(out SetupFirmwarePageViewModel fwvm)
|
||||||
.Show();
|
.Show();
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
|
|
@ -98,11 +96,22 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
||||||
{
|
{
|
||||||
mwvm.ContentManager.InstallFirmware(fwvm.FirmwareSourcePath);
|
mwvm.ContentManager.InstallFirmware(fwvm.FirmwareSourcePath);
|
||||||
SystemVersion installedFwVer = mwvm.ContentManager.GetCurrentFirmwareVersion();
|
SystemVersion installedFwVer = mwvm.ContentManager.GetCurrentFirmwareVersion();
|
||||||
|
if (installedFwVer != null)
|
||||||
|
{
|
||||||
NotificationHelper.ShowInformation(
|
NotificationHelper.ShowInformation(
|
||||||
"Firmware installed",
|
"Firmware installed",
|
||||||
$"Installed firmware version {installedFwVer.VersionString}."
|
$"Installed firmware version {installedFwVer.VersionString}."
|
||||||
);
|
);
|
||||||
mwvm.RefreshFirmwareStatus(installedFwVer);
|
}
|
||||||
|
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.
|
// Purge Applet Cache.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1758,10 +1758,18 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
public static void UpdateGameMetadata(string titleId, TimeSpan playTime)
|
public static void UpdateGameMetadata(string titleId, TimeSpan playTime)
|
||||||
=> ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata => appMetadata.UpdatePostGame(playTime));
|
=> ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata => appMetadata.UpdatePostGame(playTime));
|
||||||
|
|
||||||
public void RefreshFirmwareStatus(SystemVersion version = null)
|
/// <remarks>
|
||||||
|
/// By default, this method will try to retrieve the installed FW version if the version parameter is null.
|
||||||
|
/// <paramref name="allowNullVersion"/> 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.
|
||||||
|
/// </remarks>
|
||||||
|
public void RefreshFirmwareStatus(SystemVersion version = null, bool allowNullVersion = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (!allowNullVersion)
|
||||||
version ??= ContentManager.GetCurrentFirmwareVersion();
|
version ??= ContentManager.GetCurrentFirmwareVersion();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue