diff --git a/Content.Client/SS220/Pinpointer/UI/PinpointerBoundUserInterface.cs b/Content.Client/SS220/Pinpointer/UI/PinpointerBoundUserInterface.cs new file mode 100644 index 000000000000..fdf9f2254a57 --- /dev/null +++ b/Content.Client/SS220/Pinpointer/UI/PinpointerBoundUserInterface.cs @@ -0,0 +1,89 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt + +using Content.Shared.Pinpointer; +using Content.Shared.SS220.Pinpointer; +using JetBrains.Annotations; +using Robust.Client.UserInterface; + +namespace Content.Client.SS220.Pinpointer.UI; + +[UsedImplicitly] +public sealed partial class PinpointerBoundUserInterface : BoundUserInterface +{ + private PinpointerMenu? _crewMenu; + private PinpointerUplinkMenu? _itemMenu; + + public PinpointerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + switch (state) + { + case PinpointerCrewUIState crewState: + if (_crewMenu == null) + return; + + _crewMenu.CrewListCoords = crewState.Sensors; + _crewMenu.PopulateList(); + break; + + case PinpointerItemUIState itemState: + if (_itemMenu == null) + return; + + _itemMenu.ItemListSet = itemState.Items; + _itemMenu.PopulateList(); + break; + } + } + + protected override void Open() + { + base.Open(); + + if (!EntMan.TryGetComponent(Owner, out var pinpointer)) + return; + + switch (pinpointer.Mode) + { + case PinpointerMode.Crew: + { + _crewMenu = this.CreateWindow(); + _crewMenu.OnTargetPicked = OnTargetPicked; + _crewMenu.PopulateList(); + break; + } + + case PinpointerMode.Item: + { + _itemMenu = this.CreateWindow(); + _itemMenu.OnTargetPicked = OnTargetPicked; + _itemMenu.OnDnaPicked = OnDnaPicked; + _itemMenu.PopulateList(); + break; + } + } + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + _crewMenu?.Close(); + _itemMenu?.Close(); + _itemMenu?.DnaWindow?.Close(); + } + + private void OnTargetPicked(NetEntity target) + { + SendMessage(new PinpointerTargetPick(target)); + } + + private void OnDnaPicked(string? dna) + { + SendMessage(new PinpointerDnaPick(dna)); + } +} diff --git a/Content.Client/SS220/Pinpointer/UI/PinpointerMenu.xaml b/Content.Client/SS220/Pinpointer/UI/PinpointerMenu.xaml new file mode 100644 index 000000000000..154e3ed27252 --- /dev/null +++ b/Content.Client/SS220/Pinpointer/UI/PinpointerMenu.xaml @@ -0,0 +1,17 @@ + + + + + + diff --git a/Content.Client/SS220/Pinpointer/UI/PinpointerMenu.xaml.cs b/Content.Client/SS220/Pinpointer/UI/PinpointerMenu.xaml.cs new file mode 100644 index 000000000000..16b4d5178925 --- /dev/null +++ b/Content.Client/SS220/Pinpointer/UI/PinpointerMenu.xaml.cs @@ -0,0 +1,75 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt + +using Content.Client.UserInterface.Controls; +using Content.Shared.SS220.Pinpointer; +using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.XAML; + +namespace Content.Client.SS220.Pinpointer.UI; + +[GenerateTypedNameReferences] +public sealed partial class PinpointerMenu : FancyWindow +{ + public Action? OnTargetPicked; + + public HashSet CrewListCoords = []; + + private string _searchText = string.Empty; + + public PinpointerMenu() + { + RobustXamlLoader.Load(this); + IoCManager.InjectDependencies(this); + + SearchBar.OnTextChanged += OnSearchChanged; + } + + private void OnSearchChanged(LineEdit.LineEditEventArgs args) + { + _searchText = args.Text.Trim().ToLower(); + PopulateList(); + } + + public void PopulateList() + { + CrewList.RemoveAllChildren(); + + foreach (var entry in CrewListCoords) + { + var button = CreateTargetButton(entry.Name, () => OnTargetPicked?.Invoke(entry.Entity)); + + if (button == null) + continue; + + CrewList.AddChild(button); + } + } + + private Button? CreateTargetButton(string fullName, Action onClick) + { + if (!fullName.Contains(_searchText, StringComparison.CurrentCultureIgnoreCase)) + return null; + + var button = new Button + { + ToolTip = fullName, + StyleClasses = { "OpenBoth" }, + SetHeight = 30, + Margin = new Thickness(5, 0, 5, 5), + HorizontalExpand = true, + }; + + var label = new Label + { + Text = fullName, + HorizontalExpand = true, + HorizontalAlignment = HAlignment.Center, + }; + + button.OnPressed += _ => onClick(); + button.AddChild(label); + + return button; + } +} diff --git a/Content.Client/SS220/Pinpointer/UI/PinpointerUplinkMenu.xaml b/Content.Client/SS220/Pinpointer/UI/PinpointerUplinkMenu.xaml new file mode 100644 index 000000000000..adb4f9863ca1 --- /dev/null +++ b/Content.Client/SS220/Pinpointer/UI/PinpointerUplinkMenu.xaml @@ -0,0 +1,29 @@ + + + + +