mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-12 07:36:59 +00:00
use a custom key install function with notifications instead of the normal one with dialogs
This commit is contained in:
parent
50c3dd0573
commit
4857fde4fe
4 changed files with 89 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ using Avalonia.Controls.Notifications;
|
|||
using Avalonia.Threading;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.UI.SetupWizard;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
|
|
@ -48,6 +49,8 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
|
||||
host.Closing += (sender, args) =>
|
||||
{
|
||||
if (sender is RyujinxSetupWizardWindow) return;
|
||||
|
||||
if (maybeAsyncWorkQueue.IsValueCreated)
|
||||
{
|
||||
maybeAsyncWorkQueue.Value.Dispose();
|
||||
|
|
|
|||
76
src/Ryujinx/UI/SetupWizard/RyujinxSetupWizard.Helpers.cs
Normal file
76
src/Ryujinx/UI/SetupWizard/RyujinxSetupWizard.Helpers.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using DynamicData;
|
||||
using Gommon;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Ava.UI.SetupWizard
|
||||
{
|
||||
public partial class RyujinxSetupWizard
|
||||
{
|
||||
private Result InstallKeys(string directory)
|
||||
{
|
||||
try
|
||||
{
|
||||
string systemDirectory = AppDataManager.KeysDirPath;
|
||||
if (AppDataManager.Mode == AppDataManager.LaunchMode.UserProfile &&
|
||||
Directory.Exists(AppDataManager.KeysDirPathUser))
|
||||
{
|
||||
systemDirectory = AppDataManager.KeysDirPathUser;
|
||||
}
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, $"Installing keys from {directory}");
|
||||
|
||||
Thread thread = new(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ContentManager.InstallKeys(directory, systemDirectory);
|
||||
|
||||
NotificationHelper.ShowInformation(
|
||||
title: LocaleManager.Instance[LocaleKeys.RyujinxInfo],
|
||||
text: LocaleManager.Instance[LocaleKeys.DialogKeysInstallerKeysInstallSuccessMessage]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string message = ex.Message;
|
||||
if (ex is FormatException)
|
||||
{
|
||||
message = LocaleManager.Instance.UpdateAndGetDynamicValue(
|
||||
LocaleKeys.DialogKeysInstallerKeysNotFoundErrorMessage, directory);
|
||||
}
|
||||
|
||||
NotificationHelper.ShowError(message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
mwvm.VirtualFileSystem.ReloadKeySet();
|
||||
}
|
||||
}) { Name = "GUI.KeysInstallerThread" };
|
||||
|
||||
thread.Start();
|
||||
}
|
||||
catch (MissingKeyException ex)
|
||||
{
|
||||
NotificationHelper.ShowError(ex.ToString());
|
||||
return Result.Failure(NoKeysFoundInFolder.Shared);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Failure(new MessageError(ex.Message));
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
|
||||
public struct NoKeysFoundInFolder : IErrorState
|
||||
{
|
||||
public static readonly NoKeysFoundInFolder Shared = new();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using Avalonia.Controls.Presenters;
|
||||
using Gommon;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Systems.Configuration;
|
||||
using Ryujinx.Ava.Systems.SetupWizard;
|
||||
|
|
@ -11,7 +12,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Ryujinx.Ava.UI.SetupWizard
|
||||
{
|
||||
public class RyujinxSetupWizard(ContentPresenter presenter, MainWindowViewModel mwvm, Action onClose) : BaseSetupWizard(presenter)
|
||||
public partial class RyujinxSetupWizard(ContentPresenter presenter, MainWindowViewModel mwvm, Action onClose) : BaseSetupWizard(presenter)
|
||||
{
|
||||
private bool _configWasModified = false;
|
||||
|
||||
|
|
@ -39,7 +40,11 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
|||
if (!Directory.Exists(kpvm.KeysFolderPath))
|
||||
goto Retry;
|
||||
|
||||
await mwvm.HandleKeysInstallation(kpvm.KeysFolderPath);
|
||||
Result installResult = InstallKeys(kpvm.KeysFolderPath);
|
||||
if (!installResult.IsSuccess)
|
||||
{
|
||||
goto Retry;
|
||||
}
|
||||
}
|
||||
|
||||
Firmware:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Ryujinx.Ava;
|
||||
using Ryujinx.Ava.Systems.Configuration;
|
||||
using Ryujinx.Ava.Systems.SetupWizard;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Ava.UI.SetupWizard;
|
||||
using Ryujinx.Ava.UI.ViewModels;
|
||||
using Ryujinx.Ava.UI.Windows;
|
||||
|
|
@ -30,11 +31,13 @@ namespace Ryujinx.UI.SetupWizard
|
|||
RyujinxSetupWizardWindow window = new();
|
||||
window.DataContext = setupWizard = new RyujinxSetupWizard(window.WizardPresenter, mwvm, () =>
|
||||
{
|
||||
NotificationHelper.SetNotificationManager(RyujinxApp.MainWindow);
|
||||
window.Close();
|
||||
IsUsingSetupWizard = false;
|
||||
});
|
||||
window.Height = 600;
|
||||
window.Width = 750;
|
||||
NotificationHelper.SetNotificationManager(window);
|
||||
return window;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue