From 640ec3e031b2273534ec20281e9b2cdc67124a98 Mon Sep 17 00:00:00 2001 From: qwerltaz <69696513+qwerltaz@users.noreply.github.com> Date: Wed, 11 Jun 2025 01:04:39 +0100 Subject: [PATCH] Fix construction menu grid view quirky button selection (#38214) * make hover and info use construction proto name, not entity name * recipeButtons uses IDs as keys, not names * return making item green when selected --- .../Construction/UI/ConstructionMenuPresenter.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Content.Client/Construction/UI/ConstructionMenuPresenter.cs b/Content.Client/Construction/UI/ConstructionMenuPresenter.cs index b1cebab33a..119e92fc6f 100644 --- a/Content.Client/Construction/UI/ConstructionMenuPresenter.cs +++ b/Content.Client/Construction/UI/ConstructionMenuPresenter.cs @@ -38,7 +38,7 @@ namespace Content.Client.Construction.UI private ConstructionSystem? _constructionSystem; private ConstructionPrototype? _selected; private List _favoritedRecipes = []; - private Dictionary _recipeButtons = new(); + private readonly Dictionary _recipeButtons = new(); private string _selectedCategory = string.Empty; private const string FavoriteCatName = "construction-category-favorites"; @@ -217,8 +217,8 @@ namespace Content.Client.Construction.UI var itemButton = new ContainerButton() { VerticalAlignment = Control.VAlignment.Center, - Name = recipe.TargetPrototype.Name, - ToolTip = recipe.TargetPrototype.Name, + Name = recipe.Prototype.Name, + ToolTip = recipe.Prototype.Name, ToggleMode = true, Children = { protoView }, }; @@ -235,7 +235,7 @@ namespace Content.Client.Construction.UI if (buttonToggledEventArgs.Pressed && _selected != null && - _recipeButtons.TryGetValue(_selected.Name!, out var oldButton)) + _recipeButtons.TryGetValue(_selected.ID, out var oldButton)) { oldButton.Pressed = false; SelectGridButton(oldButton, false); @@ -245,7 +245,7 @@ namespace Content.Client.Construction.UI }; recipesGrid.AddChild(itemButtonPanelContainer); - _recipeButtons[recipe.Prototype.Name!] = itemButton; + _recipeButtons[recipe.Prototype.ID] = itemButton; var isCurrentButtonSelected = _selected == recipe.Prototype; itemButton.Pressed = isCurrentButtonSelected; SelectGridButton(itemButton, isCurrentButtonSelected); @@ -307,7 +307,7 @@ namespace Content.Client.Construction.UI if (button.Parent is not PanelContainer buttonPanel) return; - button.Modulate = select ? Color.Green : Color.Transparent; + button.Children.Single().Modulate = select ? Color.Green : Color.White; var buttonColor = select ? StyleNano.ButtonColorDefault : Color.Transparent; buttonPanel.PanelOverride = new StyleBoxFlat { BackgroundColor = buttonColor }; } -- 2.51.2