36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
// Cherry-picked from space-station-14#32938 courtesy of Ilya246
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
namespace Content.Client.Stack
|
|
{
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class StackCustomSplitWindow : DefaultWindow
|
|
{
|
|
private int _max = Int32.MaxValue;
|
|
private int _min = 1;
|
|
|
|
public StackCustomSplitWindow()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
AmountLineEdit.OnTextChanged += OnValueChanged;
|
|
}
|
|
|
|
public void SetMax(int max)
|
|
{
|
|
_max = max;
|
|
MaximumAmount.Text = Loc.GetString("comp-stack-split-size", ("size", _max));
|
|
}
|
|
|
|
private void OnValueChanged(LineEdit.LineEditEventArgs args)
|
|
{
|
|
if (!int.TryParse(AmountLineEdit.Text, out var amount) || amount > _max || amount < _min)
|
|
ApplyButton.Disabled = true;
|
|
else
|
|
ApplyButton.Disabled = false;
|
|
}
|
|
}
|
|
}
|