diff --git a/Content.Client/_NF/Chemistry/UI/ChemPrenticeBoundUserInterface.cs b/Content.Client/_NF/Chemistry/UI/ChemPrenticeBoundUserInterface.cs new file mode 100644 index 00000000000..d10d645c17d --- /dev/null +++ b/Content.Client/_NF/Chemistry/UI/ChemPrenticeBoundUserInterface.cs @@ -0,0 +1,63 @@ +using Content.Client.Chemistry.UI; +using Content.Shared._NF.Chemistry; +using Content.Shared.Chemistry; +using Content.Shared.Containers.ItemSlots; +using JetBrains.Annotations; +using Robust.Client.GameObjects; +using Robust.Client.UserInterface; + +namespace Content.Client._NF.Chemistry.UI +{ + /// + /// Initializes a and updates it when new server messages are received. + /// + [UsedImplicitly] + public sealed class ChemPrenticeBoundUserInterface : BoundUserInterface + { + [ViewVariables] + private ChemPrenticeWindow? _window; + + public ChemPrenticeBoundUserInterface(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. + /// + protected override void Open() + { + base.Open(); + + // Setup window layout/elements + _window = this.CreateWindow(); + _window.Title = EntMan.GetComponent(Owner).EntityName; + + // Setup static button actions. + _window.InputEjectButton.OnPressed += _ => SendMessage( + new ItemSlotButtonPressedEvent(SharedChemMaster.InputSlotName)); + _window.BufferTransferButton.OnPressed += _ => SendMessage( + new ChemMasterSetModeMessage(ChemMasterMode.Transfer)); + _window.BufferDiscardButton.OnPressed += _ => SendMessage( + new ChemMasterSetModeMessage(ChemMasterMode.Discard)); + + _window.OnReagentButtonPressed += (_, button) => SendMessage(new ChemMasterReagentAmountButtonMessage(button.Id, button.Amount, button.IsBuffer)); + } + + /// + /// 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 = (ChemPrenticeBoundUserInterfaceState)state; + + _window?.UpdateState(castState); // Update window state + } + } +} diff --git a/Content.Client/_NF/Chemistry/UI/ChemPrenticeWindow.xaml b/Content.Client/_NF/Chemistry/UI/ChemPrenticeWindow.xaml new file mode 100644 index 00000000000..370d200348f --- /dev/null +++ b/Content.Client/_NF/Chemistry/UI/ChemPrenticeWindow.xaml @@ -0,0 +1,53 @@ + + + + +