diff --git a/Content.Client/Stack/StackCustomSplitBoundUserInterface.cs b/Content.Client/Stack/StackCustomSplitBoundUserInterface.cs new file mode 100644 index 00000000000..ff9a03580a9 --- /dev/null +++ b/Content.Client/Stack/StackCustomSplitBoundUserInterface.cs @@ -0,0 +1,41 @@ +// Cherry-picked from space-station-14#32938 courtesy of Ilya246 +using JetBrains.Annotations; +using Content.Shared.Stacks; +using Robust.Client.GameObjects; +using Robust.Client.UserInterface; + +namespace Content.Client.Stack +{ + [UsedImplicitly] + public sealed class StackCustomSplitBoundUserInterface : BoundUserInterface + { + private IEntityManager _entManager; + private EntityUid _owner; + [ViewVariables] + private StackCustomSplitWindow? _window; + + public StackCustomSplitBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + _owner = owner; + _entManager = IoCManager.Resolve(); + } + + protected override void Open() + { + base.Open(); + _window = this.CreateWindow(); + + if (_entManager.TryGetComponent(_owner, out var comp)) + _window.SetMax(comp.Count); + + _window.ApplyButton.OnPressed += _ => + { + if (int.TryParse(_window.AmountLineEdit.Text, out var i)) + { + SendMessage(new StackCustomSplitAmountMessage(i)); + _window.Close(); + } + }; + } + } +} diff --git a/Content.Client/Stack/StackCustomSplitWindow.xaml b/Content.Client/Stack/StackCustomSplitWindow.xaml new file mode 100644 index 00000000000..2294d459415 --- /dev/null +++ b/Content.Client/Stack/StackCustomSplitWindow.xaml @@ -0,0 +1,15 @@ + + + + + + + + + +