Skip to content

Commit

Permalink
Added MuteSounds property for BaseButton control (#5465)
Browse files Browse the repository at this point in the history
  • Loading branch information
stalengd committed Sep 28, 2024
1 parent c9d7d44 commit f467a70
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Robust.Client/UserInterface/Controls/BaseButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public abstract class BaseButton : Control
private bool _enableAllKeybinds;
private ButtonGroup? _group;
private bool _toggleMode;
private bool _muteSounds;

/// <summary>
/// Specifies the group this button belongs to.
Expand Down Expand Up @@ -135,7 +136,8 @@ public void SetClickPressed(bool value)
if (Pressed != value)
return;

UserInterfaceManager.ClickSound();
if (!MuteSounds)
UserInterfaceManager.ClickSound();
}

/// <summary>
Expand Down Expand Up @@ -199,6 +201,16 @@ public DrawModeEnum DrawMode
}
}

/// <summary>
/// If <c>true</c>, this button will not emit sounds when the mouse is pressed or hovered over.
/// </summary>
[ViewVariables]
public bool MuteSounds
{
get => _muteSounds;
set => _muteSounds = value;
}

/// <summary>
/// Fired when the button is pushed down by the mouse.
/// </summary>
Expand Down Expand Up @@ -298,7 +310,8 @@ protected internal override void KeyBindUp(GUIBoundKeyEventArgs args)
}
else
{
UserInterfaceManager.ClickSound();
if (!MuteSounds)
UserInterfaceManager.ClickSound();
}

OnPressed?.Invoke(buttonEventArgs);
Expand Down Expand Up @@ -353,7 +366,7 @@ protected internal override void MouseEntered()
{
base.MouseEntered();

if (!Disabled)
if (!Disabled && !MuteSounds)
{
UserInterfaceManager.HoverSound();
}
Expand Down

0 comments on commit f467a70

Please sign in to comment.