diff --git a/src/main/java/dev/resent/util/misc/FuncUtils.java b/src/main/java/dev/resent/util/misc/FuncUtils.java index ba08b394..f3683c98 100644 --- a/src/main/java/dev/resent/util/misc/FuncUtils.java +++ b/src/main/java/dev/resent/util/misc/FuncUtils.java @@ -17,4 +17,9 @@ public class FuncUtils { } return ret; } + + public static boolean isInside(int mouseX, int mouseY, double x, double y, double width, double height) { + return (mouseX > x && mouseX < (x + width)) && (mouseY > y && mouseY < (y + height)); + } + } 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 a578f0bf..e8b8efe0 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 @@ -1,29 +1,48 @@ package dev.resent.visual.ui.clickgui.rewrite; +import java.util.ArrayList; + +import dev.resent.client.Resent; +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.GlUtils; import dev.resent.visual.ui.Theme; import dev.resent.visual.ui.animation.Animation; import dev.resent.visual.ui.animation.Direction; +import dev.resent.visual.ui.clickgui.rewrite.comp.Comp; +import dev.resent.visual.ui.clickgui.rewrite.comp.impl.CompCheck; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; public class ClickGuiRewrite extends GuiScreen{ + public ArrayList comps = new ArrayList<>(); + public int x, y, width, height, offset; public Animation introAnimation; - public int x, y, width, height; public ScaledResolution sr; public boolean closing; + public Mod selectedMod; @Override public void drawScreen(int mouseX, int mouseY, float var3) { GlUtils.startScale((this.x + this.width) / 2, (this.y + this.height) / 2, introAnimation != null ? (float) introAnimation.getValue() : 1); - + for(Mod m : Resent.INSTANCE.modManager.modules){ + + } GlUtils.stopScale(); + if(selectedMod != null){ + for (Comp comp : comps) { + comp.drawScreen(mouseX, mouseY); + } + } + if (closing) { + comps.clear(); if(introAnimation == null) { mc.displayGuiScreen(null); return; @@ -37,7 +56,26 @@ public class ClickGuiRewrite extends GuiScreen{ } @Override - protected void mouseClicked(int parInt1, int parInt2, int parInt3) { + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { + + for(Mod m : Resent.INSTANCE.modManager.modules){ + + //replace params with gear icon pos + if(isMouseInside(mouseX, mouseY, width-20, y+20, width-40, y+40) && mouseButton == 0){ + for(Setting s : m.settings){ + if(s instanceof BooleanSetting){ + comps.add(new CompCheck(4, 4, selectedMod, s)); + } + } + } + + } + + if(selectedMod != null){ + for(Comp c : comps){ + c.mouseClicked(mouseX, mouseY, mouseButton); + } + } } @@ -52,10 +90,16 @@ public class ClickGuiRewrite extends GuiScreen{ } @Override - protected void keyTyped(char par1, int par2) { - if (par2 == 0x01 || par2 == Minecraft.getMinecraft().gameSettings.keyBindClickGui.keyCode) { + protected void keyTyped(char par1, int key) { + if (key == 0x01 || key == Minecraft.getMinecraft().gameSettings.keyBindClickGui.keyCode) { closing = true; } + + if(selectedMod != null){ + for(Comp c : comps){ + c.keyTyped(par1, key); + } + } } public boolean isMouseInside(double mouseX, double mouseY, double x, double y, double width, double height) { 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 a36f4499..df0b9e39 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 @@ -1,9 +1,17 @@ package dev.resent.visual.ui.clickgui.rewrite.comp; +import dev.resent.module.base.Mod; +import dev.resent.module.base.setting.Setting; + public abstract class Comp { - public abstract void draw(); - public void mouseClicked() { } - public int x, y; + public Mod mod; + public Setting setting; + public int 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) {} } 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 new file mode 100644 index 00000000..1ecd98df --- /dev/null +++ b/src/main/java/dev/resent/visual/ui/clickgui/rewrite/comp/impl/CompCheck.java @@ -0,0 +1,31 @@ +package dev.resent.visual.ui.clickgui.rewrite.comp.impl; + +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.visual.ui.clickgui.rewrite.comp.Comp; + +public class CompCheck extends Comp{ + + public CompCheck(int x, int y, Mod m, Setting s){ + this.x = x; + this.y = y; + this.mod = m; + this.setting = s; + } + + @Override + public void drawScreen(int mouseX, int mouseY) { + + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int mouseButton) { + //replace with checkbox location + if(FuncUtils.isInside(mouseX, mouseY, x, y, width, height)){ + ((BooleanSetting)setting).toggle(); + } + } + +}