Overhaul setup wizard help pages

the context can now override a virtual method named `CreateHelpContent` which the setup wizard system will automatically try to use when you use the generic overload taking a generic context type. If the return is null, it skips setting entirely (the default impl is null)

additionally made the discord join link a button with code copied from the about window, and made it centered at the bottom.
This commit is contained in:
GreemDev
2025-11-27 02:11:49 -06:00
parent 4bdee89288
commit 211498e060
10 changed files with 229 additions and 40 deletions

View File

@@ -1,14 +1,22 @@
using Avalonia;
using Avalonia.Controls.Notifications;
using Avalonia.Media.Imaging;
using Avalonia.Styling;
using Avalonia.Threading;
using Gommon;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.Systems.Configuration;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.SetupWizard.Pages;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Ryujinx.Ava.UI.SetupWizard
{
public class RyujinxSetupWizard(RyujinxSetupWizardWindow wizardWindow, bool overwriteMode)
public class RyujinxSetupWizard : IDisposable, INotifyPropertyChanged
{
private bool _configWasModified;
@@ -18,12 +26,12 @@ namespace Ryujinx.Ava.UI.SetupWizard
public async Task Start()
{
NotificationManager = wizardWindow.CreateNotificationManager(
NotificationManager = _window.CreateNotificationManager(
// I wanted to do bottom center but that...literally just shows top center? Okay.
// Fuck it, weird window height hack to do it instead.
// 120 is not exact, just a random number. Looks fine though.
NotificationPosition.TopCenter,
margin: new Thickness(0, wizardWindow.Height - 120, 0, 0)
margin: new Thickness(0, _window.Height - 120, 0, 0)
);
RyujinxSetupWizardWindow.IsOpen = true;
@@ -49,13 +57,38 @@ namespace Ryujinx.Ava.UI.SetupWizard
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.GlobalConfigurationPath);
NotificationManager = null;
wizardWindow.Close();
_window.Close();
RyujinxSetupWizardWindow.IsOpen = false;
}
public Bitmap DiscordLogo
{
get;
set => SetField(ref field, value);
}
private void Ryujinx_ThemeChanged()
{
Dispatcher.UIThread.Post(() => UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value));
}
private const string LogoPathFormat = "resm:Ryujinx.Assets.UIImages.Logo_{0}_{1}.png?assembly=Ryujinx";
private void UpdateLogoTheme(string theme)
{
bool isDarkTheme = theme == "Dark" ||
(theme == "Auto" && RyujinxApp.DetectSystemTheme() == ThemeVariant.Dark);
string themeName = isDarkTheme ? "Dark" : "Light";
DiscordLogo = LoadBitmap(LogoPathFormat.Format("Discord", themeName));
}
private static Bitmap LoadBitmap(string uri) => new(Avalonia.Platform.AssetLoader.Open(new Uri(uri)));
private async ValueTask<bool> SetupKeys()
{
if (overwriteMode || !RyujinxApp.MainWindow.VirtualFileSystem.HasKeySet)
if (_overwrite || !RyujinxApp.MainWindow.VirtualFileSystem.HasKeySet)
{
Retry:
bool result = await NextPage()
@@ -75,7 +108,7 @@ namespace Ryujinx.Ava.UI.SetupWizard
private async ValueTask<bool> SetupFirmware()
{
if (overwriteMode || !HasFirmware)
if (_overwrite || !HasFirmware)
{
if (!RyujinxApp.MainWindow.VirtualFileSystem.HasKeySet)
{
@@ -99,13 +132,54 @@ namespace Ryujinx.Ava.UI.SetupWizard
return true;
}
private SetupWizardPage FirstPage() => new(wizardWindow.WizardPresenter, this, isFirstPage: true);
private SetupWizardPage FirstPage() => new(_window.WizardPresenter, this, isFirstPage: true);
private SetupWizardPage NextPage() => new(wizardWindow.WizardPresenter, this);
private SetupWizardPage NextPage() => new(_window.WizardPresenter, this);
public void SignalConfigModified()
{
_configWasModified = true;
}
private readonly RyujinxSetupWizardWindow _window;
private readonly bool _overwrite;
public RyujinxSetupWizard(RyujinxSetupWizardWindow wizardWindow, bool overwriteMode)
{
_window = wizardWindow;
_overwrite = overwriteMode;
if (Program.PreviewerDetached)
{
UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle);
RyujinxApp.ThemeChanged += Ryujinx_ThemeChanged;
}
}
public void Dispose()
{
RyujinxApp.ThemeChanged -= Ryujinx_ThemeChanged;
DiscordLogo.Dispose();
Console.WriteLine("disposed");
GC.SuppressFinalize(this);
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
return true;
}
}
}