feat(ui): add per-tab notification sound for inactive tabs

This commit is contained in:
2026-05-21 10:39:09 +02:00
parent 246f0e2511
commit 36ea8ddcfc
4 changed files with 68 additions and 0 deletions
+27
View File
@@ -7,7 +7,9 @@ using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Hooking;
using Dalamud.Interface.ImGuiNotification;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
using HellionChat._Helpers;
using HellionChat.Code;
using HellionChat.Resources;
using HellionChat.Util;
@@ -330,6 +332,7 @@ internal class MessageManager : IAsyncDisposable
Store.UpsertMessage(message);
var currentMatches = Plugin.CurrentTab.Matches(message);
uint? notificationSound = null;
foreach (var tab in Plugin.Config.Tabs)
{
var unread = !(
@@ -337,7 +340,31 @@ internal class MessageManager : IAsyncDisposable
);
if (tab.Matches(message))
{
tab.AddMessage(message, unread);
// UI-3: per-tab notification sound. Fire once for the first
// inactive tab that wants it — keeps a message matching several
// background tabs from stacking sounds.
// TEST-MIRROR: ../_Helpers/TabSoundDecision.cs
if (notificationSound is null
&& TabSoundDecision.ShouldPlay(
Plugin.CurrentTab == tab,
tab.EnableNotificationSound,
Plugin.Config.PlaySounds))
{
notificationSound = tab.NotificationSoundId;
}
}
}
if (notificationSound is { } soundId)
{
// ProcessMessage runs on the PendingMessageThread worker; the native
// UIGlobals.PlaySoundEffect must be marshalled onto the framework
// thread (reference_dalamud_framework_thread).
Plugin.Framework.RunOnFrameworkThread(
() => { unsafe { UIGlobals.PlaySoundEffect(soundId); } });
}
MessageProcessed?.Invoke(message);