From 716702623d494ef83a27acdc72d030b436976551 Mon Sep 17 00:00:00 2001 From: "Matthew (or Maya) Peng" <54301439+MEEPofFaith@users.noreply.github.com> Date: Sun, 23 Jan 2022 16:34:28 -0800 Subject: [PATCH] onConfigureClosed (#6523) * onConfigureClosed * Run the closing of the previous block's config on the opening of another --- core/src/mindustry/entities/comp/BuildingComp.java | 5 +++++ core/src/mindustry/ui/fragments/BlockConfigFragment.java | 2 ++ 2 files changed, 7 insertions(+) diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 262c53d414..5847ef8966 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -1249,6 +1249,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, return self() != other; } + /** + * Called when this block's config menu is closed + */ + public void onConfigureClosed(){} + /** Returns whether this config menu should show when the specified player taps it. */ public boolean shouldShowConfigure(Player player){ return true; diff --git a/core/src/mindustry/ui/fragments/BlockConfigFragment.java b/core/src/mindustry/ui/fragments/BlockConfigFragment.java index 1523508aa4..10cd46f6ef 100644 --- a/core/src/mindustry/ui/fragments/BlockConfigFragment.java +++ b/core/src/mindustry/ui/fragments/BlockConfigFragment.java @@ -49,6 +49,7 @@ public class BlockConfigFragment extends Fragment{ } public void showConfig(Building tile){ + if(configTile != null) configTile.onConfigureClosed(); if(tile.configTapped()){ configTile = tile; @@ -82,6 +83,7 @@ public class BlockConfigFragment extends Fragment{ } public void hideConfig(){ + if(configTile != null) configTile.onConfigureClosed(); configTile = null; table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interp.pow3Out), Actions.visible(false)); }