--- /dev/null
+<Control xmlns="https://spacestation14.io" HorizontalExpand="True">
+ <BoxContainer Name="MainContainer"
+ Orientation="Horizontal"
+ HorizontalExpand="True">
+ <PanelContainer Name="ColorPanel"
+ VerticalExpand="True"
+ SetWidth="7"
+ Margin="0 1 0 0" />
+ <Button Name="MainButton"
+ HorizontalExpand="True"
+ VerticalExpand="True"
+ StyleClasses="ButtonSquare"
+ Margin="-1 0 0 0">
+ <BoxContainer Orientation="Horizontal" HorizontalExpand="True">
+ <Label Name="BeaconNameLabel" />
+ </BoxContainer>
+ </Button>
+ </BoxContainer>
+</Control>
--- /dev/null
+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<StationMapBeaconControl>
+{
+ [Dependency] private readonly IEntityManager _entMan = default!;
+
+ public readonly EntityCoordinates BeaconPosition;
+ public Action<EntityCoordinates>? 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);
+ }
+}
_window = this.CreateWindow<StationMapWindow>();
_window.Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName;
+
+ string stationName = string.Empty;
+ if(EntMan.TryGetComponent<MetaDataComponent>(gridUid, out var gridMetaData))
+ {
+ stationName = gridMetaData.EntityName;
+ }
+
if (EntMan.TryGetComponent<StationMapComponent>(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);
}
}
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">
<BoxContainer Orientation="Vertical">
- <BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="0 8 0 10" VerticalAlignment="Top">
+ <!-- Station name -->
+ <controls:StripeBack>
+ <PanelContainer>
+ <Label Name="StationName" Text="Unknown station" StyleClasses="LabelBig" Align="Center"/>
+ </PanelContainer>
+ </controls:StripeBack>
+
+ <BoxContainer Orientation="Horizontal" HorizontalExpand="True" VerticalAlignment="Top">
<ui:NavMapControl Name="NavMapScreen"/>
+
+ <BoxContainer Orientation="Vertical" SetWidth="200">
+ <!-- Search bar -->
+ <LineEdit Name="FilterBar" PlaceHolder="{Loc 'station-map-filter-placeholder'}" Margin="0 0 10 10" HorizontalExpand="True"/>
+
+ <ScrollContainer HorizontalExpand="True" VerticalExpand="True">
+ <!-- Beacon Buttons (filled by code) -->
+ <BoxContainer Name="BeaconButtons" Orientation="Vertical" HorizontalExpand="True" />
+ </ScrollContainer>
+ </BoxContainer>
</BoxContainer>
<!-- Footer -->
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<StationMapBeaconControl> _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<NavMapComponent>(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
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