diff --git a/Content.Client/Construction/UI/ConstructionMenuPresenter.cs b/Content.Client/Construction/UI/ConstructionMenuPresenter.cs index c315cdedb2ca92..f078f83584cca8 100644 --- a/Content.Client/Construction/UI/ConstructionMenuPresenter.cs +++ b/Content.Client/Construction/UI/ConstructionMenuPresenter.cs @@ -95,19 +95,17 @@ public ConstructionMenuPresenter() _placementManager.PlacementChanged += OnPlacementChanged; - _constructionView.OnClose += () => _uiManager.GetActiveUIWidget().CraftingButton.Pressed = false; + _constructionView.OnClose += () => + { + if (_constructionView.BuildButtonPressed) BuildButtonToggled(false); + if (_constructionView.EraseButtonPressed) EraseButtonToggled(false); + _uiManager.GetActiveUIWidget().CraftingButton.Pressed = false; + }; _constructionView.ClearAllGhosts += (_, _) => _constructionSystem?.ClearAllGhosts(); _constructionView.PopulateRecipes += OnViewPopulateRecipes; _constructionView.RecipeSelected += OnViewRecipeSelected; _constructionView.BuildButtonToggled += (_, b) => BuildButtonToggled(b); - _constructionView.EraseButtonToggled += (_, b) => - { - if (_constructionSystem is null) return; - if (b) _placementManager.Clear(); - _placementManager.ToggleEraserHijacked(new ConstructionPlacementHijack(_constructionSystem, null)); - _constructionView.EraseButtonPressed = b; - }; - + _constructionView.EraseButtonToggled += (_, b) => EraseButtonToggled(b); _constructionView.RecipeFavorited += (_, _) => OnViewFavoriteRecipe(); PopulateCategories(); @@ -307,6 +305,14 @@ private static ItemList.Item GetItem(ConstructionPrototype recipe, ItemList item }; } + private void EraseButtonToggled(bool pressed) + { + if (_constructionSystem is null) return; + if (pressed) _placementManager.Clear(); + _placementManager.ToggleEraserHijacked(new ConstructionPlacementHijack(_constructionSystem, null)); + _constructionView.EraseButtonPressed = pressed; + } + private void BuildButtonToggled(bool pressed) { if (pressed)