Voice mask (#10458)

This commit is contained in:
Flipp Syder
2022-09-28 19:22:27 -07:00
committed by GitHub
parent 336e9ee609
commit 0385f1387c
18 changed files with 357 additions and 7 deletions

View File

@@ -0,0 +1,46 @@
using Content.Shared.VoiceMask;
using Robust.Client.GameObjects;
namespace Content.Client.VoiceMask;
public sealed class VoiceMaskBoundUserInterface : BoundUserInterface
{
public VoiceMaskBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
}
private VoiceMaskNameChangeWindow? _window;
protected override void Open()
{
base.Open();
_window = new();
_window.OpenCentered();
_window.OnNameChange += OnNameSelected;
_window.OnClose += Close;
}
private void OnNameSelected(string name)
{
SendMessage(new VoiceMaskChangeNameMessage(name));
}
protected override void UpdateState(BoundUserInterfaceState state)
{
if (state is not VoiceMaskBuiState cast || _window == null)
{
return;
}
_window.UpdateState(cast.Name);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Close();
}
}

View File

@@ -0,0 +1,11 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'voice-mask-name-change-window'}"
MinSize="5 20">
<BoxContainer Orientation="Vertical">
<Label Text="{Loc 'voice-mask-name-change-info'}" />
<BoxContainer Orientation="Horizontal">
<LineEdit Name="NameSelector" HorizontalExpand="True" />
<Button Name="NameSelectorSet" Text="{Loc 'voice-mask-name-change-set'}" />
</BoxContainer>
</BoxContainer>
</DefaultWindow>

View File

@@ -0,0 +1,26 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.VoiceMask;
[GenerateTypedNameReferences]
public sealed partial class VoiceMaskNameChangeWindow : DefaultWindow
{
public Action<string>? OnNameChange;
public VoiceMaskNameChangeWindow()
{
RobustXamlLoader.Load(this);
NameSelectorSet.OnPressed += _ =>
{
OnNameChange!(NameSelector.Text);
};
}
public void UpdateState(string name)
{
NameSelector.Text = name;
}
}