Voice mask (#10458)
This commit is contained in:
46
Content.Client/VoiceMask/VoiceMaskBoundUserInterface.cs
Normal file
46
Content.Client/VoiceMask/VoiceMaskBoundUserInterface.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
11
Content.Client/VoiceMask/VoiceMaskNameChangeWindow.xaml
Normal file
11
Content.Client/VoiceMask/VoiceMaskNameChangeWindow.xaml
Normal 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>
|
||||
26
Content.Client/VoiceMask/VoiceMaskNameChangeWindow.xaml.cs
Normal file
26
Content.Client/VoiceMask/VoiceMaskNameChangeWindow.xaml.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user