diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..5a8e332 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..c7fade1 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# HeroGUI-v2 + HeroCode's GUI library (second version) + original archive. + + Download link (DEAD): [https://heroco.de/download/HeroGUI_v2.zip](https://heroco.de/download/HeroGUI_v2.zip) + +## HeroGUI + HeroGUI is a very flexible ClickGUI for Minecraft clients on 1.8.x. \ No newline at end of file diff --git a/de/Hero/clickgui/ClickGUI.java b/de/Hero/clickgui/ClickGUI.java new file mode 100644 index 0000000..b5c62dc --- /dev/null +++ b/de/Hero/clickgui/ClickGUI.java @@ -0,0 +1,363 @@ +package de.Hero.clickgui; + +import java.awt.Color; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import de.Hero.clickgui.elements.Element; +import de.Hero.clickgui.elements.ModuleButton; +import de.Hero.clickgui.elements.menu.ElementSlider; +import de.Hero.clickgui.util.ColorUtil; +import de.Hero.clickgui.util.FontUtil; +import de.Hero.settings.SettingsManager; + +//Deine Imports +import me.deinclient.Client; +import me.deinclient.modules.Category; +import me.deinclient.modules.Module; +import me.deinclient.modules.ModuleMgr; + + /** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class ClickGUI extends GuiScreen { + public static ArrayList panels; + public static ArrayList rpanels; + private ModuleButton mb = null; + public SettingsManager setmgr; + + /* + * Konstrukor sollte nur einmal aufgerufen werden => in der MainMethode des eigenen Codes + * hier Client.startClient() + * das GUI wird dann so geöffnet: + * mc.displayGuiScreen(Client.clickgui); + * this.setToggled(false); + * das Module wird sofort wieder beendet damit + * nächstes mal nicht 2mal der z.B. 'RSHIFT' Knopf gedrückt + * werden muss + */ + public ClickGUI() { + setmgr = Client.setmgr; + + FontUtil.setupFontUtils(); + panels = new ArrayList<>(); + double pwidth = 80; + double pheight = 15; + double px = 10; + double py = 10; + double pyplus = pheight + 10; + + /* + * Zum Sortieren der Panels einfach die Reihenfolge im Enum ändern ;) + */ + for (Category c : Category.values()) { + String title = Character.toUpperCase(c.name().toLowerCase().charAt(0)) + c.name().toLowerCase().substring(1); + ClickGUI.panels.add(new Panel(title, px, py, pwidth, pheight, false, this) { + @Override + public void setup() { + for (Module m : ModuleMgr.modules) { + if (!m.getCategory().equals(c))continue; + this.Elements.add(new ModuleButton(m, this)); + } + } + }); + py += pyplus; + } + + /* + * Wieso nicht einfach + * rpanels = panels; + * Collections.reverse(rpanels); + * Ganz eifach: + * durch diese Zuweisung wird rpanels einfach nur eine Weiterleitung + * zu panels, was mit 'Collections.reverse(rpanels);' nicht ganz + * funktionieren würde. Und da die Elemente nur 'rüberkopiert' werden + * gibt es keine Probleme ;) + */ + rpanels = new ArrayList(); + for (Panel p : panels) { + rpanels.add(p); + } + Collections.reverse(rpanels); + + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + /* + * Panels und damit auch Buttons rendern. + * panels wird NUR hier im Code verwendet, da das + * zuletzt gerenderte Panel ganz oben ist + * Auch wenn es manchmal egal wäre ob panels/rpanels + * benutzt wird habe ich mich einfach mal dazu entschieden, + * einfach weil es einfacher ist nur einmal panels zu benutzen + */ + for (Panel p : panels) { + p.drawScreen(mouseX, mouseY, partialTicks); + } + + + /* */ ScaledResolution s = new ScaledResolution(mc, mc.displayWidth,mc.displayHeight); + /* DO NOT REMOVE */ GL11.glPushMatrix(); + /* copyright HeroCode 2017 */ GL11.glTranslated(s.getScaledWidth(), s.getScaledHeight(), 0);GL11.glScaled(0.5, 0.5, 0.5); + /* https://www.youtube.com/channel/UCJum3PIbnYvIfIEu05GL_yQ */ FontUtil.drawStringWithShadow("b"+"y"+ "H"+"e"+"r"+"o"+"C"+"o"+"d"+"e", -Minecraft.getMinecraft().fontRendererObj.getStringWidth("b"+"y"+ "H"+"e"+"r"+"o"+"C"+"o"+"d"+"e"), -Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT, 0xff11F86B); + /* */ GL11.glPopMatrix(); + + mb = null; + /* + * Überprüfen ob ein Button listening == true hat, wenn + * ja, dann soll nicht mehr gesucht werden, nicht dass + * 1+ auf listening steht... + */ + listen: + for (Panel p : panels) { + if (p != null && p.visible && p.extended && p.Elements != null + && p.Elements.size() > 0) { + for (ModuleButton e : p.Elements) { + if (e.listening) { + mb = e; + break listen; + } + } + } + } + + /* + * Settings rendern. Da Settings über alles gerendert werden soll, + * abgesehen vom ListeningOverlay werden die Elements von hier aus + * fast am Schluss gerendert + */ + for (Panel panel : panels) { + if (panel.extended && panel.visible && panel.Elements != null) { + for (ModuleButton b : panel.Elements) { + if (b.extended && b.menuelements != null && !b.menuelements.isEmpty()) { + double off = 0; + Color temp = ColorUtil.getClickGUIColor().darker(); + int outlineColor = new Color(temp.getRed(), temp.getGreen(), temp.getBlue(), 170).getRGB(); + + for (Element e : b.menuelements) { + e.offset = off; + e.update(); + if(Client.setmgr.getSettingByName("Design").getValString().equalsIgnoreCase("New")){ + Gui.drawRect(e.x, e.y, e.x + e.width + 2, e.y + e.height, outlineColor); + } + e.drawScreen(mouseX, mouseY, partialTicks); + off += e.height; + } + } + } + } + + } + + /* + * Wenn mb != null ist => ein Button listening == true + * dann wird das Overlay gerendert mit ein paar Informationen. + */ + if(mb != null){ + drawRect(0, 0, this.width, this.height, 0x88101010); + GL11.glPushMatrix(); + GL11.glTranslatef(s.getScaledWidth() / 2, s.getScaledHeight() / 2, 0.0F); + GL11.glScalef(4.0F, 4.0F, 0F); + FontUtil.drawTotalCenteredStringWithShadow("Listening...", 0, -10, 0xffffffff); + GL11.glScalef(0.5F, 0.5F, 0F); + FontUtil.drawTotalCenteredStringWithShadow("Press 'ESCAPE' to unbind " + mb.mod.getName() + (mb.mod.getKeybind() > -1 ? " (" + Keyboard.getKeyName(mb.mod.getKeybind())+ ")" : ""), 0, 0, 0xffffffff); + GL11.glScalef(0.25F, 0.25F, 0F); + FontUtil.drawTotalCenteredStringWithShadow("by HeroCode", 0, 20, 0xffffffff); + GL11.glPopMatrix(); + } + + /* + * Nicht benötigt, aber es ist so einfach sauberer ;) + * Und ohne diesen call können keine GUIButtons/andere Elemente + * gerendert werden + */ + super.drawScreen(mouseX, mouseY, partialTicks); + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int mouseButton) { + /* + * Damit man nicht nochmal den Listeningmode aktivieren kann, + * wenn er schon aktiviert ist + */ + if(mb != null)return; + + /* + * Benötigt damit auch mit Elements interagiert werden kann + * besonders zu beachten ist dabei, dass zum einen rpanels aufgerufen + * wird welche eine Eigenständige Kopie von panels ist, genauer oben erklärt + * Also rpanels damit zuerst das panel 'untersucht' wird, dass als letztes + * gerendert wurde => Ganz oben ist! + * sodass der Nutzer nicht mit dem Unteren interagiern kann, weil er es wohl + * nicht will. Und damit nicht einfach mit Panels anstatt Elements interagiert wird + * werden hier nur die Settings untersucht. Und wenn wirklich interagiert wurde, dann + * endet diese Methode hier. + * Das ist auch in anderen Loops zu beobachten + */ + for (Panel panel : rpanels) { + if (panel.extended && panel.visible && panel.Elements != null) { + for (ModuleButton b : panel.Elements) { + if (b.extended) { + for (Element e : b.menuelements) { + if (e.mouseClicked(mouseX, mouseY, mouseButton)) + return; + } + } + } + } + } + + /* + * Benötigt damit mit ModuleButtons interagiert werden kann + * und Panels 'gegriffen' werden können + */ + for (Panel p : rpanels) { + if (p.mouseClicked(mouseX, mouseY, mouseButton)) + return; + } + + /* + * Nicht benötigt, aber es ist so einfach sauberer ;) + */ + try { + super.mouseClicked(mouseX, mouseY, mouseButton); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public void mouseReleased(int mouseX, int mouseY, int state) { + /* + * Damit man nicht nochmal den Listeningmode aktivieren kann, + * wenn er schon aktiviert ist + */ + if(mb != null)return; + + /* + * Eigentlich nur für die Slider benötigt, aber + * durch diesen Call erfährt jedes Element, wenn + * z.B. Rechtsklick losgelassen wurde + */ + for (Panel panel : rpanels) { + if (panel.extended && panel.visible && panel.Elements != null) { + for (ModuleButton b : panel.Elements) { + if (b.extended) { + for (Element e : b.menuelements) { + e.mouseReleased(mouseX, mouseY, state); + } + } + } + } + } + + /* + * Benötigt damit Slider auch losgelassen werden können und nicht + * immer an der Maus 'festkleben' :> + */ + for (Panel p : rpanels) { + p.mouseReleased(mouseX, mouseY, state); + } + + /* + * Nicht benötigt, aber es ist so einfach sauberer ;) + */ + super.mouseReleased(mouseX, mouseY, state); + } + + @Override + protected void keyTyped(char typedChar, int keyCode) { + /* + * Benötigt für die Keybindfunktion + */ + for (Panel p : rpanels) { + if (p != null && p.visible && p.extended && p.Elements != null && p.Elements.size() > 0) { + for (ModuleButton e : p.Elements) { + try { + if (e.keyTyped(typedChar, keyCode))return; + } catch (IOException e1) { + e1.printStackTrace(); + } + } + } + } + + /* + * keyTyped in GuiScreen MUSS aufgerufen werden, damit + * man mit z.B. ESCAPE aus dem GUI gehen kann + */ + try { + super.keyTyped(typedChar, keyCode); + } catch (IOException e2) { + e2.printStackTrace(); + } + } + + @Override + public void initGui() { + /* + * Start blur + */ + if (OpenGlHelper.shadersSupported && mc.func_175606_aa() instanceof EntityPlayer) { + if (mc.entityRenderer.theShaderGroup != null) { + mc.entityRenderer.theShaderGroup.deleteShaderGroup(); + } + mc.entityRenderer.func_175069_a(new ResourceLocation("shaders/post/blur.json")); + } + } + + @Override + public void onGuiClosed() { + /* + * End blur + */ + if (mc.entityRenderer.theShaderGroup != null) { + mc.entityRenderer.theShaderGroup.deleteShaderGroup(); + mc.entityRenderer.theShaderGroup = null; + } + /* + * Sliderfix + */ + for (Panel panel : ClickGUI.rpanels) { + if (panel.extended && panel.visible && panel.Elements != null) { + for (ModuleButton b : panel.Elements) { + if (b.extended) { + for (Element e : b.menuelements) { + if(e instanceof ElementSlider){ + ((ElementSlider)e).dragging = false; + } + } + } + } + } + } + } + + public void closeAllSettings() { + for (Panel p : rpanels) { + if (p != null && p.visible && p.extended && p.Elements != null + && p.Elements.size() > 0) { + for (ModuleButton e : p.Elements) { + //e.extended = false; + } + } + } + } +} diff --git a/de/Hero/clickgui/Panel.java b/de/Hero/clickgui/Panel.java new file mode 100644 index 0000000..410f3ac --- /dev/null +++ b/de/Hero/clickgui/Panel.java @@ -0,0 +1,142 @@ +package de.Hero.clickgui; + +import java.awt.Color; +import java.util.ArrayList; + +import me.deinclient.Client; +import net.minecraft.client.gui.Gui; +import de.Hero.clickgui.elements.ModuleButton; +import de.Hero.clickgui.util.ColorUtil; +import de.Hero.clickgui.util.FontUtil; + +/** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class Panel { + public String title; + public double x; + public double y; + private double x2; + private double y2; + public double width; + public double height; + public boolean dragging; + public boolean extended; + public boolean visible; + public ArrayList Elements = new ArrayList<>(); + public ClickGUI clickgui; + + /* + * Konstrukor + */ + public Panel(String ititle, double ix, double iy, double iwidth, double iheight, boolean iextended, ClickGUI parent) { + this.title = ititle; + this.x = ix; + this.y = iy; + this.width = iwidth; + this.height = iheight; + this.extended = iextended; + this.dragging = false; + this.visible = true; + this.clickgui = parent; + setup(); + } + + /* + * Wird in ClickGUI überschrieben, sodass auch ModuleButtons hinzugefügt werden können :3 + */ + public void setup() {} + + /* + * Rendern des Elements. + */ + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + if (!this.visible) + return; + + if (this.dragging) { + x = x2 + mouseX; + y = y2 + mouseY; + } + + Color temp = ColorUtil.getClickGUIColor().darker(); + int outlineColor = new Color(temp.getRed(), temp.getGreen(), temp.getBlue(), 170).getRGB(); + + Gui.drawRect(x, y, x + width, y + height, 0xff121212); + if(Client.setmgr.getSettingByName("Design").getValString().equalsIgnoreCase("New")){ + Gui.drawRect(x - 2, y, x, y + height, outlineColor); + FontUtil.drawStringWithShadow(title, x + 2, y + height / 2 - FontUtil.getFontHeight()/2, 0xffefefef); + }else if(Client.setmgr.getSettingByName("Design").getValString().equalsIgnoreCase("JellyLike")){ + Gui.drawRect(x + 4, y + 2, x + 4.3, y + height - 2, 0xffaaaaaa); + Gui.drawRect(x - 4 + width, y + 2, x - 4.3 + width, y + height - 2, 0xffaaaaaa); + FontUtil.drawTotalCenteredStringWithShadow(title, x + width / 2, y + height / 2, 0xffefefef); + } + + if (this.extended && !Elements.isEmpty()) { + double startY = y + height; + int epanelcolor = Client.setmgr.getSettingByName("Design").getValString().equalsIgnoreCase("New") ? 0xff232323 : Client.setmgr.getSettingByName("Design").getValString().equalsIgnoreCase("JellyLike") ? 0xbb151515 : 0;; + for (ModuleButton et : Elements) { + if(Client.setmgr.getSettingByName("Design").getValString().equalsIgnoreCase("New")){ + Gui.drawRect(x - 2, startY, x + width, startY + et.height + 1, outlineColor); + } + Gui.drawRect(x, startY, x + width, startY + et.height + 1, epanelcolor); + et.x = x + 2; + et.y = startY; + et.width = width - 4; + et.drawScreen(mouseX, mouseY, partialTicks); + startY += et.height + 1; + } + Gui.drawRect(x, startY + 1, x + width, startY + 1, epanelcolor); + + } + } + + /* + * Zum Bewegen und Extenden des Panels + * usw. + */ + public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) { + if (!this.visible) { + return false; + } + if (mouseButton == 0 && isHovered(mouseX, mouseY)) { + x2 = this.x - mouseX; + y2 = this.y - mouseY; + dragging = true; + return true; + } else if (mouseButton == 1 && isHovered(mouseX, mouseY)) { + extended = !extended; + return true; + } else if (extended) { + for (ModuleButton et : Elements) { + if (et.mouseClicked(mouseX, mouseY, mouseButton)) { + return true; + } + } + } + return false; + } + + /* + * Damit das Panel auch losgelassen werden kann + */ + public void mouseReleased(int mouseX, int mouseY, int state) { + if (!this.visible) { + return; + } + if (state == 0) { + this.dragging = false; + } + } + + /* + * HoverCheck + */ + public boolean isHovered(int mouseX, int mouseY) { + return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height; + } +} diff --git a/de/Hero/clickgui/elements/Element.java b/de/Hero/clickgui/elements/Element.java new file mode 100644 index 0000000..0e3f057 --- /dev/null +++ b/de/Hero/clickgui/elements/Element.java @@ -0,0 +1,93 @@ +package de.Hero.clickgui.elements; + +import de.Hero.clickgui.ClickGUI; +import de.Hero.clickgui.elements.menu.ElementComboBox; +import de.Hero.clickgui.util.FontUtil; +import de.Hero.settings.Setting; + +/** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class Element { + public ClickGUI clickgui; + public ModuleButton parent; + public Setting set; + public double offset; + public double x; + public double y; + public double width; + public double height; + + public String setstrg; + + public boolean comboextended; + + public void setup(){ + clickgui = parent.parent.clickgui; + } + + public void update(){ + /* + * Richtig positionieren! Offset wird von ClickGUI aus bestimmt, sodass + * nichts ineinander gerendert wird + */ + x = parent.x + parent.width + 2; + y = parent.y + offset; + width = parent.width + 10; + height = 15; + + /* + * Title der Box bestimmen und falls nötig die Breite der CheckBox + * erweitern + */ + String sname = set.getName(); + if(set.isCheck()){ + setstrg = sname.substring(0, 1).toUpperCase() + sname.substring(1, sname.length()); + double textx = x + width - FontUtil.getStringWidth(setstrg); + if (textx < x + 13) { + width += (x + 13) - textx + 1; + } + }else if(set.isCombo()){ + height = comboextended ? set.getOptions().size() * (FontUtil.getFontHeight() + 2) + 15 : 15; + + setstrg = sname.substring(0, 1).toUpperCase() + sname.substring(1, sname.length()); + int longest = FontUtil.getStringWidth(setstrg); + for (String s : set.getOptions()) { + int temp = FontUtil.getStringWidth(s); + if (temp > longest) { + longest = temp; + } + } + double textx = x + width - longest; + if (textx < x) { + width += x - textx + 1; + } + }else if(set.isSlider()){ + setstrg = sname.substring(0, 1).toUpperCase() + sname.substring(1, sname.length()); + String displayval = "" + Math.round(set.getValDouble() * 100D)/ 100D; + String displaymax = "" + Math.round(set.getMax() * 100D)/ 100D; + double textx = x + width - FontUtil.getStringWidth(setstrg) - FontUtil.getStringWidth(displaymax) - 4; + if (textx < x) { + width += x - textx + 1; + } + } + } + + public void drawScreen(int mouseX, int mouseY, float partialTicks) {} + + public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) { + return isHovered(mouseX, mouseY); + } + + public void mouseReleased(int mouseX, int mouseY, int state) {} + + public boolean isHovered(int mouseX, int mouseY) + { + + return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height; + } +} diff --git a/de/Hero/clickgui/elements/ModuleButton.java b/de/Hero/clickgui/elements/ModuleButton.java new file mode 100644 index 0000000..70994d4 --- /dev/null +++ b/de/Hero/clickgui/elements/ModuleButton.java @@ -0,0 +1,164 @@ +package de.Hero.clickgui.elements; + +import java.awt.Color; +import java.io.IOException; +import java.util.ArrayList; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; + +import org.lwjgl.input.Keyboard; + +import de.Hero.clickgui.Panel; +import de.Hero.clickgui.elements.menu.ElementCheckBox; +import de.Hero.clickgui.elements.menu.ElementComboBox; +import de.Hero.clickgui.elements.menu.ElementSlider; +import de.Hero.clickgui.util.ColorUtil; +import de.Hero.clickgui.util.FontUtil; +import de.Hero.settings.Setting; + +//Deine Imports +import me.deinclient.Client; +import me.deinclient.modules.KeyBinds; +import me.deinclient.modules.Module; + +/** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class ModuleButton { + public Module mod; + public ArrayList menuelements; + public Panel parent; + public double x; + public double y; + public double width; + public double height; + public boolean extended = false; + public boolean listening = false; + + /* + * Konstrukor + */ + public ModuleButton(Module imod, Panel pl) { + mod = imod; + height = Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT + 2; + parent = pl; + menuelements = new ArrayList<>(); + /* + * Settings wurden zuvor in eine ArrayList eingetragen + * dieses SettingSystem hat 3 Konstruktoren je nach + * verwendetem Konstruktor ändert sich die Value + * bei .isCheck() usw. so kann man ganz einfach ohne + * irgendeinen Aufwand bestimmen welches Element + * für ein Setting benötigt wird :> + */ + if (Client.setmgr.getSettingsByMod(imod) != null) + for (Setting s : Client.setmgr.getSettingsByMod(imod)) { + if (s.isCheck()) { + menuelements.add(new ElementCheckBox(this, s)); + } else if (s.isSlider()) { + menuelements.add(new ElementSlider(this, s)); + } else if (s.isCombo()) { + menuelements.add(new ElementComboBox(this, s)); + } + } + + } + + /* + * Rendern des Elements + */ + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + Color temp = ColorUtil.getClickGUIColor(); + int color = new Color(temp.getRed(), temp.getGreen(), temp.getBlue(), 150).getRGB(); + + /* + * Ist das Module an, wenn ja dann soll + * #ein neues Rechteck in Größe des Buttons den Knopf als Toggled kennzeichnen + * #sich der Text anders färben + */ + int textcolor = 0xffafafaf; + if (mod.isToggled()) { + Gui.drawRect(x - 2, y, x + width + 2, y + height + 1, color); + textcolor = 0xffefefef; + } + + /* + * Ist die Maus über dem Element, wenn ja dann soll der Button sich anders färben + */ + if (isHovered(mouseX, mouseY)) { + Gui.drawRect(x - 2, y, x + width + 2, y + height + 1, 0x55111111); + } + + /* + * Den Namen des Modules in die Mitte (x und y) rendern + */ + FontUtil.drawTotalCenteredStringWithShadow(mod.getName(), x + width / 2, y + 1 + height / 2, textcolor); + } + + /* + * 'true' oder 'false' bedeutet hat der Nutzer damit interagiert und + * sollen alle anderen Versuche der Interaktion abgebrochen werden? + */ + public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) { + if (!isHovered(mouseX, mouseY)) + return false; + + /* + * Rechtsklick, wenn ja dann Module togglen, + */ + if (mouseButton == 0) { + mod.toggle(); + + if(Client.setmgr.getSettingByName("Sound").getValBoolean()) + Minecraft.getMinecraft().thePlayer.playSound("random.click", 0.5f, 0.5f); + } else if (mouseButton == 1) { + /* + * Wenn ein Settingsmenu existiert dann sollen alle Settingsmenus + * geschlossen werden und dieses geöffnet/geschlossen werden + */ + if (menuelements != null && menuelements.size() > 0) { + boolean b = !this.extended; + Client.clickgui.closeAllSettings(); + this.extended = b; + + if(Client.setmgr.getSettingByName("Sound").getValBoolean()) + if(extended)Minecraft.getMinecraft().thePlayer.playSound("tile.piston.out", 1f, 1f);else Minecraft.getMinecraft().thePlayer.playSound("tile.piston.in", 1f, 1f); + } + } else if (mouseButton == 2) { + /* + * MidClick => Set keybind (wait for next key) + */ + listening = true; + } + return true; + } + + public boolean keyTyped(char typedChar, int keyCode) throws IOException { + /* + * Wenn listening, dann soll der nächster Key (abgesehen 'ESCAPE') als Keybind für mod + * danach soll nicht mehr gewartet werden! + */ + if (listening) { + if (keyCode != Keyboard.KEY_ESCAPE) { + Client.sendChatMessage("Bound '" + mod.getName() + "'" + " to '" + Keyboard.getKeyName(keyCode) + "'"); + KeyBinds.bindKey(mod, keyCode); + } else { + Client.sendChatMessage("Unbound '" + mod.getName() + "'"); + KeyBinds.bindKey(mod, Keyboard.KEY_NONE); + } + listening = false; + return true; + } + return false; + } + + public boolean isHovered(int mouseX, int mouseY) { + return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height; + } + +} diff --git a/de/Hero/clickgui/elements/menu/ElementCheckBox.java b/de/Hero/clickgui/elements/menu/ElementCheckBox.java new file mode 100644 index 0000000..4827db4 --- /dev/null +++ b/de/Hero/clickgui/elements/menu/ElementCheckBox.java @@ -0,0 +1,70 @@ +package de.Hero.clickgui.elements.menu; + +import java.awt.Color; + +import me.deinclient.Client; +import net.minecraft.client.gui.Gui; +import de.Hero.clickgui.elements.Element; +import de.Hero.clickgui.elements.ModuleButton; +import de.Hero.clickgui.util.ColorUtil; +import de.Hero.clickgui.util.FontUtil; +import de.Hero.settings.Setting; + +/** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class ElementCheckBox extends Element { + /* + * Konstrukor + */ + public ElementCheckBox(ModuleButton iparent, Setting iset) { + parent = iparent; + set = iset; + super.setup(); + } + + /* + * Rendern des Elements + */ + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + Color temp = ColorUtil.getClickGUIColor(); + int color = new Color(temp.getRed(), temp.getGreen(), temp.getBlue(), 200).getRGB(); + + /* + * Die Box und Umrandung rendern + */ + Gui.drawRect(x, y, x + width, y + height, 0xff1a1a1a); + + /* + * Titel und Checkbox rendern. + */ + FontUtil.drawString(setstrg, x + width - FontUtil.getStringWidth(setstrg), y + FontUtil.getFontHeight() / 2 - 0.5, 0xffffffff); + Gui.drawRect(x + 1, y + 2, x + 12, y + 13, set.getValBoolean() ? color : 0xff000000); + if (isCheckHovered(mouseX, mouseY)) + Gui.drawRect(x + 1, y + 2, x + 12, y + 13, 0x55111111); + } + + /* + * 'true' oder 'false' bedeutet hat der Nutzer damit interagiert und + * sollen alle anderen Versuche der Interaktion abgebrochen werden? + */ + public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) { + if (mouseButton == 0 && isCheckHovered(mouseX, mouseY)) { + set.setValBoolean(!set.getValBoolean()); + return true; + } + + return super.mouseClicked(mouseX, mouseY, mouseButton); + } + + /* + * Einfacher HoverCheck, benötigt damit die Value geändert werden kann + */ + public boolean isCheckHovered(int mouseX, int mouseY) { + return mouseX >= x + 1 && mouseX <= x + 12 && mouseY >= y + 2 && mouseY <= y + 13; + } +} diff --git a/de/Hero/clickgui/elements/menu/ElementComboBox.java b/de/Hero/clickgui/elements/menu/ElementComboBox.java new file mode 100644 index 0000000..22f093c --- /dev/null +++ b/de/Hero/clickgui/elements/menu/ElementComboBox.java @@ -0,0 +1,114 @@ +package de.Hero.clickgui.elements.menu; + +import java.awt.Color; + +import me.deinclient.Client; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import de.Hero.clickgui.elements.Element; +import de.Hero.clickgui.elements.ModuleButton; +import de.Hero.clickgui.util.ColorUtil; +import de.Hero.clickgui.util.FontUtil; +import de.Hero.settings.Setting; + +/** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class ElementComboBox extends Element { + /* + * Konstrukor + */ + public ElementComboBox(ModuleButton iparent, Setting iset) { + parent = iparent; + set = iset; + super.setup(); + } + + /* + * Rendern des Elements + */ + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + Color temp = ColorUtil.getClickGUIColor(); + int color = new Color(temp.getRed(), temp.getGreen(), temp.getBlue(), 150).getRGB(); + + /* + * Die Box und Umrandung rendern + */ + Gui.drawRect(x, y, x + width, y + height, 0xff1a1a1a); + + FontUtil.drawTotalCenteredString(setstrg, x + width / 2, y + 15/2, 0xffffffff); + int clr1 = color; + int clr2 = temp.getRGB(); + + Gui.drawRect(x, y + 14, x + width, y + 15, 0x77000000); + if (comboextended) { + Gui.drawRect(x, y + 15, x + width, y + height, 0xaa121212); + double ay = y + 15; + for (String sld : set.getOptions()) { + String elementtitle = sld.substring(0, 1).toUpperCase() + sld.substring(1, sld.length()); + FontUtil.drawCenteredString(elementtitle, x + width / 2, ay + 2, 0xffffffff); + + /* + * Ist das Element ausgewählt, wenn ja dann markiere + * das Element in der ComboBox + */ + if (sld.equalsIgnoreCase(set.getValString())) { + Gui.drawRect(x, ay, x + 1.5, ay + FontUtil.getFontHeight() + 2, clr1); + } + /* + * Wie bei mouseClicked 'is hovered', wenn ja dann markiere + * das Element in der ComboBox + */ + if (mouseX >= x && mouseX <= x + width && mouseY >= ay && mouseY < ay + FontUtil.getFontHeight() + 2) { + Gui.drawRect(x + width - 1.2, ay, x + width, ay + FontUtil.getFontHeight() + 2, clr2); + } + ay += FontUtil.getFontHeight() + 2; + } + } + } + + /* + * 'true' oder 'false' bedeutet hat der Nutzer damit interagiert und + * sollen alle anderen Versuche der Interaktion abgebrochen werden? + */ + public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) { + if (mouseButton == 0) { + if (isButtonHovered(mouseX, mouseY)) { + comboextended = !comboextended; + return true; + } + + /* + * Also wenn die Box ausgefahren ist, dann wird für jede mögliche Options + * überprüft, ob die Maus auf diese zeigt, wenn ja dann global jeder weitere + * call an mouseClicked gestoppt und die Values werden aktualisiert + */ + if (!comboextended)return false; + double ay = y + 15; + for (String slcd : set.getOptions()) { + if (mouseX >= x && mouseX <= x + width && mouseY >= ay && mouseY <= ay + FontUtil.getFontHeight() + 2) { + if(Client.setmgr.getSettingByName("Sound").getValBoolean()) + Minecraft.getMinecraft().thePlayer.playSound("tile.piston.in", 20.0F, 20.0F); + + if(clickgui != null && clickgui.setmgr != null) + clickgui.setmgr.getSettingByName(set.getName()).setValString(slcd.toLowerCase()); + return true; + } + ay += FontUtil.getFontHeight() + 2; + } + } + + return super.mouseClicked(mouseX, mouseY, mouseButton); + } + + /* + * Einfacher HoverCheck, benötigt damit die Combobox geöffnet und geschlossen werden kann + */ + public boolean isButtonHovered(int mouseX, int mouseY) { + return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 15; + } +} diff --git a/de/Hero/clickgui/elements/menu/ElementSlider.java b/de/Hero/clickgui/elements/menu/ElementSlider.java new file mode 100644 index 0000000..5a206c8 --- /dev/null +++ b/de/Hero/clickgui/elements/menu/ElementSlider.java @@ -0,0 +1,105 @@ +package de.Hero.clickgui.elements.menu; + +import java.awt.Color; + +import net.minecraft.client.gui.Gui; +import net.minecraft.util.MathHelper; +import de.Hero.clickgui.elements.Element; +import de.Hero.clickgui.elements.ModuleButton; +import de.Hero.clickgui.util.ColorUtil; +import de.Hero.clickgui.util.FontUtil; +import de.Hero.settings.Setting; + +/** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class ElementSlider extends Element { + public boolean dragging; + + /* + * Konstrukor + */ + public ElementSlider(ModuleButton iparent, Setting iset) { + parent = iparent; + set = iset; + dragging = false; + super.setup(); + } + + /* + * Rendern des Elements + */ + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + String displayval = "" + Math.round(set.getValDouble() * 100D)/ 100D; + boolean hoveredORdragged = isSliderHovered(mouseX, mouseY) || dragging; + + Color temp = ColorUtil.getClickGUIColor(); + int color = new Color(temp.getRed(), temp.getGreen(), temp.getBlue(), hoveredORdragged ? 250 : 200).getRGB(); + int color2 = new Color(temp.getRed(), temp.getGreen(), temp.getBlue(), hoveredORdragged ? 255 : 230).getRGB(); + + //selected = iset.getValDouble() / iset.getMax(); + double percentBar = (set.getValDouble() - set.getMin())/(set.getMax() - set.getMin()); + + /* + * Die Box und Umrandung rendern + */ + Gui.drawRect(x, y, x + width, y + height, 0xff1a1a1a); + + /* + * Den Text rendern + */ + FontUtil.drawString(setstrg, x + 1, y + 2, 0xffffffff); + FontUtil.drawString(displayval, x + width - FontUtil.getStringWidth(displayval), y + 2, 0xffffffff); + + /* + * Den Slider rendern + */ + Gui.drawRect(x, y + 12, x + width, y + 13.5, 0xff101010); + Gui.drawRect(x, y + 12, x + (percentBar * width), y + 13.5, color); + + if(percentBar > 0 && percentBar < 1) + Gui.drawRect(x + (percentBar * width)-1, y + 12, x + Math.min((percentBar * width), width), y + 13.5, color2); + + + /* + * Neue Value berechnen, wenn dragging + */ + if (this.dragging) { + double diff = set.getMax() - set.getMin(); + double val = set.getMin() + (MathHelper.clamp_double((mouseX - x) / width, 0, 1)) * diff; + set.setValDouble(val); //Die Value im Setting updaten + } + + } + + /* + * 'true' oder 'false' bedeutet hat der Nutzer damit interagiert und + * sollen alle anderen Versuche der Interaktion abgebrochen werden? + */ + public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) { + if (mouseButton == 0 && isSliderHovered(mouseX, mouseY)) { + this.dragging = true; + return true; + } + + return super.mouseClicked(mouseX, mouseY, mouseButton); + } + + /* + * Wenn die Maus losgelassen wird soll aufgehört werden die Slidervalue zu verändern + */ + public void mouseReleased(int mouseX, int mouseY, int state) { + this.dragging = false; + } + + /* + * Einfacher HoverCheck, benötigt damit dragging auf true gesetzt werden kann + */ + public boolean isSliderHovered(int mouseX, int mouseY) { + return mouseX >= x && mouseX <= x + width && mouseY >= y + 11 && mouseY <= y + 14; + } +} \ No newline at end of file diff --git a/de/Hero/clickgui/util/ColorUtil.java b/de/Hero/clickgui/util/ColorUtil.java new file mode 100644 index 0000000..d21667e --- /dev/null +++ b/de/Hero/clickgui/util/ColorUtil.java @@ -0,0 +1,20 @@ +package de.Hero.clickgui.util; + +import java.awt.Color; + +//Deine Imports +import me.deinclient.Client; + +/** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class ColorUtil { + + public static Color getClickGUIColor(){ + return new Color((int)Client.setmgr.getSettingByName("GuiRed").getValDouble(), (int)Client.setmgr.getSettingByName("GuiGreen").getValDouble(), (int)Client.setmgr.getSettingByName("GuiBlue").getValDouble()); + } +} diff --git a/de/Hero/clickgui/util/FontUtil.java b/de/Hero/clickgui/util/FontUtil.java new file mode 100644 index 0000000..6d843d5 --- /dev/null +++ b/de/Hero/clickgui/util/FontUtil.java @@ -0,0 +1,53 @@ +package de.Hero.clickgui.util; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.util.StringUtils; + +/** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class FontUtil { + private static FontRenderer fontRenderer; + + + public static void setupFontUtils() { + fontRenderer = Minecraft.getMinecraft().fontRendererObj; + } + + public static int getStringWidth(String text) { + return fontRenderer.getStringWidth(StringUtils.stripControlCodes(text)); + } + + public static int getFontHeight() { + return fontRenderer.FONT_HEIGHT; + } + + public static void drawString(String text, double x, double y, int color) { + fontRenderer.drawString(text, x, y, color); + } + + public static void drawStringWithShadow(String text, double x, double y, int color) { + fontRenderer.func_175063_a(text, (float) x, (float) y, color); + } + + public static void drawCenteredString(String text, double x, double y, int color) { + drawString(text, x - fontRenderer.getStringWidth(text) / 2, y, color); + } + + public static void drawCenteredStringWithShadow(String text, double x, double y, int color) { + drawStringWithShadow(text, x - fontRenderer.getStringWidth(text) / 2, y, color); + } + + public static void drawTotalCenteredString(String text, double x, double y, int color) { + drawString(text, x - fontRenderer.getStringWidth(text) / 2, y - fontRenderer.FONT_HEIGHT / 2, color); + } + + public static void drawTotalCenteredStringWithShadow(String text, double x, double y, int color) { + drawStringWithShadow(text, x - fontRenderer.getStringWidth(text) / 2, y - fontRenderer.FONT_HEIGHT / 2F, color); + } +} diff --git a/de/Hero/example/ClientMain.java b/de/Hero/example/ClientMain.java new file mode 100644 index 0000000..91e503e --- /dev/null +++ b/de/Hero/example/ClientMain.java @@ -0,0 +1,30 @@ +package de.Hero.example; + +import me.deinclient.modules.Module; +import me.deinclient.modules.ModuleMgr; +import de.Hero.clickgui.ClickGUI; +import de.Hero.settings.SettingsManager; + +/** \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ + * ----> This is just how your client main class <----- + * ----> should look like <----- + * /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ + * + * @author HeroCode + */ +public class ClientMain { + public static SettingsManager setmgr; + public static ModuleMgr modulemgr; + public static ClickGUI clickgui; + + public static void setupClient(){ + //SettingsMgr zuerst + setmgr = new SettingsManager(); + //Dann modulemgr + modulemgr = new ModuleMgr(); + modulemgr.rM(new GUI()); //Das würde natürlich in der Klasse des ModuleMgr passieren ;) + //modulemgr.rM(new ...); und so weiter + //Zu letzt das ClickGUI setzen + clickgui = new ClickGUI(); + } +} diff --git a/de/Hero/example/GUI.java b/de/Hero/example/GUI.java new file mode 100644 index 0000000..32d9ff2 --- /dev/null +++ b/de/Hero/example/GUI.java @@ -0,0 +1,52 @@ +package de.Hero.example; + +import java.util.ArrayList; + +import org.lwjgl.input.Keyboard; + +import de.Hero.settings.Setting; + +//Deine Imports +import me.deinclient.Client; +import me.deinclient.modules.Category; +import me.deinclient.modules.Module; + +/** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class GUI extends Module{ + + public GUI() + { + super("ClickGUI", Keyboard.KEY_T, Category.HIDDEN, 0xff0B21D6); + } + + //Setup is called in the Module con + @Override + public void setup(){ + ArrayList options = new ArrayList<>(); + options.add("JellyLike"); + options.add("New"); + Client.setmgr.rSetting(new Setting("Design", this, "New", options)); + Client.setmgr.rSetting(new Setting("Sound", this, false)); + Client.setmgr.rSetting(new Setting("GuiRed", this, 255, 0, 255, true)); + Client.setmgr.rSetting(new Setting("GuiGreen", this, 26, 0, 255, true)); + Client.setmgr.rSetting(new Setting("GuiBlue", this, 42, 0, 255, true)); + } + + @Override + public void onEnable() + { + /** + * Einfach in der StartMethode + * clickgui = new ClickGUI(); ;) + */ + mc.displayGuiScreen(Client.clickgui); + toggle(); + super.onEnable(); + } +} diff --git a/de/Hero/settings/Setting.java b/de/Hero/settings/Setting.java new file mode 100644 index 0000000..56c534e --- /dev/null +++ b/de/Hero/settings/Setting.java @@ -0,0 +1,119 @@ +package de.Hero.settings; + +import java.util.ArrayList; + +//Deine Imports +import me.deinclient.modules.Module; + +/** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class Setting { + + private String name; + private Module parent; + private String mode; + + private String sval; + private ArrayList options; + + private boolean bval; + + private double dval; + private double min; + private double max; + private boolean onlyint = false; + + + public Setting(String name, Module parent, String sval, ArrayList options){ + this.name = name; + this.parent = parent; + this.sval = sval; + this.options = options; + this.mode = "Combo"; + } + + public Setting(String name, Module parent, boolean bval){ + this.name = name; + this.parent = parent; + this.bval = bval; + this.mode = "Check"; + } + + public Setting(String name, Module parent, double dval, double min, double max, boolean onlyint){ + this.name = name; + this.parent = parent; + this.dval = dval; + this.min = min; + this.max = max; + this.onlyint = onlyint; + this.mode = "Slider"; + } + + public String getName(){ + return name; + } + + public Module getParentMod(){ + return parent; + } + + public String getValString(){ + return this.sval; + } + + public void setValString(String in){ + this.sval = in; + } + + public ArrayList getOptions(){ + return this.options; + } + + public boolean getValBoolean(){ + return this.bval; + } + + public void setValBoolean(boolean in){ + this.bval = in; + } + + public double getValDouble(){ + if(this.onlyint){ + this.dval = (int)dval; + } + return this.dval; + } + + public void setValDouble(double in){ + this.dval = in; + } + + public double getMin(){ + return this.min; + } + + public double getMax(){ + return this.max; + } + + public boolean isCombo(){ + return this.mode.equalsIgnoreCase("Combo") ? true : false; + } + + public boolean isCheck(){ + return this.mode.equalsIgnoreCase("Check") ? true : false; + } + + public boolean isSlider(){ + return this.mode.equalsIgnoreCase("Slider") ? true : false; + } + + public boolean onlyInt(){ + return this.onlyint; + } +} diff --git a/de/Hero/settings/SettingsManager.java b/de/Hero/settings/SettingsManager.java new file mode 100644 index 0000000..0026485 --- /dev/null +++ b/de/Hero/settings/SettingsManager.java @@ -0,0 +1,55 @@ +package de.Hero.settings; + +import java.util.ArrayList; + +//Deine Imports +import me.deinclient.Client; +import me.deinclient.modules.Module; + +/** + * Made by HeroCode + * it's free to use + * but you have to credit me + * + * @author HeroCode + */ +public class SettingsManager { + + private ArrayList settings; + + public SettingsManager(){ + this.settings = new ArrayList<>(); + } + + public void rSetting(Setting in){ + this.settings.add(in); + } + + public ArrayList getSettings(){ + return this.settings; + } + + public ArrayList getSettingsByMod(Module mod){ + ArrayList out = new ArrayList<>(); + for(Setting s : getSettings()){ + if(s.getParentMod().equals(mod)){ + out.add(s); + } + } + if(out.isEmpty()){ + return null; + } + return out; + } + + public Setting getSettingByName(String name){ + for(Setting set : getSettings()){ + if(set.getName().equalsIgnoreCase(name)){ + return set; + } + } + System.err.println("["+ Client.client_name + "] Error Setting NOT found: '" + name +"'!"); + return null; + } + +} \ No newline at end of file