optimize some code
This commit is contained in:
parent
55a9ab7762
commit
e8497380a1
File diff suppressed because it is too large
Load Diff
31535
javascript/classes.js
31535
javascript/classes.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
26
src/main/java/dev/resent/util/misc/TimerUtil.java
Normal file
26
src/main/java/dev/resent/util/misc/TimerUtil.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package dev.resent.util.misc;
|
||||
|
||||
public class TimerUtil {
|
||||
private static long halfSecond = 500000000;
|
||||
private long lastTime;
|
||||
|
||||
private long getDeltaTime(){
|
||||
return (System.nanoTime()-lastTime);
|
||||
}
|
||||
|
||||
private void updateTime(){
|
||||
this.lastTime = System.nanoTime();
|
||||
}
|
||||
|
||||
public TimerUtil() {
|
||||
this.lastTime = System.nanoTime();
|
||||
}
|
||||
|
||||
public boolean hasHalfSecondPassoed() {
|
||||
if (getDeltaTime() >= halfSecond) {
|
||||
updateTime();
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
}
|
|
@ -2,9 +2,6 @@ package dev.resent.visual.ui.clickgui.rewrite;
|
|||
|
||||
import java.io.IOException;
|
||||
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.module.base.Mod;
|
||||
|
@ -21,7 +18,6 @@ import dev.resent.visual.ui.clickgui.rewrite.comp.Comp;
|
|||
import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompCheck;
|
||||
import net.lax1dude.eaglercraft.v1_8.Mouse;
|
||||
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.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
@ -40,7 +36,7 @@ public class ClickGuiRewrite extends GuiScreen{
|
|||
public float x, y, width, height;
|
||||
public Animation introAnimation;
|
||||
public ScaledResolution sr;
|
||||
public boolean closing;
|
||||
public boolean closing, isSearchFocused;
|
||||
public Mod selectedMod;
|
||||
public String searchString = "";
|
||||
public SimpleAnimation partAnimation = new SimpleAnimation(0);
|
||||
|
@ -51,7 +47,6 @@ public class ClickGuiRewrite extends GuiScreen{
|
|||
secondaryFontColor = new Color(187, 134, 252).getRGB();
|
||||
public int partOffset = 0, scrollOffset = 0;
|
||||
public String part = "Home";
|
||||
private boolean isSearchFocused = false;
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float var3) {
|
||||
|
@ -74,7 +69,7 @@ public class ClickGuiRewrite extends GuiScreen{
|
|||
//Title
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(x + 80, y + 36, 0);
|
||||
GlStateManager.scale(3.5f, 3.5f, 1);
|
||||
GlStateManager.scale(3.5F, 3.5F, 1);
|
||||
GlStateManager.translate(-(x + 80), -(y + 36), 0);
|
||||
fr.drawString("Resent", x + 80, y + 36, -1, false);
|
||||
GlStateManager.popMatrix();
|
||||
|
@ -95,16 +90,16 @@ public class ClickGuiRewrite extends GuiScreen{
|
|||
|
||||
GlStateManager.pushMatrix();
|
||||
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);
|
||||
if (searchString.length() > 0) {
|
||||
fr.drawString(searchString, x + width - 290, y + 40, secondaryFontColor, false);
|
||||
}else if (!isSearchFocused) {
|
||||
fr.drawString(EnumChatFormatting.ITALIC + "Search" + EnumChatFormatting.RESET, x+width-290, y+40, new Color(97, 97, 97).getRGB(), false);
|
||||
} else {
|
||||
fr.drawString(EnumChatFormatting.ITALIC + "Search", 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);
|
||||
drawRect(x + width - 290 - fr.getStringWidth(searchString), y + 38, x + width - 289 - fr.getStringWidth(searchString), y + 50, secondaryFontColor);
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
@ -175,8 +170,7 @@ public class ClickGuiRewrite extends GuiScreen{
|
|||
|
||||
if (isMouseInside(mouseX, mouseY, x + width - 300, y + 25, x + width - 50, y + 65)) {
|
||||
isSearchFocused = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
isSearchFocused = false;
|
||||
}
|
||||
|
||||
|
@ -209,9 +203,9 @@ public class ClickGuiRewrite extends GuiScreen{
|
|||
sr = new ScaledResolution(mc);
|
||||
x = sr.getScaledWidth() / 10;
|
||||
y = sr.getScaledHeight() / 10;
|
||||
width = sr.getScaledWidth()/1.25f;
|
||||
height = sr.getScaledHeight()/1.25f;
|
||||
introAnimation = Theme.getAnimation(500, 1, 3, 3.8f, 1.35f, false);
|
||||
width = sr.getScaledWidth() / 1.25F;
|
||||
height = sr.getScaledHeight() / 1.25F;
|
||||
introAnimation = Theme.getAnimation(500, 1, 3, 3.8F, 1.35F, false);
|
||||
fr = mc.fontRendererObj;
|
||||
}
|
||||
|
||||
|
@ -220,7 +214,7 @@ public class ClickGuiRewrite extends GuiScreen{
|
|||
if (key == 0x01 || key == Minecraft.getMinecraft().gameSettings.keyBindClickGui.keyCode) {
|
||||
closing = true;
|
||||
}
|
||||
if (isSearchFocused) {
|
||||
|
||||
if (selectedMod != null) {
|
||||
for (Comp c: comps) {
|
||||
c.keyTyped(par1, key);
|
||||
|
@ -228,12 +222,12 @@ public class ClickGuiRewrite extends GuiScreen{
|
|||
}
|
||||
|
||||
// Search box stuff
|
||||
else if(key == KeyboardConstants.KEY_BACK) {
|
||||
else if (key == KeyboardConstants.KEY_BACK && isSearchFocused) {
|
||||
if (searchString.length() != 0) {
|
||||
searchString = searchString.substring(0, searchString.length() - 1);
|
||||
}
|
||||
} else {
|
||||
if(searchString.length() <= 18) {
|
||||
if (searchString.length() <= 18 && isSearchFocused) {
|
||||
String balls = ChatAllowedCharacters.filterAllowedCharacters(String.valueOf(par1));
|
||||
if (balls != null && balls != "") {
|
||||
searchString += String.valueOf(par1);
|
||||
|
@ -243,7 +237,6 @@ public class ClickGuiRewrite extends GuiScreen{
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() throws IOException {
|
||||
|
@ -262,9 +255,6 @@ public class ClickGuiRewrite extends GuiScreen{
|
|||
}
|
||||
|
||||
public int getMaxScroll() {
|
||||
return Resent.INSTANCE.modManager.modules.size() * -68;
|
||||
return Resent.INSTANCE.modManager.modules.size() * -69;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user