From d27164528e983946e9074ff16e4c58545985b88c Mon Sep 17 00:00:00 2001 From: mirrorcult Date: Sun, 25 Jul 2021 00:53:53 -0700 Subject: [PATCH] Add UI for setting solution transfer amount (#4074) * basic eui and window * finish EUI, update defaults * unnecessary usings * convert to bounduserinterface * merge me up merge me up inside * Fix repeated define for component in prototype * impl swept UI suggestion * apply discord reviews * small changes --- .../UI/TransferAmountBoundUserInterface.cs | 35 ++++ .../Chemistry/UI/TransferAmountWindow.xaml | 11 + .../Chemistry/UI/TransferAmountWindow.xaml.cs | 19 ++ .../Components/SolutionTransferComponent.cs | 194 +++++++++++++++++- .../Chemistry/SharedTransferAmount.cs | 37 ++++ Content.Shared/Verbs/VerbCategories.cs | 2 + .../solution-transfer-component.ftl | 23 ++- Resources/Locale/en-US/ui/transfer-amount.ftl | 13 ++ .../Consumable/Food/Containers/condiments.yml | 6 +- .../Objects/Consumable/Food/ingredients.yml | 1 - .../Entities/Objects/Consumable/drinks.yml | 12 +- .../Objects/Consumable/drinks_bottles.yml | 6 +- .../Objects/Consumable/drinks_cans.yml | 7 +- .../Objects/Consumable/drinks_cups.yml | 7 +- .../Objects/Consumable/trash_drinks.yml | 9 +- .../Objects/Specific/Janitorial/spray.yml | 1 - .../Objects/Specific/chemistry-bottles.yml | 7 +- .../Entities/Objects/Specific/chemistry.yml | 23 ++- .../Entities/Objects/Tools/bucket.yml | 7 + .../Guns/Ammunition/Cartridges/shotgun.yml | 1 + .../Entities/Objects/Weapons/Melee/spear.yml | 1 + 21 files changed, 393 insertions(+), 29 deletions(-) create mode 100644 Content.Client/Chemistry/UI/TransferAmountBoundUserInterface.cs create mode 100644 Content.Client/Chemistry/UI/TransferAmountWindow.xaml create mode 100644 Content.Client/Chemistry/UI/TransferAmountWindow.xaml.cs create mode 100644 Content.Shared/Chemistry/SharedTransferAmount.cs create mode 100644 Resources/Locale/en-US/ui/transfer-amount.ftl diff --git a/Content.Client/Chemistry/UI/TransferAmountBoundUserInterface.cs b/Content.Client/Chemistry/UI/TransferAmountBoundUserInterface.cs new file mode 100644 index 0000000000..03eb454372 --- /dev/null +++ b/Content.Client/Chemistry/UI/TransferAmountBoundUserInterface.cs @@ -0,0 +1,35 @@ +using Content.Shared.Chemistry; +using Content.Shared.Chemistry.Reagent; +using JetBrains.Annotations; +using Robust.Client.GameObjects; +using Robust.Shared.GameObjects; + +namespace Content.Client.Chemistry.UI +{ + [UsedImplicitly] + public class TransferAmountBoundUserInterface : BoundUserInterface + { + private TransferAmountWindow? _window; + + protected override void Open() + { + base.Open(); + _window = new TransferAmountWindow(); + + _window.applyButton.OnPressed += _ => + { + if (int.TryParse(_window.amountLineEdit.Text, out var i)) + { + SendMessage(new TransferAmountSetValueMessage(ReagentUnit.New(i))); + _window.Close(); + } + }; + + _window.OpenCentered(); + } + + public TransferAmountBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) + { + } + } +} diff --git a/Content.Client/Chemistry/UI/TransferAmountWindow.xaml b/Content.Client/Chemistry/UI/TransferAmountWindow.xaml new file mode 100644 index 0000000000..50716c563c --- /dev/null +++ b/Content.Client/Chemistry/UI/TransferAmountWindow.xaml @@ -0,0 +1,11 @@ + + + + + + +