* Fix handlabeler/utility belt misprediction * Partly moved HandLabelerSystem to shared And cleaned up HandLabelerComponent * WIP format the files so later commits look clearer Doesn't change individual code lines, but may move functions to another file * WIP some more code movement * Hand Labeler is now mostly predicted Only the UI isn't * WIP: Formatting and moved stuff * Using componentstates for prediction correction * review * Update label on label change * Don't overwrite label while editing --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com> Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using Robust.Client.UserInterface.CustomControls;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
namespace Content.Client.Labels.UI
|
|
{
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class HandLabelerWindow : DefaultWindow
|
|
{
|
|
public event Action<string>? OnLabelChanged;
|
|
|
|
/// <summary>
|
|
/// Is the user currently entering text into the control?
|
|
/// </summary>
|
|
private bool _focused;
|
|
// TODO LineEdit Make this a bool on the LineEdit control
|
|
|
|
private string _label = string.Empty;
|
|
|
|
public HandLabelerWindow()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
|
|
LabelLineEdit.OnTextEntered += e =>
|
|
{
|
|
_label = e.Text;
|
|
OnLabelChanged?.Invoke(_label);
|
|
};
|
|
|
|
LabelLineEdit.OnFocusEnter += _ => _focused = true;
|
|
LabelLineEdit.OnFocusExit += _ =>
|
|
{
|
|
_focused = false;
|
|
LabelLineEdit.Text = _label;
|
|
};
|
|
}
|
|
|
|
public void SetCurrentLabel(string label)
|
|
{
|
|
if (label == _label)
|
|
return;
|
|
|
|
_label = label;
|
|
if (!_focused)
|
|
LabelLineEdit.Text = label;
|
|
}
|
|
}
|
|
}
|