Files
space-station-14/Content.Client/VoiceMask/VoiceMaskBoundUserInterface.cs
alexalexmax 4ff7411fb7 Voice mask effects are toggleable and hide your accent (#41965)
* apply negate accents system

* add toggle to voice mask ui

* roll negateaccents into voice mask system, delete negate accents comp&system, update yml entries

* convert button to ToggleButton and some cleanup

* retry for heisenfail

* accent toggle

* update names and add mask active check for accent hiding
2025-12-26 02:47:05 +00:00

65 lines
1.6 KiB
C#

using Content.Shared.VoiceMask;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Shared.Prototypes;
namespace Content.Client.VoiceMask;
public sealed class VoiceMaskBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IPrototypeManager _protomanager = default!;
[ViewVariables]
private VoiceMaskNameChangeWindow? _window;
public VoiceMaskBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = this.CreateWindow<VoiceMaskNameChangeWindow>();
_window.ReloadVerbs(_protomanager);
_window.AddVerbs();
_window.OnNameChange += OnNameSelected;
_window.OnVerbChange += verb => SendMessage(new VoiceMaskChangeVerbMessage(verb));
_window.OnToggle += OnToggle;
_window.OnAccentToggle += OnAccentToggle;
}
private void OnNameSelected(string name)
{
SendMessage(new VoiceMaskChangeNameMessage(name));
}
private void OnToggle()
{
SendMessage(new VoiceMaskToggleMessage());
}
private void OnAccentToggle()
{
SendMessage(new VoiceMaskAccentToggleMessage());
}
protected override void UpdateState(BoundUserInterfaceState state)
{
if (state is not VoiceMaskBuiState cast || _window == null)
{
return;
}
_window.UpdateState(cast.Name, cast.Verb, cast.Active, cast.AccentHide);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Close();
}
}