* Revert "Change keybindings for paper (#25853)"
This reverts commit 4b56996fcd.
* Add a save button to the paper editing UI instead.
58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using JetBrains.Annotations;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.Utility;
|
|
using static Content.Shared.Paper.SharedPaperComponent;
|
|
|
|
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 = new PaperWindow();
|
|
_window.OnClose += Close;
|
|
_window.OnSaved += Input_OnTextEntered;
|
|
|
|
if (EntMan.TryGetComponent<PaperVisualsComponent>(Owner, out var visuals))
|
|
{
|
|
_window.InitVisuals(Owner, visuals);
|
|
}
|
|
|
|
_window.OpenCentered();
|
|
}
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
{
|
|
base.UpdateState(state);
|
|
_window?.Populate((PaperBoundUserInterfaceState) state);
|
|
}
|
|
|
|
private void Input_OnTextEntered(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);
|
|
}
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
base.Dispose(disposing);
|
|
if (!disposing) return;
|
|
_window?.Dispose();
|
|
}
|
|
}
|