diff --git a/Content.Client/Chemistry/UI/ChemMasterBoundUserInterface.cs b/Content.Client/Chemistry/UI/ChemMasterBoundUserInterface.cs
index 3ef7f0ae73e..57bd34ed064 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.
@@ -53,7 +49,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));
+
+
}
///
@@ -68,7 +68,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 61bbba3c35f..94e7a0e84be 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 770"
+ MinSize="500 770"
Title="{Loc 'chem-master-bound-user-interface-title'}">
@@ -10,7 +10,9 @@
-
+
+
+
@@ -34,6 +36,7 @@
+
@@ -57,6 +60,8 @@
+
+
@@ -129,4 +134,4 @@
-
\ No newline at end of file
+
diff --git a/Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs b/Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs
index ec6d41bd32c..bba3533d614 100644
--- a/Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs
+++ b/Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs
@@ -24,9 +24,19 @@ namespace Content.Client.Chemistry.UI
public sealed partial class ChemMasterWindow : FancyWindow
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
- public event Action? OnReagentButtonPressed;
+ public event Action? OnReagentButtonPressed;
+ public event Action? OnSortMethodChanged;
+ public event Action? OnTransferAmountChanged;
public readonly Button[] PillTypeButtons;
+ private Dictionary _reagents;
+ private const string TransferringAmountColor = "#ffa500";
+ private ReagentSortMethod _currentSortMethod = ReagentSortMethod.Alphabetical;
+ private ChemMasterBoundUserInterfaceState? _lastState;
+ private string _lastAmountText = "50";
+ private int _transferAmount = 50;
+
+
private const string PillsRsiPath = "/Textures/Objects/Specific/Chemistry/pills.rsi";
///
@@ -38,6 +48,14 @@ public ChemMasterWindow()
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
+ _reagents = new();
+
+ InputAmountLineEdit.OnTextEntered += SetAmount;
+ InputAmountLineEdit.OnFocusExit += SetAmount;
+
+ OutputAmountLineEdit.OnTextEntered += SetAmount;
+ OutputAmountLineEdit.OnFocusExit += SetAmount;
+
// Pill type selection buttons, in total there are 20 pills.
// Pill rsi file should have states named as pill1, pill2, and so on.
var resourcePath = new ResPath(PillsRsiPath);
@@ -87,46 +105,118 @@ public ChemMasterWindow()
Tabs.SetTabTitle(0, Loc.GetString("chem-master-window-input-tab"));
Tabs.SetTabTitle(1, Loc.GetString("chem-master-window-output-tab"));
+
+ SortMethod.AddItem(
+ Loc.GetString("chem-master-window-sort-method-Alphabetical-text"),
+ (int) ReagentSortMethod.Alphabetical);
+ SortMethod.AddItem(Loc.GetString("chem-master-window-sort-method-Amount-text"), (int) ReagentSortMethod.Amount);
+ SortMethod.AddItem(Loc.GetString("chem-master-window-sort-method-Time-text"), (int) ReagentSortMethod.Time);
+ SortMethod.OnItemSelected += HandleChildPressed;
+
+ BufferTransferButton.OnPressed += HandleDiscardTransferPress;
+ BufferDiscardButton.OnPressed += HandleDiscardTransferPress;
+ }
+
+ private void HandleDiscardTransferPress(BaseButton.ButtonEventArgs args)
+ {
+ var buttons = BufferInfo.Children
+ .Where(c => c is Button)
+ .Cast