further simplify pagebuilding by embedding the desired title locale key in the context base type

This commit is contained in:
GreemDev 2025-11-28 00:21:51 -06:00
parent a336bb0568
commit 327cdb825a
5 changed files with 22 additions and 12 deletions

View file

@ -17,7 +17,7 @@ using System.Threading.Tasks;
namespace Ryujinx.Ava.UI.SetupWizard.Pages
{
public partial class SetupFirmwarePageContext : SetupWizardPageContext
public partial class SetupFirmwarePageContext() : SetupWizardPageContext(LocaleKeys.SetupWizardFirmwarePageTitle)
{
[ObservableProperty]
public partial string FirmwareSourcePath { get; set; }

View file

@ -19,12 +19,12 @@ using System.Threading.Tasks;
namespace Ryujinx.Ava.UI.SetupWizard.Pages
{
public partial class SetupKeysPageContext : SetupWizardPageContext
public partial class SetupKeysPageContext() : SetupWizardPageContext(LocaleKeys.SetupWizardKeysPageTitle)
{
public override Result CompleteStep() =>
!Directory.Exists(KeysFolderPath)
? Result.Fail
: InstallKeys(KeysFolderPath);
Directory.Exists(KeysFolderPath)
? InstallKeys(KeysFolderPath)
: Result.Fail;
public override object CreateHelpContent()
{

View file

@ -11,9 +11,7 @@ namespace Ryujinx.Ava.UI.SetupWizard
if (_overwrite || !RyujinxApp.MainWindow.VirtualFileSystem.HasKeySet)
{
Retry:
bool result = await NextPage()
.WithTitle(LocaleKeys.SetupWizardKeysPageTitle)
.WithContent<SetupKeysPage, SetupKeysPageContext>(out SetupKeysPageContext keyContext)
bool result = await NextPage<SetupKeysPage, SetupKeysPageContext>(out SetupKeysPageContext keyContext)
.Show();
if (!result)
@ -37,9 +35,7 @@ namespace Ryujinx.Ava.UI.SetupWizard
}
Retry:
bool result = await NextPage()
.WithTitle(LocaleKeys.SetupWizardFirmwarePageTitle)
.WithContent<SetupFirmwarePage, SetupFirmwarePageContext>(out SetupFirmwarePageContext fwContext)
bool result = await NextPage<SetupFirmwarePage, SetupFirmwarePageContext>(out SetupFirmwarePageContext fwContext)
.Show();
if (!result)

View file

@ -7,6 +7,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
using Ryujinx.Ava.Common;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.Systems.Configuration;
using Ryujinx.Ava.UI.Controls;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.ViewModels;
using System;
@ -37,6 +38,13 @@ namespace Ryujinx.Ava.UI.SetupWizard
private SetupWizardPage NextPage() => new(_window.WizardPresenter, this);
private SetupWizardPage NextPage<TControl, TContext>(out TContext boundContext)
where TControl : RyujinxControl<TContext>, new()
where TContext : SetupWizardPageContext, new()
=> NextPage()
.WithContent<TControl, TContext>(out boundContext)
.WithTitle(boundContext.Title);
public void SignalConfigModified()
{
_configWasModified = true;

View file

@ -1,13 +1,19 @@
using Gommon;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.ViewModels;
namespace Ryujinx.Ava.UI.SetupWizard
{
public abstract class SetupWizardPageContext : BaseModel
public abstract class SetupWizardPageContext(LocaleKeys title) : BaseModel
{
public LocaleKeys Title => title;
public RyujinxNotificationManager NotificationManager { get; init; }
// ReSharper disable once UnusedMemberInSuper.Global
// it's used implicitly as we use this type as a where guard for generics for WithContent<TControl, TContext>,
// it also ensures all context types implement completion
public abstract Result CompleteStep();
#nullable enable
public virtual object? CreateHelpContent()