From fb91ed996b01f986492de4007cb86be5e68ad192 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 28 Aug 2022 20:48:46 +0900 Subject: More internal changes --- .../rei/RoughlyEnoughItemsCoreClient.java | 31 +- .../shedaniel/rei/impl/client/REIRuntimeImpl.java | 7 +- .../gui/screen/AbstractDisplayViewingScreen.java | 13 +- .../gui/widget/search/DelegateTextField.java | 176 --------- .../gui/widget/search/OverlaySearchField.java | 415 --------------------- .../OverlaySearchFieldSyntaxHighlighter.java | 87 ----- .../client/runtime/DefaultClientRuntimePlugin.java | 150 -------- .../plugin/client/runtime/InputMethodWatcher.java | 9 +- .../runtime/PluginStageExecutionWatcher.java | 3 +- .../client/runtime/SearchBarHighlightWatcher.java | 3 +- 10 files changed, 24 insertions(+), 870 deletions(-) delete mode 100644 runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/DelegateTextField.java delete mode 100644 runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchField.java delete mode 100644 runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchFieldSyntaxHighlighter.java (limited to 'runtime') diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java index 435bdc722..9526129fe 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java @@ -43,7 +43,6 @@ import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.client.overlay.ScreenOverlay; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.screen.ClickArea; -import me.shedaniel.rei.api.client.registry.screen.OverlayDecider; import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.util.CollectionUtils; @@ -54,8 +53,8 @@ import me.shedaniel.rei.impl.client.REIRuntimeImpl; import me.shedaniel.rei.impl.client.gui.InternalCursorState; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.widget.CatchingExceptionUtils; -import me.shedaniel.rei.impl.client.gui.widget.TooltipImpl; import me.shedaniel.rei.impl.client.gui.widget.TooltipContextImpl; +import me.shedaniel.rei.impl.client.gui.widget.TooltipImpl; import me.shedaniel.rei.impl.common.util.IssuesDetector; import me.shedaniel.rei.impl.init.PluginDetector; import net.fabricmc.api.EnvType; @@ -74,7 +73,6 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.InteractionResult; import net.minecraft.world.inventory.CraftingMenu; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; @@ -85,7 +83,6 @@ import org.apache.commons.lang3.function.TriFunction; import org.jetbrains.annotations.Nullable; import java.util.Collection; -import java.util.ConcurrentModificationException; import java.util.List; import java.util.function.BiFunction; import java.util.function.BooleanSupplier; @@ -108,10 +105,8 @@ public class RoughlyEnoughItemsCoreClient { ClientInternals.attachInstance((TriFunction) TooltipContextImpl::new, "tooltipContextProvider"); ClientInternals.attachInstance((Function) TooltipImpl.TooltipEntryImpl::new, "tooltipEntryProvider"); ClientInternals.attachInstance((Function<@Nullable Boolean, ClickArea.Result>) successful -> new ClickArea.Result() { - private List> categories = Lists.newArrayList(); - private BooleanSupplier execute = () -> { - return false; - }; + private final List> categories = Lists.newArrayList(); + private BooleanSupplier execute = () -> false; private Supplier tooltip = () -> { if (categories != null && !categories.isEmpty()) { Component collect = CollectionUtils.mapAndJoinToComponent(categories, @@ -213,27 +208,11 @@ public class RoughlyEnoughItemsCoreClient { } public static boolean shouldReturn(Screen screen) { - if (REIRuntime.getInstance().getOverlay().isEmpty()) return true; - if (screen == null) return true; - if (screen != Minecraft.getInstance().screen) return true; - return _shouldReturn(screen); + return !ScreenRegistry.getInstance().shouldDisplay(screen); } private static ScreenOverlay getOverlay() { - return REIRuntime.getInstance().getOverlay().orElseThrow(() -> new IllegalStateException("Overlay not initialized!")); - } - - private static boolean _shouldReturn(Screen screen) { - try { - for (OverlayDecider decider : ScreenRegistry.getInstance().getDeciders(screen)) { - InteractionResult result = decider.shouldScreenBeOverlaid(screen); - if (result != InteractionResult.PASS) { - return result == InteractionResult.FAIL || REIRuntime.getInstance().getPreviousScreen() == null; - } - } - } catch (ConcurrentModificationException ignored) { - } - return true; + return REIRuntime.getInstance().getOverlay().orElseThrow(); } private void registerEvents() { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java index a38354ff6..d14d6a72b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java @@ -53,12 +53,12 @@ import org.jetbrains.annotations.Nullable; import java.util.Optional; -import static me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListWidget.entrySize; +import static me.shedaniel.rei.impl.client.util.InternalEntryBounds.entrySize; @ApiStatus.Internal @Environment(EnvType.CLIENT) public class REIRuntimeImpl implements REIRuntime { - private ScreenOverlayImpl overlay; + private ScreenOverlay overlay; private AbstractContainerScreen previousContainerScreen = null; private Screen previousScreen = null; @@ -74,8 +74,7 @@ public class REIRuntimeImpl implements REIRuntime { @Override public Optional getOverlay(boolean reset, boolean init) { if ((overlay == null && init) || reset) { - overlay = new ScreenOverlayImpl(); - overlay.init(); + overlay = ClientInternals.getNewOverlay(); overlay.getSearchField().setFocused(false); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java index 4e3f612df..7a704e62b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java @@ -48,7 +48,6 @@ import me.shedaniel.rei.api.common.entry.type.EntryType; import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.client.ClientHelperImpl; -import me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListWidget; import me.shedaniel.rei.impl.display.DisplaySpec; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.Font; @@ -74,6 +73,8 @@ import java.util.*; import java.util.function.UnaryOperator; import java.util.stream.Stream; +import static me.shedaniel.rei.impl.client.util.InternalEntryBounds.entrySize; + public abstract class AbstractDisplayViewingScreen extends Screen implements DisplayScreen { protected final Map, List> categoryMap; protected final List> categories; @@ -273,7 +274,7 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis @Override public int getHeight() { - int entrySize = EntryListWidget.entrySize(); + int entrySize = entrySize(); int w = Math.max(1, MAX_WIDTH / entrySize); int height = Math.min(6, Mth.ceil(widget.getEntries().size() / (float) w)) * entrySize + 2; height += 12; @@ -283,7 +284,7 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis @Override public int getWidth(Font font) { - int entrySize = EntryListWidget.entrySize(); + int entrySize = entrySize(); int w = Math.max(1, MAX_WIDTH / entrySize); int size = widget.getEntries().size(); int width = Math.min(size, w) * entrySize; @@ -294,7 +295,7 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis @Override public void renderImage(Font font, int x, int y, PoseStack poses, ItemRenderer renderer, int z) { - int entrySize = EntryListWidget.entrySize(); + int entrySize = entrySize(); int w = Math.max(1, MAX_WIDTH / entrySize); int i = 0; poses.pushPose(); @@ -322,7 +323,7 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis x, y + 2, -1, true, pose, buffers, false, 0, 15728880); if (tagMatch != null) { - int entrySize = EntryListWidget.entrySize(); + int entrySize = entrySize(); int w = Math.max(1, MAX_WIDTH / entrySize); font.drawInBatch(new TranslatableComponent("text.rei.tag_accept", tagMatch.toString()) .withStyle(ChatFormatting.GRAY), @@ -336,7 +337,7 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis } protected static ScreenOverlay getOverlay() { - return REIRuntime.getInstance().getOverlay().orElseThrow(() -> new IllegalStateException("Overlay not initialized!")); + return REIRuntime.getInstance().getOverlay().orElseThrow(); } private boolean handleFocuses(int button) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/DelegateTextField.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/DelegateTextField.java deleted file mode 100644 index f0eefef0d..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/DelegateTextField.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.impl.client.gui.widget.search; - -import it.unimi.dsi.fastutil.booleans.BooleanConsumer; -import me.shedaniel.rei.api.client.gui.widgets.TextField; -import org.jetbrains.annotations.Nullable; - -import java.util.function.Consumer; -import java.util.function.Function; - -public interface DelegateTextField extends TextField { - TextField delegateTextField(); - - @Override - default void setFocusedResponder(BooleanConsumer responder) { - delegateTextField().setFocusedResponder(responder); - } - - @Override - @Nullable - default String getSuggestion() { - return delegateTextField().getSuggestion(); - } - - @Override - default void setSuggestion(@Nullable String suggestion) { - delegateTextField().setSuggestion(suggestion); - } - - @Override - default void setBorderColorProvider(BorderColorProvider borderColorProvider) { - delegateTextField().setBorderColorProvider(borderColorProvider); - } - - @Override - default void setFormatter(TextFormatter formatter) { - delegateTextField().setFormatter(formatter); - } - - @Override - default TextFormatter getFormatter() { - return delegateTextField().getFormatter(); - } - - @Override - default void setSuggestionRenderer(SuggestionRenderer renderer) { - delegateTextField().setSuggestionRenderer(renderer); - } - - @Override - default SuggestionRenderer getSuggestionRenderer() { - return delegateTextField().getSuggestionRenderer(); - } - - @Override - default void setTextTransformer(Function textTransformer) { - delegateTextField().setTextTransformer(textTransformer); - } - - @Override - default void setResponder(Consumer responder) { - delegateTextField().setResponder(responder); - } - - @Override - default String getText() { - return delegateTextField().getText(); - } - - @Override - default void setText(String text) { - delegateTextField().setText(text); - } - - @Override - default String getSelectedText() { - return delegateTextField().getSelectedText(); - } - - @Override - default void addText(String text) { - delegateTextField().addText(text); - } - - @Override - default void moveCursorTo(int cursor) { - delegateTextField().moveCursorTo(cursor); - } - - @Override - default void moveCursorToStart() { - delegateTextField().moveCursorToStart(); - } - - @Override - default void moveCursorToEnd() { - delegateTextField().moveCursorToEnd(); - } - - @Override - default int getMaxLength() { - return delegateTextField().getMaxLength(); - } - - @Override - default void setMaxLength(int maxLength) { - delegateTextField().setMaxLength(maxLength); - } - - @Override - default int getCursor() { - return delegateTextField().getCursor(); - } - - @Override - default void setCursorPosition(int cursor) { - delegateTextField().setCursorPosition(cursor); - } - - @Override - default boolean hasBorder() { - return delegateTextField().hasBorder(); - } - - @Override - default void setHasBorder(boolean hasBorder) { - delegateTextField().setHasBorder(hasBorder); - } - - @Override - default void setEditableColor(int editableColor) { - delegateTextField().setEditableColor(editableColor); - } - - @Override - default void setNotEditableColor(int notEditableColor) { - delegateTextField().setNotEditableColor(notEditableColor); - } - - @Override - default boolean isFocused() { - return delegateTextField().isFocused(); - } - - @Override - default void setFocused(boolean focused) { - delegateTextField().setFocused(focused); - } - - @Override - default void tick() { - delegateTextField().tick(); - } -} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchField.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchField.java deleted file mode 100644 index edf611866..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchField.java +++ /dev/null @@ -1,415 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.impl.client.gui.widget.search; - -import com.google.common.collect.Lists; -import com.mojang.blaze3d.platform.InputConstants; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; -import com.mojang.datafixers.util.Pair; -import com.mojang.math.Matrix4f; -import me.shedaniel.clothconfig2.api.animator.NumberAnimator; -import me.shedaniel.clothconfig2.api.animator.ValueAnimator; -import me.shedaniel.math.Color; -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; -import me.shedaniel.math.impl.PointHelper; -import me.shedaniel.rei.api.client.REIRuntime; -import me.shedaniel.rei.api.client.config.ConfigObject; -import me.shedaniel.rei.api.client.gui.config.SyntaxHighlightingMode; -import me.shedaniel.rei.api.client.gui.widgets.*; -import me.shedaniel.rei.api.client.search.SearchFilter; -import me.shedaniel.rei.api.common.util.CollectionUtils; -import me.shedaniel.rei.api.common.util.EntryStacks; -import me.shedaniel.rei.impl.client.gui.hints.HintProvider; -import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchFieldSyntaxHighlighter.HighlightInfo; -import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchFieldSyntaxHighlighter.PartHighlightInfo; -import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchFieldSyntaxHighlighter.QuoteHighlightInfo; -import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchFieldSyntaxHighlighter.SplitterHighlightInfo; -import me.shedaniel.rei.impl.client.util.TextTransformations; -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.resources.language.I18n; -import net.minecraft.client.resources.sounds.SimpleSoundInstance; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TextColor; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.util.FormattedCharSequence; -import net.minecraft.util.Tuple; -import net.minecraft.world.inventory.Slot; -import org.jetbrains.annotations.ApiStatus; -import org.lwjgl.glfw.GLFW; - -import java.util.List; -import java.util.Objects; -import java.util.OptionalDouble; -import java.util.function.Consumer; - -@SuppressWarnings("UnstableApiUsage") -@ApiStatus.Internal -public class OverlaySearchField extends DelegateWidget implements DelegateTextField, TextField.TextFormatter, TextField.SuggestionRenderer, TextField.BorderColorProvider { - public static boolean isHighlighting = false; - private static final Style SPLITTER_STYLE = Style.EMPTY.withColor(ChatFormatting.GRAY); - private static final Style QUOTES_STYLE = Style.EMPTY.withColor(ChatFormatting.GOLD); - private static final Style ERROR_STYLE = Style.EMPTY.withColor(TextColor.fromRgb(0xff5555)); - private final TextField textField; - private boolean previouslyClicking = false; - private final OverlaySearchFieldSyntaxHighlighter highlighter; - public long keybindFocusTime = -1; - public int keybindFocusKey = -1; - public boolean isMain = true; - protected Tuple lastClickedDetails = null; - private List history = Lists.newArrayListWithCapacity(100); - private final NumberAnimator progress = ValueAnimator.ofDouble(); - - public OverlaySearchField(int x, int y, int width, int height) { - super(Widgets.noOp()); - this.textField = Widgets.createTextField(new Rectangle(x, y, width, height)); - this.textField.setMaxLength(10000); - this.textField.setFormatter(this); - this.textField.setSuggestionRenderer(this); - this.textField.setFocusedResponder(this::focused); - this.textField.setBorderColorProvider(this); - this.highlighter = new OverlaySearchFieldSyntaxHighlighter(textField.getText()); - this.textField.setResponder(highlighter); - } - - @Override - protected Widget delegate() { - return this.textField.asWidget(); - } - - @Override - public TextField delegateTextField() { - return this.textField; - } - - @Override - public FormattedCharSequence format(String text, int index) { - boolean isPlain = ConfigObject.getInstance().getSyntaxHighlightingMode() == SyntaxHighlightingMode.PLAIN || ConfigObject.getInstance().getSyntaxHighlightingMode() == SyntaxHighlightingMode.PLAIN_UNDERSCORED; - boolean hasUnderscore = ConfigObject.getInstance().getSyntaxHighlightingMode() == SyntaxHighlightingMode.PLAIN_UNDERSCORED || ConfigObject.getInstance().getSyntaxHighlightingMode() == SyntaxHighlightingMode.COLORFUL_UNDERSCORED; - return TextTransformations.forwardWithTransformation(text, (s, charIndex, c) -> { - HighlightInfo arg = highlighter.highlighted[charIndex + index]; - Style style = Style.EMPTY; - if (isMain && REIRuntime.getInstance().getOverlay().get().getEntryList().getEntries().findAny().isEmpty() && !textField.getText().isEmpty()) { - style = ERROR_STYLE; - } - if (arg instanceof PartHighlightInfo part) { - if (!isPlain) { - style = part.style(); - } - if (part.style() != Style.EMPTY && hasUnderscore && part.grammar()) { - style = style.withUnderlined(true); - } - } else if (!isPlain) { - if (arg == SplitterHighlightInfo.INSTANCE) { - style = SPLITTER_STYLE; - } else if (arg == QuoteHighlightInfo.INSTANCE) { - style = QUOTES_STYLE; - } - } - - if (containsMouse(PointHelper.ofMouse()) || textField.isFocused()) { - return style; - } - return style.withColor(TextColor.fromRgb(Color.ofOpaque(style.getColor() == null ? -1 : style.getColor().getValue()).brighter(0.75).getColor())); - }); - } - - public void focused(boolean focused) { - if (textField.isFocused() != focused && isMain) - addToHistory(textField.getText()); - } - - @ApiStatus.Internal - public void addToHistory(String text) { - if (!text.isEmpty()) { - history.removeIf(str -> str.equalsIgnoreCase(text)); - if (history.size() > 100) - history.remove(0); - history.add(text); - } - } - - private void drawHint(PoseStack poses, int mouseX, int mouseY) { - boolean mouseDown = GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_LEFT) != 0; - boolean clicking = false; - if (mouseDown != previouslyClicking) { - previouslyClicking = mouseDown; - clicking = mouseDown; - } - - List hintProviders = HintProvider.PROVIDERS; - List> hints = CollectionUtils.flatMap(hintProviders, provider -> - CollectionUtils.map(provider.provide(), component -> new Pair<>(provider, component))); - if (hints.isEmpty()) return; - int width = getBounds().getWidth() - 4; - List> sequences = CollectionUtils.flatMap(hints, pair -> - CollectionUtils.map(font.split(pair.getSecond(), width - 6), sequence -> new Pair<>(pair.getFirst(), sequence))); - OptionalDouble progress = hintProviders.stream().map(HintProvider::getProgress).filter(Objects::nonNull).mapToDouble(Double::doubleValue) - .average(); - List buttons = hints.stream().map(Pair::getFirst).distinct() - .map(HintProvider::getButtons) - .flatMap(List::stream) - .toList(); - boolean hasProgress = progress.isPresent(); - if (!hasProgress) { - this.progress.setAs(0); - } else { - this.progress.setTo(progress.getAsDouble(), 200); - } - Color color = hints.stream() - .map(Pair::getFirst) - .distinct() - .map(HintProvider::getColor) - .reduce((color1, color2) -> { - int r = color1.getRed() - (color1.getRed() - color2.getRed()) / 2; - int g = color1.getGreen() - (color1.getGreen() - color2.getGreen()) / 2; - int b = color1.getBlue() - (color1.getBlue() - color2.getBlue()) / 2; - return Color.ofRGBA(r, g, b, (color1.getAlpha() + color2.getAlpha()) / 2); - }).orElse(Color.ofTransparent(0x50000000)); - int height = 6 + font.lineHeight * sequences.size() + (hasProgress ? 2 : 0) + (buttons.isEmpty() ? 0 : (int) Math.ceil(buttons.size() / 3.0) * 20); - int x = getBounds().getX() + 2; - int y = getBounds().getY() - height; - Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder bufferBuilder = tesselator.getBuilder(); - RenderSystem.setShader(GameRenderer::getPositionColorShader); - bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - Matrix4f pose = poses.last().pose(); - int background = 0xf0100010; - int color1 = color.getColor(); - int color2 = color.darker(2).getColor(); - fillGradient(pose, bufferBuilder, x, y - 1, x + width, y, 400, background, background); - fillGradient(pose, bufferBuilder, x, y + height, x + width, y + height + 1, 400, background, background); - fillGradient(pose, bufferBuilder, x, y, x + width, y + height, 400, background, background); - fillGradient(pose, bufferBuilder, x - 1, y, x, y + height, 400, background, background); - fillGradient(pose, bufferBuilder, x + width, y, x + width + 1, y + height, 400, background, background); - fillGradient(pose, bufferBuilder, x, y + 1, x + 1, y + height - 1, 400, color1, color2); - fillGradient(pose, bufferBuilder, x + width - 1, y + 1, x + width, y + height - 1, 400, color1, color2); - fillGradient(pose, bufferBuilder, x, y, x + width, y + 1, 400, color1, color1); - fillGradient(pose, bufferBuilder, x, y + height - 1, x + width, y + height, 400, color2, color2); - - if (hasProgress) { - int progressWidth = (int) Math.round(width * this.progress.doubleValue()); - fillGradient(pose, bufferBuilder, x + 1, y + height - 3, x + progressWidth - 1, y + height - 1, 400, 0xffffffff, 0xffffffff); - } - - bufferBuilder.end(); - BufferUploader.end(bufferBuilder); - poses.pushPose(); - poses.translate(0.0D, 0.0D, 450.0D); - for (int i = 0; i < sequences.size(); i++) { - Pair pair = sequences.get(i); - int lineWidth = font.drawShadow(poses, pair.getSecond(), x + 3, y + 3 + font.lineHeight * i, -1); - if (new Rectangle(x + 3, y + 3 + font.lineHeight * i, lineWidth, font.lineHeight).contains(mouseX, mouseY)) { - Tooltip tooltip = pair.getFirst().provideTooltip(new Point(mouseX, mouseY)); - if (tooltip != null) { - REIRuntime.getInstance().clearTooltips(); - REIRuntime.getInstance().getOverlay().get().renderTooltip(poses, tooltip); - } - } - } - - int split = 2; - for (HintProvider.HintButton button : buttons) { - int x1 = x + 4 + ((width - 8 - 8) / split) * (buttons.indexOf(button) % split); - int y1 = y + height - 20 - 20 * (int) Math.floor(buttons.indexOf(button) / (float) split); - int x2 = x1 + (width - 8 - 8) / split; - int y2 = y1 + 16; - Rectangle bounds = new Rectangle(x1, y1, x2 - x1 - 4, y2 - y1); - int buttonColor = bounds.contains(mouseX, mouseY) ? 0x8f8f8f8f : 0x66666666; - fillGradient(poses, x1, y1, x2 - 4, y2, buttonColor, buttonColor); - font.drawShadow(poses, button.name(), (x1 + x2 - 4 - font.width(button.name())) / 2, y1 + 4, -1); - - if (bounds.contains(mouseX, mouseY) && clicking) { - Widgets.produceClickSound(); - button.action().accept(bounds); - } - } - - poses.popPose(); - } - - @Override - public void renderSuggestion(PoseStack matrices, int x, int y, int color) { - matrices.pushPose(); - matrices.translate(0, 0, 400); - if (containsMouse(PointHelper.ofMouse()) || textField.isFocused()) { - color = 0xddeaeaea; - } else { - color = -6250336; - } - this.font.drawShadow(matrices, this.font.plainSubstrByWidth(textField.getSuggestion(), textField.asWidget().getBounds().getWidth()), x, y, color); - matrices.popPose(); - } - - @Override - public int getBorderColor(TextField textField) { - isHighlighting = isHighlighting && ConfigObject.getInstance().isInventoryHighlightingAllowed(); - if (isMain && isHighlighting) { - return 0xfff2ff0c; - } else if (isMain && REIRuntime.getInstance().getOverlay().get().getEntryList().getEntries().findAny().isEmpty() && !textField.getText().isEmpty()) { - return 0xffff5555; - } else { - return TextField.BorderColorProvider.DEFAULT.getBorderColor(textField); - } - } - - public int getManhattanDistance(Point point1, Point point2) { - int e = Math.abs(point1.getX() - point2.getX()); - int f = Math.abs(point1.getY() - point2.getY()); - return e + f; - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - boolean contains = containsMouse(mouseX, mouseY); - if (contains && button == 1) - textField.setText(""); - if (contains && button == 0 && isMain && ConfigObject.getInstance().isInventoryHighlightingAllowed()) - if (lastClickedDetails == null) - 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(mouseX, mouseY)) <= 25) { - lastClickedDetails = null; - isHighlighting = !isHighlighting; - minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - } else { - lastClickedDetails = new Tuple<>(System.currentTimeMillis(), new Point(mouseX, mouseY)); - } - return super.mouseClicked(mouseX, mouseY, button); - } - - @Override - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - if (textField.isFocused() && isMain) - if (keyCode == 257 || keyCode == 335) { - addToHistory(textField.getText()); - setFocused(false); - return true; - } else if (keyCode == 265) { - int i = history.indexOf(textField.getText()) - 1; - if (i < -1 && textField.getText().isEmpty()) - i = history.size() - 1; - else if (i < -1) { - addToHistory(textField.getText()); - i = history.size() - 2; - } - if (i >= 0) { - textField.setText(history.get(i)); - return true; - } - } else if (keyCode == 264) { - int i = history.indexOf(textField.getText()) + 1; - if (i > 0) { - textField.setText(i < history.size() ? history.get(i) : ""); - return true; - } - } - return super.keyPressed(keyCode, scanCode, modifiers); - } - - @Override - public boolean keyReleased(int keyCode, int scanCode, int modifiers) { - if (textField.isFocused() && isMain && keybindFocusKey != -1) { - keybindFocusTime = -1; - keybindFocusKey = -1; - return true; - } - return super.keyReleased(keyCode, scanCode, modifiers); - } - - @Override - public boolean charTyped(char character, int modifiers) { - if (isMain && System.currentTimeMillis() - keybindFocusTime < 1000 && keybindFocusKey != -1 && InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), keybindFocusKey)) { - keybindFocusTime = -1; - keybindFocusKey = -1; - return true; - } - return super.charTyped(character, modifiers); - } - - @Override - public boolean containsMouse(double mouseX, double mouseY) { - return (!isMain || REIRuntime.getInstance().getOverlay().get().isNotInExclusionZones(mouseX, mouseY)) && super.containsMouse(mouseX, mouseY); - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - progress.update(delta); - RenderSystem.disableDepthTest(); - if (isMain) drawHint(matrices, mouseX, mouseY); - textField.setSuggestion(!textField.isFocused() && textField.getText().isEmpty() ? I18n.get("text.rei.search.field.suggestion") : null); - super.render(matrices, mouseX, mouseY, delta); - RenderSystem.enableDepthTest(); - if (isMain && isHighlighting) { - this.renderEntryHighlighting(matrices); - } - } - - @Override - public void setResponder(Consumer responder) { - DelegateTextField.super.setResponder(highlighter.andThen(responder)); - } - - @Override - public WidgetWithBounds asWidget() { - return this; - } - - public static void renderEntryHighlighting(PoseStack matrices) { - RenderSystem.disableDepthTest(); - RenderSystem.colorMask(true, true, true, false); - SearchFilter filter = REIRuntime.getInstance().getOverlay().get().getCurrentSearchFilter(); - if (filter == null) return; - if (Minecraft.getInstance().screen instanceof AbstractContainerScreen containerScreen) { - int x = containerScreen.leftPos, y = containerScreen.topPos; - for (Slot slot : containerScreen.getMenu().slots) { - if (!slot.hasItem() || !filter.test(EntryStacks.of(slot.getItem()))) { - matrices.pushPose(); - matrices.translate(0, 0, 500f); - fillGradient(matrices, x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, 0xdc202020, 0xdc202020, 0); - matrices.popPose(); - } else { - matrices.pushPose(); - matrices.translate(0, 0, 200f); - fillGradient(matrices, x + slot.x, y + slot.y, x + slot.x + 16, y + slot.y + 16, 0x345fff3b, 0x345fff3b, 0); - - fillGradient(matrices, x + slot.x - 1, y + slot.y - 1, x + slot.x, y + slot.y + 16 + 1, 0xff5fff3b, 0xff5fff3b, 0); - fillGradient(matrices, x + slot.x + 16, y + slot.y - 1, x + slot.x + 16 + 1, y + slot.y + 16 + 1, 0xff5fff3b, 0xff5fff3b, 0); - fillGradient(matrices, x + slot.x - 1, y + slot.y - 1, x + slot.x + 16, y + slot.y, 0xff5fff3b, 0xff5fff3b, 0); - fillGradient(matrices, x + slot.x - 1, y + slot.y + 16, x + slot.x + 16, y + slot.y + 16 + 1, 0xff5fff3b, 0xff5fff3b, 0); - - matrices.popPose(); - } - } - } - RenderSystem.colorMask(true, true, true, true); - RenderSystem.enableDepthTest(); - } -} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchFieldSyntaxHighlighter.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchFieldSyntaxHighlighter.java deleted file mode 100644 index 487aba72f..000000000 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchFieldSyntaxHighlighter.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.impl.client.gui.widget.search; - -import it.unimi.dsi.fastutil.ints.IntIntPair; -import me.shedaniel.rei.api.client.search.SearchFilter; -import me.shedaniel.rei.api.client.search.SearchProvider; -import net.minecraft.network.chat.Style; -import org.jetbrains.annotations.ApiStatus; - -import java.util.Collection; -import java.util.function.Consumer; - -@ApiStatus.Internal -public class OverlaySearchFieldSyntaxHighlighter implements Consumer { - public HighlightInfo[] highlighted; - - public OverlaySearchFieldSyntaxHighlighter(String text) { - this.accept(text); - } - - @Override - public void accept(String text) { - this.highlighted = new HighlightInfo[text.length()]; - SearchProvider.getInstance().createFilter(text).processDecoration(new SearchFilter.ParseDecorationSink() { - @Override - public void addQuote(int index) { - highlighted[index] = QuoteHighlightInfo.INSTANCE; - } - - @Override - public void addSplitter(int index) { - highlighted[index] = SplitterHighlightInfo.INSTANCE; - } - - @Override - public void addPart(IntIntPair range, Style style, boolean usingGrammar, Collection grammarRanges, int index) { - if (usingGrammar) { - PartHighlightInfo base = new PartHighlightInfo(style, false); - PartHighlightInfo grammar = new PartHighlightInfo(style, true); - for (int i = range.leftInt(); i < range.rightInt(); i++) { - highlighted[i] = base; - } - for (IntIntPair grammarRange : grammarRanges) { - for (int i = grammarRange.leftInt(); i <= grammarRange.rightInt(); i++) { - highlighted[i + index] = grammar; - } - } - } - } - }); - } - - public sealed interface HighlightInfo { - } - - public record PartHighlightInfo(Style style, boolean grammar) implements HighlightInfo {} - - public enum QuoteHighlightInfo implements HighlightInfo { - INSTANCE, - } - - public enum SplitterHighlightInfo implements HighlightInfo { - INSTANCE, - } -} diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java index 4ae0ed545..b06294a6a 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java @@ -23,75 +23,23 @@ package me.shedaniel.rei.plugin.client.runtime; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.serialization.DataResult; -import com.mojang.serialization.Lifecycle; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.RoughlyEnoughItemsCoreClient; -import me.shedaniel.rei.api.client.ClientHelper; -import me.shedaniel.rei.api.client.REIRuntime; -import me.shedaniel.rei.api.client.favorites.FavoriteEntry; -import me.shedaniel.rei.api.client.favorites.FavoriteEntryType; -import me.shedaniel.rei.api.client.gui.AbstractRenderer; -import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponentProviderWidget; -import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponentVisitorWidget; import me.shedaniel.rei.api.client.gui.widgets.Panel; -import me.shedaniel.rei.api.client.gui.widgets.Tooltip; -import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; -import me.shedaniel.rei.api.client.gui.widgets.Widgets; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; -import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; -import me.shedaniel.rei.api.client.util.ClientEntryStacks; -import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.screen.DefaultDisplayViewingScreen; import me.shedaniel.rei.impl.client.gui.widget.favorites.FavoritesListWidget; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.time.LocalDateTime; import java.util.Collections; -import java.util.function.Function; @Environment(EnvType.CLIENT) @ApiStatus.Internal public class DefaultClientRuntimePlugin implements REIClientPlugin { - @SuppressWarnings("rawtypes") - public DefaultClientRuntimePlugin() { - } - - @Override - public void registerEntries(EntryRegistry registry) { - if (LocalDateTime.now().getMonthValue() == 4 && LocalDateTime.now().getDayOfMonth() == 1) { - registry.addEntry(ClientEntryStacks.of(new AbstractRenderer() { - private ResourceLocation id = new ResourceLocation("roughlyenoughitems", "textures/gui/kirb.png"); - - @Override - public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { - RenderSystem.setShaderTexture(0, id); - innerBlit(matrices.last().pose(), bounds.x, bounds.getMaxX(), bounds.y, bounds.getMaxY(), getBlitOffset(), 0, 1, 0, 1); - } - - @Override - @Nullable - public Tooltip getTooltip(TooltipContext context) { - return Tooltip.create(context, new TextComponent("Kirby"), ClientHelper.getInstance().getFormattedModFromModId("Dream Land")); - } - })); - } - } - @Override public void registerScreens(ScreenRegistry registry) { ExclusionZones zones = registry.exclusionZones(); @@ -110,103 +58,5 @@ public class DefaultClientRuntimePlugin implements REIClientPlugin { } return Collections.emptyList(); }); - registry.registerDraggableComponentProvider(DraggableComponentProviderWidget.from(context -> { - if (RoughlyEnoughItemsCoreClient.shouldReturn(context.getScreen()) || !REIRuntime.getInstance().isOverlayVisible()) return Collections.emptyList(); - return Widgets.walk(REIRuntime.getInstance().getOverlay().get().children(), DraggableComponentProviderWidget.class::isInstance); - })); - registry.registerDraggableComponentVisitor(DraggableComponentVisitorWidget.from(context -> { - if (RoughlyEnoughItemsCoreClient.shouldReturn(context.getScreen()) || !REIRuntime.getInstance().isOverlayVisible()) return Collections.emptyList(); - return Widgets.walk(REIRuntime.getInstance().getOverlay().get().children(), DraggableComponentVisitorWidget.class::isInstance); - })); - } - - @Override - public void registerFavorites(FavoriteEntryType.Registry registry) { - registry.register(EntryStackFavoriteType.INSTANCE.id, EntryStackFavoriteType.INSTANCE); - } - - private enum EntryStackFavoriteType implements FavoriteEntryType { - INSTANCE(FavoriteEntryType.ENTRY_STACK); - - private final String key = "data"; - private ResourceLocation id; - - EntryStackFavoriteType(ResourceLocation id) { - this.id = id; - } - - @Override - public DataResult read(CompoundTag object) { - EntryStack stack; - try { - stack = EntryStack.read(object.getCompound(key)); - } catch (Throwable throwable) { - return DataResult.error(throwable.getMessage()); - } - return DataResult.success(new EntryStackFavoriteEntry(stack), Lifecycle.stable()); - } - - @Override - public DataResult fromArgs(Object... args) { - if (args.length == 0) return DataResult.error("Cannot create EntryStackFavoriteEntry from empty args!"); - if (!(args[0] instanceof EntryStack stack)) - return DataResult.error("Creation of EntryStackFavoriteEntry from args expected EntryStack as the first argument!"); - if (!stack.supportSaving()) - return DataResult.error("Creation of EntryStackFavoriteEntry from an unserializable stack!"); - return DataResult.success(new EntryStackFavoriteEntry(stack), Lifecycle.stable()); - } - - @Override - public CompoundTag save(EntryStackFavoriteEntry entry, CompoundTag tag) { - tag.put(key, entry.stack.saveStack()); - return tag; - } - } - - private static class EntryStackFavoriteEntry extends FavoriteEntry { - private static final Function, String> CANCEL_FLUID_AMOUNT = s -> null; - private final EntryStack stack; - private final long hash; - - public EntryStackFavoriteEntry(EntryStack stack) { - this.stack = stack.normalize(); - this.hash = EntryStacks.hashExact(this.stack); - } - - @Override - public boolean isInvalid() { - return this.stack.isEmpty(); - } - - @Override - public Renderer getRenderer(boolean showcase) { - return this.stack; - } - - @Override - public boolean doAction(int button) { - return false; - } - - @Override - public long hashIgnoreAmount() { - return hash; - } - - @Override - public FavoriteEntry copy() { - return new EntryStackFavoriteEntry(stack.normalize()); - } - - @Override - public ResourceLocation getType() { - return EntryStackFavoriteType.INSTANCE.id; - } - - @Override - public boolean isSame(FavoriteEntry other) { - if (!(other instanceof EntryStackFavoriteEntry that)) return false; - return EntryStacks.equalsExact(stack, that.stack); - } } } diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/InputMethodWatcher.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/InputMethodWatcher.java index 49d419973..94d1514f9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/InputMethodWatcher.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/InputMethodWatcher.java @@ -32,7 +32,6 @@ import me.shedaniel.rei.api.client.search.method.InputMethodRegistry; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.client.config.ConfigManagerInternal; -import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.hints.HintProvider; import me.shedaniel.rei.impl.client.gui.menu.MenuAccess; import me.shedaniel.rei.impl.client.gui.widget.CraftableFilterButtonWidget; @@ -48,8 +47,11 @@ import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.UUID; public class InputMethodWatcher implements HintProvider { + public static final UUID MENU_UUID = UUID.fromString("b93cc166-d06f-4c5f-9bf0-334d18b4adaf"); + @Override public List provide() { if (PluginManager.areAnyReloading() || OverlaySearchField.isHighlighting) return Collections.emptyList(); @@ -91,11 +93,10 @@ public class InputMethodWatcher implements HintProvider { } @Override - public List getButtons() { + public List getButtons(MenuAccess access) { return List.of( new HintButton(new TranslatableComponent("text.rei.input.methods.hint.configure"), bounds -> { - MenuAccess access = ScreenOverlayImpl.getInstance().menuAccess(); - access.openOrClose(CraftableFilterButtonWidget.FILTER_MENU_UUID, bounds.clone(), + access.openOrClose(MENU_UUID, bounds.clone(), () -> CraftableFilterButtonWidget.createInputMethodEntries(CraftableFilterButtonWidget.getApplicableInputMethods())); }), new HintButton(new TranslatableComponent("text.rei.input.methods.hint.ignore"), bounds -> { diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/PluginStageExecutionWatcher.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/PluginStageExecutionWatcher.java index 179a89724..4380b71bd 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/PluginStageExecutionWatcher.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/PluginStageExecutionWatcher.java @@ -36,6 +36,7 @@ import me.shedaniel.rei.api.common.registry.ReloadStage; import me.shedaniel.rei.api.common.registry.Reloadable; import me.shedaniel.rei.api.common.util.ImmutableTextComponent; import me.shedaniel.rei.impl.client.gui.hints.HintProvider; +import me.shedaniel.rei.impl.client.gui.menu.MenuAccess; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; import org.apache.commons.lang3.StringUtils; @@ -190,7 +191,7 @@ public class PluginStageExecutionWatcher implements HintProvider { } @Override - public List getButtons() { + public List getButtons(MenuAccess access) { return Collections.emptyList(); } diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/SearchBarHighlightWatcher.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/SearchBarHighlightWatcher.java index efaaa35d1..157c0b098 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/SearchBarHighlightWatcher.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/SearchBarHighlightWatcher.java @@ -27,6 +27,7 @@ import me.shedaniel.math.Color; import me.shedaniel.math.Point; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.impl.client.gui.hints.HintProvider; +import me.shedaniel.rei.impl.client.gui.menu.MenuAccess; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; @@ -54,7 +55,7 @@ public class SearchBarHighlightWatcher implements HintProvider { } @Override - public List getButtons() { + public List getButtons(MenuAccess access) { return Collections.emptyList(); } } -- cgit