diff --git a/Content.Client/_DEN/Containers/EntitySystems/ContainerSelectionSystem.cs b/Content.Client/_DEN/Containers/EntitySystems/ContainerSelectionSystem.cs new file mode 100644 index 0000000000..631676e169 --- /dev/null +++ b/Content.Client/_DEN/Containers/EntitySystems/ContainerSelectionSystem.cs @@ -0,0 +1,6 @@ +using Content.Shared._DEN.Containers.EntitySystems; +using Content.Shared._DEN.Containers.Events; + +namespace Content.Client._DEN.Containers.EntitySystems; + +public sealed class ContainerSelectionSystem : SharedContainerSelectionSystem; diff --git a/Content.Client/_DEN/Containers/UI/ContainerSelectionBoundUserInterface.cs b/Content.Client/_DEN/Containers/UI/ContainerSelectionBoundUserInterface.cs new file mode 100644 index 0000000000..8dc8792b26 --- /dev/null +++ b/Content.Client/_DEN/Containers/UI/ContainerSelectionBoundUserInterface.cs @@ -0,0 +1,61 @@ +using Content.Client._DEN.Containers.EntitySystems; +using Content.Shared._DEN.Containers.Components; +using Content.Shared._DEN.Containers.Events; +using Content.Shared.EntityTable; +using JetBrains.Annotations; +using Robust.Client.Graphics; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.Prototypes; + +namespace Content.Client._DEN.Containers.UI; + +[UsedImplicitly] +public sealed class ContainerSelectionBoundUserInterface : BoundUserInterface +{ + private ContainerSelectionWindow? _window; + + public ContainerSelectionBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + IoCManager.InjectDependencies(this); + } + + protected override void Open() + { + base.Open(); + + if (!EntMan.TryGetComponent(Owner, out var entityTableSelectComp)) + return; + + _window = this.CreateWindow(); + var controls = ConvertToControls(entityTableSelectComp); + _window.SetControls(controls); + _window.OpenCentered(); + + } + + private IEnumerable ConvertToControls(EntityTableContainerSelectionComponent entityTableSelectComp) + { + var containers = new ContainerSelectionControl[entityTableSelectComp.Selections.Count]; + var containerIndex = 0; + + // Create a ContainerSelectionControl for each of the possible selections. + foreach (var selection in entityTableSelectComp.Selections) + { + var selectionControl = new ContainerSelectionControl(); + selectionControl.SetData(EntMan, selection.SelectionName, selection.Containers); + var curIndex = containerIndex; + selectionControl.ChooseButton.OnPressed += _ => MakeSelection(curIndex); + + containers[containerIndex++] = selectionControl; + } + + return containers; + } + + private void MakeSelection(int index) + { + SendMessage(new ContainerSelectionMessage(index)); + _window?.Close(); + } +} diff --git a/Content.Client/_DEN/Containers/UI/ContainerSelectionControl.xaml b/Content.Client/_DEN/Containers/UI/ContainerSelectionControl.xaml new file mode 100644 index 0000000000..09c1228906 --- /dev/null +++ b/Content.Client/_DEN/Containers/UI/ContainerSelectionControl.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + +