mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-12 07:36:59 +00:00
rename NotificationHelper to RyujinxNotificationManager,
rename instance method names. Additionally clarified what the math is in the notification manager margin parameter.
This commit is contained in:
parent
d9128ece5b
commit
8ec1a3a594
12 changed files with 49 additions and 40 deletions
|
|
@ -264,7 +264,7 @@ namespace Ryujinx.Ava.Common
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.Post(waitingDialog.Close);
|
Dispatcher.UIThread.Post(waitingDialog.Close);
|
||||||
|
|
||||||
NotificationHelper.ShowInformation(
|
RyujinxNotificationManager.ShowInformation(
|
||||||
RyujinxApp.FormatTitle(LocaleKeys.DialogNcaExtractionTitle),
|
RyujinxApp.FormatTitle(LocaleKeys.DialogNcaExtractionTitle),
|
||||||
$"{titleName}\n\n{LocaleManager.Instance[LocaleKeys.DialogNcaExtractionSuccessMessage]}");
|
$"{titleName}\n\n{LocaleManager.Instance[LocaleKeys.DialogNcaExtractionSuccessMessage]}");
|
||||||
}
|
}
|
||||||
|
|
@ -380,7 +380,7 @@ namespace Ryujinx.Ava.Common
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.Post(waitingDialog.Close);
|
Dispatcher.UIThread.Post(waitingDialog.Close);
|
||||||
|
|
||||||
NotificationHelper.ShowInformation(
|
RyujinxNotificationManager.ShowInformation(
|
||||||
RyujinxApp.FormatTitle(LocaleKeys.DialogNcaExtractionTitle),
|
RyujinxApp.FormatTitle(LocaleKeys.DialogNcaExtractionTitle),
|
||||||
$"{updateName}\n\n{LocaleManager.Instance[LocaleKeys.DialogNcaExtractionSuccessMessage]}");
|
$"{updateName}\n\n{LocaleManager.Instance[LocaleKeys.DialogNcaExtractionSuccessMessage]}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,18 @@
|
||||||
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.Notifications;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Helpers
|
namespace Ryujinx.Ava.UI.Helpers
|
||||||
{
|
{
|
||||||
public static class ControlExtensions
|
public static class ControlExtensions
|
||||||
{
|
{
|
||||||
|
public static RyujinxNotificationManager CreateNotificationManager(
|
||||||
|
this Window window,
|
||||||
|
NotificationPosition visiblePosition = NotificationPosition.BottomRight,
|
||||||
|
int maxItems = RyujinxNotificationManager.MaxNotifications,
|
||||||
|
Thickness? margin = null
|
||||||
|
) => new(window, visiblePosition, maxItems, margin);
|
||||||
|
|
||||||
extension(Control ctrl)
|
extension(Control ctrl)
|
||||||
{
|
{
|
||||||
public int GridRow
|
public int GridRow
|
||||||
|
|
|
||||||
|
|
@ -4,25 +4,24 @@ using Avalonia.Controls.Notifications;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
using Ryujinx.Ava.UI.SetupWizard;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Helpers
|
namespace Ryujinx.Ava.UI.Helpers
|
||||||
{
|
{
|
||||||
public class NotificationHelper
|
public class RyujinxNotificationManager
|
||||||
{
|
{
|
||||||
public static NotificationHelper Shared { get; set; }
|
public static RyujinxNotificationManager Shared { get; set; }
|
||||||
|
|
||||||
private const int MaxNotifications = 4;
|
public const int MaxNotifications = 4;
|
||||||
private const int NotificationDelayInMs = 5000;
|
private const int NotificationDelayInMs = 5000;
|
||||||
|
|
||||||
private readonly WindowNotificationManager _notificationManager;
|
private readonly WindowNotificationManager _notificationManager;
|
||||||
|
|
||||||
private readonly BlockingCollection<Notification> _notifications = new();
|
private readonly BlockingCollection<Notification> _notifications = new();
|
||||||
|
|
||||||
public NotificationHelper(Window host,
|
public RyujinxNotificationManager(Window host,
|
||||||
NotificationPosition visiblePosition = NotificationPosition.BottomRight,
|
NotificationPosition visiblePosition = NotificationPosition.BottomRight,
|
||||||
int maxItems = MaxNotifications,
|
int maxItems = MaxNotifications,
|
||||||
Thickness? margin = null)
|
Thickness? margin = null)
|
||||||
|
|
@ -63,9 +62,9 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
|
|
||||||
public static void Show(string title, string text, NotificationType type, bool waitingExit = false,
|
public static void Show(string title, string text, NotificationType type, bool waitingExit = false,
|
||||||
Action onClick = null, Action onClose = null)
|
Action onClick = null, Action onClose = null)
|
||||||
=> Shared?.Notify(title, text, type, waitingExit, onClick, onClose);
|
=> Shared?.Send(title, text, type, waitingExit, onClick, onClose);
|
||||||
|
|
||||||
public void Notify(string title, string text, NotificationType type, bool waitingExit = false,
|
public void Send(string title, string text, NotificationType type, bool waitingExit = false,
|
||||||
Action onClick = null, Action onClose = null)
|
Action onClick = null, Action onClose = null)
|
||||||
{
|
{
|
||||||
TimeSpan delay = waitingExit
|
TimeSpan delay = waitingExit
|
||||||
|
|
@ -77,9 +76,9 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
|
|
||||||
#region Instance notification senders
|
#region Instance notification senders
|
||||||
|
|
||||||
public void NotifyInformation(string title, string text, bool waitingExit = false, Action onClick = null,
|
public void Information(string title, string text, bool waitingExit = false, Action onClick = null,
|
||||||
Action onClose = null) =>
|
Action onClose = null) =>
|
||||||
Notify(
|
Send(
|
||||||
title,
|
title,
|
||||||
text,
|
text,
|
||||||
NotificationType.Information,
|
NotificationType.Information,
|
||||||
|
|
@ -87,9 +86,9 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
onClick,
|
onClick,
|
||||||
onClose);
|
onClose);
|
||||||
|
|
||||||
public void NotifySuccess(string title, string text, bool waitingExit = false, Action onClick = null,
|
public void Success(string title, string text, bool waitingExit = false, Action onClick = null,
|
||||||
Action onClose = null) =>
|
Action onClose = null) =>
|
||||||
Notify(
|
Send(
|
||||||
title,
|
title,
|
||||||
text,
|
text,
|
||||||
NotificationType.Success,
|
NotificationType.Success,
|
||||||
|
|
@ -97,9 +96,9 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
onClick,
|
onClick,
|
||||||
onClose);
|
onClose);
|
||||||
|
|
||||||
public void NotifyWarning(string title, string text, bool waitingExit = false, Action onClick = null,
|
public void Warning(string title, string text, bool waitingExit = false, Action onClick = null,
|
||||||
Action onClose = null) =>
|
Action onClose = null) =>
|
||||||
Notify(
|
Send(
|
||||||
title,
|
title,
|
||||||
text,
|
text,
|
||||||
NotificationType.Warning,
|
NotificationType.Warning,
|
||||||
|
|
@ -107,9 +106,9 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
onClick,
|
onClick,
|
||||||
onClose);
|
onClose);
|
||||||
|
|
||||||
public void NotifyError(string title, string text, bool waitingExit = false, Action onClick = null,
|
public void Error(string title, string text, bool waitingExit = false, Action onClick = null,
|
||||||
Action onClose = null) =>
|
Action onClose = null) =>
|
||||||
Notify(
|
Send(
|
||||||
title,
|
title,
|
||||||
text,
|
text,
|
||||||
NotificationType.Error,
|
NotificationType.Error,
|
||||||
|
|
@ -117,8 +116,8 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
onClick,
|
onClick,
|
||||||
onClose);
|
onClose);
|
||||||
|
|
||||||
public void NotifyError(string message, bool waitingExit = false) =>
|
public void Error(string message, bool waitingExit = false) =>
|
||||||
NotifyError(
|
Error(
|
||||||
LocaleManager.Instance[LocaleKeys.DialogErrorTitle],
|
LocaleManager.Instance[LocaleKeys.DialogErrorTitle],
|
||||||
$"{LocaleManager.Instance[LocaleKeys.DialogErrorMessage]}\n\n{message}",
|
$"{LocaleManager.Instance[LocaleKeys.DialogErrorMessage]}\n\n{message}",
|
||||||
waitingExit: waitingExit
|
waitingExit: waitingExit
|
||||||
|
|
@ -79,14 +79,14 @@ namespace Ryujinx.Ava.UI.SetupWizard.Pages
|
||||||
SystemVersion installedFwVer = RyujinxApp.MainWindow.ContentManager.GetCurrentFirmwareVersion();
|
SystemVersion installedFwVer = RyujinxApp.MainWindow.ContentManager.GetCurrentFirmwareVersion();
|
||||||
if (installedFwVer != null)
|
if (installedFwVer != null)
|
||||||
{
|
{
|
||||||
Notifications.NotifyInformation(
|
NotificationManager.Information(
|
||||||
"Firmware installed",
|
"Firmware installed",
|
||||||
$"Installed firmware version {installedFwVer.VersionString}."
|
$"Installed firmware version {installedFwVer.VersionString}."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Notifications.NotifyError(
|
NotificationManager.Error(
|
||||||
"Firmware not installed",
|
"Firmware not installed",
|
||||||
$"It seems some error occurred when trying to install the firmware at path '{FirmwareSourcePath}'." +
|
$"It seems some error occurred when trying to install the firmware at path '{FirmwareSourcePath}'." +
|
||||||
"\nDid that folder contain a firmware dump?"
|
"\nDid that folder contain a firmware dump?"
|
||||||
|
|
@ -107,7 +107,7 @@ namespace Ryujinx.Ava.UI.SetupWizard.Pages
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Notifications.NotifyError(e.Message, waitingExit: true);
|
NotificationManager.Error(e.Message, waitingExit: true);
|
||||||
return Result.Fail;
|
return Result.Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,18 +55,18 @@ namespace Ryujinx.Ava.UI.SetupWizard.Pages
|
||||||
|
|
||||||
ContentManager.InstallKeys(directory, systemDirectory);
|
ContentManager.InstallKeys(directory, systemDirectory);
|
||||||
|
|
||||||
Notifications.NotifyInformation(
|
NotificationManager.Information(
|
||||||
title: LocaleManager.Instance[LocaleKeys.RyujinxInfo],
|
title: LocaleManager.Instance[LocaleKeys.RyujinxInfo],
|
||||||
text: LocaleManager.Instance[LocaleKeys.DialogKeysInstallerKeysInstallSuccessMessage]);
|
text: LocaleManager.Instance[LocaleKeys.DialogKeysInstallerKeysInstallSuccessMessage]);
|
||||||
}
|
}
|
||||||
catch (InvalidFirmwarePackageException ifwpe)
|
catch (InvalidFirmwarePackageException ifwpe)
|
||||||
{
|
{
|
||||||
Notifications.NotifyError(ifwpe.Message, waitingExit: true);
|
NotificationManager.Error(ifwpe.Message, waitingExit: true);
|
||||||
return Result.Failure(NoKeysFoundInFolder.Shared);
|
return Result.Failure(NoKeysFoundInFolder.Shared);
|
||||||
}
|
}
|
||||||
catch (MissingKeyException ex)
|
catch (MissingKeyException ex)
|
||||||
{
|
{
|
||||||
Notifications.NotifyError(ex.ToString(), waitingExit: true);
|
NotificationManager.Error(ex.ToString(), waitingExit: true);
|
||||||
return Result.Failure(NoKeysFoundInFolder.Shared);
|
return Result.Failure(NoKeysFoundInFolder.Shared);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -78,7 +78,7 @@ namespace Ryujinx.Ava.UI.SetupWizard.Pages
|
||||||
LocaleKeys.DialogKeysInstallerKeysNotFoundErrorMessage, directory);
|
LocaleKeys.DialogKeysInstallerKeysNotFoundErrorMessage, directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notifications.NotifyError(message, waitingExit: true);
|
NotificationManager.Error(message, waitingExit: true);
|
||||||
|
|
||||||
return Result.Failure(new MessageError(message));
|
return Result.Failure(new MessageError(message));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,15 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
||||||
|
|
||||||
public bool HasFirmware => RyujinxApp.MainWindow.ContentManager.GetCurrentFirmwareVersion() != null;
|
public bool HasFirmware => RyujinxApp.MainWindow.ContentManager.GetCurrentFirmwareVersion() != null;
|
||||||
|
|
||||||
public NotificationHelper Notification { get; private set; }
|
public RyujinxNotificationManager NotificationManager { get; private set; }
|
||||||
|
|
||||||
public async Task Start()
|
public async Task Start()
|
||||||
{
|
{
|
||||||
Notification = new NotificationHelper(
|
NotificationManager = wizardWindow.CreateNotificationManager(
|
||||||
wizardWindow,
|
|
||||||
// I wanted to do bottom center but that...literally just shows top center? Okay.
|
// I wanted to do bottom center but that...literally just shows top center? Okay.
|
||||||
NotificationPosition.TopCenter,
|
// 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, wizardWindow.Height - 120, 0, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -47,7 +48,7 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
||||||
if (_configWasModified)
|
if (_configWasModified)
|
||||||
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.GlobalConfigurationPath);
|
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.GlobalConfigurationPath);
|
||||||
|
|
||||||
Notification = null;
|
NotificationManager = null;
|
||||||
wizardWindow.Close();
|
wizardWindow.Close();
|
||||||
RyujinxSetupWizardWindow.IsOpen = false;
|
RyujinxSetupWizardWindow.IsOpen = false;
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +79,7 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
||||||
{
|
{
|
||||||
if (!RyujinxApp.MainWindow.VirtualFileSystem.HasKeySet)
|
if (!RyujinxApp.MainWindow.VirtualFileSystem.HasKeySet)
|
||||||
{
|
{
|
||||||
Notification.NotifyError("Keys still seem to not be installed. Please try again.");
|
NotificationManager.Error("Keys still seem to not be installed. Please try again.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
||||||
where TControl : RyujinxControl<TViewModel>, new()
|
where TControl : RyujinxControl<TViewModel>, new()
|
||||||
where TViewModel : SetupWizardPageContext, new()
|
where TViewModel : SetupWizardPageContext, new()
|
||||||
{
|
{
|
||||||
boundViewModel = new() { Notifications = ownerWizard.Notification };
|
boundViewModel = new() { NotificationManager = ownerWizard.NotificationManager };
|
||||||
|
|
||||||
return WithContent<TControl>(boundViewModel);
|
return WithContent<TControl>(boundViewModel);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
||||||
{
|
{
|
||||||
public abstract class SetupWizardPageContext : BaseModel
|
public abstract class SetupWizardPageContext : BaseModel
|
||||||
{
|
{
|
||||||
public NotificationHelper Notifications { get; init; }
|
public RyujinxNotificationManager NotificationManager { get; init; }
|
||||||
|
|
||||||
public abstract Result CompleteStep();
|
public abstract Result CompleteStep();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1955,14 +1955,14 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
if (ConfigurationState.Instance.Debug.DebuggerSuspendOnStart)
|
if (ConfigurationState.Instance.Debug.DebuggerSuspendOnStart)
|
||||||
{
|
{
|
||||||
NotificationHelper.ShowInformation(
|
RyujinxNotificationManager.ShowInformation(
|
||||||
LocaleManager.Instance[LocaleKeys.NotificationLaunchCheckSuspendOnStartTitle],
|
LocaleManager.Instance[LocaleKeys.NotificationLaunchCheckSuspendOnStartTitle],
|
||||||
LocaleManager.Instance[LocaleKeys.NotificationLaunchCheckSuspendOnStartMessage]);
|
LocaleManager.Instance[LocaleKeys.NotificationLaunchCheckSuspendOnStartMessage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigurationState.Instance.Debug.EnableGdbStub)
|
if (ConfigurationState.Instance.Debug.EnableGdbStub)
|
||||||
{
|
{
|
||||||
NotificationHelper.ShowInformation(
|
RyujinxNotificationManager.ShowInformation(
|
||||||
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.NotificationLaunchCheckGdbStubTitle, ConfigurationState.Instance.Debug.GdbStubPort.Value),
|
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.NotificationLaunchCheckGdbStubTitle, ConfigurationState.Instance.Debug.GdbStubPort.Value),
|
||||||
LocaleManager.Instance[LocaleKeys.NotificationLaunchCheckGdbStubMessage]);
|
LocaleManager.Instance[LocaleKeys.NotificationLaunchCheckGdbStubMessage]);
|
||||||
}
|
}
|
||||||
|
|
@ -1981,7 +1981,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
_ => LocaleKeys.SettingsTabSystemDramSize4GiB,
|
_ => LocaleKeys.SettingsTabSystemDramSize4GiB,
|
||||||
};
|
};
|
||||||
|
|
||||||
NotificationHelper.ShowWarning(
|
RyujinxNotificationManager.ShowWarning(
|
||||||
LocaleManager.Instance.UpdateAndGetDynamicValue(
|
LocaleManager.Instance.UpdateAndGetDynamicValue(
|
||||||
LocaleKeys.NotificationLaunchCheckDramSizeTitle,
|
LocaleKeys.NotificationLaunchCheckDramSizeTitle,
|
||||||
LocaleManager.Instance[memoryConfigurationLocaleKey]
|
LocaleManager.Instance[memoryConfigurationLocaleKey]
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ namespace Ryujinx.Ava.UI.Views.Dialog
|
||||||
|
|
||||||
await clipboard.SetTextAsync(appData.IdString);
|
await clipboard.SetTextAsync(appData.IdString);
|
||||||
|
|
||||||
NotificationHelper.ShowInformation(
|
RyujinxNotificationManager.ShowInformation(
|
||||||
"Copied Title ID",
|
"Copied Title ID",
|
||||||
$"{appData.Name} ({appData.IdString})");
|
$"{appData.Name} ({appData.IdString})");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ namespace Ryujinx.Ava.UI.Views.Misc
|
||||||
|
|
||||||
await clipboard.SetTextAsync(appData.IdString);
|
await clipboard.SetTextAsync(appData.IdString);
|
||||||
|
|
||||||
NotificationHelper.ShowInformation(
|
RyujinxNotificationManager.ShowInformation(
|
||||||
"Copied Title ID",
|
"Copied Title ID",
|
||||||
$"{appData.Name} ({appData.IdString})");
|
$"{appData.Name} ({appData.IdString})");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
{
|
{
|
||||||
base.OnApplyTemplate(e);
|
base.OnApplyTemplate(e);
|
||||||
|
|
||||||
NotificationHelper.Shared = new NotificationHelper(this);
|
RyujinxNotificationManager.Shared = new RyujinxNotificationManager(this);
|
||||||
|
|
||||||
Executor.ExecuteBackgroundAsync(async () =>
|
Executor.ExecuteBackgroundAsync(async () =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue