From 5e288e914f015adda495b3cd8570943b399172ff Mon Sep 17 00:00:00 2001 From: xander Date: Fri, 23 Sep 2022 14:12:38 +0100 Subject: 1.4.4 Fix search not behaving properly with default collapsed option groups Minor refactors --- src/main/java/dev/isxander/yacl/gui/YACLScreen.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/main/java/dev/isxander/yacl/gui/YACLScreen.java') diff --git a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java index 63cb2f6..70c61c1 100644 --- a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java +++ b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java @@ -21,7 +21,7 @@ import java.util.concurrent.atomic.AtomicBoolean; public class YACLScreen extends Screen { public final YetAnotherConfigLib config; - public int currentCategoryIdx; + private int currentCategoryIdx; private final Screen parent; @@ -139,6 +139,9 @@ public class YACLScreen extends Screen { } public void changeCategory(int idx) { + if (idx == currentCategoryIdx) + return; + if (idx != -1 && config.categories().get(idx) instanceof PlaceholderCategory placeholderCategory) { client.setScreen(placeholderCategory.screen().apply(client, this)); } else { @@ -147,6 +150,10 @@ public class YACLScreen extends Screen { } } + public int getCurrentCategoryIdx() { + return currentCategoryIdx; + } + private void updateActionAvailability() { boolean pendingChanges = pendingChanges(); @@ -160,12 +167,6 @@ public class YACLScreen extends Screen { @Override public void tick() { searchFieldWidget.tick(); - if (!searchFieldWidget.getText().isEmpty() && currentCategoryIdx != -1) { - changeCategory(-1); - } - if (searchFieldWidget.getText().isEmpty() && currentCategoryIdx == -1) { - changeCategory(0); - } updateActionAvailability(); -- cgit