Fix verb categories shuffling (#28368)

If it's an extra category we leave it in its default spot.
This commit is contained in:
metalgearsloth
2024-05-31 11:55:01 +10:00
committed by GitHub
parent 75ef8e4fec
commit d90cbee7f2

View File

@@ -8,6 +8,7 @@ using Content.Shared.Verbs;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers; using Robust.Client.UserInterface.Controllers;
using Robust.Shared.Collections;
using Robust.Shared.Input; using Robust.Shared.Input;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -115,6 +116,13 @@ namespace Content.Client.Verbs.UI
private void FillVerbPopup(ContextMenuPopup popup) private void FillVerbPopup(ContextMenuPopup popup)
{ {
HashSet<string> listedCategories = new(); HashSet<string> listedCategories = new();
var extras = new ValueList<string>(ExtraCategories.Count);
foreach (var cat in ExtraCategories)
{
extras.Add(cat.Text);
}
foreach (var verb in CurrentVerbs) foreach (var verb in CurrentVerbs)
{ {
if (verb.Category == null) if (verb.Category == null)
@@ -122,18 +130,16 @@ namespace Content.Client.Verbs.UI
var element = new VerbMenuElement(verb); var element = new VerbMenuElement(verb);
_context.AddElement(popup, element); _context.AddElement(popup, element);
} }
else if (listedCategories.Add(verb.Category.Text)) // Add the category if it's not an extra (this is to avoid shuffling if we're filling from server verbs response).
else if (!extras.Contains(verb.Category.Text) && listedCategories.Add(verb.Category.Text))
AddVerbCategory(verb.Category, popup); AddVerbCategory(verb.Category, popup);
} }
if (ExtraCategories != null)
{
foreach (var category in ExtraCategories) foreach (var category in ExtraCategories)
{ {
if (listedCategories.Add(category.Text)) if (listedCategories.Add(category.Text))
AddVerbCategory(category, popup); AddVerbCategory(category, popup);
} }
}
popup.InvalidateMeasure(); popup.InvalidateMeasure();
} }