Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add checks to reset buttons in construction menu on close #32319

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions Content.Client/Construction/UI/ConstructionMenuPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,17 @@ public ConstructionMenuPresenter()

_placementManager.PlacementChanged += OnPlacementChanged;

_constructionView.OnClose += () => _uiManager.GetActiveUIWidget<GameTopMenuBar>().CraftingButton.Pressed = false;
_constructionView.OnClose += () =>
{
if (_constructionView.BuildButtonPressed) BuildButtonToggled(false);
if (_constructionView.EraseButtonPressed) EraseButtonToggled(false);
_uiManager.GetActiveUIWidget<GameTopMenuBar>().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();
Expand Down Expand Up @@ -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)
Expand Down
Loading