made search bar a little better

This commit is contained in:
ParadoxGitHub 2023-04-04 20:32:55 -04:00
parent a45ef0d7e9
commit 55a9ab7762
2 changed files with 52 additions and 26 deletions

View File

@ -130,8 +130,9 @@ public class PlatformAudio {
public void errorMessage(String parString1, String parString2, int parInt1) { public void errorMessage(String parString1, String parString2, int parInt1) {
if (!parString2.isEmpty()) { if (!parString2.isEmpty()) {
logger.error("Error in class \"{}\"!", parString1); // stfu pls
logger.error(parString2); //logger.error("Error in class \"{}\"!", parString1);
//logger.error(parString2);
} }
} }
} }

View File

@ -2,6 +2,9 @@ package dev.resent.visual.ui.clickgui.rewrite;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import dev.resent.client.Resent; import dev.resent.client.Resent;
import dev.resent.module.base.Mod; import dev.resent.module.base.Mod;
@ -18,6 +21,7 @@ import dev.resent.visual.ui.clickgui.rewrite.comp.Comp;
import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompCheck; import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompCheck;
import net.lax1dude.eaglercraft.v1_8.Mouse; import net.lax1dude.eaglercraft.v1_8.Mouse;
import net.lax1dude.eaglercraft.v1_8.internal.KeyboardConstants; import net.lax1dude.eaglercraft.v1_8.internal.KeyboardConstants;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformInput;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
@ -25,6 +29,7 @@ import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.util.ChatAllowedCharacters; import net.minecraft.util.ChatAllowedCharacters;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -46,10 +51,12 @@ public class ClickGuiRewrite extends GuiScreen{
secondaryFontColor = new Color(187, 134, 252).getRGB(); secondaryFontColor = new Color(187, 134, 252).getRGB();
public int partOffset = 0, scrollOffset = 0; public int partOffset = 0, scrollOffset = 0;
public String part = "Home"; public String part = "Home";
private boolean isSearchFocused = false;
@Override @Override
public void drawScreen(int mouseX, int mouseY, float var3) { public void drawScreen(int mouseX, int mouseY, float var3) {
int offset = 0; int offset = 0;
GlUtils.startScale((this.x + this.width) / 2, (this.y + this.height) / 2, introAnimation != null ? (float) introAnimation.getValue() : 1); GlUtils.startScale((this.x + this.width) / 2, (this.y + this.height) / 2, introAnimation != null ? (float) introAnimation.getValue() : 1);
@ -61,7 +68,7 @@ public class ClickGuiRewrite extends GuiScreen{
RenderUtils.drawRoundedRect(x+60, y, x+width, y+height, 32, backgroundColor); RenderUtils.drawRoundedRect(x+60, y, x+width, y+height, 32, backgroundColor);
Gui.drawRect(x+60, y, x+102, y+height, backgroundColor); Gui.drawRect(x+60, y, x+102, y+height, backgroundColor);
//Seperating line //Separating line
Gui.drawRect(x, y+90, x+width, y+95, secondaryColor); Gui.drawRect(x, y+90, x+width, y+95, secondaryColor);
//Title //Title
@ -84,15 +91,22 @@ public class ClickGuiRewrite extends GuiScreen{
//Search //Search
RenderUtils.drawRoundedRect(x+width-300, y+25, x+width-50, y+65, 9, secondaryColor); RenderUtils.drawRoundedRect(x+width-300, y+25, x+width-50, y+65, 9, secondaryColor);
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translate(x+width-290, y+40, 0); GlStateManager.translate(x+width-290, y+40, 0);
GlStateManager.scale(1.5f, 1.5f, 1); GlStateManager.scale(1.5f, 1.5f, 1);
GlStateManager.translate(-(x+width-290), -(y+40), 0); GlStateManager.translate(-(x+width-290), -(y+40), 0);
if(searchString.length() > 0) { if(searchString.length() > 0) {
fr.drawString(searchString, x+width-290, y+40, secondaryFontColor, false); fr.drawString(searchString, x+width-290, y+40, secondaryFontColor, false);
}else { }else if (!isSearchFocused) {
fr.drawString("Search", x+width-290, y+40, new Color(97, 97, 97).getRGB(), false); fr.drawString(EnumChatFormatting.ITALIC + "Search" + EnumChatFormatting.RESET, x+width-290, y+40, new Color(97, 97, 97).getRGB(), false);
} }
if (isSearchFocused) {
drawRect(x + width - (290 - fr.getStringWidth(searchString)), y+38, x + width - (289 - fr.getStringWidth(searchString)), y+50, secondaryFontColor);
}
GlStateManager.popMatrix(); GlStateManager.popMatrix();
//Draw module button //Draw module button
@ -147,6 +161,7 @@ public class ClickGuiRewrite extends GuiScreen{
mc.displayGuiScreen(null); mc.displayGuiScreen(null);
} }
} }
} }
@Override @Override
@ -158,6 +173,13 @@ public class ClickGuiRewrite extends GuiScreen{
partAnimation.setAnimation(0-partOffset, 10); partAnimation.setAnimation(0-partOffset, 10);
} }
if (isMouseInside(mouseX, mouseY, x+width-300, y+25, x+width-50, y+65)) {
isSearchFocused = true;
}
else {
isSearchFocused = false;
}
int offset = 0; int offset = 0;
for(Mod m : Resent.INSTANCE.modManager.modules){ for(Mod m : Resent.INSTANCE.modManager.modules){
@ -198,7 +220,7 @@ public class ClickGuiRewrite extends GuiScreen{
if (key == 0x01 || key == Minecraft.getMinecraft().gameSettings.keyBindClickGui.keyCode) { if (key == 0x01 || key == Minecraft.getMinecraft().gameSettings.keyBindClickGui.keyCode) {
closing = true; closing = true;
} }
if (isSearchFocused) {
if(selectedMod != null){ if(selectedMod != null){
for(Comp c : comps){ for(Comp c : comps){
c.keyTyped(par1, key); c.keyTyped(par1, key);
@ -219,6 +241,7 @@ public class ClickGuiRewrite extends GuiScreen{
} }
} }
} }
}
} }
@ -242,4 +265,6 @@ public class ClickGuiRewrite extends GuiScreen{
return Resent.INSTANCE.modManager.modules.size() * -68; return Resent.INSTANCE.modManager.modules.size() * -68;
} }
} }