Implement sounds on interaction
This commit is contained in:
@@ -38,6 +38,7 @@ internal class Configuration : IPluginConfiguration
|
|||||||
public bool SharedMode;
|
public bool SharedMode;
|
||||||
public bool SortAutoTranslate;
|
public bool SortAutoTranslate;
|
||||||
public bool CollapseDuplicateMessages;
|
public bool CollapseDuplicateMessages;
|
||||||
|
public bool PlaySounds = true;
|
||||||
|
|
||||||
public bool FontsEnabled = true;
|
public bool FontsEnabled = true;
|
||||||
public ExtraGlyphRanges ExtraGlyphRanges = 0;
|
public ExtraGlyphRanges ExtraGlyphRanges = 0;
|
||||||
@@ -83,6 +84,7 @@ internal class Configuration : IPluginConfiguration
|
|||||||
SharedMode = other.SharedMode;
|
SharedMode = other.SharedMode;
|
||||||
SortAutoTranslate = other.SortAutoTranslate;
|
SortAutoTranslate = other.SortAutoTranslate;
|
||||||
CollapseDuplicateMessages = other.CollapseDuplicateMessages;
|
CollapseDuplicateMessages = other.CollapseDuplicateMessages;
|
||||||
|
PlaySounds = other.PlaySounds;
|
||||||
FontsEnabled = other.FontsEnabled;
|
FontsEnabled = other.FontsEnabled;
|
||||||
ExtraGlyphRanges = other.ExtraGlyphRanges;
|
ExtraGlyphRanges = other.ExtraGlyphRanges;
|
||||||
FontSize = other.FontSize;
|
FontSize = other.FontSize;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using Dalamud.Interface.Internal;
|
|||||||
using Dalamud.Interface.Internal.Notifications;
|
using Dalamud.Interface.Internal.Notifications;
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Lumina.Excel;
|
using Lumina.Excel;
|
||||||
@@ -40,6 +41,8 @@ public sealed class PayloadHandler {
|
|||||||
private readonly ExcelSheet<TerritoryType> TerritorySheet;
|
private readonly ExcelSheet<TerritoryType> TerritorySheet;
|
||||||
private readonly ExcelSheet<EventItemHelp> EventItemHelpSheet;
|
private readonly ExcelSheet<EventItemHelp> EventItemHelpSheet;
|
||||||
|
|
||||||
|
private uint PopupSfx = 1u;
|
||||||
|
|
||||||
internal PayloadHandler(ChatLogWindow logWindow)
|
internal PayloadHandler(ChatLogWindow logWindow)
|
||||||
{
|
{
|
||||||
LogWindow = logWindow;
|
LogWindow = logWindow;
|
||||||
@@ -206,6 +209,9 @@ public sealed class PayloadHandler {
|
|||||||
|
|
||||||
internal void Click(Chunk chunk, Payload? payload, ImGuiMouseButton button)
|
internal void Click(Chunk chunk, Payload? payload, ImGuiMouseButton button)
|
||||||
{
|
{
|
||||||
|
if (LogWindow.Plugin.Config.PlaySounds)
|
||||||
|
UIModule.PlaySound(PopupSfx);
|
||||||
|
|
||||||
switch (button)
|
switch (button)
|
||||||
{
|
{
|
||||||
case ImGuiMouseButton.Left:
|
case ImGuiMouseButton.Left:
|
||||||
@@ -408,6 +414,9 @@ public sealed class PayloadHandler {
|
|||||||
case URIPayload uri:
|
case URIPayload uri:
|
||||||
TryOpenURI(uri.Uri);
|
TryOpenURI(uri.Uri);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
RightClickPayload(chunk, payload);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Generated
+18
@@ -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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Display messages in a more modern style..
|
/// Looks up a localized string similar to Display messages in a more modern style..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -988,4 +988,10 @@
|
|||||||
<data name="Options_OverrideStyle_NotAvailable" xml:space="preserve">
|
<data name="Options_OverrideStyle_NotAvailable" xml:space="preserve">
|
||||||
<value>No dalamud styles available</value>
|
<value>No dalamud styles available</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ using Dalamud.Interface.Style;
|
|||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
using Dalamud.Memory;
|
using Dalamud.Memory;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
@@ -73,6 +74,10 @@ public sealed class ChatLogWindow : Window, IUiComponent
|
|||||||
private Dictionary<string, ChatType> TextCommandChannels { get; } = new();
|
private Dictionary<string, ChatType> TextCommandChannels { get; } = new();
|
||||||
private HashSet<string> AllCommands { 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")
|
internal ChatLogWindow(Plugin plugin) : base($"{Plugin.PluginName}###chat2")
|
||||||
{
|
{
|
||||||
Plugin = plugin;
|
Plugin = plugin;
|
||||||
@@ -195,6 +200,10 @@ public sealed class ChatLogWindow : Window, IUiComponent
|
|||||||
|
|
||||||
if (info.Text != null && Chat.Length == 0)
|
if (info.Text != null && Chat.Length == 0)
|
||||||
Chat = info.Text;
|
Chat = info.Text;
|
||||||
|
|
||||||
|
PlayedClosingSound = false;
|
||||||
|
if (Plugin.Config.PlaySounds)
|
||||||
|
UIModule.PlaySound(ChatOpenSfx);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsValidCommand(string command)
|
private bool IsValidCommand(string command)
|
||||||
@@ -562,11 +571,7 @@ public sealed class ChatLogWindow : Window, IUiComponent
|
|||||||
ImGui.OpenPopup(ChatChannelPicker);
|
ImGui.OpenPopup(ChatChannelPicker);
|
||||||
|
|
||||||
if (activeTab is { Channel: { } } && ImGui.IsItemHovered())
|
if (activeTab is { Channel: { } } && ImGui.IsItemHovered())
|
||||||
{
|
ImGui.SetTooltip(Language.ChatLog_SwitcherDisabled);
|
||||||
ImGui.BeginTooltip();
|
|
||||||
ImGui.TextUnformatted(Language.ChatLog_SwitcherDisabled);
|
|
||||||
ImGui.EndTooltip();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.BeginPopup(ChatChannelPicker))
|
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
|
// Only trigger unfocused if we are currently not calling the auto complete
|
||||||
if (!Activate && !ImGui.IsItemActive() && _autoCompleteInfo == null)
|
if (!Activate && !ImGui.IsItemActive() && _autoCompleteInfo == null)
|
||||||
{
|
{
|
||||||
|
if (Plugin.Config.PlaySounds && !PlayedClosingSound)
|
||||||
|
{
|
||||||
|
PlayedClosingSound = true;
|
||||||
|
UIModule.PlaySound(ChatCloseSfx);
|
||||||
|
}
|
||||||
|
|
||||||
if (_tempChannel is InputChannel.Tell)
|
if (_tempChannel is InputChannel.Tell)
|
||||||
_tellTarget = null;
|
_tellTarget = null;
|
||||||
|
|
||||||
@@ -1332,6 +1343,13 @@ public sealed class ChatLogWindow : Window, IUiComponent
|
|||||||
|
|
||||||
private unsafe int Callback(ImGuiInputTextCallbackData* data)
|
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);
|
var ptr = new ImGuiInputTextCallbackDataPtr(data);
|
||||||
|
|
||||||
if (data->EventFlag == ImGuiInputTextFlags.CallbackCompletion)
|
if (data->EventFlag == ImGuiInputTextFlags.CallbackCompletion)
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ internal sealed class Display : ISettingsTab {
|
|||||||
public void Draw(bool changed) {
|
public void Draw(bool changed) {
|
||||||
ImGui.PushTextWrapPos();
|
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);
|
ImGuiUtil.OptionCheckbox(ref Mutable.HideChat, Language.Options_HideChat_Name, Language.Options_HideChat_Description);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user