From 7d81d63aa01472ce59af33100cb3628d7bc3acbb Mon Sep 17 00:00:00 2001 From: Fildrance Date: Fri, 18 Apr 2025 07:50:15 +0300 Subject: [PATCH] fix: return deconstruct to the top level option of radial menu (#36486) 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 --- .../RCD/RCDMenuBoundUserInterface.cs | 25 +++++++++++++++++-- Resources/Prototypes/RCD/rcd.yml | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Content.Client/RCD/RCDMenuBoundUserInterface.cs b/Content.Client/RCD/RCDMenuBoundUserInterface.cs index d599c324e1..c001b7ec70 100644 --- a/Content.Client/RCD/RCDMenuBoundUserInterface.cs +++ b/Content.Client/RCD/RCDMenuBoundUserInterface.cs @@ -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 PrototypesGroupingInfo = new Dictionary { @@ -48,12 +51,24 @@ public sealed class RCDMenuBoundUserInterface : BoundUserInterface _menu.OpenOverMouseScreenPosition(); } - private IEnumerable ConvertToButtons(HashSet> prototypes) + private IEnumerable ConvertToButtons(HashSet> prototypes) { Dictionary> buttonsByCategory = new(); + ValueList topLevelActions = new(); foreach (var protoId in prototypes) { var prototype = _prototypeManager.Index(protoId); + if (prototype.Category == TopLevelActionCategory) + { + var topLevelActionOption = new RadialMenuActionOption(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; } diff --git a/Resources/Prototypes/RCD/rcd.yml b/Resources/Prototypes/RCD/rcd.yml index f476f06dc4..5fb5356f91 100644 --- a/Resources/Prototypes/RCD/rcd.yml +++ b/Resources/Prototypes/RCD/rcd.yml @@ -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 -- 2.51.2