From 969d5e6aa6c20ba216bcc3de7a14a53edd6567e8 Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Thu, 21 May 2026 19:01:45 +0200 Subject: [PATCH] feat(ui): add a preview button for the per-tab notification sound --- .../Resources/HellionStrings.Designer.cs | 1 + HellionChat/Resources/HellionStrings.resx | 3 ++ HellionChat/Ui/SettingsTabs/Tabs.cs | 41 +++++++++++++++---- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/HellionChat/Resources/HellionStrings.Designer.cs b/HellionChat/Resources/HellionStrings.Designer.cs index d0e1dd3..96d38cf 100644 --- a/HellionChat/Resources/HellionStrings.Designer.cs +++ b/HellionChat/Resources/HellionStrings.Designer.cs @@ -462,6 +462,7 @@ internal class HellionStrings internal static string Tabs_NotificationSound_Enable_Name => Get(nameof(Tabs_NotificationSound_Enable_Name)); internal static string Tabs_NotificationSound_Description => Get(nameof(Tabs_NotificationSound_Description)); internal static string Tabs_NotificationSound_Option => Get(nameof(Tabs_NotificationSound_Option)); + internal static string Tabs_NotificationSound_Preview => Get(nameof(Tabs_NotificationSound_Preview)); // Scroll-to-bottom and item/flag linking internal static string ChatLog_ScrollToBottom_Tooltip => Get(nameof(ChatLog_ScrollToBottom_Tooltip)); diff --git a/HellionChat/Resources/HellionStrings.resx b/HellionChat/Resources/HellionStrings.resx index 22889fa..acadbc7 100644 --- a/HellionChat/Resources/HellionStrings.resx +++ b/HellionChat/Resources/HellionStrings.resx @@ -1073,6 +1073,9 @@ Sound + + Preview the selected sound + diff --git a/HellionChat/Ui/SettingsTabs/Tabs.cs b/HellionChat/Ui/SettingsTabs/Tabs.cs index 45e1f64..8ad1e91 100755 --- a/HellionChat/Ui/SettingsTabs/Tabs.cs +++ b/HellionChat/Ui/SettingsTabs/Tabs.cs @@ -2,6 +2,7 @@ using Dalamud.Bindings.ImGui; using Dalamud.Game.ClientState.Objects.SubKinds; using Dalamud.Interface; using Dalamud.Interface.Utility.Raii; +using FFXIVClientStructs.FFXIV.Client.UI; using HellionChat.Code; using HellionChat.Resources; using HellionChat.Util; @@ -175,20 +176,42 @@ internal sealed class Tabs : ISettingsTab using var indent = ImRaii.PushIndent(10.0f); var soundPreview = $"{HellionStrings.Tabs_NotificationSound_Option} {tab.NotificationSoundId}"; - using var combo = ImRaii.Combo($"##notif-sound-{i}", soundPreview); - if (combo.Success) + using (var combo = ImRaii.Combo($"##notif-sound-{i}", soundPreview)) { - for (uint s = 1; s <= 16; s++) + if (combo.Success) { - if ( - ImGui.Selectable( - $"{HellionStrings.Tabs_NotificationSound_Option} {s}", - tab.NotificationSoundId == s + for (uint s = 1; s <= 16; s++) + { + if ( + ImGui.Selectable( + $"{HellionStrings.Tabs_NotificationSound_Option} {s}", + tab.NotificationSoundId == s + ) ) - ) - tab.NotificationSoundId = s; + tab.NotificationSoundId = s; + } } } + + // Let the user hear the currently selected sound without waiting + // for a real message to arrive in this tab. + ImGui.SameLine(); + if ( + ImGuiUtil.IconButton( + FontAwesomeIcon.Play, + tooltip: HellionStrings.Tabs_NotificationSound_Preview + ) + ) + { + var previewId = tab.NotificationSoundId; + Plugin.Framework.RunOnFrameworkThread(() => + { + unsafe + { + UIGlobals.PlaySoundEffect(previewId); + } + }); + } } ImGui.Checkbox(Language.Options_Tabs_PopOut, ref tab.PopOut); if (tab.PopOut)