From 18e1b0491de404830d1eb49266c48b0b5082ae74 Mon Sep 17 00:00:00 2001 From: ReeZer2 <63300653+ReeZer2@users.noreply.github.com> Date: Sun, 9 Mar 2025 15:20:48 +0200 Subject: [PATCH] ADD: Activatable UI for Pinpointer (#2664) --- .../UI/PinpointerBoundUserInterface.cs | 89 ++++++++++ .../SS220/Pinpointer/UI/PinpointerMenu.xaml | 17 ++ .../Pinpointer/UI/PinpointerMenu.xaml.cs | 75 ++++++++ .../Pinpointer/UI/PinpointerUplinkMenu.xaml | 29 ++++ .../UI/PinpointerUplinkMenu.xaml.cs | 129 ++++++++++++++ .../SS220/Pinpointer/PinpointerSystem.cs | 161 ++++++++++++++++++ .../SS220/Pinpointer/TrackedItemComponent.cs | 8 + .../Pinpointer/PinpointerComponent.cs | 34 ++++ .../SS220/Pinpointer/PinpointerEvents.cs | 79 +++++++++ .../entities/devices/pinpointer.ftl | 11 ++ .../ru-RU/ss220/research/technologies.ftl | 1 + .../ru-RU/ss220/store/uplink-catalog.ftl | 2 + .../Catalog/Fills/Lockers/medical.yml | 1 + .../Clothing/OuterClothing/hardsuits.yml | 3 + .../Entities/Clothing/Shoes/magboots.yml | 3 + .../Objects/Devices/hand_teleporter.yml | 3 + .../Entities/Objects/Misc/dat_fukken_disk.yml | 3 + .../Medical/handheld_crew_monitor.yml | 3 + .../Objects/Specific/Medical/hypospray.yml | 3 + .../Entities/Objects/Tools/jetpacks.yml | 3 + .../Weapons/Guns/Battery/battery_guns.yml | 3 + .../Entities/Structures/Machines/lathe.yml | 1 + .../SS220/Catalog/Fills/Lockers/command.yml | 1 + .../SS220/Catalog/uplink_catalog.yml | 11 ++ .../OuterClothing/reactive_armor_rd.yml | 23 +-- .../Entities/Objects/Devices/pinpointer.yml | 56 ++++++ .../Objects/Misc/secret_documents.yml | 1 + .../SS220/Entities/Objects/Tools/rcd-ce.yml | 3 +- .../Weapons/Guns/multiphase_energy_gun.yml | 1 + .../SS220/Recipes/Lathes/Packs/medical.yml | 4 + .../SS220/Recipes/Lathes/devices.yml | 10 ++ .../SS220/Research/civilianservices.yml | 12 ++ 32 files changed, 771 insertions(+), 12 deletions(-) create mode 100644 Content.Client/SS220/Pinpointer/UI/PinpointerBoundUserInterface.cs create mode 100644 Content.Client/SS220/Pinpointer/UI/PinpointerMenu.xaml create mode 100644 Content.Client/SS220/Pinpointer/UI/PinpointerMenu.xaml.cs create mode 100644 Content.Client/SS220/Pinpointer/UI/PinpointerUplinkMenu.xaml create mode 100644 Content.Client/SS220/Pinpointer/UI/PinpointerUplinkMenu.xaml.cs create mode 100644 Content.Server/SS220/Pinpointer/PinpointerSystem.cs create mode 100644 Content.Server/SS220/Pinpointer/TrackedItemComponent.cs create mode 100644 Content.Shared/SS220/Pinpointer/PinpointerEvents.cs create mode 100644 Resources/Locale/ru-RU/ss220/prototypes/entities/devices/pinpointer.ftl create mode 100644 Resources/Prototypes/SS220/Recipes/Lathes/Packs/medical.yml 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 @@ + + + + +