diff --git a/Content.Client/Ghost/UI/GhostTargetWindow.xaml.cs b/Content.Client/Ghost/UI/GhostTargetWindow.xaml.cs index c01bd17599..d5e67a6ed0 100644 --- a/Content.Client/Ghost/UI/GhostTargetWindow.xaml.cs +++ b/Content.Client/Ghost/UI/GhostTargetWindow.xaml.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Globalization; using Content.Shared.Ghost; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; @@ -34,11 +36,20 @@ namespace Content.Client.Ghost.UI private void AddButtonPlayers() { - foreach (var (key, value) in Players) + var sortedPlayers = new List<(string, EntityUid)>(Players.Count); + + foreach (var (key, player) in Players) + { + sortedPlayers.Add((player, key)); + } + + sortedPlayers.Sort((x, y) => string.Compare(x.Item1, y.Item1, StringComparison.Ordinal)); + + foreach (var (key, player) in sortedPlayers) { var currentButtonRef = new Button { - Text = value, + Text = key, TextAlign = Label.AlignMode.Right, HorizontalAlignment = HAlignment.Center, VerticalAlignment = VAlignment.Center, @@ -49,7 +60,7 @@ namespace Content.Client.Ghost.UI currentButtonRef.OnPressed += (_) => { - var msg = new GhostWarpToTargetRequestEvent(key); + var msg = new GhostWarpToTargetRequestEvent(player); _netManager.SendSystemNetworkMessage(msg); }; @@ -59,7 +70,11 @@ namespace Content.Client.Ghost.UI private void AddButtonLocations() { - foreach (var name in Locations) + // Server COULD send these sorted but how about we just use the client to do it instead. + var sortedLocations = new List(Locations); + sortedLocations.Sort((x, y) => string.Compare(x, y, StringComparison.Ordinal)); + + foreach (var name in sortedLocations) { var currentButtonRef = new Button {