qstbak/Questionable/Questionable.Notifications/NotificationService.cs
2026-08-17 20:29:32 +10:00

63 lines
1.5 KiB
C#

using LLib.Notifications;
using Questionable.Model.Questing;
namespace Questionable.Notifications;
internal sealed class NotificationService(OutOfGameNotifier notifier, Configuration configuration)
{
public void Notify(EInteractionType interactionType, string text)
{
Configuration.NotificationConfiguration notifications = configuration.Notifications;
if (notifications.Enabled && interactionType switch
{
EInteractionType.Duty => notifications.AlertForDuties,
EInteractionType.SinglePlayerDuty => notifications.AlertForSinglePlayerDuties,
EInteractionType.Snipe => notifications.AlertForSnipe,
_ => true,
})
{
Dispatch(text);
}
}
public void NotifyStopCondition(string text)
{
Configuration.NotificationConfiguration notifications = configuration.Notifications;
if (notifications.Enabled && notifications.AlertForStopConditions)
{
Dispatch(text);
}
}
private void Dispatch(string text)
{
Configuration.NotificationConfiguration notifications = configuration.Notifications;
if (notifications.FlashTaskbar)
{
notifier.FlashTaskbar();
}
int num;
if (notifications.OnlyWhenUnfocused)
{
num = ((!notifier.IsGameForeground) ? 1 : 0);
if (num == 0)
{
goto IL_0054;
}
}
else
{
num = 1;
}
if (notifications.ShowTrayMessage)
{
notifier.ShowTrayNotification("Questionable", text);
}
goto IL_0054;
IL_0054:
if (num != 0 && notifications.PlaySound)
{
notifier.PlayAlertSound(WindowsSounds.ResolvePath(notifications.SoundFile));
}
}
}