]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix entity menu grouping and sorting (#24243)
authorKot <1192090+koteq@users.noreply.github.com>
Thu, 18 Jan 2024 22:18:53 +0000 (02:18 +0400)
committerGitHub <noreply@github.com>
Thu, 18 Jan 2024 22:18:53 +0000 (09:18 +1100)
* Group entity menu by the displayed name instead of by the prototype

* Sort entity menu by the displayed name (with label) in current culture

Content.Client/ContextMenu/UI/EntityMenuPresenterGrouping.cs
Content.Client/ContextMenu/UI/EntityMenuUIController.cs

index d8804a1218e9cd5a28ff9b03d7018f335d91688d..3345c114998ea7530e5aaed1a0854dbe21f311ab 100644 (file)
@@ -18,7 +18,7 @@ namespace Content.Client.ContextMenu.UI
         {
             if (GroupingContextMenuType == 0)
             {
-                var newEntities = entities.GroupBy(e => Identity.Name(e, _entityManager) + (_entityManager.GetComponent<MetaDataComponent>(e).EntityPrototype?.ID ?? string.Empty)).ToList();
+                var newEntities = entities.GroupBy(e => Identity.Name(e, _entityManager)).ToList();
                 return newEntities.Select(grp => grp.ToList()).ToList();
             }
             else
index 03d5a9486b4e4ea58e222c26c8cd90c43000082b..039c03601ade6cb1b8885cabfc1f78f728b332db 100644 (file)
@@ -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<MetaDataComponent>(x.First()).EntityPrototype?.Name, _entityManager.GetComponent<MetaDataComponent>(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);