diff --git a/Content.Client/ADT/Chemistry/UI/ReagentAnalyzerBoundUserInterface.cs b/Content.Client/ADT/Chemistry/UI/ReagentAnalyzerBoundUserInterface.cs new file mode 100644 index 00000000000..5e5658f5411 --- /dev/null +++ b/Content.Client/ADT/Chemistry/UI/ReagentAnalyzerBoundUserInterface.cs @@ -0,0 +1,71 @@ +using Content.Shared.Chemistry; +using Content.Shared.Containers.ItemSlots; +using JetBrains.Annotations; +using Robust.Client.GameObjects; +using Content.Shared.ADT.Chemistry; + +namespace Content.Client.ADT.Chemistry.UI +{ + /// + /// Initializes a and updates it when new server messages are received. + /// + [UsedImplicitly] + public sealed class ReagentAnalyzerBoundUserInterface : BoundUserInterface + { + [ViewVariables] + private ReagentAnalyzerWindow? _window; + + + public ReagentAnalyzerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + } + + /// + /// Called each time an analyzer UI instance is opened. Generates the dispenser window and fills it with + /// relevant info. Sets the actions for static buttons. + /// + protected override void Open() + { + base.Open(); + + // Setup window layout/elements + _window = new() + { + Title = EntMan.GetComponent(Owner).EntityName, + }; + + _window.OpenCentered(); + _window.OnClose += Close; + + // Setup static button actions. + _window.EjectButton.OnPressed += _ => SendMessage(new ItemSlotButtonPressedEvent(SharedReagentAnalyzer.OutputSlotName)); + _window.ClearButton.OnPressed += _ => SendMessage(new ReagentAnalyzerClearContainerSolutionMessage()); + } + + /// + /// Update the UI each time new state data is sent from the server. + /// + /// + /// Data of the that this UI represents. + /// Sent from the server. + /// + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + var castState = (ReagentAnalyzerBoundUserInterfaceState) state; + + _window?.UpdateState(castState); //Update window state + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + if (disposing) + { + _window?.Dispose(); + } + } + } +} \ No newline at end of file diff --git a/Content.Client/ADT/Chemistry/UI/ReagentAnalyzerWindow.xaml b/Content.Client/ADT/Chemistry/UI/ReagentAnalyzerWindow.xaml new file mode 100644 index 00000000000..895329b587f --- /dev/null +++ b/Content.Client/ADT/Chemistry/UI/ReagentAnalyzerWindow.xaml @@ -0,0 +1,35 @@ + + + + +