diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-10-17 12:10:15 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-10-17 12:10:15 +0800 |
| commit | b7f8fc61dcaa6d202809651d46cf0946b63beef7 (patch) | |
| tree | 31ddc7dcf995a2107e28e8ab58fcce62f41155ab /RoughlyEnoughItems-runtime/src/main/java/me | |
| parent | cfd5c2a5b41388036b3e67f237bb8c18bf5bb1c2 (diff) | |
| download | RoughlyEnoughItems-b7f8fc61dcaa6d202809651d46cf0946b63beef7.tar.gz RoughlyEnoughItems-b7f8fc61dcaa6d202809651d46cf0946b63beef7.tar.bz2 RoughlyEnoughItems-b7f8fc61dcaa6d202809651d46cf0946b63beef7.zip | |
Close #423
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'RoughlyEnoughItems-runtime/src/main/java/me')
3 files changed, 21 insertions, 15 deletions
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,12 +328,16 @@ 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 { |
