diff --git a/Content.Client/Pinpointer/UI/StationMapBeaconControl.xaml b/Content.Client/Pinpointer/UI/StationMapBeaconControl.xaml new file mode 100644 index 0000000000..e1c55131cd --- /dev/null +++ b/Content.Client/Pinpointer/UI/StationMapBeaconControl.xaml @@ -0,0 +1,19 @@ + + + + + + diff --git a/Content.Client/Pinpointer/UI/StationMapBeaconControl.xaml.cs b/Content.Client/Pinpointer/UI/StationMapBeaconControl.xaml.cs new file mode 100644 index 0000000000..a4d4055c7d --- /dev/null +++ b/Content.Client/Pinpointer/UI/StationMapBeaconControl.xaml.cs @@ -0,0 +1,50 @@ +using Content.Shared.Pinpointer; +using Robust.Client.AutoGenerated; +using Robust.Client.Graphics; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.XAML; +using Robust.Shared.Map; + +namespace Content.Client.Pinpointer.UI; + +[GenerateTypedNameReferences] +public sealed partial class StationMapBeaconControl : Control, IComparable +{ + [Dependency] private readonly IEntityManager _entMan = default!; + + public readonly EntityCoordinates BeaconPosition; + public Action? OnPressed; + public string? Label => BeaconNameLabel.Text; + private StyleBoxFlat _styleBox; + public Color Color => _styleBox.BackgroundColor; + + public StationMapBeaconControl(EntityUid mapUid, SharedNavMapSystem.NavMapBeacon beacon) + { + RobustXamlLoader.Load(this); + IoCManager.InjectDependencies(this); + + BeaconPosition = new EntityCoordinates(mapUid, beacon.Position); + + _styleBox = new StyleBoxFlat { BackgroundColor = beacon.Color }; + ColorPanel.PanelOverride = _styleBox; + BeaconNameLabel.Text = beacon.Text; + + MainButton.OnPressed += args => OnPressed?.Invoke(BeaconPosition); + } + + public int CompareTo(StationMapBeaconControl? other) + { + if (other == null) + return 1; + + // Group by color + var colorCompare = Color.ToArgb().CompareTo(other.Color.ToArgb()); + if (colorCompare != 0) + { + return colorCompare; + } + + // If same color, sort by text + return string.Compare(Label, other.Label); + } +} diff --git a/Content.Client/Pinpointer/UI/StationMapBoundUserInterface.cs b/Content.Client/Pinpointer/UI/StationMapBoundUserInterface.cs index 91fb4ef71b..3d1eb1723c 100644 --- a/Content.Client/Pinpointer/UI/StationMapBoundUserInterface.cs +++ b/Content.Client/Pinpointer/UI/StationMapBoundUserInterface.cs @@ -24,9 +24,16 @@ public sealed class StationMapBoundUserInterface : BoundUserInterface _window = this.CreateWindow(); _window.Title = EntMan.GetComponent(Owner).EntityName; + + string stationName = string.Empty; + if(EntMan.TryGetComponent(gridUid, out var gridMetaData)) + { + stationName = gridMetaData.EntityName; + } + if (EntMan.TryGetComponent(Owner, out var comp) && comp.ShowLocation) - _window.Set(gridUid, Owner); + _window.Set(stationName, gridUid, Owner); else - _window.Set(gridUid, null); + _window.Set(stationName, gridUid, null); } } diff --git a/Content.Client/Pinpointer/UI/StationMapWindow.xaml b/Content.Client/Pinpointer/UI/StationMapWindow.xaml index 00424a3566..c79fc8f9e7 100644 --- a/Content.Client/Pinpointer/UI/StationMapWindow.xaml +++ b/Content.Client/Pinpointer/UI/StationMapWindow.xaml @@ -3,11 +3,28 @@ xmlns:ui="clr-namespace:Content.Client.Pinpointer.UI" Title="{Loc 'station-map-window-title'}" Resizable="False" - SetSize="668 713" - MinSize="668 713"> + SetSize="868 748" + MinSize="868 748"> - + + + + + + + + + + + + + + + + + diff --git a/Content.Client/Pinpointer/UI/StationMapWindow.xaml.cs b/Content.Client/Pinpointer/UI/StationMapWindow.xaml.cs index 7cbb8b7d0d..52ef2ab7da 100644 --- a/Content.Client/Pinpointer/UI/StationMapWindow.xaml.cs +++ b/Content.Client/Pinpointer/UI/StationMapWindow.xaml.cs @@ -3,24 +3,75 @@ using Content.Client.UserInterface.Controls; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.XAML; using Robust.Shared.Map; +using Content.Shared.Pinpointer; namespace Content.Client.Pinpointer.UI; [GenerateTypedNameReferences] public sealed partial class StationMapWindow : FancyWindow { + [Dependency] private readonly IEntityManager _entMan = default!; + + private readonly List _buttons = new(); + public StationMapWindow() { RobustXamlLoader.Load(this); + IoCManager.InjectDependencies(this); + + FilterBar.OnTextChanged += (bar) => OnFilterChanged(bar.Text); } - public void Set(EntityUid? mapUid, EntityUid? trackedEntity) + public void Set(string stationName, EntityUid? mapUid, EntityUid? trackedEntity) { NavMapScreen.MapUid = mapUid; if (trackedEntity != null) NavMapScreen.TrackedCoordinates.Add(new EntityCoordinates(trackedEntity.Value, Vector2.Zero), (true, Color.Cyan)); + if (!string.IsNullOrEmpty(stationName)) + { + StationName.Text = stationName; + } + NavMapScreen.ForceNavMapUpdate(); + UpdateBeaconList(mapUid); } -} + + public void OnFilterChanged(string newFilter) + { + foreach (var button in _buttons) + { + button.Visible = string.IsNullOrEmpty(newFilter) || ( + !string.IsNullOrEmpty(button.Label) && + button.Label.Contains(newFilter, StringComparison.OrdinalIgnoreCase) + ); + }; + } + + public void UpdateBeaconList(EntityUid? mapUid) + { + BeaconButtons.Children.Clear(); + _buttons.Clear(); + + if (!mapUid.HasValue) + return; + + if (!_entMan.TryGetComponent(mapUid, out var navMap)) + return; + + foreach (var beacon in navMap.Beacons.Values) + { + var button = new StationMapBeaconControl(mapUid.Value, beacon); + + button.OnPressed += NavMapScreen.CenterToCoordinates; + + _buttons.Add(button); + } + + _buttons.Sort(); + + foreach (var button in _buttons) + BeaconButtons.AddChild(button); + } +} \ No newline at end of file diff --git a/Resources/Locale/en-US/navmap-beacons/station_map.ftl b/Resources/Locale/en-US/navmap-beacons/station_map.ftl index 1563e0abaf..e252851556 100644 --- a/Resources/Locale/en-US/navmap-beacons/station_map.ftl +++ b/Resources/Locale/en-US/navmap-beacons/station_map.ftl @@ -1,6 +1,7 @@ station-map-window-title = Station map station-map-user-interface-flavor-left = Don't panic station-map-user-interface-flavor-right = v1.42 +station-map-filter-placeholder = Search by name nav-beacon-window-title = Station Beacon nav-beacon-toggle-visible = Visible