From 9f5a9eae9a7863412cc5eb433bf15e5ee71da616 Mon Sep 17 00:00:00 2001 From: Danielshe Date: Sun, 3 Nov 2019 14:44:52 +0800 Subject: 3.2.1 --- .../rei/gui/widget/SearchFieldWidget.java | 97 ---------------------- 1 file changed, 97 deletions(-) delete mode 100644 src/main/java/me/shedaniel/rei/gui/widget/SearchFieldWidget.java (limited to 'src/main/java/me/shedaniel/rei/gui/widget/SearchFieldWidget.java') diff --git a/src/main/java/me/shedaniel/rei/gui/widget/SearchFieldWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/SearchFieldWidget.java deleted file mode 100644 index f9f03f87e..000000000 --- a/src/main/java/me/shedaniel/rei/gui/widget/SearchFieldWidget.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Roughly Enough Items by Danielshe. - * Licensed under the MIT License. - */ - -package me.shedaniel.rei.gui.widget; - -import com.mojang.blaze3d.systems.RenderSystem; -import me.shedaniel.rei.RoughlyEnoughItemsCore; -import me.shedaniel.rei.gui.ContainerScreenOverlay; -import me.shedaniel.rei.impl.ScreenHelper; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.GuiLighting; -import net.minecraft.client.resource.language.I18n; -import net.minecraft.client.sound.PositionedSoundInstance; -import net.minecraft.client.util.InputUtil; -import net.minecraft.sound.SoundEvents; - -public class SearchFieldWidget extends TextFieldWidget { - - public static boolean isSearching = false; - public long keybindFocusTime = -1; - public int keybindFocusKey = -1; - protected long lastClickedTime = -1; - - public SearchFieldWidget(int x, int y, int width, int height) { - super(x, y, width, height); - setMaxLength(10000); - } - - public void laterRender(int int_1, int int_2, float float_1) { - GuiLighting.disable(); - RenderSystem.disableDepthTest(); - setEditableColor(ContainerScreenOverlay.getEntryListWidget().children().isEmpty() && !getText().isEmpty() ? 16733525 : isSearching ? -1313241 : 14737632); - setSuggestion(!isFocused() && getText().isEmpty() ? I18n.translate("text.rei.search.field.suggestion") : null); - super.render(int_1, int_2, float_1); - RenderSystem.enableDepthTest(); - } - - @Override - public void renderBorder() { - if (!isSearching) - super.renderBorder(); - else if (this.hasBorder()) { - fill(this.getBounds().x - 1, this.getBounds().y - 1, this.getBounds().x + this.getBounds().width + 1, this.getBounds().y + this.getBounds().height + 1, -1313241); - fill(this.getBounds().x, this.getBounds().y, this.getBounds().x + this.getBounds().width, this.getBounds().y + this.getBounds().height, -16777216); - } - } - - @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) - setText(""); - if (contains && int_1 == 0) - if (lastClickedTime == -1) - lastClickedTime = System.currentTimeMillis(); - else if (System.currentTimeMillis() - lastClickedTime > 1200) - lastClickedTime = -1; - else { - lastClickedTime = -1; - isSearching = !isSearching; - minecraft.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - } - return super.mouseClicked(double_1, double_2, int_1); - } - - @Override - public boolean keyPressed(int int_1, int int_2, int int_3) { - if (this.isVisible() && this.isFocused()) - if (int_1 == 257 || int_1 == 335) { - setFocused(false); - return true; - } - return super.keyPressed(int_1, int_2, int_3); - } - - @Override - public boolean charTyped(char char_1, int int_1) { - if (System.currentTimeMillis() - keybindFocusTime < 1000 && InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), keybindFocusKey)) { - keybindFocusTime = -1; - keybindFocusKey = -1; - return true; - } - return super.charTyped(char_1, int_1); - } - - @Override - public boolean containsMouse(double mouseX, double mouseY) { - return ScreenHelper.getLastOverlay().isNotInExclusionZones(mouseX, mouseY) && super.containsMouse(mouseX, mouseY); - } - - @Override - public void render(int int_1, int int_2, float float_1) { - } - -} -- cgit