From 9b97c7f2f215ec9862d8146e7db07ba03005a71f Mon Sep 17 00:00:00 2001 From: Kot <1192090+koteq@users.noreply.github.com> Date: Fri, 19 Jan 2024 02:18:53 +0400 Subject: [PATCH] Fix entity menu grouping and sorting (#24243) * Group entity menu by the displayed name instead of by the prototype * Sort entity menu by the displayed name (with label) in current culture --- .../ContextMenu/UI/EntityMenuPresenterGrouping.cs | 2 +- Content.Client/ContextMenu/UI/EntityMenuUIController.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Content.Client/ContextMenu/UI/EntityMenuPresenterGrouping.cs b/Content.Client/ContextMenu/UI/EntityMenuPresenterGrouping.cs index d8804a1218..3345c11499 100644 --- a/Content.Client/ContextMenu/UI/EntityMenuPresenterGrouping.cs +++ b/Content.Client/ContextMenu/UI/EntityMenuPresenterGrouping.cs @@ -18,7 +18,7 @@ namespace Content.Client.ContextMenu.UI { if (GroupingContextMenuType == 0) { - var newEntities = entities.GroupBy(e => Identity.Name(e, _entityManager) + (_entityManager.GetComponent(e).EntityPrototype?.ID ?? string.Empty)).ToList(); + var newEntities = entities.GroupBy(e => Identity.Name(e, _entityManager)).ToList(); return newEntities.Select(grp => grp.ToList()).ToList(); } else diff --git a/Content.Client/ContextMenu/UI/EntityMenuUIController.cs b/Content.Client/ContextMenu/UI/EntityMenuUIController.cs index 03d5a9486b..039c03601a 100644 --- a/Content.Client/ContextMenu/UI/EntityMenuUIController.cs +++ b/Content.Client/ContextMenu/UI/EntityMenuUIController.cs @@ -7,6 +7,7 @@ using Content.Client.Verbs; using Content.Client.Verbs.UI; using Content.Shared.CCVar; using Content.Shared.Examine; +using Content.Shared.IdentityManagement; using Content.Shared.Input; using Robust.Client.GameObjects; using Robust.Client.Graphics; @@ -91,7 +92,10 @@ namespace Content.Client.ContextMenu.UI var entitySpriteStates = GroupEntities(entities); var orderedStates = entitySpriteStates.ToList(); - orderedStates.Sort((x, y) => string.CompareOrdinal(_entityManager.GetComponent(x.First()).EntityPrototype?.Name, _entityManager.GetComponent(y.First()).EntityPrototype?.Name)); + orderedStates.Sort((x, y) => string.Compare( + Identity.Name(x.First(), _entityManager), + Identity.Name(y.First(), _entityManager), + StringComparison.CurrentCulture)); Elements.Clear(); AddToUI(orderedStates);