From b7f8fc61dcaa6d202809651d46cf0946b63beef7 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 17 Oct 2020 12:10:15 +0800 Subject: Close #423 Signed-off-by: shedaniel --- .../java/me/shedaniel/rei/api/ConfigObject.java | 3 ++- .../shedaniel/rei/gui/ContainerScreenOverlay.java | 3 +-- .../me/shedaniel/rei/gui/OverlaySearchField.java | 26 ++++++++++++---------- .../me/shedaniel/rei/impl/ConfigObjectImpl.java | 7 +++++- gradle.properties | 2 +- .../assets/roughlyenoughitems/lang/en_us.json | 3 ++- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/ConfigObject.java index e7b2bf1a5..948c969dc 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/ConfigObject.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/ConfigObject.java @@ -162,8 +162,9 @@ public interface ConfigObject { @ApiStatus.Experimental boolean doDebugSearchTimeRequired(); - @ApiStatus.Experimental boolean isSubsetsEnabled(); + boolean isInventoryHighlightingAllowed(); + boolean shouldResizeDynamically(); } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index 5ab13593c..4e0a5e06b 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -364,7 +364,6 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl } } - @ApiStatus.Experimental private Rectangle getSubsetsButtonBounds() { if (ConfigObject.getInstance().isSubsetsEnabled()) { if (Minecraft.getInstance().screen instanceof RecipeViewingScreen) { @@ -511,7 +510,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl ENTRY_LIST_WIDGET.updateSearch(ScreenHelper.getSearchField().getText(), true); } } - if (OverlaySearchField.isSearching) { + if (OverlaySearchField.isHighlighting) { matrices.pushPose(); matrices.translate(0, 0, 200f); if (Minecraft.getInstance().screen instanceof AbstractContainerScreen) { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java index a2596fd0d..9aff059ca 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/OverlaySearchField.java @@ -29,6 +29,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Point; import me.shedaniel.math.impl.PointHelper; +import me.shedaniel.rei.api.ConfigObject; import me.shedaniel.rei.api.REIHelper; import me.shedaniel.rei.gui.widget.TextFieldWidget; import me.shedaniel.rei.impl.ScreenHelper; @@ -44,7 +45,7 @@ import java.util.List; @ApiStatus.Internal public class OverlaySearchField extends TextFieldWidget { - public static boolean isSearching = false; + public static boolean isHighlighting = false; public long keybindFocusTime = -1; public int keybindFocusKey = -1; public boolean isMain = true; @@ -75,7 +76,7 @@ public class OverlaySearchField extends TextFieldWidget { public void laterRender(PoseStack matrices, int int_1, int int_2, float float_1) { RenderSystem.disableDepthTest(); - setEditableColor(isMain && ContainerScreenOverlay.getEntryListWidget().getAllStacks().isEmpty() && !getText().isEmpty() ? 16733525 : isSearching && isMain ? -852212 : (containsMouse(PointHelper.ofMouse()) || isFocused()) ? (REIHelper.getInstance().isDarkThemeEnabled() ? -17587 : -1) : -6250336); + setEditableColor(isMain && ContainerScreenOverlay.getEntryListWidget().getAllStacks().isEmpty() && !getText().isEmpty() ? 16733525 : isHighlighting && isMain ? -852212 : (containsMouse(PointHelper.ofMouse()) || isFocused()) ? (REIHelper.getInstance().isDarkThemeEnabled() ? -17587 : -1) : -6250336); setSuggestion(!isFocused() && getText().isEmpty() ? I18n.get("text.rei.search.field.suggestion") : null); super.render(matrices, int_1, int_2, float_1); RenderSystem.enableDepthTest(); @@ -91,7 +92,8 @@ public class OverlaySearchField extends TextFieldWidget { @Override public void renderBorder(PoseStack matrices) { - if (isMain && isSearching) { + isHighlighting = isHighlighting && ConfigObject.getInstance().isInventoryHighlightingAllowed(); + if (isMain && isHighlighting) { fill(matrices, this.getBounds().x - 1, this.getBounds().y - 1, this.getBounds().x + this.getBounds().width + 1, this.getBounds().y + this.getBounds().height + 1, -852212); } else if (isMain && ContainerScreenOverlay.getEntryListWidget().getAllStacks().isEmpty() && !getText().isEmpty()) { fill(matrices, this.getBounds().x - 1, this.getBounds().y - 1, this.getBounds().x + this.getBounds().width + 1, this.getBounds().y + this.getBounds().height + 1, -43691); @@ -109,23 +111,23 @@ public class OverlaySearchField extends TextFieldWidget { } @Override - public boolean mouseClicked(double double_1, double double_2, int int_1) { - boolean contains = containsMouse(double_1, double_2); - if (isVisible() && contains && int_1 == 1) + public boolean mouseClicked(double mouseX, double mouseY, int button) { + boolean contains = containsMouse(mouseX, mouseY); + if (isVisible() && contains && button == 1) setText(""); - if (contains && int_1 == 0 && isMain) + if (contains && button == 0 && isMain && ConfigObject.getInstance().isInventoryHighlightingAllowed()) if (lastClickedDetails == null) - lastClickedDetails = new Tuple<>(System.currentTimeMillis(), new Point(double_1, double_2)); + lastClickedDetails = new Tuple<>(System.currentTimeMillis(), new Point(mouseX, mouseY)); else if (System.currentTimeMillis() - lastClickedDetails.getA() > 1500) lastClickedDetails = null; - else if (getManhattanDistance(lastClickedDetails.getB(), new Point(double_1, double_2)) <= 25) { + else if (getManhattanDistance(lastClickedDetails.getB(), new Point(mouseX, mouseY)) <= 25) { lastClickedDetails = null; - isSearching = !isSearching; + isHighlighting = !isHighlighting; minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); } else { - lastClickedDetails = new Tuple<>(System.currentTimeMillis(), new Point(double_1, double_2)); + lastClickedDetails = new Tuple<>(System.currentTimeMillis(), new Point(mouseX, mouseY)); } - return super.mouseClicked(double_1, double_2, int_1); + return super.mouseClicked(mouseX, mouseY, button); } @Override diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java index 0be9b9e12..ba9b7701e 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java @@ -328,11 +328,15 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { } @Override - @ApiStatus.Experimental public boolean isSubsetsEnabled() { return functionality.isSubsetsEnabled; } + @Override + public boolean isInventoryHighlightingAllowed() { + return functionality.allowInventoryHighlighting; + } + @Override public boolean shouldResizeDynamically() { return advanced.accessibility.resizeDynamically; @@ -404,6 +408,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { public static class Functionality { @Comment("Declares whether REI should remove the recipe book.") private boolean disableRecipeBook = false; @Comment("Declares whether subsets is enabled.") private boolean isSubsetsEnabled = false; + private boolean allowInventoryHighlighting = true; } public static class Advanced { diff --git a/gradle.properties b/gradle.properties index 40eb69955..38e32767a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx3G -mod_version=5.6.1 +mod_version=5.6.2 supported_version=1.16.2/3 minecraft_version=1.16.3 fabricloader_version=0.9.1+build.205 diff --git a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json index 008c51dfe..d551b2cc3 100755 --- a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json +++ b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json @@ -141,6 +141,7 @@ "config.roughlyenoughitems.miscellaneous": "Miscellaneous", "config.roughlyenoughitems.miscellaneous.clickableRecipeArrows": "Clickable Recipe Arrows:", "config.roughlyenoughitems.isSubsetsEnabled": "Subsets Enabled:", + "config.roughlyenoughitems.allowInventoryHighlighting": "Inventory Highlighting Enabled:", "config.roughlyenoughitems.miscellaneous.renderEntryEnchantmentGlint": "Render Enchantment Glint:", "config.roughlyenoughitems.layout.configButtonLocation": "Config Button Position:", "config.roughlyenoughitems.layout.configButtonLocation.upper": "Upper", @@ -152,7 +153,7 @@ "config.roughlyenoughitems.filteredEntries.loadWorldFirst": "Load World First!", "config.roughlyenoughitems.accessibility.entrySize": "Entry Size:", "config.roughlyenoughitems.search.asyncSearch": "Async Search:", - "config.roughlyenoughitems.search.numberAsyncSearch": "Async Group Size:", + "config.roughlyenoughitems.search.asyncSearchPartitionSize": "Async Search Partition Size:", "config.roughlyenoughitems.accessibility.useCompactTabs": "Compact Tabs:", "config.roughlyenoughitems.theme": "Appearance Theme:", "config.roughlyenoughitems.theme.dark": "Dark Theme", -- cgit