Adds hand labelers (#4903)

* Adds hand labelers

* Removes unnecessary thing

* Docs

* Reverts some changes

* Addresses comments and adds inhand sprites

* Addressed comments

Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>
This commit is contained in:
Watermelon914
2021-10-16 21:34:05 +01:00
committed by GitHub
parent 2ce5e5ee49
commit 4bf8a5d527
16 changed files with 390 additions and 1 deletions

View File

@@ -285,7 +285,9 @@ namespace Content.Client.Entry
"DeviceNetworkConnection",
"WiredNetworkConnection",
"WirelessNetworkConnection",
"GhostRadio"
"HandLabeler",
"Label",
"GhostRadio",
};
}
}

View File

@@ -0,0 +1,60 @@
using Content.Shared.HandLabeler;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.HandLabeler.UI
{
/// <summary>
/// Initializes a <see cref="HandLabelerWindow"/> and updates it when new server messages are received.
/// </summary>
public class HandLabelerBoundUserInterface : BoundUserInterface
{
private HandLabelerWindow? _window;
public HandLabelerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new HandLabelerWindow();
if (State != null)
UpdateState(State);
_window.OpenCentered();
_window.OnClose += Close;
_window.OnLabelEntered += OnLabelChanged;
}
private void OnLabelChanged(string newLabel)
{
SendMessage(new HandLabelerLabelChangedMessage(newLabel));
Close();
}
/// <summary>
/// Update the UI state based on server-sent info
/// </summary>
/// <param name="state"></param>
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (_window == null || state is not HandLabelerBoundUserInterfaceState cast)
return;
_window.SetCurrentLabel(cast.CurrentLabel);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing) return;
_window?.Dispose();
}
}
}

View File

@@ -0,0 +1,8 @@
<SS14Window xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Hand Labeler">
<BoxContainer Orientation="Vertical" SeparationOverride="4" MinWidth="150">
<Label Name="CurrentTextLabel" Text="{Loc 'hand-labeler-current-text-label'}" />
<LineEdit Name="LabelLineEdit" />
</BoxContainer>
</SS14Window>

View File

@@ -0,0 +1,26 @@
using System;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.HandLabeler.UI
{
[GenerateTypedNameReferences]
public partial class HandLabelerWindow : SS14Window
{
public event Action<string>? OnLabelEntered;
public HandLabelerWindow()
{
RobustXamlLoader.Load(this);
LabelLineEdit.OnTextEntered += e => OnLabelEntered?.Invoke(e.Text);
}
public void SetCurrentLabel(string label)
{
LabelLineEdit.Text = label;
}
}
}