Implement sounds on interaction

This commit is contained in:
Infi
2024-04-16 00:36:30 +02:00
parent 230e63033d
commit 30ccf8e416
6 changed files with 61 additions and 5 deletions
+2
View File
@@ -38,6 +38,7 @@ internal class Configuration : IPluginConfiguration
public bool SharedMode;
public bool SortAutoTranslate;
public bool CollapseDuplicateMessages;
public bool PlaySounds = true;
public bool FontsEnabled = true;
public ExtraGlyphRanges ExtraGlyphRanges = 0;
@@ -83,6 +84,7 @@ internal class Configuration : IPluginConfiguration
SharedMode = other.SharedMode;
SortAutoTranslate = other.SortAutoTranslate;
CollapseDuplicateMessages = other.CollapseDuplicateMessages;
PlaySounds = other.PlaySounds;
FontsEnabled = other.FontsEnabled;
ExtraGlyphRanges = other.ExtraGlyphRanges;
FontSize = other.FontSize;
+9
View File
@@ -13,6 +13,7 @@ using Dalamud.Interface.Internal;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Lumina.Excel;
@@ -40,6 +41,8 @@ public sealed class PayloadHandler {
private readonly ExcelSheet<TerritoryType> TerritorySheet;
private readonly ExcelSheet<EventItemHelp> EventItemHelpSheet;
private uint PopupSfx = 1u;
internal PayloadHandler(ChatLogWindow logWindow)
{
LogWindow = logWindow;
@@ -206,6 +209,9 @@ public sealed class PayloadHandler {
internal void Click(Chunk chunk, Payload? payload, ImGuiMouseButton button)
{
if (LogWindow.Plugin.Config.PlaySounds)
UIModule.PlaySound(PopupSfx);
switch (button)
{
case ImGuiMouseButton.Left:
@@ -408,6 +414,9 @@ public sealed class PayloadHandler {
case URIPayload uri:
TryOpenURI(uri.Uri);
break;
default:
RightClickPayload(chunk, payload);
break;
}
}
+18
View File
@@ -2183,6 +2183,24 @@ namespace ChatTwo.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Play sounds on interaction..
/// </summary>
internal static string Options_PlaySounds_Description {
get {
return ResourceManager.GetString("Options_PlaySounds_Description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Play sounds.
/// </summary>
internal static string Options_PlaySounds_Name {
get {
return ResourceManager.GetString("Options_PlaySounds_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Display messages in a more modern style..
/// </summary>
+6
View File
@@ -988,4 +988,10 @@
<data name="Options_OverrideStyle_NotAvailable" xml:space="preserve">
<value>No dalamud styles available</value>
</data>
<data name="Options_PlaySounds_Name" xml:space="preserve">
<value>Play sounds</value>
</data>
<data name="Options_PlaySounds_Description" xml:space="preserve">
<value>Play sounds on interaction.</value>
</data>
</root>
+23 -5
View File
@@ -17,6 +17,7 @@ using Dalamud.Interface.Style;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Windowing;
using Dalamud.Memory;
using FFXIVClientStructs.FFXIV.Client.UI;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
@@ -73,6 +74,10 @@ public sealed class ChatLogWindow : Window, IUiComponent
private Dictionary<string, ChatType> TextCommandChannels { get; } = new();
private HashSet<string> AllCommands { get; } = new();
private uint ChatOpenSfx = 35u;
private uint ChatCloseSfx = 3u;
private bool PlayedClosingSound = true;
internal ChatLogWindow(Plugin plugin) : base($"{Plugin.PluginName}###chat2")
{
Plugin = plugin;
@@ -195,6 +200,10 @@ public sealed class ChatLogWindow : Window, IUiComponent
if (info.Text != null && Chat.Length == 0)
Chat = info.Text;
PlayedClosingSound = false;
if (Plugin.Config.PlaySounds)
UIModule.PlaySound(ChatOpenSfx);
}
private bool IsValidCommand(string command)
@@ -562,11 +571,7 @@ public sealed class ChatLogWindow : Window, IUiComponent
ImGui.OpenPopup(ChatChannelPicker);
if (activeTab is { Channel: { } } && ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.TextUnformatted(Language.ChatLog_SwitcherDisabled);
ImGui.EndTooltip();
}
ImGui.SetTooltip(Language.ChatLog_SwitcherDisabled);
if (ImGui.BeginPopup(ChatChannelPicker))
{
@@ -687,6 +692,12 @@ public sealed class ChatLogWindow : Window, IUiComponent
// Only trigger unfocused if we are currently not calling the auto complete
if (!Activate && !ImGui.IsItemActive() && _autoCompleteInfo == null)
{
if (Plugin.Config.PlaySounds && !PlayedClosingSound)
{
PlayedClosingSound = true;
UIModule.PlaySound(ChatCloseSfx);
}
if (_tempChannel is InputChannel.Tell)
_tellTarget = null;
@@ -1332,6 +1343,13 @@ public sealed class ChatLogWindow : Window, IUiComponent
private unsafe int Callback(ImGuiInputTextCallbackData* data)
{
// We play the opening sound here only if closing sound has been played before
if (Plugin.Config.PlaySounds && PlayedClosingSound)
{
PlayedClosingSound = false;
UIModule.PlaySound(ChatOpenSfx);
}
var ptr = new ImGuiInputTextCallbackDataPtr(data);
if (data->EventFlag == ImGuiInputTextFlags.CallbackCompletion)
+3
View File
@@ -17,6 +17,9 @@ internal sealed class Display : ISettingsTab {
public void Draw(bool changed) {
ImGui.PushTextWrapPos();
ImGuiUtil.OptionCheckbox(ref Mutable.PlaySounds, Language.Options_PlaySounds_Name, Language.Options_PlaySounds_Description);
ImGui.Spacing();
ImGuiUtil.OptionCheckbox(ref Mutable.HideChat, Language.Options_HideChat_Name, Language.Options_HideChat_Description);
ImGui.Spacing();