mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-12 07:36:59 +00:00
move more of the setup wizard logic into the setup wizard itself instead of having some critical logic in a random lambda in MainWindow.axaml.cs
This commit is contained in:
parent
615b2c8b8a
commit
c4873ca06b
5 changed files with 33 additions and 31 deletions
|
|
@ -22,7 +22,7 @@ namespace Ryujinx.Ava.Systems.SetupWizard
|
|||
.Show();
|
||||
}
|
||||
|
||||
protected SetupWizardPageBuilder NextPage()
|
||||
protected SetupWizardPageBuilder NextPage()
|
||||
=> new(presenter);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
|||
}
|
||||
finally
|
||||
{
|
||||
mwvm.VirtualFileSystem.ReloadKeySet();
|
||||
_mainWindow.VirtualFileSystem.ReloadKeySet();
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
using Avalonia.Controls.Presenters;
|
||||
using Gommon;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Systems.Configuration;
|
||||
using Ryujinx.Ava.Systems.SetupWizard;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Ava.UI.ViewModels;
|
||||
using Ryujinx.Ava.UI.SetupWizard.Pages;
|
||||
using Ryujinx.Ava.UI.Windows;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using System;
|
||||
|
|
@ -14,15 +13,18 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Ryujinx.Ava.UI.SetupWizard
|
||||
{
|
||||
public partial class RyujinxSetupWizard(ContentPresenter presenter, MainWindowViewModel mwvm, Action onClose)
|
||||
: BaseSetupWizard(presenter)
|
||||
public partial class RyujinxSetupWizard(RyujinxSetupWizardWindow wizardWindow)
|
||||
: BaseSetupWizard(wizardWindow.WizardPresenter)
|
||||
{
|
||||
private readonly MainWindow _mainWindow = RyujinxApp.MainWindow;
|
||||
|
||||
private bool _configWasModified = false;
|
||||
|
||||
public bool HasFirmware => mwvm.ContentManager.GetCurrentFirmwareVersion() != null;
|
||||
public bool HasFirmware => _mainWindow.ContentManager.GetCurrentFirmwareVersion() != null;
|
||||
|
||||
public override async Task Start()
|
||||
{
|
||||
NotificationHelper.SetNotificationManager(wizardWindow);
|
||||
RyujinxSetupWizardWindow.IsUsingSetupWizard = true;
|
||||
Start:
|
||||
await FirstPage();
|
||||
|
|
@ -35,9 +37,10 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
|||
if (!await SetupFirmware())
|
||||
goto Keys;
|
||||
|
||||
|
||||
Return:
|
||||
onClose();
|
||||
NotificationHelper.SetNotificationManager(_mainWindow);
|
||||
wizardWindow.Close();
|
||||
RyujinxSetupWizardWindow.IsUsingSetupWizard = false;
|
||||
|
||||
if (_configWasModified)
|
||||
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.GlobalConfigurationPath);
|
||||
|
|
@ -45,7 +48,7 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
|||
|
||||
private async ValueTask<bool> SetupKeys()
|
||||
{
|
||||
if (!mwvm.VirtualFileSystem.HasKeySet)
|
||||
if (!_mainWindow.VirtualFileSystem.HasKeySet)
|
||||
{
|
||||
Retry:
|
||||
bool result = await NextPage()
|
||||
|
|
@ -73,7 +76,7 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
|||
{
|
||||
if (!HasFirmware)
|
||||
{
|
||||
if (!mwvm.VirtualFileSystem.HasKeySet)
|
||||
if (!_mainWindow.VirtualFileSystem.HasKeySet)
|
||||
{
|
||||
NotificationHelper.ShowError("Keys still seem to not be installed. Please try again.");
|
||||
return false;
|
||||
|
|
@ -93,8 +96,8 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
|||
|
||||
try
|
||||
{
|
||||
mwvm.ContentManager.InstallFirmware(fwvm.FirmwareSourcePath);
|
||||
SystemVersion installedFwVer = mwvm.ContentManager.GetCurrentFirmwareVersion();
|
||||
_mainWindow.ContentManager.InstallFirmware(fwvm.FirmwareSourcePath);
|
||||
SystemVersion installedFwVer = _mainWindow.ContentManager.GetCurrentFirmwareVersion();
|
||||
if (installedFwVer != null)
|
||||
{
|
||||
NotificationHelper.ShowInformation(
|
||||
|
|
@ -110,7 +113,7 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
|||
"\nPlease check the log or try again."
|
||||
);
|
||||
}
|
||||
mwvm.RefreshFirmwareStatus(installedFwVer, allowNullVersion: true);
|
||||
_mainWindow.ViewModel.RefreshFirmwareStatus(installedFwVer, allowNullVersion: true);
|
||||
|
||||
// Purge Applet Cache.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
using Avalonia.Controls;
|
||||
using Ryujinx.Ava.Systems.Configuration;
|
||||
using Ryujinx.Ava.Systems.SetupWizard;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Ava.UI.ViewModels;
|
||||
using Ryujinx.Ava.UI.Windows;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ryujinx.Ava.UI.SetupWizard
|
||||
{
|
||||
public partial class RyujinxSetupWizardWindow : StyleableAppWindow
|
||||
{
|
||||
public static bool IsUsingSetupWizard { get; set; }
|
||||
|
||||
|
||||
public RyujinxSetupWizardWindow() : base(useCustomTitleBar: true)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
|
@ -24,18 +24,22 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
|||
}
|
||||
}
|
||||
|
||||
public static RyujinxSetupWizardWindow CreateWindow(MainWindowViewModel mwvm, out BaseSetupWizard setupWizard)
|
||||
public static Task ShowAsync(Window owner = null)
|
||||
{
|
||||
Task windowTask = ShowAsync(
|
||||
CreateWindow(out BaseSetupWizard wiz),
|
||||
owner ?? RyujinxApp.MainWindow
|
||||
);
|
||||
_ = wiz.Start();
|
||||
return windowTask;
|
||||
}
|
||||
|
||||
public static RyujinxSetupWizardWindow CreateWindow(out BaseSetupWizard setupWizard)
|
||||
{
|
||||
RyujinxSetupWizardWindow window = new();
|
||||
window.DataContext = setupWizard = new RyujinxSetupWizard(window.WizardPresenter, mwvm, () =>
|
||||
{
|
||||
NotificationHelper.SetNotificationManager(RyujinxApp.MainWindow);
|
||||
window.Close();
|
||||
IsUsingSetupWizard = false;
|
||||
});
|
||||
window.DataContext = setupWizard = new RyujinxSetupWizard(window);
|
||||
window.Height = 600;
|
||||
window.Width = 750;
|
||||
NotificationHelper.SetNotificationManager(window);
|
||||
return window;
|
||||
}
|
||||
|
||||
|
|
@ -82,4 +86,3 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,11 +146,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
if (Program.IsFirstStart && RyujinxSetupWizardWindow.CanShowSetupWizard)
|
||||
{
|
||||
Task windowTask = ShowAsync(
|
||||
RyujinxSetupWizardWindow.CreateWindow(ViewModel, out BaseSetupWizard wiz),
|
||||
this);
|
||||
_ = wiz.Start();
|
||||
await windowTask;
|
||||
await RyujinxSetupWizardWindow.ShowAsync(this);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue