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 <pa.pecherskij@interfax.ru>
This commit is contained in:
Fildrance
2025-04-18 07:50:15 +03:00
committed by GitHub
parent e00e2ba407
commit 7d81d63aa0
2 changed files with 24 additions and 3 deletions

View 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;
}

View 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