From 60a08c3dad4e20e8d7ce54fcd12a4ab7e950db54 Mon Sep 17 00:00:00 2001 From: ThisIsALegitUsername <73719631+ThisIsALegitUsername@users.noreply.github.com> Date: Wed, 5 Apr 2023 12:42:12 -0600 Subject: [PATCH] Add boolean settings also made eclipse stfu about imports --- .../resent/module/impl/hud/ComboCounter.java | 1 - .../java/dev/resent/module/impl/hud/FPS.java | 1 - .../resent/module/impl/hud/PotCounter.java | 1 - .../resent/module/impl/hud/ReachDisplay.java | 1 - .../dev/resent/util/render/RenderUtils.java | 33 +-------------- .../ui/clickgui/rewrite/ClickGuiRewrite.java | 42 +++++++++++-------- .../visual/ui/clickgui/rewrite/comp/Comp.java | 6 ++- .../clickgui/rewrite/comp/impl/CompCheck.java | 12 +++--- 8 files changed, 38 insertions(+), 59 deletions(-) diff --git a/src/main/java/dev/resent/module/impl/hud/ComboCounter.java b/src/main/java/dev/resent/module/impl/hud/ComboCounter.java index 1657d576..36f39a18 100644 --- a/src/main/java/dev/resent/module/impl/hud/ComboCounter.java +++ b/src/main/java/dev/resent/module/impl/hud/ComboCounter.java @@ -2,7 +2,6 @@ package dev.resent.module.impl.hud; import dev.resent.annotation.RenderModule; import dev.resent.module.base.Mod.Category; -import dev.resent.visual.ui.Theme; import dev.resent.module.base.RenderMod; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; diff --git a/src/main/java/dev/resent/module/impl/hud/FPS.java b/src/main/java/dev/resent/module/impl/hud/FPS.java index 3e148150..b42f3ebc 100644 --- a/src/main/java/dev/resent/module/impl/hud/FPS.java +++ b/src/main/java/dev/resent/module/impl/hud/FPS.java @@ -2,7 +2,6 @@ package dev.resent.module.impl.hud; import dev.resent.annotation.RenderModule; import dev.resent.module.base.Mod.Category; -import dev.resent.visual.ui.Theme; import dev.resent.module.base.RenderMod; import net.minecraft.client.Minecraft; diff --git a/src/main/java/dev/resent/module/impl/hud/PotCounter.java b/src/main/java/dev/resent/module/impl/hud/PotCounter.java index 7dc5100d..6b6377b9 100644 --- a/src/main/java/dev/resent/module/impl/hud/PotCounter.java +++ b/src/main/java/dev/resent/module/impl/hud/PotCounter.java @@ -2,7 +2,6 @@ package dev.resent.module.impl.hud; import dev.resent.annotation.RenderModule; import dev.resent.module.base.Mod.Category; -import dev.resent.visual.ui.Theme; import dev.resent.module.base.RenderMod; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; diff --git a/src/main/java/dev/resent/module/impl/hud/ReachDisplay.java b/src/main/java/dev/resent/module/impl/hud/ReachDisplay.java index 03204440..ee2417b1 100644 --- a/src/main/java/dev/resent/module/impl/hud/ReachDisplay.java +++ b/src/main/java/dev/resent/module/impl/hud/ReachDisplay.java @@ -2,7 +2,6 @@ package dev.resent.module.impl.hud; import dev.resent.annotation.RenderModule; import dev.resent.module.base.Mod.Category; -import dev.resent.visual.ui.Theme; import dev.resent.module.base.RenderMod; import java.text.DecimalFormat; diff --git a/src/main/java/dev/resent/util/render/RenderUtils.java b/src/main/java/dev/resent/util/render/RenderUtils.java index 4255a8e0..48d9521c 100644 --- a/src/main/java/dev/resent/util/render/RenderUtils.java +++ b/src/main/java/dev/resent/util/render/RenderUtils.java @@ -44,38 +44,6 @@ public class RenderUtils { } } } - - public static void drawChromaRect(int zLevel, int x, int y, int width, int height) { - GlStateManager.pushMatrix(); - GlStateManager.translate((float)x, (float)(y + height), (float)0.0f); - GlStateManager.rotate((float)-90.0f, (float)0.0f, (float)0.0f, (float)1.0f); - boolean p_drawGradientRect_1_ = false; - boolean p_drawGradientRect_2_ = false; - int p_drawGradientRect_5_ = Color.HSBtoRGB((float)((System.currentTimeMillis() - (long)x * 10L - (long)y * 10L) % 2000L) / 2000.0f, 0.8f, 0.8f); - int p_drawGradientRect_6_ = Color.HSBtoRGB((float)((System.currentTimeMillis() - (long)(x + width / 2) * 10L - (long)y * 10L) % 2000L) / 2000.0f, 0.8f, 0.8f); - float lvt_7_1_ = (float)(p_drawGradientRect_5_ >> 24 & 0xFF) / 255.0f; - float lvt_8_1_ = (float)(p_drawGradientRect_5_ >> 16 & 0xFF) / 255.0f; - float lvt_9_1_ = (float)(p_drawGradientRect_5_ >> 8 & 0xFF) / 255.0f; - float lvt_10_1_ = (float)(p_drawGradientRect_5_ & 0xFF) / 255.0f; - float lvt_11_1_ = (float)(p_drawGradientRect_6_ >> 24 & 0xFF) / 255.0f; - float lvt_12_1_ = (float)(p_drawGradientRect_6_ >> 16 & 0xFF) / 255.0f; - float lvt_13_1_ = (float)(p_drawGradientRect_6_ >> 8 & 0xFF) / 255.0f; - float lvt_14_1_ = (float)(p_drawGradientRect_6_ & 0xFF) / 255.0f; - GlStateManager.disableTexture2D(); - GlStateManager.enableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.tryBlendFuncSeparate((int)770, (int)771, (int)1, (int)0); - GlStateManager.shadeModel((int)7425); - Tessellator lvt_15_1_ = Tessellator.getInstance(); - WorldRenderer lvt_16_1_ = lvt_15_1_.getWorldRenderer(); - lvt_16_1_.begin(7, DefaultVertexFormats.POSITION_COLOR); - lvt_16_1_.pos((double)height, (double)width, (double)zLevel).color(lvt_12_1_, lvt_13_1_, lvt_14_1_, lvt_11_1_).endVertex(); - lvt_15_1_.draw(); - GlStateManager.shadeModel((int)7424); - GlStateManager.disableBlend(); - GlStateManager.enableTexture2D(); - GlStateManager.popMatrix(); - } public static int astolfoColorsDraw(float yOffset, int yTotal, float speed) { float hue = (float) (System.currentTimeMillis() % (int) speed) + ((yTotal - yOffset) * 9); @@ -166,6 +134,7 @@ public class RenderUtils { Gui.drawRect((int) paramInt1, (int) paramInt2, (int) paramInt3, (int) paramInt4, color); } } + public static void drawRoundedRect(final float paramFloat1, final float paramFloat2, final float paramFloat3, final float paramFloat4, final float paramFloat5) { final int i = 18; diff --git a/src/main/java/dev/resent/visual/ui/clickgui/rewrite/ClickGuiRewrite.java b/src/main/java/dev/resent/visual/ui/clickgui/rewrite/ClickGuiRewrite.java index 5e9b28ff..596a7428 100644 --- a/src/main/java/dev/resent/visual/ui/clickgui/rewrite/ClickGuiRewrite.java +++ b/src/main/java/dev/resent/visual/ui/clickgui/rewrite/ClickGuiRewrite.java @@ -126,7 +126,7 @@ public class ClickGuiRewrite extends GuiScreen { //Toggle RenderUtils.drawRoundedRect(x + 90, y + 125 + offset + scrollOffset, x + 140, y + 175 + offset + scrollOffset, 8, m.isEnabled() ? onSurfaceColor : new Color(66, 66, 66).getRGB()); - + GlUtils.startScale(x + 90, y + 140 + offset + scrollOffset, 2); fr.drawString(m.getName(), x + 120, y + 140 + offset + scrollOffset, -1, false); GlStateManager.popMatrix(); @@ -191,30 +191,38 @@ public class ClickGuiRewrite extends GuiScreen { if (!m.isAdmin() && m.getName().toLowerCase().startsWith(searchString.toLowerCase()) && selectedMod == null) { if (y + 115 + offset + scrollOffset > y + 95 && y + 185 + offset + scrollOffset < y + height && part == "Home") { + if (isMouseInside(mouseX, mouseY, x + width - 60, y + 140 + offset, x + width - 40, y + 160 + offset) && mouseButton == 0 && m.doesHaveSetting()) { + selectedMod = m; + + int settingOffset = 0; + for (Setting s: selectedMod.settings) { + if (s instanceof BooleanSetting) { + comps.add(new CompCheck(x+110, y+125+settingOffset, selectedMod, s)); + } + + settingOffset += 25; + } + } + if(isMouseInside(mouseX, mouseY, x + 80, y + 115 + offset + scrollOffset, x + width - 20, y + 185 + offset + scrollOffset)) { if(mouseButton == 0) { m.toggle(); } - if(mouseButton == 1) { + if(mouseButton == 1 && m.doesHaveSetting()) { selectedMod = m; + + int settingOffset = 0; for (Setting s: selectedMod.settings) { - if (s instanceof BooleanSetting) { - comps.add(new CompCheck(4, 4, selectedMod, s)); - } - } - } - } - - if (isMouseInside(mouseX, mouseY, x + width - 60, y + 140 + offset, x + width - 40, y + 160 + offset) && mouseButton == 0 && m.doesHaveSetting()) { - selectedMod = m; - for (Setting s: selectedMod.settings) { - if (s instanceof BooleanSetting) { - comps.add(new CompCheck(4, 4, selectedMod, s)); + + if (s instanceof BooleanSetting) { + comps.add(new CompCheck(x+110, y+125+settingOffset, selectedMod, s)); + } + + settingOffset += 25; } - } - } - + } + } } offset += 80; diff --git a/src/main/java/dev/resent/visual/ui/clickgui/rewrite/comp/Comp.java b/src/main/java/dev/resent/visual/ui/clickgui/rewrite/comp/Comp.java index df0b9e39..eff8e1e5 100644 --- a/src/main/java/dev/resent/visual/ui/clickgui/rewrite/comp/Comp.java +++ b/src/main/java/dev/resent/visual/ui/clickgui/rewrite/comp/Comp.java @@ -7,11 +7,15 @@ public abstract class Comp { public Mod mod; public Setting setting; - public int x, y, width, height; + public float x, y, width, height; public void mouseClicked(int mouseX, int mouseY, int mouseButton) {} public void mouseReleased(int mouseX, int mouseY, int state) {} public void drawScreen(int mouseX, int mouseY) {} public void keyTyped(char typedChar, int keyCode) {} + public boolean isMouseInside(double mouseX, double mouseY, double x, double y, double width, double height) { + return (mouseX >= x && mouseX <= width) && (mouseY >= y && mouseY <= height); + } + } diff --git a/src/main/java/dev/resent/visual/ui/clickgui/rewrite/comp/impl/CompCheck.java b/src/main/java/dev/resent/visual/ui/clickgui/rewrite/comp/impl/CompCheck.java index 541c20b3..89af7c0c 100644 --- a/src/main/java/dev/resent/visual/ui/clickgui/rewrite/comp/impl/CompCheck.java +++ b/src/main/java/dev/resent/visual/ui/clickgui/rewrite/comp/impl/CompCheck.java @@ -4,12 +4,14 @@ import dev.resent.module.base.Mod; import dev.resent.module.base.setting.BooleanSetting; import dev.resent.module.base.setting.Setting; import dev.resent.util.misc.FuncUtils; +import dev.resent.util.render.Color; +import dev.resent.util.render.RenderUtils; import dev.resent.visual.ui.clickgui.rewrite.comp.Comp; -import net.minecraft.client.gui.Gui; +import net.minecraft.client.Minecraft; public class CompCheck extends Comp{ - public CompCheck(int x, int y, Mod m, Setting s){ + public CompCheck(float x, float y, Mod m, Setting s){ this.x = x; this.y = y; this.mod = m; @@ -18,13 +20,13 @@ public class CompCheck extends Comp{ @Override public void drawScreen(int mouseX, int mouseY) { - + RenderUtils.drawRoundedRect(this.x, this.y, this.x+20, this.y+20, 8, ((BooleanSetting)setting).getValue() ? new Color(3, 218, 197).getRGB() : new Color(66, 66, 66).getRGB()); + Minecraft.getMinecraft().fontRendererObj.drawString(setting.name, this.x+25, this.y+6.5f, -1, false); } @Override public void mouseClicked(int mouseX, int mouseY, int mouseButton) { - //replace with checkbox location - if(FuncUtils.isInside(mouseX, mouseY, x, y, width, height)){ + if(isMouseInside(mouseX, mouseY, this.x, this.y, this.x+20, this.y+20)){ ((BooleanSetting)setting).toggle(); } }