2021-08-22 03:20:18 +10:00
|
|
|
using Content.Shared.Chemistry;
|
2024-08-02 01:20:36 +00:00
|
|
|
using Content.Shared.Chemistry.Components;
|
2021-11-03 16:48:03 -07:00
|
|
|
using Content.Shared.FixedPoint;
|
2021-07-25 00:53:53 -07:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Client.GameObjects;
|
2024-07-21 14:48:13 +10:00
|
|
|
using Robust.Client.UserInterface;
|
2021-07-25 00:53:53 -07:00
|
|
|
|
|
|
|
|
namespace Content.Client.Chemistry.UI
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class TransferAmountBoundUserInterface : BoundUserInterface
|
2021-07-25 00:53:53 -07:00
|
|
|
{
|
2024-08-02 01:20:36 +00:00
|
|
|
private IEntityManager _entManager;
|
|
|
|
|
private EntityUid _owner;
|
2023-07-08 09:02:17 -07:00
|
|
|
[ViewVariables]
|
2021-07-25 00:53:53 -07:00
|
|
|
private TransferAmountWindow? _window;
|
|
|
|
|
|
2023-07-08 09:02:17 -07:00
|
|
|
public TransferAmountBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
|
|
|
{
|
2024-08-02 01:20:36 +00:00
|
|
|
_owner = owner;
|
|
|
|
|
_entManager = IoCManager.Resolve<IEntityManager>();
|
2023-07-08 09:02:17 -07:00
|
|
|
}
|
|
|
|
|
|
2021-07-25 00:53:53 -07:00
|
|
|
protected override void Open()
|
|
|
|
|
{
|
|
|
|
|
base.Open();
|
2024-07-21 14:48:13 +10:00
|
|
|
_window = this.CreateWindow<TransferAmountWindow>();
|
2021-07-25 00:53:53 -07:00
|
|
|
|
2024-08-02 01:20:36 +00:00
|
|
|
if (_entManager.TryGetComponent<SolutionTransferComponent>(_owner, out var comp))
|
|
|
|
|
_window.SetBounds(comp.MinimumTransferAmount.Int(), comp.MaximumTransferAmount.Int());
|
|
|
|
|
|
2021-10-28 14:23:17 +02:00
|
|
|
_window.ApplyButton.OnPressed += _ =>
|
2021-07-25 00:53:53 -07:00
|
|
|
{
|
2021-10-28 14:23:17 +02:00
|
|
|
if (int.TryParse(_window.AmountLineEdit.Text, out var i))
|
2021-07-25 00:53:53 -07:00
|
|
|
{
|
2021-11-03 16:48:03 -07:00
|
|
|
SendMessage(new TransferAmountSetValueMessage(FixedPoint2.New(i)));
|
2021-07-25 00:53:53 -07:00
|
|
|
_window.Close();
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-11-26 16:37:18 +13:00
|
|
|
}
|
2021-07-25 00:53:53 -07:00
|
|
|
}
|
|
|
|
|
}
|