]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix: return deconstruct to the top level option of radial menu (#36486)
authorFildrance <fildrance@gmail.com>
Fri, 18 Apr 2025 04:50:15 +0000 (07:50 +0300)
committerGitHub <noreply@github.com>
Fri, 18 Apr 2025 04:50:15 +0000 (23:50 -0500)
feat: now RCD can have recepies that are placed on the top level of radial menu - 'Main' category name is reserved for this

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
Content.Client/RCD/RCDMenuBoundUserInterface.cs
Resources/Prototypes/RCD/rcd.yml

index d599c324e17f177c270a54d5df9552be81dc8e17..c001b7ec70a5850ed0aa6bba7529bc2b966765e5 100644 (file)
@@ -4,6 +4,7 @@ using Content.Shared.RCD;
 using Content.Shared.RCD.Components;
 using JetBrains.Annotations;
 using Robust.Client.UserInterface;
+using Robust.Shared.Collections;
 using Robust.Shared.Player;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Utility;
@@ -13,6 +14,8 @@ namespace Content.Client.RCD;
 [UsedImplicitly]
 public sealed class RCDMenuBoundUserInterface : BoundUserInterface
 {
+    private const string TopLevelActionCategory = "Main";
+
     private static readonly Dictionary<string, (string Tooltip, SpriteSpecifier Sprite)> PrototypesGroupingInfo
         = new Dictionary<string, (string Tooltip, SpriteSpecifier Sprite)>
         {
@@ -48,12 +51,24 @@ public sealed class RCDMenuBoundUserInterface : BoundUserInterface
         _menu.OpenOverMouseScreenPosition();
     }
 
-    private IEnumerable<RadialMenuNestedLayerOption> ConvertToButtons(HashSet<ProtoId<RCDPrototype>> prototypes)
+    private IEnumerable<RadialMenuOption> ConvertToButtons(HashSet<ProtoId<RCDPrototype>> prototypes)
     {
         Dictionary<string, List<RadialMenuActionOption>> buttonsByCategory = new();
+        ValueList<RadialMenuActionOption> topLevelActions = new();
         foreach (var protoId in prototypes)
         {
             var prototype = _prototypeManager.Index(protoId);
+            if (prototype.Category == TopLevelActionCategory)
+            {
+                var topLevelActionOption = new RadialMenuActionOption<RCDPrototype>(HandleMenuOptionClick, prototype)
+                {
+                    Sprite = prototype.Sprite,
+                    ToolTip = GetTooltip(prototype)
+                };
+                topLevelActions.Add(topLevelActionOption);
+                continue;
+            }
+
             if (!PrototypesGroupingInfo.TryGetValue(prototype.Category, out var groupInfo))
                 continue;
 
@@ -71,7 +86,7 @@ public sealed class RCDMenuBoundUserInterface : BoundUserInterface
             list.Add(actionOption);
         }
 
-        var models = new RadialMenuNestedLayerOption[buttonsByCategory.Count];
+        var models = new RadialMenuOption[buttonsByCategory.Count + topLevelActions.Count];
         var i = 0;
         foreach (var (key, list) in buttonsByCategory)
         {
@@ -84,6 +99,12 @@ public sealed class RCDMenuBoundUserInterface : BoundUserInterface
             i++;
         }
 
+        foreach (var action in topLevelActions)
+        {
+            models[i] = action;
+            i++;
+        }
+
         return models;
     }
 
index f476f06dc48f5fd0eb76fd552cf9d3fef4709e3d..5fb5356f91d32d56f02a86ad95f1645de837ed52 100644 (file)
@@ -6,7 +6,7 @@
 - type: rcd
   id: Deconstruct
   name: rcd-component-deconstruct
-  category: WallsAndFlooring
+  category: Main
   sprite: /Textures/Interface/Radial/RCD/deconstruct.png
   mode: Deconstruct
   prototype: EffectRCDDeconstructPreview