├── README.md └── de └── vinii └── management └── ui └── clickgui ├── ClickGui.java ├── Panel.java ├── components ├── Frame.java ├── GuiButton.java ├── GuiComboBox.java ├── GuiComponent.java ├── GuiFrame.java ├── GuiGetKey.java ├── GuiLabel.java ├── GuiSlider.java ├── GuiToggleButton.java └── listeners │ ├── ComboListener.java │ ├── ComponentListener.java │ ├── KeyListener.java │ ├── TextListener.java │ └── ValueListener.java ├── listeners ├── ClickListener.java └── ComponentsListener.java └── util ├── FramePosition.java ├── MathUtil.java └── RenderUtil.java /README.md: -------------------------------------------------------------------------------- 1 | # Usage 2 | **Use is only authorized if given credit!** 3 | 4 | In order to display the gui use: 5 | *mc.displayGuiScreen(new Panel("Caesium", 22));* 6 | - use "Caesium" as default theme! 7 | 8 | ## Important classes to modify: 9 | - ClickListener.java -> change module activation 10 | - ComponentsListener.java -> replace Settingssystem to your preferred system 11 | - Panel.java -> change for loops for your categorys and modules 12 | 13 | ## Previews 14 | - ![1](https://vinii.de/github/ClickGui/1.png) 15 | - ![2](http://vinii.de/github/ClickGui/2.png) 16 | - ![3](http://vinii.de/github/ClickGui/3.png) 17 | - ![4](http://vinii.de/github/ClickGui/4.png) 18 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/ClickGui.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui; 2 | 3 | import java.io.IOException; 4 | import java.util.ArrayList; 5 | 6 | import de.vinii.management.ui.clickgui.components.Frame; 7 | import de.vinii.management.utils.render.FontRenderer; 8 | import net.minecraft.client.gui.GuiScreen; 9 | import net.minecraft.client.gui.ScaledResolution; 10 | 11 | /** 12 | * @author sendQueue 13 | * 14 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 15 | * Use is only authorized if given credit! 16 | * 17 | */ 18 | public class ClickGui extends GuiScreen { 19 | 20 | public static int compID = 0; 21 | 22 | private ArrayList frames = new ArrayList(); 23 | // dont change 24 | private final FontRenderer fr = new FontRenderer("Arial", 12); 25 | 26 | /** 27 | * 28 | */ 29 | public ClickGui() { 30 | compID = 0; 31 | 32 | } 33 | 34 | protected void addFrame(Frame frame) { 35 | if (!frames.contains(frame)) { 36 | frames.add(frame); 37 | } 38 | } 39 | 40 | protected ArrayList getFrames() { 41 | return frames; 42 | } 43 | 44 | @Override 45 | public void initGui() { 46 | for (Frame frame : frames) { 47 | frame.initialize(); 48 | } 49 | } 50 | 51 | @Override 52 | protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { 53 | for (Frame frame : frames) { 54 | frame.mouseClicked(mouseX, mouseY, mouseButton); 55 | } 56 | } 57 | 58 | @Override 59 | protected void keyTyped(char typedChar, int keyCode) throws IOException { 60 | super.keyTyped(typedChar, keyCode); 61 | 62 | for (Frame frame : frames) { 63 | frame.keyTyped(keyCode, typedChar); 64 | } 65 | } 66 | 67 | @Override 68 | public void drawScreen(int mouseX, int mouseY, float partialTicks) { 69 | // removing will give you cancer 70 | ScaledResolution sR = new ScaledResolution(mc); 71 | fr.drawString("ClickGui by Vinii | sendQueue", 2, sR.getScaledHeight() - fr.FONT_HEIGHT, Panel.fontColor); 72 | for (Frame frame : frames) { 73 | frame.render(mouseX, mouseY); 74 | } 75 | } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/Panel.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui; 2 | 3 | import java.awt.Color; 4 | import java.util.HashMap; 5 | 6 | import de.vinii.management.module.Category; 7 | import de.vinii.management.module.Module; 8 | import de.vinii.management.module.ModuleManager; 9 | import de.vinii.management.ui.clickgui.components.Frame; 10 | import de.vinii.management.ui.clickgui.components.GuiButton; 11 | import de.vinii.management.ui.clickgui.components.GuiFrame; 12 | import de.vinii.management.ui.clickgui.listeners.ClickListener; 13 | import de.vinii.management.ui.clickgui.listeners.ComponentsListener; 14 | import de.vinii.management.ui.clickgui.util.FramePosition; 15 | import de.vinii.management.utils.render.FontRenderer; 16 | 17 | 18 | /** 19 | * @author sendQueue 20 | * 21 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 22 | * Use is only authorized if given credit! 23 | * 24 | * Some renderstuff requires https://github.com/sendQueue/LWJGLUtil 25 | * 26 | */ 27 | public class Panel extends ClickGui { 28 | public static HashMap framePositions = new HashMap(); 29 | 30 | public static FontRenderer fR = new FontRenderer("Arial", 18); 31 | 32 | public static String theme; 33 | 34 | public static int FRAME_WIDTH = 100; 35 | 36 | // colors 37 | public static int color = new Color(193, 105, 170, 220).getRGB(); 38 | public static int fontColor = Color.white.getRGB(); 39 | public static int grey40_240 = new Color(40, 40, 40, 140).getRGB(); 40 | public static int black195 = new Color(0, 0, 0, 195).getRGB(); 41 | public static int black100 = new Color(0, 0, 0, 100).getRGB(); 42 | 43 | 44 | /** 45 | * Initializes Panel 46 | * 47 | * @param theme 48 | * @param fontSize 49 | */ 50 | public Panel(String theme, int fontSize) { 51 | this.theme = theme; 52 | fR = new FontRenderer("BigNoodleTitling", fontSize); 53 | } 54 | 55 | @Override 56 | public void initGui() { 57 | int x = 25; 58 | for (Category cat : Category.values()) { 59 | GuiFrame frame; 60 | // load frame positions 61 | if (framePositions.containsKey(cat.name())) { 62 | FramePosition curPos = framePositions.get(cat.name()); 63 | frame = new GuiFrame(cat.name(), curPos.getPosX(), curPos.getPosY(), curPos.isExpanded()); 64 | } else { 65 | frame = new GuiFrame(cat.name(), x, 50, true); 66 | } 67 | for (Module m : ModuleManager.moduleList) { 68 | if (cat == m.category && (m.shown)) { 69 | GuiButton button = new GuiButton(m.getName()); 70 | button.addClickListener(new ClickListener(button)); 71 | button.addExtendListener(new ComponentsListener(button)); 72 | frame.addButton(button); 73 | } 74 | } 75 | addFrame(frame); 76 | x += 140; 77 | } 78 | super.initGui(); 79 | } 80 | 81 | public void onGuiClosed() { 82 | // save positions to framePositions 83 | if (!getFrames().isEmpty()) { 84 | for (Frame frame : getFrames()) { 85 | GuiFrame guiFrame = ((GuiFrame) frame); 86 | framePositions.put(guiFrame.getTitle(), 87 | new FramePosition(guiFrame.getPosX(), guiFrame.getPosY(), guiFrame.isExpaned())); 88 | } 89 | } 90 | ModuleManager.getModule(de.vinii.modules.render.ClickGui.class).onDisable(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/Frame.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components; 2 | 3 | /** 4 | * @author sendQueue 5 | * 6 | * Further info at Vinii.de or github@vinii.de, file created at 7 | * 10.11.2020. Use is only authorized if given credit! 8 | * 9 | */ 10 | public interface Frame { 11 | 12 | void initialize(); 13 | 14 | void render(int mouseX, int mouseY); 15 | 16 | void mouseClicked(int mouseX, int mouseY, int mouseButton); 17 | 18 | void keyTyped(int keyCode, char typedChar); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/GuiButton.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components; 2 | 3 | import java.awt.Color; 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.util.ArrayList; 7 | 8 | import de.vinii.management.module.ModuleManager; 9 | import de.vinii.management.ui.clickgui.ClickGui; 10 | import de.vinii.management.ui.clickgui.Panel; 11 | import de.vinii.management.ui.clickgui.components.listeners.ComponentListener; 12 | import de.vinii.management.ui.clickgui.util.RenderUtil; 13 | 14 | 15 | /** 16 | * @author sendQueue 17 | * 18 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 19 | * Use is only authorized if given credit! 20 | * 21 | */ 22 | public class GuiButton implements GuiComponent { 23 | public static int expandedID = -1; 24 | private int id; 25 | 26 | private String text; 27 | 28 | private ArrayList clickListeners = new ArrayList(); 29 | private ArrayList guiComponents = new ArrayList(); 30 | 31 | private int width, textWidth, posX, posY; 32 | 33 | /** 34 | * 35 | */ 36 | public GuiButton(String text) { 37 | this.text = text; 38 | textWidth = Panel.fR.getStringWidth(text); 39 | id = ClickGui.compID += 1; 40 | } 41 | 42 | @Override 43 | public void render(int posX, int posY, int width, int mouseX, int mouseY, int wheelY) { 44 | this.posX = posX; 45 | this.posY = posY; 46 | this.width = width; 47 | 48 | final int height = getHeight(); 49 | switch (Panel.theme) { 50 | case "Caesium": 51 | renderCaesium(posX, posY, width, height); 52 | break; 53 | default: 54 | break; 55 | } 56 | 57 | } 58 | 59 | /** 60 | * Renders button for theme Caesium 61 | */ 62 | private void renderCaesium(int posX, int posY, int width, int height) { 63 | 64 | RenderUtil.drawRect(posX, posY, posX + width - 1, posY + height, Panel.black100); 65 | 66 | int color = Panel.fontColor; 67 | 68 | if (ModuleManager.getModule(getText()).getState()) 69 | color = Panel.color; 70 | 71 | Panel.fR.drawStringWithShadow(getText(), posX + (width / 2) - Panel.fR.getStringWidth(getText()) / 2, posY + 2, 72 | color); 73 | } 74 | 75 | @Override 76 | public void mouseClicked(int mouseX, int mouseY, int mouseButton) { 77 | if (GuiFrame.dragID == -1 && RenderUtil.isHovered(posX, posY, width, getHeight(), mouseX, mouseY)) { 78 | if (mouseButton == 1) { 79 | if (expandedID != id) { 80 | expandedID = id; 81 | } else { 82 | expandedID = -1; 83 | } 84 | } else if (mouseButton == 0) { 85 | for (ActionListener listener : clickListeners) { 86 | listener.actionPerformed(new ActionEvent(this, id, "click", System.currentTimeMillis(), 0)); 87 | } 88 | } 89 | } 90 | 91 | if (expandedID == id) { 92 | for (GuiComponent component : guiComponents) { 93 | component.mouseClicked(mouseX, mouseY, mouseButton); 94 | } 95 | } 96 | 97 | } 98 | 99 | @Override 100 | public void keyTyped(int keyCode, char typedChar) { 101 | if (expandedID == id) { 102 | for (GuiComponent component : guiComponents) { 103 | component.keyTyped(keyCode, typedChar); 104 | } 105 | } 106 | 107 | } 108 | 109 | @Override 110 | public int getWidth() { 111 | return 5 + textWidth; 112 | } 113 | 114 | @Override 115 | public int getHeight() { 116 | return Panel.fR.FONT_HEIGHT + 3; 117 | } 118 | 119 | @Override 120 | public boolean allowScroll() { 121 | return true; 122 | } 123 | 124 | public String getText() { 125 | return text; 126 | } 127 | 128 | public int getButtonID() { 129 | return id; 130 | } 131 | 132 | public ArrayList getComponents() { 133 | return guiComponents; 134 | } 135 | 136 | public void addClickListener(ActionListener actionlistener) { 137 | clickListeners.add(actionlistener); 138 | } 139 | 140 | public void addExtendListener(ComponentListener listener) { 141 | listener.addComponents(); 142 | guiComponents.addAll(listener.getComponents()); 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/GuiComboBox.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package de.vinii.management.ui.clickgui.components; 5 | 6 | import java.awt.Color; 7 | import java.util.ArrayList; 8 | 9 | import de.vinii.management.settings.Setting; 10 | import de.vinii.management.ui.clickgui.ClickGui; 11 | import de.vinii.management.ui.clickgui.Panel; 12 | import de.vinii.management.ui.clickgui.components.listeners.ComboListener; 13 | import de.vinii.management.ui.clickgui.util.RenderUtil; 14 | 15 | /** 16 | * @author sendQueue 17 | * 18 | * Further info at Vinii.de or github@vinii.de, file created at 19 | * 11.11.2020. Use is only authorized if given credit! 20 | * 21 | */ 22 | public class GuiComboBox implements GuiComponent { 23 | private Setting setting; 24 | private boolean extended; 25 | private int height, posX, posY, width; 26 | 27 | private ArrayList comboListeners = new ArrayList(); 28 | 29 | public GuiComboBox(Setting setting) { 30 | this.setting = setting; 31 | } 32 | 33 | public void addComboListener(ComboListener comboListener) { 34 | comboListeners.add(comboListener); 35 | } 36 | 37 | @Override 38 | public void render(int posX, int posY, int width, int mouseX, int mouseY, int wheelY) { 39 | this.posX = posX; 40 | this.posY = posY; 41 | this.width = width; 42 | switch (Panel.theme) { 43 | case "Caesium": 44 | renderCaesium(); 45 | break; 46 | 47 | default: 48 | break; 49 | } 50 | } 51 | 52 | public void renderCaesium() { 53 | if (extended) { 54 | RenderUtil.drawRect(posX, posY, posX + width, posY + Panel.fR.FONT_HEIGHT + 2, Panel.grey40_240); 55 | RenderUtil.drawHorizontalLine(posX, posX + width, posY , Panel.black195); 56 | RenderUtil.drawHorizontalLine(posX, posX + width, posY + Panel.fR.FONT_HEIGHT + 2, 57 | new Color(0, 0, 0, 150).getRGB()); 58 | Panel.fR.drawStringWithShadow(setting.getName() + " -", 59 | posX + width / 2 - Panel.fR.getStringWidth(setting.getName() + " -") / 2, posY + 2, Panel.fontColor); 60 | 61 | int innerHeight = (Panel.fR.FONT_HEIGHT + 5); 62 | for (String combo : setting.getCombos()) { 63 | if (setting.getSelectedCombo().equalsIgnoreCase(combo)) { 64 | Panel.fR.drawStringWithShadow(combo, posX + 10, posY + innerHeight, Panel.color); 65 | } else { 66 | Panel.fR.drawStringWithShadow(combo, posX + 5, posY + innerHeight, Panel.fontColor); 67 | } 68 | innerHeight += (Panel.fR.FONT_HEIGHT + 2); 69 | } 70 | height = innerHeight + 2; 71 | } else { 72 | RenderUtil.drawRect(posX, posY, posX + width, posY + Panel.fR.FONT_HEIGHT + 2, Panel.grey40_240); 73 | 74 | RenderUtil.drawHorizontalLine(posX, posX + width, posY, Panel.black195); 75 | RenderUtil.drawHorizontalLine(posX, posX + width, posY + Panel.fR.FONT_HEIGHT + 2, Panel.black195); 76 | Panel.fR.drawStringWithShadow(setting.getName() + " +", 77 | posX + width / 2 - Panel.fR.getStringWidth(setting.getName()+ " +") / 2, posY + 2, Panel.fontColor); 78 | height = Panel.fR.FONT_HEIGHT + 4; 79 | } 80 | } 81 | 82 | @Override 83 | public void mouseClicked(int mouseX, int mouseY, int mouseButton) { 84 | if (RenderUtil.isHovered(posX, posY, width, Panel.fR.FONT_HEIGHT +2, mouseX, mouseY)) { 85 | extended = !extended; 86 | } 87 | if (extended) { 88 | if (RenderUtil.isHovered(posX, posY + Panel.fR.FONT_HEIGHT + 2, width, 89 | (Panel.fR.FONT_HEIGHT + 2) * setting.getCombos().length, mouseX, mouseY) && mouseButton == 0) { 90 | int h = Panel.fR.FONT_HEIGHT + 2; 91 | for (int i = 1; i <= setting.getCombos().length + 1; i++) { 92 | if (RenderUtil.isHovered(posX, posY + h * i, width, h * i, mouseX, mouseY)) { 93 | setting.setSelectedCombo(setting.getCombos()[i - 1]); 94 | } 95 | } 96 | for (ComboListener comboListener : comboListeners) { 97 | comboListener.comboChanged(setting.getSelectedCombo()); 98 | } 99 | } 100 | } 101 | } 102 | 103 | @Override 104 | public void keyTyped(int keyCode, char typedChar) { 105 | 106 | } 107 | 108 | @Override 109 | public int getWidth() { 110 | 111 | return 0; 112 | } 113 | 114 | @Override 115 | public int getHeight() { 116 | return height; 117 | } 118 | 119 | @Override 120 | public boolean allowScroll() { 121 | return true; 122 | } 123 | 124 | /** 125 | * @return the setting 126 | */ 127 | public Setting getSetting() { 128 | return setting; 129 | } 130 | 131 | /** 132 | * @param setting the setting to set 133 | */ 134 | public void setSetting(Setting setting) { 135 | this.setting = setting; 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/GuiComponent.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components; 2 | 3 | /** 4 | * @author sendQueue 5 | * 6 | * Further info at Vinii.de or github@vinii.de, file created at 7 | * 11.11.2020. Use is only authorized if given credit! 8 | * 9 | */ 10 | public interface GuiComponent { 11 | 12 | void render(int posX, int posY, int width, int mouseX, int mouseY, int wheelY); 13 | 14 | void mouseClicked(int mouseX, int mouseY, int mouseButton); 15 | 16 | void keyTyped(int keyCode, char typedChar); 17 | 18 | int getWidth(); 19 | 20 | int getHeight(); 21 | 22 | boolean allowScroll(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/GuiFrame.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components; 2 | 3 | import java.awt.Color; 4 | import java.util.ArrayList; 5 | 6 | import org.lwjgl.input.Mouse; 7 | 8 | import de.vinii.management.ui.clickgui.ClickGui; 9 | import de.vinii.management.ui.clickgui.Panel; 10 | import de.vinii.management.ui.clickgui.util.RenderUtil; 11 | import de.vinii.management.utils.render.GL11Util; 12 | 13 | /** 14 | * @author sendQueue 15 | * 16 | * Further info at Vinii.de or github@vinii.de, file created at 17 | * 11.11.2020. Use is only authorized if given credit! 18 | * 19 | */ 20 | public class GuiFrame implements Frame { 21 | private ArrayList buttons = new ArrayList(); 22 | 23 | private boolean isExpaned, isDragging; 24 | 25 | private int id, posX, posY, prevPosX, prevPosY, scrollHeight; 26 | public static int dragID; 27 | 28 | private String title; 29 | 30 | /** 31 | * 32 | */ 33 | public GuiFrame(String title, int posX, int posY, boolean expanded) { 34 | this.title = title; 35 | this.posX = posX; 36 | this.posY = posY; 37 | this.isExpaned = expanded; 38 | this.id = ClickGui.compID += 1; 39 | this.scrollHeight = 0; 40 | } 41 | 42 | @Override 43 | public void render(int mouseX, int mouseY) { 44 | switch (Panel.theme) { 45 | case "Caesium": 46 | renderCaesium(mouseX, mouseY); 47 | break; 48 | 49 | default: 50 | break; 51 | } 52 | } 53 | 54 | /** 55 | * Handles Caesium theme 56 | * 57 | * @param mouseX 58 | * @param mouseY 59 | */ 60 | private void renderCaesium(int mouseX, int mouseY) { 61 | final int color = Panel.color; 62 | final int fontColor = Panel.fontColor; 63 | int width = Math.max(Panel.FRAME_WIDTH, Panel.fR.getStringWidth(title) + 15); 64 | if (isDragging && Mouse.isButtonDown(0)) { 65 | posX = mouseX - prevPosX; 66 | posY = mouseY - prevPosY; 67 | dragID = id; 68 | } else { 69 | isDragging = false; 70 | dragID = -1; 71 | } 72 | for (GuiButton button : buttons) { 73 | width = Math.max(width, button.getWidth() + 15); 74 | } 75 | RenderUtil.drawRect(posX + 1, posY - 5, posX + width, posY + 12, color); 76 | GL11Util.drawVerticalGradient(posX + 1, posY - 5, width - 1, 17, 77 | GL11Util.brighter(new Color(color), 0.7f).getRGB(), GL11Util.darker(new Color(color), 0.7f).getRGB()); 78 | Panel.fR.drawStringWithShadow(title, (posX + (width / 2)) - Panel.fR.getStringWidth(title) / 2, posY, 79 | fontColor); 80 | Panel.fR.drawStringWithShadow(isExpaned ? "-" : "+", 81 | posX + width - Panel.fR.getStringWidth(isExpaned ? "-" : "+") - 4, posY, fontColor); 82 | if (isExpaned) { 83 | int height = 0; 84 | final int background = Panel.grey40_240; 85 | for (GuiButton button : buttons) { 86 | button.render(posX + 1, posY + height + 12, width, mouseX, mouseY, 0); 87 | // check if -1 88 | if (button.getButtonID() == GuiButton.expandedID) { 89 | ArrayList components = button.getComponents(); 90 | if (!components.isEmpty()) { 91 | int xOffset = 10; 92 | int yOffset = 0; 93 | boolean allowScroll = true; 94 | for (GuiComponent component : components) { 95 | xOffset = Math.max(xOffset, component.getWidth()); 96 | yOffset += component.getHeight(); 97 | if (!component.allowScroll()) { 98 | allowScroll = false; 99 | } 100 | } 101 | final int left = posX + width + 2; 102 | final int right = left + xOffset; 103 | final int top = posY + height + 12; 104 | final int bottom = top + yOffset + 1; 105 | // 8 is the scroll reduction 106 | int wheelY = Mouse.getDWheel() * -1 / 8; 107 | if (bottom + scrollHeight < 30) { 108 | wheelY *= -1; 109 | scrollHeight += 10; 110 | } 111 | if (allowScroll) 112 | scrollHeight += wheelY; 113 | 114 | RenderUtil.drawRect(left + 1, top + 1 + scrollHeight, right, bottom + scrollHeight, 115 | Panel.black100); 116 | int height2 = 0; 117 | for (GuiComponent component : components) { 118 | component.render(left, top + height2 + 2 + scrollHeight, xOffset, mouseX, mouseY, wheelY); 119 | height2 += component.getHeight(); 120 | } 121 | RenderUtil.drawVerticalLine(left, top + scrollHeight, bottom + scrollHeight, color); 122 | RenderUtil.drawVerticalLine(right, top + scrollHeight, bottom + scrollHeight, color); 123 | RenderUtil.drawHorizontalLine(left, right, top + scrollHeight, color); 124 | RenderUtil.drawHorizontalLine(left, right, bottom + scrollHeight, color); 125 | } 126 | } 127 | height += button.getHeight(); 128 | } 129 | // RenderUtil.drawHorizontalLine(posX + 1, posX + width - 1, posY + height + 12, color); 130 | GL11Util.drawVerticalGradient(posX + 1, posY + height + 12, width - 1, 1, 131 | GL11Util.darker(new Color(color), 0.7f).getRGB(), 132 | GL11Util.brighter(new Color(color), 0.7f).getRGB()); 133 | 134 | RenderUtil.drawVerticalLine(posX + width, posY - 5, posY + height + 14, Panel.black100); 135 | RenderUtil.drawVerticalLine(posX + width, posY - 4, posY + height + 14, Panel.black100); 136 | RenderUtil.drawVerticalLine(posX + width + 1, posY - 4, posY + height + 15, Panel.black100); 137 | RenderUtil.drawHorizontalLine(posX + 2, posX + width - 1, posY + height + 13, Panel.black100); 138 | RenderUtil.drawHorizontalLine(posX + 2, posX + width - 1, posY + height + 13, Panel.black100); 139 | RenderUtil.drawHorizontalLine(posX + 3, posX + width, posY + height + 14, Panel.black100); 140 | } 141 | } 142 | 143 | @Override 144 | public void mouseClicked(int mouseX, int mouseY, int mouseButton) { 145 | int width = Panel.FRAME_WIDTH; 146 | if (isExpaned) { 147 | 148 | for (GuiButton button : buttons) { 149 | // sort for the max needed width 150 | width = Math.max(width, button.getWidth()); 151 | button.mouseClicked(mouseX, mouseY, mouseButton); 152 | } 153 | } 154 | if (RenderUtil.isHovered(posX, posY, width, 13, mouseX, mouseY)) { 155 | if (mouseButton == 0) { 156 | prevPosX = mouseX - posX; 157 | prevPosY = mouseY - posY; 158 | isDragging = true; 159 | dragID = id; 160 | } else if (mouseButton == 1) { 161 | isExpaned = !isExpaned; 162 | scrollHeight = 0; 163 | isDragging = false; 164 | dragID = -1; 165 | } 166 | } 167 | } 168 | 169 | @Override 170 | public void keyTyped(int keyCode, char typedChar) { 171 | if (isExpaned) { 172 | for (GuiButton button : buttons) { 173 | button.keyTyped(keyCode, typedChar); 174 | } 175 | } 176 | } 177 | 178 | @Override 179 | public void initialize() { 180 | // TODO Auto-generated method stub 181 | 182 | } 183 | 184 | public void addButton(GuiButton button) { 185 | if (!buttons.contains(button)) { 186 | buttons.add(button); 187 | } 188 | } 189 | 190 | public int getButtonID() { 191 | return id; 192 | } 193 | 194 | /** 195 | * @return isExpaned 196 | */ 197 | public boolean isExpaned() { 198 | return isExpaned; 199 | } 200 | 201 | /** 202 | * @return the posX 203 | */ 204 | public int getPosX() { 205 | return posX; 206 | } 207 | 208 | /** 209 | * @return the posY 210 | */ 211 | public int getPosY() { 212 | return posY; 213 | } 214 | 215 | /** 216 | * @return the title 217 | */ 218 | public String getTitle() { 219 | return title; 220 | } 221 | 222 | } 223 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/GuiGetKey.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components; 2 | 3 | import java.awt.Color; 4 | import java.util.ArrayList; 5 | 6 | import org.lwjgl.input.Keyboard; 7 | 8 | import de.vinii.management.ui.clickgui.Panel; 9 | import de.vinii.management.ui.clickgui.components.listeners.KeyListener; 10 | import de.vinii.management.ui.clickgui.util.RenderUtil; 11 | import de.vinii.management.utils.render.GL11Util; 12 | 13 | /** 14 | * @author sendQueue 15 | * 16 | * Further info at Vinii.de or github@vinii.de, file created at 17 | * 11.11.2020. Use is only authorized if given credit! 18 | * 19 | */ 20 | public class GuiGetKey implements GuiComponent { 21 | private boolean wasChanged, allowChange; 22 | private int key, posX, posY, width; 23 | private String text; 24 | 25 | private ArrayList keylisteners = new ArrayList(); 26 | 27 | public GuiGetKey(String text, int key) { 28 | this.text = text; 29 | this.key = key; 30 | if (key < 0) 31 | this.key = 0; 32 | } 33 | 34 | public void addKeyListener(KeyListener listener) { 35 | keylisteners.add(listener); 36 | } 37 | 38 | @Override 39 | public void render(int posX, int posY, int width, int mouseX, int mouseY, int wheelY) { 40 | this.posX = posX; 41 | this.posY = posY; 42 | this.width = width; 43 | switch (Panel.theme) { 44 | case "Caesium": 45 | renderCaesium(posX, posY); 46 | break; 47 | default: 48 | break; 49 | } 50 | } 51 | 52 | private void renderCaesium(int posX, int posY) { 53 | String keyString = Keyboard.getKeyName(key); 54 | if (allowChange) { 55 | wasChanged = !wasChanged; 56 | }else { 57 | wasChanged = true; 58 | } 59 | GL11Util.drawVerticalGradient(posX, posY, width, 14, GL11Util.darker(new Color(Panel.color), 0.7f).getRGB(), GL11Util.brighter(new Color(Panel.color), 0.7f).getRGB()); 60 | Panel.fR.drawStringWithShadow(text + ":", posX + 3, posY + 3, Panel.fontColor); 61 | if (wasChanged) { 62 | Panel.fR.drawStringWithShadow(keyString, posX + width - Panel.fR.getStringWidth(keyString) - 3, posY + 3, 63 | Panel.fontColor); 64 | } else { 65 | Panel.fR.drawString(keyString, posX + width - Panel.fR.getStringWidth(keyString) - 3, posY + 3, 66 | Panel.fontColor); 67 | } 68 | } 69 | 70 | @Override 71 | public void mouseClicked(int mouseX, int mouseY, int mouseButton) { 72 | String keyString = Keyboard.getKeyName(key); 73 | final int w = Panel.fR.getStringWidth(text); 74 | if (RenderUtil.isHovered(posX, posY, width, 11, mouseX, mouseY)) { 75 | allowChange = true; 76 | } else { 77 | allowChange = false; 78 | } 79 | 80 | } 81 | 82 | @Override 83 | public void keyTyped(int keyCode, char typedChar) { 84 | if (allowChange) { 85 | for (KeyListener listener : keylisteners) { 86 | listener.keyChanged(keyCode); 87 | } 88 | 89 | key = keyCode; 90 | allowChange = false; 91 | } 92 | } 93 | 94 | @Override 95 | public int getWidth() { 96 | return Panel.fR.getStringWidth(text + Keyboard.getKeyName(key)) + 15; 97 | } 98 | 99 | @Override 100 | public int getHeight() { 101 | return Panel.fR.FONT_HEIGHT + 4; 102 | } 103 | 104 | @Override 105 | public boolean allowScroll() { 106 | // TODO Auto-generated method stub 107 | return true; 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/GuiLabel.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components; 2 | 3 | import de.vinii.management.ui.clickgui.Panel; 4 | 5 | /** 6 | * @author sendQueue 7 | * 8 | * Further info at Vinii.de or github@vinii.de, file created at 9 | * 11.11.2020. Use is only authorized if given credit! 10 | * 11 | */ 12 | public class GuiLabel implements GuiComponent { 13 | private String text; 14 | 15 | public GuiLabel(String text) { 16 | this.text = text; 17 | } 18 | 19 | @Override 20 | public void render(int posX, int posY, int width, int mouseX, int mouseY, int wheelY) { 21 | Panel.fR.drawStringWithShadow(text, posX + width / 2 - Panel.fR.getStringWidth(text) / 2, posY + 2, 22 | Panel.fontColor); 23 | } 24 | 25 | @Override 26 | public void mouseClicked(int mouseX, int mouseY, int mouseButton) { 27 | } 28 | 29 | @Override 30 | public void keyTyped(int keyCode, char typedChar) { 31 | } 32 | 33 | @Override 34 | public int getWidth() { 35 | return Panel.fR.getStringWidth(text) + 4; 36 | } 37 | 38 | @Override 39 | public int getHeight() { 40 | return Panel.fR.FONT_HEIGHT + 2; 41 | } 42 | 43 | @Override 44 | public boolean allowScroll() { 45 | return true; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/GuiSlider.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components; 2 | 3 | import java.awt.Color; 4 | import java.util.ArrayList; 5 | 6 | import org.lwjgl.input.Mouse; 7 | 8 | import de.vinii.management.ui.clickgui.ClickGui; 9 | import de.vinii.management.ui.clickgui.Panel; 10 | import de.vinii.management.ui.clickgui.components.listeners.ValueListener; 11 | import de.vinii.management.ui.clickgui.util.MathUtil; 12 | import de.vinii.management.ui.clickgui.util.RenderUtil; 13 | import de.vinii.management.utils.render.GL11Util; 14 | import net.minecraft.util.MathHelper; 15 | 16 | /** 17 | * @author sendQueue 18 | * 19 | * Further info at Vinii.de or github@vinii.de, file created at 20 | * 11.11.2020. Use is only authorized if given credit! 21 | * 22 | */ 23 | public class GuiSlider implements GuiComponent { 24 | private static int dragId = -1; 25 | private int round, id, width, posX, posY; 26 | private float min, max, current; 27 | private double c; 28 | 29 | private boolean wasSliding, hovered; 30 | 31 | private String text; 32 | 33 | private ArrayList valueListeners = new ArrayList(); 34 | 35 | public GuiSlider(String text, float min, float max, float current, int round) { 36 | this.text = text; 37 | this.min = min; 38 | this.max = max; 39 | this.current = current; 40 | c = current / max; 41 | this.round = round; 42 | this.id = Panel.compID += 1; 43 | } 44 | 45 | public void addValueListener(ValueListener vallistener) { 46 | valueListeners.add(vallistener); 47 | } 48 | 49 | @Override 50 | public void render(int posX, int posY, int width, int mouseX, int mouseY, int wheelY) { 51 | this.posX = posX; 52 | this.posY = posY; 53 | this.width = width; 54 | hovered = RenderUtil.isHovered(posX, posY, width, getHeight(), mouseX, mouseY); 55 | if (hovered && wheelY != 0) { 56 | double diff = min < 0 ? Math.abs(min - max) : max - min; 57 | double w = wheelY / 15; 58 | // 100 => per scroll 1/100 of the diff is being added/subtracted 59 | w *= diff / 100; 60 | if (round == 0) { 61 | current = (int) MathHelper.clamp_double(current + w, min, max); 62 | } else { 63 | current = (float) MathHelper.clamp_double(current + w, min, max); 64 | } 65 | } 66 | if (Mouse.isButtonDown(0) && (dragId == id || dragId == -1) && hovered) { 67 | if (mouseX < posX + 2) { 68 | current = min; 69 | } else if (mouseX > posX + width) { 70 | current = max; 71 | } else { 72 | double diff = max - min; 73 | double val = min + (MathHelper.clamp_double((mouseX - posX + 3) / (double) width, 0, 1)) * diff; 74 | if (round == 0) { 75 | current = (int) val; 76 | } else { 77 | current = (float) val; 78 | } 79 | } 80 | dragId = id; 81 | for (ValueListener listener : valueListeners) { 82 | listener.valueUpdated(current); 83 | } 84 | wasSliding = true; 85 | 86 | } else if (!Mouse.isButtonDown(0) && wasSliding) { 87 | for (ValueListener listener : valueListeners) { 88 | listener.valueChanged(current); 89 | } 90 | dragId = -1; 91 | wasSliding = false; 92 | } 93 | double percent = (current - min) / (max - min); 94 | switch (Panel.theme) { 95 | case "Caesium": 96 | renderCaesium(percent); 97 | break; 98 | 99 | default: 100 | break; 101 | } 102 | } 103 | 104 | private void renderCaesium(double percent) { 105 | String value; 106 | if (round == 0) { 107 | value = "" + Math.round(current); 108 | } else { 109 | value = "" + MathUtil.round(current, round); 110 | } 111 | 112 | final Color color = new Color(Panel.color); 113 | 114 | Panel.fR.drawStringWithShadow(text + ":", posX + 3, posY + 3, Panel.fontColor); 115 | Panel.fR.drawStringWithShadow(value, posX + width - Panel.fR.getStringWidth(value) - 3, posY + 3, 116 | Panel.fontColor); 117 | 118 | GL11Util.drawRect(posX, posY + Panel.fR.FONT_HEIGHT + 3, posX + width - 2, posY + Panel.fR.FONT_HEIGHT + 5, 119 | Color.black.getRGB()); 120 | GL11Util.drawHorizontalGradient(posX, posY + Panel.fR.FONT_HEIGHT + 3, (float) (percent * width - 2), 2, 121 | color.darker().getRGB(), color.brighter().getRGB()); 122 | 123 | } 124 | 125 | @Override 126 | public void mouseClicked(int mouseX, int mouseY, int mouseButton) { 127 | } 128 | 129 | @Override 130 | public void keyTyped(int keyCode, char typedChar) { 131 | } 132 | 133 | @Override 134 | public int getWidth() { 135 | return Panel.fR.getStringWidth(text + (round == 0 ? Math.round(current) : MathUtil.round(current, round))) + 68; 136 | } 137 | 138 | @Override 139 | public int getHeight() { 140 | return Panel.fR.FONT_HEIGHT + 6; 141 | } 142 | 143 | @Override 144 | public boolean allowScroll() { 145 | return !hovered; 146 | } 147 | 148 | } 149 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/GuiToggleButton.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components; 2 | 3 | import java.awt.Color; 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.util.ArrayList; 7 | 8 | import de.vinii.management.ui.clickgui.Panel; 9 | import de.vinii.management.ui.clickgui.util.RenderUtil; 10 | import de.vinii.management.utils.render.GL11Util; 11 | 12 | /** 13 | * @author sendQueue 14 | * 15 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 16 | * Use is only authorized if given credit! 17 | * 18 | */ 19 | public class GuiToggleButton implements GuiComponent { 20 | 21 | private String text; 22 | private boolean toggled; 23 | 24 | private int posX, posY; 25 | 26 | private ArrayList clickListeners = new ArrayList(); 27 | 28 | /** 29 | * 30 | */ 31 | public GuiToggleButton(String text) { 32 | this.text = text; 33 | } 34 | 35 | @Override 36 | public void render(int posX, int posY, int width, int mouseX, int mouseY, int wheelY) { 37 | this.posX = posX; 38 | this.posY = posY; 39 | 40 | switch (Panel.theme) { 41 | case "Caesium": 42 | renderCaesium(posX, posY); 43 | break; 44 | default: 45 | break; 46 | } 47 | 48 | } 49 | 50 | /** 51 | * Renders toggleButton for theme Caesium 52 | */ 53 | private void renderCaesium(int posX, int posY) { 54 | GL11Util.drawFilledCircle(posX + 8, posY + 7, 6, new Color(Panel.color)); 55 | if(!toggled) 56 | GL11Util.drawFilledCircle(posX + 8, posY + 7, 5, new Color(Panel.grey40_240)); 57 | Panel.fR.drawStringWithShadow(text, posX + 17, posY + 3, Panel.fontColor); 58 | } 59 | 60 | @Override 61 | public void mouseClicked(int mouseX, int mouseY, int mouseButton) { 62 | final int width = Panel.fR.getStringWidth(text) + 10; 63 | if (RenderUtil.isHovered(posX, posY + 2, width, getHeight(), mouseX, mouseY)) { 64 | toggled = !toggled; 65 | for (ActionListener listener : clickListeners) { 66 | listener.actionPerformed(new ActionEvent(this, hashCode(), "click", System.currentTimeMillis(), 0)); 67 | } 68 | } 69 | 70 | } 71 | 72 | @Override 73 | public void keyTyped(int keyCode, char typedChar) { 74 | 75 | } 76 | 77 | @Override 78 | public int getWidth() { 79 | return Panel.fR.getStringWidth(text) + 20; 80 | } 81 | 82 | @Override 83 | public int getHeight() { 84 | return Panel.fR.FONT_HEIGHT + 5; 85 | } 86 | @Override 87 | public boolean allowScroll() { 88 | return true; 89 | } 90 | 91 | public boolean isToggled() { 92 | return toggled; 93 | } 94 | 95 | public void setToggled(boolean toggled) { 96 | this.toggled = toggled; 97 | } 98 | 99 | public void addClickListener(ActionListener actionlistener) { 100 | clickListeners.add(actionlistener); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/listeners/ComboListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package de.vinii.management.ui.clickgui.components.listeners; 5 | 6 | /** 7 | * @author sendQueue 8 | * 9 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 10 | * Use is only authorized if given credit! 11 | * 12 | */ 13 | public interface ComboListener { 14 | 15 | void comboChanged(String combo); 16 | } 17 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/listeners/ComponentListener.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components.listeners; 2 | 3 | import java.util.ArrayList; 4 | 5 | import de.vinii.management.ui.clickgui.components.GuiComponent; 6 | 7 | 8 | /** 9 | * @author sendQueue 10 | * 11 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 12 | * Use is only authorized if given credit! 13 | * 14 | */ 15 | public abstract class ComponentListener { 16 | 17 | private final ArrayList components = new ArrayList(); 18 | 19 | public ComponentListener() { 20 | } 21 | 22 | /** 23 | * @param component 24 | */ 25 | protected void add(GuiComponent component) { 26 | components.add(component); 27 | } 28 | 29 | /** 30 | * 31 | */ 32 | public void clearComponents() { 33 | components.clear(); 34 | } 35 | 36 | /** 37 | * @return 38 | */ 39 | public ArrayList getComponents() { 40 | return components; 41 | } 42 | 43 | /** 44 | * 45 | */ 46 | public abstract void addComponents(); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/listeners/KeyListener.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components.listeners; 2 | 3 | /** 4 | * @author sendQueue 5 | * 6 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 7 | * Use is only authorized if given credit! 8 | * 9 | */ 10 | public interface KeyListener { 11 | 12 | void keyChanged(int key); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/listeners/TextListener.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components.listeners; 2 | 3 | /** 4 | * @author sendQueue 5 | * 6 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 7 | * Use is only authorized if given credit! 8 | * 9 | */ 10 | public interface TextListener { 11 | 12 | void keyTyped(char key, String text); 13 | 14 | void keyEntered(String text); 15 | } 16 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/components/listeners/ValueListener.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.components.listeners; 2 | 3 | /** 4 | * @author sendQueue 5 | * 6 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 7 | * Use is only authorized if given credit! 8 | * 9 | */ 10 | public interface ValueListener { 11 | 12 | void valueUpdated(float value); 13 | 14 | void valueChanged(float value); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/listeners/ClickListener.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.listeners; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | 6 | import de.vinii.management.module.Module; 7 | import de.vinii.management.module.ModuleManager; 8 | import de.vinii.management.ui.clickgui.components.GuiButton; 9 | 10 | 11 | /** 12 | * @author sendQueue 13 | * 14 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 15 | * Use is only authorized if given credit! 16 | * 17 | */ 18 | public class ClickListener implements ActionListener { 19 | 20 | private GuiButton button; 21 | 22 | public ClickListener(GuiButton button) { 23 | this.button = button; 24 | } 25 | 26 | @Override 27 | public void actionPerformed(ActionEvent event) { 28 | Module m = ModuleManager.getModule(button.getText()); 29 | m.toggleModule(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/listeners/ComponentsListener.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.listeners; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | 6 | import de.vinii.management.module.Module; 7 | import de.vinii.management.module.ModuleManager; 8 | import de.vinii.management.settings.Setting; 9 | import de.vinii.management.settings.SettingManager; 10 | import de.vinii.management.ui.clickgui.components.GuiButton; 11 | import de.vinii.management.ui.clickgui.components.GuiComboBox; 12 | import de.vinii.management.ui.clickgui.components.GuiGetKey; 13 | import de.vinii.management.ui.clickgui.components.GuiLabel; 14 | import de.vinii.management.ui.clickgui.components.GuiSlider; 15 | import de.vinii.management.ui.clickgui.components.GuiToggleButton; 16 | import de.vinii.management.ui.clickgui.components.listeners.ComboListener; 17 | import de.vinii.management.ui.clickgui.components.listeners.ComponentListener; 18 | import de.vinii.management.ui.clickgui.components.listeners.KeyListener; 19 | import de.vinii.management.ui.clickgui.components.listeners.ValueListener; 20 | 21 | /** 22 | * @author sendQueue 23 | * 24 | * Further info at Vinii.de or github@vinii.de, file created at 25 | * 11.11.2020. Use is only authorized if given credit! 26 | * 27 | */ 28 | public class ComponentsListener extends ComponentListener { 29 | private GuiButton button; 30 | 31 | public ComponentsListener(GuiButton button) { 32 | this.button = button; 33 | } 34 | 35 | @Override 36 | public void addComponents() { 37 | add(new GuiLabel("Settings >")); 38 | final Module m = ModuleManager.getModule(button.getText()); 39 | 40 | for (Setting set : SettingManager.getSettingArrayList()) { 41 | if (set.getModule() == m) { 42 | switch (set.getSettingType()) { 43 | case BOOLEAN: 44 | GuiToggleButton toggleButton = new GuiToggleButton(set.getName()); 45 | toggleButton.setToggled(set.isState()); 46 | toggleButton.addClickListener(new ActionListener() { 47 | @Override 48 | public void actionPerformed(ActionEvent e) { 49 | set.setState(toggleButton.isToggled()); 50 | new Thread(() -> { 51 | ModuleManager.saveDetails(); 52 | }).start(); 53 | } 54 | }); 55 | add(toggleButton); 56 | break; 57 | case VALUE: 58 | GuiSlider slider = new GuiSlider(set.getName(), set.getMin(), set.getMax(), set.getCurrent(), 59 | set.isOnlyInt() ? 0 : 2); 60 | slider.addValueListener(new ValueListener() { 61 | 62 | @Override 63 | public void valueUpdated(float value) { 64 | set.setCurrent(value); 65 | } 66 | 67 | @Override 68 | public void valueChanged(float value) { 69 | set.setCurrent(value); 70 | new Thread(() -> { 71 | ModuleManager.saveDetails(); 72 | }).start(); 73 | } 74 | }); 75 | add(slider); 76 | break; 77 | case COMBO: 78 | GuiComboBox comboBox = new GuiComboBox(set); 79 | comboBox.addComboListener(new ComboListener() { 80 | 81 | @Override 82 | public void comboChanged(String combo) { 83 | new Thread(() -> { 84 | ModuleManager.saveDetails(); 85 | }).start(); 86 | } 87 | }); 88 | add(comboBox); 89 | break; 90 | default: 91 | break; 92 | } 93 | 94 | } 95 | } 96 | GuiGetKey ggk = new GuiGetKey("KeyBind", m.getKeyBind()); 97 | ggk.addKeyListener(new KeyListener() { 98 | 99 | @Override 100 | public void keyChanged(int key) { 101 | m.setKeyBind(key); 102 | new Thread(() -> { 103 | ModuleManager.saveDetails(); 104 | }).start(); 105 | 106 | } 107 | }); 108 | add(ggk); 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/util/FramePosition.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.util; 2 | 3 | /** 4 | * @author sendQueue 5 | * 6 | * Further info at Vinii.de, file created at 25.10.2020 7 | * 8 | */ 9 | public class FramePosition { 10 | private int posX, posY; 11 | private boolean isExpanded; 12 | 13 | /** 14 | * Initialize new frame position 15 | * 16 | * @param posX 17 | * @param posY 18 | * @param isExpanded 19 | */ 20 | public FramePosition(int posX, int posY, boolean isExpanded) { 21 | this.posX = posX; 22 | this.posY = posY; 23 | this.isExpanded = isExpanded; 24 | } 25 | 26 | /** 27 | * @return the posX 28 | */ 29 | public int getPosX() { 30 | return posX; 31 | } 32 | 33 | /** 34 | * @param posX to set 35 | */ 36 | public void setPosX(int posX) { 37 | this.posX = posX; 38 | } 39 | 40 | /** 41 | * @return the posY 42 | */ 43 | public int getPosY() { 44 | return posY; 45 | } 46 | 47 | /** 48 | * @param posY to set 49 | */ 50 | public void setPosY(int posY) { 51 | this.posY = posY; 52 | } 53 | 54 | /** 55 | * @return isExpanded 56 | */ 57 | public boolean isExpanded() { 58 | return isExpanded; 59 | } 60 | 61 | /** 62 | * @param isExpanded to set 63 | */ 64 | public void setExpanded(boolean isExpanded) { 65 | this.isExpanded = isExpanded; 66 | } 67 | 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/util/MathUtil.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.util; 2 | 3 | import java.math.BigDecimal; 4 | import java.math.RoundingMode; 5 | 6 | /** 7 | * @author sendQueue 8 | * 9 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 10 | * Use is only authorized if given credit! 11 | * 12 | */ 13 | public class MathUtil { 14 | 15 | /** 16 | * @param toRound 17 | * @param scale 18 | * @return 19 | */ 20 | public static float round(float toRound, int scale) { 21 | return new BigDecimal(toRound).setScale(scale, RoundingMode.HALF_EVEN).floatValue(); 22 | } 23 | 24 | /** 25 | * @param toRound 26 | * @param scale 27 | * @return 28 | */ 29 | public static double round(double toRound, int scale) { 30 | return new BigDecimal(toRound).setScale(scale, RoundingMode.HALF_EVEN).doubleValue(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /de/vinii/management/ui/clickgui/util/RenderUtil.java: -------------------------------------------------------------------------------- 1 | package de.vinii.management.ui.clickgui.util; 2 | 3 | import de.vinii.management.ui.clickgui.Panel; 4 | import net.minecraft.client.gui.Gui; 5 | 6 | /** 7 | * @author sendQueue 8 | * 9 | * Further info at Vinii.de or github@vinii.de, file created at 11.11.2020. 10 | * Use is only authorized if given credit! 11 | * 12 | */ 13 | public final class RenderUtil { 14 | 15 | /** 16 | *

CAUTION:

Your version might not support the default method. 17 | *

18 | * If so, feel free to use the use the replacement method from https://github.com/sendQueue/LWJGLUtil. 20 | * 21 | * 22 | * @param left 23 | * @param top 24 | * @param right 25 | * @param bottom 26 | * @param color 27 | */ 28 | public static void drawRect(int left, int top, int right, int bottom, int color) { 29 | // default 30 | Gui.drawRect(left, top, right, bottom, color); 31 | 32 | // replacement 33 | // LWJGLUtil.drawRect(left, top, right - left, bottom - top, color); 34 | } 35 | 36 | public static void drawHorizontalLine(int startX, int endX, int y, int color) { 37 | if (endX < startX) { 38 | int i = startX; 39 | startX = endX; 40 | endX = i; 41 | } 42 | 43 | drawRect(startX, y, endX + 1, y + 1, color); 44 | } 45 | public static void drawVerticalLine(int x, int startY, int endY, int color) { 46 | if (endY < startY) { 47 | int i = startY; 48 | startY = endY; 49 | endY = i; 50 | } 51 | 52 | drawRect(x, startY + 1, x + 1, endY, color); 53 | } 54 | 55 | /** 56 | * Checks if mouse is over rectangle. 57 | * 58 | * @param x 59 | * @param y 60 | * @param width RELATIVE to x. 61 | * @param height RELATIVE to y. 62 | * @param mouseX 63 | * @param mouseY 64 | * @return true if rectangle is hovered 65 | */ 66 | public static boolean isHovered(int x, int y, int width, int height, int mouseX, int mouseY) { 67 | return (mouseX >= x) && (mouseX <= x + width) && (mouseY >= y) && (mouseY < y + height); 68 | } 69 | 70 | 71 | } 72 | --------------------------------------------------------------------------------