From f467a7027b66928480b3b6c81e62e4c9780cf2c3 Mon Sep 17 00:00:00 2001 From: Stalen <33173619+stalengd@users.noreply.github.com> Date: Sun, 29 Sep 2024 01:25:56 +0300 Subject: [PATCH] Added MuteSounds property for BaseButton control (#5465) --- .../UserInterface/Controls/BaseButton.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Robust.Client/UserInterface/Controls/BaseButton.cs b/Robust.Client/UserInterface/Controls/BaseButton.cs index c2802ef87ea..38027733b99 100644 --- a/Robust.Client/UserInterface/Controls/BaseButton.cs +++ b/Robust.Client/UserInterface/Controls/BaseButton.cs @@ -26,6 +26,7 @@ public abstract class BaseButton : Control private bool _enableAllKeybinds; private ButtonGroup? _group; private bool _toggleMode; + private bool _muteSounds; /// /// Specifies the group this button belongs to. @@ -135,7 +136,8 @@ public void SetClickPressed(bool value) if (Pressed != value) return; - UserInterfaceManager.ClickSound(); + if (!MuteSounds) + UserInterfaceManager.ClickSound(); } /// @@ -199,6 +201,16 @@ public DrawModeEnum DrawMode } } + /// + /// If true, this button will not emit sounds when the mouse is pressed or hovered over. + /// + [ViewVariables] + public bool MuteSounds + { + get => _muteSounds; + set => _muteSounds = value; + } + /// /// Fired when the button is pushed down by the mouse. /// @@ -298,7 +310,8 @@ protected internal override void KeyBindUp(GUIBoundKeyEventArgs args) } else { - UserInterfaceManager.ClickSound(); + if (!MuteSounds) + UserInterfaceManager.ClickSound(); } OnPressed?.Invoke(buttonEventArgs); @@ -353,7 +366,7 @@ protected internal override void MouseEntered() { base.MouseEntered(); - if (!Disabled) + if (!Disabled && !MuteSounds) { UserInterfaceManager.HoverSound(); }