Sort ghost warps (#6210)

This commit is contained in:
metalgearsloth
2022-01-18 06:22:17 +11:00
committed by GitHub
parent 2a70ba88f7
commit 167e6e5cb6

View File

@@ -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<string>(Locations);
sortedLocations.Sort((x, y) => string.Compare(x, y, StringComparison.Ordinal));
foreach (var name in sortedLocations)
{
var currentButtonRef = new Button
{