Files
tbd-station-14/Content.Client/Paper/UI/PaperBoundUserInterface.cs
Plykiya 01e1624567 Move PaperSystem to Shared (#30592)
* Fix paper system late localization

* IS THIS WHAT YOU WANT

* well I guess this is happening now

* fix the BUI

* did that even do anything before?

* again with the escapeformatting...

* Dirtying

* Move dirty to function

* Rename PaperSystem to PaperVisualizerSystem

* Fix namespace

* how many namespace changes must I suffer through

* SetContent is for Setting Content

* minor shuffling

* review

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2024-08-05 14:23:23 +10:00

49 lines
1.3 KiB
C#

using JetBrains.Annotations;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Utility;
using static Content.Shared.Paper.PaperComponent;
namespace Content.Client.Paper.UI;
[UsedImplicitly]
public sealed class PaperBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private PaperWindow? _window;
public PaperBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = this.CreateWindow<PaperWindow>();
_window.OnSaved += InputOnTextEntered;
if (EntMan.TryGetComponent<PaperVisualsComponent>(Owner, out var visuals))
{
_window.InitVisuals(Owner, visuals);
}
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
_window?.Populate((PaperBoundUserInterfaceState) state);
}
private void InputOnTextEntered(string text)
{
SendMessage(new PaperInputTextMessage(text));
if (_window != null)
{
_window.Input.TextRope = Rope.Leaf.Empty;
_window.Input.CursorPosition = new TextEdit.CursorPos(0, TextEdit.LineBreakBias.Top);
}
}
}