Added a directory to station maps (#31156)
* Added directory to station maps * Add null checks to map directory sorting/filtering * Reworked station map directory to be more readable and responsive
This commit is contained in:
50
Content.Client/Pinpointer/UI/StationMapBeaconControl.xaml.cs
Normal file
50
Content.Client/Pinpointer/UI/StationMapBeaconControl.xaml.cs
Normal file
@@ -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<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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user