]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix verb categories shuffling (#28368)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Fri, 31 May 2024 01:55:01 +0000 (11:55 +1000)
committerGitHub <noreply@github.com>
Fri, 31 May 2024 01:55:01 +0000 (11:55 +1000)
If it's an extra category we leave it in its default spot.

Content.Client/Verbs/UI/VerbMenuUIController.cs

index c3fc8c835677de076f1550234ab96bd095ae752f..e9c3f90641f013a6e296c9ee943c3d912f2a90ed 100644 (file)
@@ -8,6 +8,7 @@ using Content.Shared.Verbs;
 using Robust.Client.Player;
 using Robust.Client.UserInterface;
 using Robust.Client.UserInterface.Controllers;
+using Robust.Shared.Collections;
 using Robust.Shared.Input;
 using Robust.Shared.Utility;
 
@@ -115,6 +116,13 @@ namespace Content.Client.Verbs.UI
         private void FillVerbPopup(ContextMenuPopup popup)
         {
             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)
             {
                 if (verb.Category == null)
@@ -122,17 +130,15 @@ namespace Content.Client.Verbs.UI
                     var element = new VerbMenuElement(verb);
                     _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);
             }
 
-            if (ExtraCategories != null)
+            foreach (var category in ExtraCategories)
             {
-                foreach (var category in ExtraCategories)
-                {
-                    if (listedCategories.Add(category.Text))
-                        AddVerbCategory(category, popup);
-                }
+                if (listedCategories.Add(category.Text))
+                    AddVerbCategory(category, popup);
             }
 
             popup.InvalidateMeasure();