Add Open/Close SFX to Window (#1298)

Co-authored-by: goat <16760685+goaaats@users.noreply.github.com>
This commit is contained in:
MidoriKami 2023-07-05 14:21:49 -07:00 committed by GitHub
parent 2cf3b93b64
commit e52f7696ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

View file

@ -207,6 +207,12 @@ internal sealed class DalamudConfiguration : IServiceType
/// Gets or sets a value indicating whether or not docking should be globally enabled in ImGui.
/// </summary>
public bool IsDocking { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not plugin user interfaces should trigger sound effects.
/// This setting is effected by the in-game "System Sounds" option and volume.
/// </summary>
public bool EnablePluginUISoundEffects { get; set; }
/// <summary>
/// Gets or sets a value indicating whether viewports should always be disabled.

View file

@ -101,6 +101,12 @@ public class SettingsTabLook : SettingsTab
Loc.Localize("DalamudSettingToggleDockingHint", "This will allow you to fuse and tab plugin windows."),
c => c.IsDocking,
(v, c) => c.IsDocking = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingEnablePluginUISoundEffects", "Enable sound effects for plugin windows"),
Loc.Localize("DalamudSettingEnablePluginUISoundEffectsHint", "This will allow you to enable or disable sound effects generated by plugin user interfaces.\nThis is affected by your in-game `System Sounds` volume settings."),
c => c.EnablePluginUISoundEffects,
(v, c) => c.EnablePluginUISoundEffects = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingToggleGamepadNavigation", "Control plugins via gamepad"),

View file

@ -2,6 +2,7 @@ using System.Numerics;
using Dalamud.Configuration.Internal;
using Dalamud.Game.ClientState.Keys;
using FFXIVClientStructs.FFXIV.Client.UI;
using ImGuiNET;
namespace Dalamud.Interface.Windowing;
@ -16,6 +17,7 @@ public abstract class Window
private bool internalLastIsOpen = false;
private bool internalIsOpen = false;
private bool nextFrameBringToFront = false;
private DalamudConfiguration Configuration;
/// <summary>
/// Initializes a new instance of the <see cref="Window"/> class.
@ -31,6 +33,7 @@ public abstract class Window
this.WindowName = name;
this.Flags = flags;
this.ForceMainWindow = forceMainWindow;
this.Configuration = Service<DalamudConfiguration>.Get();
}
/// <summary>
@ -55,6 +58,21 @@ public abstract class Window
/// </summary>
public bool RespectCloseHotkey { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether this window should not generate sound effects when opening and closing.
/// </summary>
public bool DisableWindowSounds { get; set; } = false;
/// <summary>
/// Gets or sets a value representing the sound effect id to be played when the window is opened.
/// </summary>
public uint OnOpenSfxId { get; set; } = 23u;
/// <summary>
/// Gets or sets a value representing the sound effect id to be played when the window is closed.
/// </summary>
public uint OnCloseSfxId { get; set; } = 24u;
/// <summary>
/// Gets or sets the position of this window.
/// </summary>
@ -219,6 +237,8 @@ public abstract class Window
this.OnClose();
this.IsFocused = false;
if (this.Configuration.EnablePluginUISoundEffects && !this.DisableWindowSounds) UIModule.PlaySound(this.OnCloseSfxId, 0, 0, 0);
}
return;
@ -243,6 +263,8 @@ public abstract class Window
{
this.internalLastIsOpen = this.internalIsOpen;
this.OnOpen();
if (this.Configuration.EnablePluginUISoundEffects && !this.DisableWindowSounds) UIModule.PlaySound(this.OnOpenSfxId, 0, 0, 0);
}
var wasFocused = this.IsFocused;