From 7b5b033c57678667ae9d5dd5c756f83602587526 Mon Sep 17 00:00:00 2001 From: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Date: Sat, 18 Jan 2025 16:03:16 -0400 Subject: [PATCH] ChemMaster+ (#1585) Changes how the ChemMaster works: 1. Removes the amount buttons and instead uses a textbox that resets whenever a value is entered or focus ends. 2. Shrinks the ChemMaster again. 3. Adds sorting options, including for quantity, last added, and a sort option for the (default) alphabetical order. 4. Sorting options save via the ChemMaster itself, not per-user. Video showcase: https://discord.com/channels/1218698320155906090/1218698321053356060/1330129166384894046 --- :cl: - add: Added sorting options to the ChemMaster. - add: Added the ability to input custom amounts into the ChemMaster via a textbox that resets on change. - tweak: The width of the ChemMaster UI has been lowered. - remove: Removed quantity buttons from the ChemMaster. --------- Co-authored-by: VMSolidus --- .../UI/ChemMasterBoundUserInterface.cs | 13 +- .../Chemistry/UI/ChemMasterWindow.xaml | 16 +- .../Chemistry/UI/ChemMasterWindow.xaml.cs | 224 +++++++++++++++--- .../Components/ChemMasterComponent.cs | 6 + .../EntitySystems/ChemMasterSystem.cs | 46 +++- Content.Shared/Chemistry/SharedChemMaster.cs | 29 ++- .../components/chem-master-component.ftl | 10 + 7 files changed, 284 insertions(+), 60 deletions(-) diff --git a/Content.Client/Chemistry/UI/ChemMasterBoundUserInterface.cs b/Content.Client/Chemistry/UI/ChemMasterBoundUserInterface.cs index 793c4694832..f429511d318 100644 --- a/Content.Client/Chemistry/UI/ChemMasterBoundUserInterface.cs +++ b/Content.Client/Chemistry/UI/ChemMasterBoundUserInterface.cs @@ -10,15 +10,11 @@ namespace Content.Client.Chemistry.UI /// Initializes a and updates it when new server messages are received. /// [UsedImplicitly] - public sealed class ChemMasterBoundUserInterface : BoundUserInterface + public sealed class ChemMasterBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey) { [ViewVariables] private ChemMasterWindow? _window; - public ChemMasterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) - { - } - /// /// Called each time a chem master UI instance is opened. Generates the window and fills it with /// relevant info. Sets the actions for static buttons. @@ -49,7 +45,11 @@ protected override void Open() _window.PillTypeButtons[i].OnPressed += _ => SendMessage(new ChemMasterSetPillTypeMessage(pillType)); } - _window.OnReagentButtonPressed += (args, button) => SendMessage(new ChemMasterReagentAmountButtonMessage(button.Id, button.Amount, button.IsBuffer)); + _window.OnReagentButtonPressed += (_, button, amount) => SendMessage(new ChemMasterReagentAmountButtonMessage(button.Id, amount, button.IsBuffer)); + _window.OnSortMethodChanged += sortMethod => SendMessage(new ChemMasterSortMethodUpdated(sortMethod)); + _window.OnTransferAmountChanged += amount => SendMessage(new ChemMasterTransferringAmountUpdated(amount)); + + } /// @@ -64,7 +64,6 @@ protected override void UpdateState(BoundUserInterfaceState state) base.UpdateState(state); var castState = (ChemMasterBoundUserInterfaceState) state; - _window?.UpdateState(castState); // Update window state } } diff --git a/Content.Client/Chemistry/UI/ChemMasterWindow.xaml b/Content.Client/Chemistry/UI/ChemMasterWindow.xaml index 04ee58f10c2..788b018d4d4 100644 --- a/Content.Client/Chemistry/UI/ChemMasterWindow.xaml +++ b/Content.Client/Chemistry/UI/ChemMasterWindow.xaml @@ -2,7 +2,7 @@ xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" - MinSize="620 670" + MinSize="500 770" Title="{Loc 'chem-master-bound-user-interface-title'}"> @@ -10,7 +10,9 @@