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
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
{
|
{
|
||||||
if (GroupingContextMenuType == 0)
|
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();
|
return newEntities.Select(grp => grp.ToList()).ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Content.Client.Verbs;
|
|||||||
using Content.Client.Verbs.UI;
|
using Content.Client.Verbs.UI;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
@@ -91,7 +92,10 @@ namespace Content.Client.ContextMenu.UI
|
|||||||
|
|
||||||
var entitySpriteStates = GroupEntities(entities);
|
var entitySpriteStates = GroupEntities(entities);
|
||||||
var orderedStates = entitySpriteStates.ToList();
|
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();
|
Elements.Clear();
|
||||||
AddToUI(orderedStates);
|
AddToUI(orderedStates);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user