-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
6 changed files
with
152 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<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> |
50 changes: 50 additions & 0 deletions
50
Content.Client/Pinpointer/UI/StationMapBeaconControl.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters