diff --git a/src/main/java/net/aoba/event/events/MouseLeftClickEvent.java b/src/main/java/net/aoba/event/events/MouseLeftClickEvent.java index 11fbda64..8932071a 100644 --- a/src/main/java/net/aoba/event/events/MouseLeftClickEvent.java +++ b/src/main/java/net/aoba/event/events/MouseLeftClickEvent.java @@ -6,20 +6,20 @@ public class MouseLeftClickEvent extends AbstractEvent{ - int mouseX; - int mouseY; + double mouseX; + double mouseY; - public MouseLeftClickEvent(int mouseX, int mouseY) { + public MouseLeftClickEvent(double mouseX2, double mouseY2) { super(); - this.mouseX = mouseX; - this.mouseY = mouseY; + this.mouseX = mouseX2; + this.mouseY = mouseY2; } - public int GetMouseX() { + public double GetMouseX() { return mouseX; } - public int GetMouseY() { + public double GetMouseY() { return mouseY; } diff --git a/src/main/java/net/aoba/gui/NavigationBar.java b/src/main/java/net/aoba/gui/NavigationBar.java index 073e12ba..ee1653b3 100644 --- a/src/main/java/net/aoba/gui/NavigationBar.java +++ b/src/main/java/net/aoba/gui/NavigationBar.java @@ -69,8 +69,8 @@ public void OnMouseLeftClick(MouseLeftClickEvent event) { AobaClient aoba = Aoba.getInstance(); Window window = mc.getWindow(); - int mouseX = event.GetMouseX(); - int mouseY = event.GetMouseY(); + double mouseX = event.GetMouseX(); + double mouseY = event.GetMouseY(); int width = 100 * options.size(); int centerX = (window.getWidth() / 2); int x = centerX - (width / 2); diff --git a/src/main/java/net/aoba/gui/hud/AbstractHud.java b/src/main/java/net/aoba/gui/hud/AbstractHud.java index 9437339e..c044917e 100644 --- a/src/main/java/net/aoba/gui/hud/AbstractHud.java +++ b/src/main/java/net/aoba/gui/hud/AbstractHud.java @@ -14,15 +14,13 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; -import java.util.function.Consumer; - public abstract class AbstractHud implements MouseLeftClickListener, MouseMoveListener { protected static RenderUtils renderUtils = new RenderUtils(); protected static MinecraftClient mc = MinecraftClient.getInstance(); protected String ID; - protected float x; - protected float y; + + protected Vector2Setting position; protected float width; protected float height; @@ -30,45 +28,32 @@ public abstract class AbstractHud implements MouseLeftClickListener, MouseMoveLi protected boolean moveable = true; // Mouse Variables - protected float lastMouseX; - protected float lastMouseY; - - - private Vector2Setting position_setting; - private Consumer position_setting_update; + protected double lastMouseX; + protected double lastMouseY; public AbstractHud(String ID, int x, int y, int width, int height) { this.ID = ID; - this.x = x; - this.y = y; + + this.position = new Vector2Setting(ID + "_position", "GUI POS", new Vector2(x, y)); this.width = width; this.height = height; - position_setting_update = new Consumer() { - @Override - public void accept(Vector2 vector2) { - setX(vector2.x); - setY(vector2.y); - } - }; - - position_setting = new Vector2Setting(ID + "_position", "Position", new Vector2(x, y), position_setting_update); - SettingManager.register_setting(position_setting, Aoba.getInstance().settingManager.hidden_category); + SettingManager.register_setting(position, Aoba.getInstance().settingManager.hidden_category); Aoba.getInstance().eventManager.AddListener(MouseLeftClickListener.class, this); Aoba.getInstance().eventManager.AddListener(MouseMoveListener.class, this); } - public float getX() { - return this.x; + public float getHeight() { + return this.height; } - public float getY() { - return this.y; + public float getX(){ + return position.getValue().x; } - public float getHeight() { - return this.height; + public float getY(){ + return position.getValue().y; } public float getWidth() { @@ -76,13 +61,11 @@ public float getWidth() { } public void setX(float x) { - this.x = x; - position_setting.silentSetX(x); + position.setX(x); } public void setY(float y) { - this.y = y; - position_setting.silentSetY(y); + position.setY(y); } public void setWidth(float width) { @@ -99,15 +82,15 @@ public void setHeight(float height) { @Override public void OnMouseLeftClick(MouseLeftClickEvent event) { - int mouseX = event.GetMouseX(); - int mouseY = event.GetMouseY(); + double mouseX = event.GetMouseX(); + double mouseY = event.GetMouseY(); + + Vector2 pos = position.getValue(); if (Aoba.getInstance().hudManager.isClickGuiOpen()) { if (HudManager.currentGrabbed == null) { - if (mouseX >= x && mouseX <= (x + width)) { - if (mouseY >= y && mouseY <= (y + height)) { - System.out.println(ID + " was clicked!"); - //HudManager.currentGrabbed = this; + if (mouseX >= pos.x && mouseX <= (pos.x + width)) { + if (mouseY >= pos.y && mouseY <= (pos.y + height)) { lastMouseX = mouseX; lastMouseY = mouseY; } diff --git a/src/main/java/net/aoba/gui/hud/ArmorHud.java b/src/main/java/net/aoba/gui/hud/ArmorHud.java index 49354034..0671d463 100644 --- a/src/main/java/net/aoba/gui/hud/ArmorHud.java +++ b/src/main/java/net/aoba/gui/hud/ArmorHud.java @@ -22,9 +22,9 @@ package net.aoba.gui.hud; +import net.aoba.core.utils.types.Vector2; import net.aoba.gui.Color; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.collection.DefaultedList; @@ -33,8 +33,6 @@ public class ArmorHud extends AbstractHud{ public ArmorHud(int x, int y, int width, int height) { super("ArmorHud", x,y,width,height); - this.x = 300; - this.y = 300; this.width = 64; this.height = 256; } @@ -47,10 +45,12 @@ public void update() { @Override public void draw(DrawContext drawContext, float partialTicks, Color color) { DefaultedList armors = mc.player.getInventory().armor; + + Vector2 pos = position.getValue(); int yOff = 16; for(ItemStack armor : armors) { if(armor.getItem() == Items.AIR) continue; - drawContext.drawItem(armor, (int)this.x, (int)(this.y + this.height - yOff)); + drawContext.drawItem(armor, (int)pos.x, (int)(pos.y + this.height - yOff)); yOff += 16; } } diff --git a/src/main/java/net/aoba/gui/hud/InfoHud.java b/src/main/java/net/aoba/gui/hud/InfoHud.java index 47122da3..38949513 100644 --- a/src/main/java/net/aoba/gui/hud/InfoHud.java +++ b/src/main/java/net/aoba/gui/hud/InfoHud.java @@ -1,5 +1,6 @@ package net.aoba.gui.hud; +import net.aoba.core.utils.types.Vector2; import net.aoba.gui.Color; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; @@ -55,11 +56,14 @@ public void update() { public void draw(DrawContext drawContext, float partialTicks, Color color) { MatrixStack matrixStack = drawContext.getMatrices(); // Draws background depending on components width and height - renderUtils.drawRoundedBox(matrixStack, x, y, width, height, 6, new Color(30,30,30), 0.4f); - renderUtils.drawRoundedOutline(matrixStack, x, y, width, height, 6, new Color(0,0,0), 0.8f); - renderUtils.drawString(drawContext, positionText, x + 5, y + 4, color); - renderUtils.drawString(drawContext, timeText, x + 5, y + 24, color); - renderUtils.drawString(drawContext, fpsText, x + 5, y + 44, color); + Vector2 pos = position.getValue(); + + renderUtils.drawRoundedBox(matrixStack, pos.x, pos.y, width, height, 6, new Color(30,30,30), 0.4f); + renderUtils.drawRoundedOutline(matrixStack, pos.x, pos.y, width, height, 6, new Color(0,0,0), 0.8f); + + renderUtils.drawString(drawContext, positionText, pos.x + 5, pos.y + 4, color); + renderUtils.drawString(drawContext, timeText, pos.x + 5, pos.y + 24, color); + renderUtils.drawString(drawContext, fpsText, pos.x + 5, pos.y + 44, color); } } diff --git a/src/main/java/net/aoba/gui/hud/ModuleSelectorHud.java b/src/main/java/net/aoba/gui/hud/ModuleSelectorHud.java index 557fbea5..f18e002f 100644 --- a/src/main/java/net/aoba/gui/hud/ModuleSelectorHud.java +++ b/src/main/java/net/aoba/gui/hud/ModuleSelectorHud.java @@ -4,6 +4,7 @@ import org.lwjgl.glfw.GLFW; import net.aoba.Aoba; import net.aoba.AobaClient; +import net.aoba.core.utils.types.Vector2; import net.aoba.gui.Color; import net.aoba.module.Module; import net.aoba.module.Module.Category; @@ -66,7 +67,7 @@ public void update() { } this.keybindDown.setPressed(false); } else if (this.keybindRight.isPressed()) { - if (!isCategoryMenuOpen && x != -width) { + if (!isCategoryMenuOpen) { isCategoryMenuOpen = !isCategoryMenuOpen; if (modules.isEmpty()) { for (Module module : aoba.moduleManager.modules) { @@ -98,39 +99,41 @@ public void draw(DrawContext drawContext, float partialTicks, Color color) { MatrixStack matrixStack = drawContext.getMatrices(); Window window = mc.getWindow(); + Vector2 pos = position.getValue(); + // Draws the top bar including "Aoba x.x" renderUtils.drawString(drawContext, "Aoba " + AobaClient.VERSION, 8, 8, color); // Draws the table including all of the categories. - renderUtils.drawRoundedBox(matrixStack, x, y, width, height * this.categories.length, 6f, new Color(30,30,30), 0.4f); - renderUtils.drawRoundedOutline(matrixStack, x, y, width, height * this.categories.length, 6f, new Color(0,0,0), 0.8f); + renderUtils.drawRoundedBox(matrixStack, pos.x, pos.y, width, height * this.categories.length, 6f, new Color(30,30,30), 0.4f); + renderUtils.drawRoundedOutline(matrixStack, pos.x, pos.y, width, height * this.categories.length, 6f, new Color(0,0,0), 0.8f); // For every category, draw a cell for it. for (int i = 0; i < this.categories.length; i++) { - renderUtils.drawString(drawContext, ">>", x + width - 24, y + (height * i) + 8, color); + renderUtils.drawString(drawContext, ">>", pos.x + width - 24, pos.y + (height * i) + 8, color); // Draws the name of the category dependent on whether it is selected. if (this.index == i) { - renderUtils.drawString(drawContext, "> " + this.categories[i].name(), x + 8, y + (height * i) + 8, color); + renderUtils.drawString(drawContext, "> " + this.categories[i].name(), pos.x + 8, pos.y + (height * i) + 8, color); } else { - renderUtils.drawString(drawContext, this.categories[i].name(), x + 8, y + (height * i) + 8, 0xFFFFFF); + renderUtils.drawString(drawContext, this.categories[i].name(), pos.x + 8, pos.y + (height * i) + 8, 0xFFFFFF); } } // If any particular category menu is open. if (isCategoryMenuOpen) { // Draw the table underneath - renderUtils.drawRoundedBox(matrixStack, x + width, y + (height * this.index), 165, height * modules.size(), 6f, new Color(30,30,30), 0.4f); - renderUtils.drawRoundedOutline(matrixStack, x + width, y + (height * this.index), 165, height * modules.size(), 6f, new Color(0,0,0), 0.8f); + renderUtils.drawRoundedBox(matrixStack, pos.x + width, pos.y + (height * this.index), 165, height * modules.size(), 6f, new Color(30,30,30), 0.4f); + renderUtils.drawRoundedOutline(matrixStack, pos.x + width, pos.y + (height * this.index), 165, height * modules.size(), 6f, new Color(0,0,0), 0.8f); // For every mod, draw a cell for it. for (int i = 0; i < modules.size(); i++) { if (this.indexMods == i) { - renderUtils.drawString(drawContext, "> " + modules.get(i).getName(), x + width + 5, - y + (i * height) + (this.index * height) + 8, + renderUtils.drawString(drawContext, "> " + modules.get(i).getName(), pos.x + width + 5, + pos.y + (i * height) + (this.index * height) + 8, modules.get(i).getState() ? 0x00FF00 : color.getColorAsInt()); } else { - renderUtils.drawString(drawContext, modules.get(i).getName(), x + width + 5, - y + (i * height) + (this.index * height) + 8, + renderUtils.drawString(drawContext, modules.get(i).getName(), pos.x + width + 5, + pos.y + (i * height) + (this.index * height) + 8, modules.get(i).getState() ? 0x00FF00 : 0xFFFFFF); } } diff --git a/src/main/java/net/aoba/gui/hud/RadarHud.java b/src/main/java/net/aoba/gui/hud/RadarHud.java index 68878a2c..9891f0bd 100644 --- a/src/main/java/net/aoba/gui/hud/RadarHud.java +++ b/src/main/java/net/aoba/gui/hud/RadarHud.java @@ -1,6 +1,7 @@ package net.aoba.gui.hud; import net.aoba.Aoba; +import net.aoba.core.utils.types.Vector2; import net.aoba.gui.Color; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.network.AbstractClientPlayerEntity; @@ -21,20 +22,23 @@ public RadarHud( int x, int y, int width, int height) { @Override public void draw(DrawContext drawContext, float partialTicks, Color color) { MatrixStack matrixStack = drawContext.getMatrices(); + + Vector2 pos = position.getValue(); + // Draws background depending on components width and height - renderUtils.drawRoundedBox(matrixStack, x, y, width, height, 6, new Color(30,30,30), 0.4f); - renderUtils.drawRoundedOutline(matrixStack, x, y, width, height, 6, new Color(0,0,0), 0.8f); + renderUtils.drawRoundedBox(matrixStack, pos.x, pos.y, width, height, 6, new Color(30,30,30), 0.4f); + renderUtils.drawRoundedOutline(matrixStack, pos.x, pos.y, width, height, 6, new Color(0,0,0), 0.8f); // Draw the 'Radar' - renderUtils.drawBox(matrixStack, x , y + (height / 2), width - 1, 1, new Color(128,128,128), 1.0f); - renderUtils.drawBox(matrixStack, x + (width / 2), y, 1, height, new Color(128,128,128), 1.0f); - renderUtils.drawBox(matrixStack, x + (width / 2) - 2, y + (height / 2) - 2, 5, 5, Aoba.getInstance().hudManager.getColor(), 1.0f); + renderUtils.drawBox(matrixStack, pos.x , pos.y + (height / 2), width - 1, 1, new Color(128,128,128), 1.0f); + renderUtils.drawBox(matrixStack, pos.x + (width / 2), pos.y, 1, height, new Color(128,128,128), 1.0f); + renderUtils.drawBox(matrixStack, pos.x + (width / 2) - 2, pos.y + (height / 2) - 2, 5, 5, Aoba.getInstance().hudManager.getColor(), 1.0f); float sin_theta = (float) Math.sin(Math.toRadians(-mc.player.getRotationClient().y)); float cos_theta = (float) Math.cos(Math.toRadians(-mc.player.getRotationClient().y)); - float center_x = x + (width / 2); - float center_y = y - 2 + (height / 2); + float center_x = pos.x + (width / 2); + float center_y = pos.y - 2 + (height / 2); // Render Entities for (Entity entity : mc.world.getEntities()) { @@ -54,13 +58,13 @@ public void draw(DrawContext drawContext, float partialTicks, Color color) { float ratio_x = (float)((entity.getX() - mc.player.getX())) / (distance); float ratio_y = (float)((entity.getZ() - mc.player.getZ())) / (distance); - float fake_x = (x + (width / 2) - (width * ratio_x / 2)); - float fake_y = (y - 2 + (height / 2) - (width * ratio_y / 2)); + float fake_x = (pos.x + (width / 2) - (width * ratio_x / 2)); + float fake_y = (pos.y - 2 + (height / 2) - (width * ratio_y / 2)); float radius_x = (float)((cos_theta * (fake_x - center_x)) - (sin_theta * (fake_y - center_y))) + center_x; float radius_y = (float)((sin_theta * (fake_x - center_x)) + (cos_theta * (fake_y - center_y))) + center_y; - renderUtils.drawBox(matrixStack, (int)(Math.min(x + width - 5, Math.max(x, radius_x))) , (int)(Math.min(y - 5 + height, Math.max(y, radius_y))), 3, 3, c, 1.0f); + renderUtils.drawBox(matrixStack, (int)(Math.min(pos.x + width - 5, Math.max(pos.x, radius_x))) , (int)(Math.min(pos.y - 5 + height, Math.max(pos.y, radius_y))), 3, 3, c, 1.0f); } // Render Players @@ -69,14 +73,14 @@ public void draw(DrawContext drawContext, float partialTicks, Color color) { float ratio_x = (float)((entity.getX() - mc.player.getX())) / (distance); float ratio_y = (float)((entity.getZ() - mc.player.getZ())) / (distance); - float fake_x = (x + (width / 2) - (width * ratio_x / 2)); - float fake_y = (y + 28 + (height / 2) - (width * ratio_y / 2)); + float fake_x = (pos.x + (width / 2) - (width * ratio_x / 2)); + float fake_y = (pos.y + 28 + (height / 2) - (width * ratio_y / 2)); float radius_x = (float)((cos_theta * (fake_x - center_x)) - (sin_theta * (fake_y - center_y))) + center_x; float radius_y = (float)((sin_theta * (fake_x - center_x)) + (cos_theta * (fake_y - center_y))) + center_y; - renderUtils.drawBox(matrixStack, (int)(Math.min(x + width - 5, Math.max(x, radius_x))), (int)(Math.min(y + 25 + height, Math.max(y, radius_y))), 3, 3, new Color(255, 255, 255), 1.0f); - renderUtils.drawStringWithScale(drawContext, entity.getName().getString(), (int)(Math.min(x + width - 5, Math.max(x, radius_x))) - (mc.textRenderer.getWidth(entity.getName()) * 0.5f), (int)(Math.min(y + 25 + height, Math.max(y, radius_y))) - 10, color, 1.0f); + renderUtils.drawBox(matrixStack, (int)(Math.min(pos.x + width - 5, Math.max(pos.x, radius_x))), (int)(Math.min(pos.y + 25 + height, Math.max(pos.y, radius_y))), 3, 3, new Color(255, 255, 255), 1.0f); + renderUtils.drawStringWithScale(drawContext, entity.getName().getString(), (int)(Math.min(pos.x + width - 5, Math.max(pos.x, radius_x))) - (mc.textRenderer.getWidth(entity.getName()) * 0.5f), (int)(Math.min(pos.y + 25 + height, Math.max(pos.y, radius_y))) - 10, color, 1.0f); } } } diff --git a/src/main/java/net/aoba/gui/tabs/ClickGuiTab.java b/src/main/java/net/aoba/gui/tabs/ClickGuiTab.java index 5184f60c..80d009bc 100644 --- a/src/main/java/net/aoba/gui/tabs/ClickGuiTab.java +++ b/src/main/java/net/aoba/gui/tabs/ClickGuiTab.java @@ -24,71 +24,41 @@ import java.util.ArrayList; import java.util.function.Consumer; - import net.aoba.Aoba; import net.aoba.core.settings.SettingManager; import net.aoba.core.settings.types.BooleanSetting; import net.aoba.core.settings.types.Vector2Setting; import net.aoba.core.utils.types.Vector2; import net.aoba.event.events.MouseLeftClickEvent; -import net.aoba.event.events.MouseMoveEvent; import net.aoba.event.listeners.MouseLeftClickListener; import net.aoba.event.listeners.MouseMoveListener; import net.aoba.gui.Color; import net.aoba.gui.HudManager; import net.aoba.gui.hud.AbstractHud; import net.aoba.gui.tabs.components.Component; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; public class ClickGuiTab extends AbstractHud implements MouseLeftClickListener, MouseMoveListener { protected String title; - protected boolean pinnable = false; - protected boolean isPinned = false; - protected boolean pinWasClicked = false; + protected boolean pinnable = true; protected boolean drawBorder = true; protected boolean inheritHeightFromChildren = true; protected ArrayList children = new ArrayList<>(); - - private Consumer update_pos; - private Vector2Setting position; - private Consumer update_pinned; - private BooleanSetting pinned_setting; + + private BooleanSetting isPinned; public ClickGuiTab(String title, int x, int y, boolean pinnable) { super(title + "_tab", x, y, 180, 0); this.title = title; - this.x = x; - this.y = y; + this.width = 180; - this.mc = MinecraftClient.getInstance(); this.pinnable = pinnable; - update_pos = new Consumer() { - @Override - public void accept(Vector2 vector2) { - setX((int) vector2.x); - setY((int) vector2.y); - } - }; - - update_pinned = new Consumer() { - @Override - public void accept(Boolean aBoolean) { - isPinned = aBoolean; - } - }; - - position = new Vector2Setting(title + "_position", "GUI POS", new Vector2(x, y), update_pos); - pinned_setting = new BooleanSetting(title + "_pinned", "IS PINNED", false, update_pinned); - SettingManager.register_setting(position, Aoba.getInstance().settingManager.hidden_category); - SettingManager.register_setting(pinned_setting, Aoba.getInstance().settingManager.hidden_category); - - Aoba.getInstance().eventManager.AddListener(MouseLeftClickListener.class, this); - Aoba.getInstance().eventManager.AddListener(MouseMoveListener.class, this); + isPinned = new BooleanSetting(title + "_pinned", "IS PINNED", false); + SettingManager.register_setting(isPinned, Aoba.getInstance().settingManager.hidden_category); } public final String getTitle() { @@ -96,42 +66,18 @@ public final String getTitle() { } public final boolean isPinned() { - return this.isPinned; + return isPinned.getValue(); } public final void setPinned(boolean pin) { - this.isPinned = pin; - } - - public final boolean getPinClicked() { - return this.pinWasClicked; - } - - public final void setPinClicked(boolean pin) { - this.pinWasClicked = pin; + this.isPinned.setValue(pin); } public final void setTitle(String title) { this.title = title; } - - public final float getX() { - return x; - } - - public final void setX(int x) { - this.x = x; - } - - public final float getY() { - return y; - } - - public final void setY(int y) { - this.y = y; - } - + public final float getWidth() { return width; } @@ -148,10 +94,6 @@ public final void setHeight(int height) { this.height = height; } - public final boolean getPinned() { - return this.isPinned; - } - public final boolean isGrabbed() { return (HudManager.currentGrabbed == this); } @@ -178,10 +120,6 @@ public void update() { i += child.getHeight(); } } - - position.silentSetX(x); - position.silentSetY(y); - pinned_setting.silentSetValue(isPinned); } public void preupdate() { @@ -193,23 +131,26 @@ public void postupdate() { @Override public void draw(DrawContext drawContext, float partialTicks, Color color) { MatrixStack matrixStack = drawContext.getMatrices(); + + Vector2 pos = position.getValue(); + if (drawBorder) { // Draws background depending on components width and height - renderUtils.drawRoundedBox(matrixStack, x, y, width, height + 30, 6, new Color(30, 30, 30), 0.4f); - renderUtils.drawRoundedOutline(matrixStack, x, y, width, height + 30, 6, new Color(0, 0, 0), 0.8f); - renderUtils.drawString(drawContext, this.title, x + 8, y + 8, Aoba.getInstance().hudManager.getColor()); - renderUtils.drawLine(matrixStack, x, y + 30, x + width, y + 30, new Color(0, 0, 0), 0.4f); + renderUtils.drawRoundedBox(matrixStack, pos.x, pos.y, width, height + 30, 6, new Color(30, 30, 30), 0.4f); + renderUtils.drawRoundedOutline(matrixStack, pos.x, pos.y, width, height + 30, 6, new Color(0, 0, 0), 0.8f); + renderUtils.drawString(drawContext, this.title, pos.x + 8, pos.y + 8, Aoba.getInstance().hudManager.getColor()); + renderUtils.drawLine(matrixStack, pos.x, pos.y + 30, pos.x + width, pos.y + 30, new Color(0, 0, 0), 0.4f); if (this.pinnable) { - if (this.isPinned) { - renderUtils.drawRoundedBox(matrixStack, x + width - 23, y + 8, 15, 15, 6f, new Color(154, 0, 0), + if (this.isPinned.getValue()) { + renderUtils.drawRoundedBox(matrixStack, pos.x + width - 23, pos.y + 8, 15, 15, 6f, new Color(154, 0, 0), 0.8f); - renderUtils.drawRoundedOutline(matrixStack, x + width - 23, y + 8, 15, 15, 6f, new Color(0, 0, 0), + renderUtils.drawRoundedOutline(matrixStack, pos.x + width - 23, pos.y + 8, 15, 15, 6f, new Color(0, 0, 0), 0.8f); } else { - renderUtils.drawRoundedBox(matrixStack, x + width - 23, y + 8, 15, 15, 6f, new Color(128, 128, 128), + renderUtils.drawRoundedBox(matrixStack, pos.x + width - 23, pos.y + 8, 15, 15, 6f, new Color(128, 128, 128), 0.2f); - renderUtils.drawRoundedOutline(matrixStack, x + width - 23, y + 8, 15, 15, 6f, new Color(0, 0, 0), + renderUtils.drawRoundedOutline(matrixStack, pos.x + width - 23, pos.y + 8, 15, 15, 6f, new Color(0, 0, 0), 0.2f); } } @@ -225,81 +166,35 @@ public void draw(DrawContext drawContext, float partialTicks, Color color) { public void OnMouseLeftClick(MouseLeftClickEvent event) { super.OnMouseLeftClick(event); - int mouseX = (int) Math.ceil(mc.mouse.getX()); - int mouseY = (int) Math.ceil(mc.mouse.getY()); - + double mouseX = mc.mouse.getX(); + double mouseY = mc.mouse.getY(); + Vector2 pos = position.getValue(); + if (Aoba.getInstance().hudManager.isClickGuiOpen()) { - if (HudManager.currentGrabbed == null) { - if (mouseX >= (x) && mouseX <= (x + width)) { - if (mouseY >= (y) && mouseY <= (y + 28)) { - boolean isInsidePinButton = false; - if (this.pinnable) { - if (mouseX >= (x + width - 24) && mouseX <= (x + width - 2)) { - if (mouseY >= (y + 4) && mouseY <= (y + 20)) { - isInsidePinButton = true; - } - } - } - if (isInsidePinButton) { - if (!this.pinWasClicked) { - this.isPinned = !this.isPinned; - this.pinWasClicked = true; - return; - } - } else { - if (!this.isPinned) { - //HudManager.currentGrabbed = this; - } - } - } else { - if (this.pinWasClicked) { - this.pinWasClicked = false; - } - if (!this.isPinned) { - //HudManager.currentGrabbed = this; - } + if (this.pinnable) { + if (mouseX >= (pos.x + width - 24) && mouseX <= (pos.x + width - 2)) { + if (mouseY >= (pos.y + 4) && mouseY <= (pos.y + 20)) { + HudManager.currentGrabbed = null; + isPinned.silentSetValue(!isPinned.getValue()); } } } } } - /*@Override - public void OnMouseMove(MouseMoveEvent mouseMoveEvent) { - double mouseX = mouseMoveEvent.GetHorizontal(); - double mouseY = mouseMoveEvent.GetVertical(); - - if (HudManager.currentGrabbed == null) { - if (mouseX >= (x) && mouseX <= (x + width)) { - if (mouseY >= (y) && mouseY <= (y + 28)) { - boolean isInsidePinButton = false; - if (this.pinnable) { - if (mouseX >= (x + width - 24) && mouseX <= (x + width - 2)) { - if (mouseY >= (y + 4) && mouseY <= (y + 20)) { - isInsidePinButton = true; - } - } - } - if (isInsidePinButton) { - if (!this.pinWasClicked) { - this.isPinned = !this.isPinned; - this.pinWasClicked = true; - return; - } - } else { - if (!this.isPinned) { - HudManager.currentGrabbed = this; - } - } - } else { - if (this.pinWasClicked) { - this.pinWasClicked = false; - } - if (!this.isPinned) { - HudManager.currentGrabbed = this; - } - } - } - } - }*/ + /* + * @Override public void OnMouseMove(MouseMoveEvent mouseMoveEvent) { double + * mouseX = mouseMoveEvent.GetHorizontal(); double mouseY = + * mouseMoveEvent.GetVertical(); + * + * if (HudManager.currentGrabbed == null) { if (mouseX >= (x) && mouseX <= (x + + * width)) { if (mouseY >= (y) && mouseY <= (y + 28)) { boolean + * isInsidePinButton = false; if (this.pinnable) { if (mouseX >= (x + width - + * 24) && mouseX <= (x + width - 2)) { if (mouseY >= (y + 4) && mouseY <= (y + + * 20)) { isInsidePinButton = true; } } } if (isInsidePinButton) { if + * (!this.pinWasClicked) { this.isPinned = !this.isPinned; this.pinWasClicked = + * true; return; } } else { if (!this.isPinned) { HudManager.currentGrabbed = + * this; } } } else { if (this.pinWasClicked) { this.pinWasClicked = false; } if + * (!this.isPinned) { HudManager.currentGrabbed = this; } } } } } + */ } diff --git a/src/main/java/net/aoba/gui/tabs/OptionsTab.java b/src/main/java/net/aoba/gui/tabs/OptionsTab.java index 23316904..f71bb51e 100644 --- a/src/main/java/net/aoba/gui/tabs/OptionsTab.java +++ b/src/main/java/net/aoba/gui/tabs/OptionsTab.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import net.aoba.Aoba; +import net.aoba.core.utils.types.Vector2; import net.aoba.gui.Color; import net.aoba.gui.hud.AbstractHud; import net.minecraft.client.gui.DrawContext; @@ -33,19 +34,21 @@ public void update() { public void draw(DrawContext drawContext, float partialTicks, Color color) { MatrixStack matrixStack = drawContext.getMatrices(); - System.out.println("X: " + this.x + ", Y: " + this.y); + Vector2 pos = position.getValue(); - renderUtils.drawRoundedBox(matrixStack, x, y, width, height, 6, new Color(30,30,30), 0.4f); - renderUtils.drawRoundedOutline(matrixStack, x, y, width, height, 6, new Color(0,0,0), 0.8f); + System.out.println("X: " + pos.x + ", Y: " + pos.y); - renderUtils.drawLine(matrixStack, x + 480, y, x + 480, y + height, new Color(0,0,0), 0.8f); + renderUtils.drawRoundedBox(matrixStack, pos.x, pos.y, width, height, 6, new Color(30,30,30), 0.4f); + renderUtils.drawRoundedOutline(matrixStack, pos.x, pos.y, width, height, 6, new Color(0,0,0), 0.8f); + + renderUtils.drawLine(matrixStack, pos.x + 480, pos.y, pos.x + 480, pos.y + height, new Color(0,0,0), 0.8f); ArrayList modules = Aoba.getInstance().moduleManager.modules; int yHeight = 30; for(int i = currentScroll; i < Math.min(modules.size(), visibleScrollElements); i++) { Module module = modules.get(i); - renderUtils.drawString(drawContext, module.getName(), this.x + 10, this.y + yHeight, color); + renderUtils.drawString(drawContext, module.getName(), pos.x + 10, pos.y + yHeight, color); yHeight += 30; } } diff --git a/src/main/java/net/aoba/gui/tabs/components/ButtonComponent.java b/src/main/java/net/aoba/gui/tabs/components/ButtonComponent.java index ae9cd47b..486ae8f4 100644 --- a/src/main/java/net/aoba/gui/tabs/components/ButtonComponent.java +++ b/src/main/java/net/aoba/gui/tabs/components/ButtonComponent.java @@ -12,7 +12,6 @@ public class ButtonComponent extends Component implements MouseLeftClickListener { private String text; - private ClickGuiTab parent; private Runnable onClick; private Color hoverColor = new Color(90, 90, 90); @@ -26,9 +25,8 @@ public class ButtonComponent extends Component implements MouseLeftClickListener * @param onClick OnClick delegate that will run when the button is pressed. */ public ButtonComponent(ClickGuiTab parent, String text, Runnable onClick) { - super(); + super(parent); this.text = text; - this.parent = parent; this.onClick = onClick; Aoba.getInstance().eventManager.AddListener(MouseLeftClickListener.class, this); @@ -79,8 +77,8 @@ public void OnMouseLeftClick(MouseLeftClickEvent event) { float parentY = parent.getY(); float parentWidth = parent.getWidth(); - int mouseX = event.GetMouseX(); - int mouseY = event.GetMouseY(); + double mouseX = event.GetMouseX(); + double mouseY = event.GetMouseY(); if (HudManager.currentGrabbed == null) { // If our delegate exists and we are inside the bounds of the button, run it. diff --git a/src/main/java/net/aoba/gui/tabs/components/CheckboxComponent.java b/src/main/java/net/aoba/gui/tabs/components/CheckboxComponent.java index afad2a6c..cd9ef710 100644 --- a/src/main/java/net/aoba/gui/tabs/components/CheckboxComponent.java +++ b/src/main/java/net/aoba/gui/tabs/components/CheckboxComponent.java @@ -16,9 +16,8 @@ public class CheckboxComponent extends Component implements MouseLeftClickListen private Runnable onClick; public CheckboxComponent(ClickGuiTab parent, BooleanSetting checkbox) { - super(); + super(parent); this.text = checkbox.displayName; - this.parent = parent; this.checkbox = checkbox; Aoba.getInstance().eventManager.AddListener(MouseLeftClickListener.class, this); diff --git a/src/main/java/net/aoba/gui/tabs/components/Component.java b/src/main/java/net/aoba/gui/tabs/components/Component.java index c1329554..d5c5e2a2 100644 --- a/src/main/java/net/aoba/gui/tabs/components/Component.java +++ b/src/main/java/net/aoba/gui/tabs/components/Component.java @@ -17,7 +17,8 @@ public abstract class Component implements MouseMoveListener { protected int offset; protected boolean hovered = false; - public Component() { + public Component(ClickGuiTab parent) { + this.parent = parent; this.renderUtils = Aoba.getInstance().renderUtils; Aoba.getInstance().eventManager.AddListener(MouseMoveListener.class, this); } @@ -97,17 +98,17 @@ public void update(int offset) { public void OnMouseMove(MouseMoveEvent mouseMoveEvent) { if (HudManager.currentGrabbed != null) { this.hovered = false; - } - - if(this.parent != null) { - float parentX = parent.getX(); - float parentY = parent.getY(); - float parentWidth = parent.getWidth(); - - double mouseX = mouseMoveEvent.GetHorizontal(); - double mouseY = mouseMoveEvent.GetVertical(); - - this.hovered = ((mouseX >= parentX && mouseX <= (parentX + parentWidth)) && (mouseY >= (parentY + offset) && mouseY <= (parentY + offset + 28))); + }else { + if(this.parent != null) { + float parentX = parent.getX(); + float parentY = parent.getY(); + float parentWidth = parent.getWidth(); + + double mouseX = mouseMoveEvent.GetHorizontal(); + double mouseY = mouseMoveEvent.GetVertical(); + + this.hovered = ((mouseX >= parentX && mouseX <= (parentX + parentWidth)) && (mouseY >= (parentY + offset) && mouseY <= (parentY + offset + 28))); + } } } } diff --git a/src/main/java/net/aoba/gui/tabs/components/KeybindComponent.java b/src/main/java/net/aoba/gui/tabs/components/KeybindComponent.java index 4b0b3c0f..05570102 100644 --- a/src/main/java/net/aoba/gui/tabs/components/KeybindComponent.java +++ b/src/main/java/net/aoba/gui/tabs/components/KeybindComponent.java @@ -12,7 +12,6 @@ public class KeybindComponent extends Component implements MouseLeftClickListener { private String text; - private ClickGuiTab parent; private boolean wasClicked = false; private boolean hovered = false; private Runnable onClick; @@ -23,9 +22,8 @@ public class KeybindComponent extends Component implements MouseLeftClickListene private Color backgroundColor = color; public KeybindComponent(ClickGuiTab parent, String text, Runnable onClick) { - super(); + super( parent); this.text = text; - this.parent = parent; this.onClick = onClick; Aoba.getInstance().eventManager.AddListener(MouseLeftClickListener.class, this); @@ -57,8 +55,8 @@ public void OnMouseLeftClick(MouseLeftClickEvent event) { float parentY = parent.getY(); float parentWidth = parent.getWidth(); - int mouseX = event.GetMouseX(); - int mouseY = event.GetMouseY(); + double mouseX = event.GetMouseX(); + double mouseY = event.GetMouseY(); if (HudManager.currentGrabbed == null) { if (!this.wasClicked) { diff --git a/src/main/java/net/aoba/gui/tabs/components/ListComponent.java b/src/main/java/net/aoba/gui/tabs/components/ListComponent.java index 67276d01..38d0e9c6 100644 --- a/src/main/java/net/aoba/gui/tabs/components/ListComponent.java +++ b/src/main/java/net/aoba/gui/tabs/components/ListComponent.java @@ -15,23 +15,20 @@ import net.minecraft.client.util.math.MatrixStack; public class ListComponent extends Component implements MouseLeftClickListener { - private String text; private IndexedStringListSetting list; private List settingsList = new ArrayList(); public ListComponent(String text, ClickGuiTab parent) { - super(); + super(parent); this.text = text; - this.parent = parent; Aoba.getInstance().eventManager.AddListener(MouseLeftClickListener.class, this); } public ListComponent(ClickGuiTab parent, IndexedStringListSetting list) { - super(); + super(parent); this.text = list.displayName; - this.parent = parent; this.list = list; Aoba.getInstance().eventManager.AddListener(MouseLeftClickListener.class, this); @@ -58,8 +55,8 @@ public void OnMouseLeftClick(MouseLeftClickEvent event) { float parentY = parent.getY(); float parentWidth = parent.getWidth(); - int mouseX = event.GetMouseX(); - int mouseY = event.GetMouseY(); + double mouseX = event.GetMouseX(); + double mouseY = event.GetMouseY(); if (HudManager.currentGrabbed == null) { if (mouseY >= (((parentY + offset + 4))) && mouseY <= (parentY + offset + 22)) { diff --git a/src/main/java/net/aoba/gui/tabs/components/ModuleComponent.java b/src/main/java/net/aoba/gui/tabs/components/ModuleComponent.java index 457948d5..a65c1005 100644 --- a/src/main/java/net/aoba/gui/tabs/components/ModuleComponent.java +++ b/src/main/java/net/aoba/gui/tabs/components/ModuleComponent.java @@ -19,10 +19,8 @@ import net.minecraft.client.util.math.MatrixStack; public class ModuleComponent extends Component implements MouseLeftClickListener { - private String text; private Module module; - private ClickGuiTab parent; private boolean popped = false; private int expandedHeight = 30; @@ -35,9 +33,8 @@ public class ModuleComponent extends Component implements MouseLeftClickListener private List settingsList = new ArrayList(); public ModuleComponent(String text, ClickGuiTab parent, Module module) { - super(); + super(parent); this.text = text; - this.parent = parent; this.module = module; for (Setting setting : this.module.getSettings()) { Component c; @@ -117,8 +114,8 @@ public void OnMouseLeftClick(MouseLeftClickEvent event) { float parentY = parent.getY(); float parentWidth = parent.getWidth(); - int mouseX = event.GetMouseX(); - int mouseY = event.GetMouseY(); + double mouseX = event.GetMouseX(); + double mouseY = event.GetMouseY(); if (hovered) { System.out.println("X: " + mouseX + ", Y: " + mouseY); diff --git a/src/main/java/net/aoba/gui/tabs/components/SliderComponent.java b/src/main/java/net/aoba/gui/tabs/components/SliderComponent.java index a6e2c92c..1fa9aad4 100644 --- a/src/main/java/net/aoba/gui/tabs/components/SliderComponent.java +++ b/src/main/java/net/aoba/gui/tabs/components/SliderComponent.java @@ -13,7 +13,6 @@ public class SliderComponent extends Component implements MouseLeftClickListener { private String text; - private ClickGuiTab parent; private float currentSliderPosition = 0.4f; float r; float g; @@ -22,18 +21,16 @@ public class SliderComponent extends Component implements MouseLeftClickListener FloatSetting slider; public SliderComponent(String text, ClickGuiTab parent) { - super(); + super(parent); this.text = text; - this.parent = parent; this.slider = null; Aoba.getInstance().eventManager.AddListener(MouseLeftClickListener.class, this); } public SliderComponent(ClickGuiTab parent, FloatSetting slider) { - super(); + super(parent); this.text = slider.displayName; - this.parent = parent; this.slider = slider; this.currentSliderPosition = (float) ((slider.getValue() - slider.min_value) / (slider.max_value - slider.min_value)); @@ -86,8 +83,8 @@ public void OnMouseLeftClick(MouseLeftClickEvent event) { float parentX = parent.getX(); float parentY = parent.getY(); - int mouseX = event.GetMouseX(); - int mouseY = event.GetMouseY(); + double mouseX = event.GetMouseX(); + double mouseY = event.GetMouseY(); float parentWidth = parent.getWidth(); if (HudManager.currentGrabbed == null) { diff --git a/src/main/java/net/aoba/gui/tabs/components/StringComponent.java b/src/main/java/net/aoba/gui/tabs/components/StringComponent.java index addb1d0c..5d387c62 100644 --- a/src/main/java/net/aoba/gui/tabs/components/StringComponent.java +++ b/src/main/java/net/aoba/gui/tabs/components/StringComponent.java @@ -12,7 +12,7 @@ public class StringComponent extends Component { private ArrayList text; public StringComponent(String text, ClickGuiTab parent) { - super(); + super(parent); this.originalText = text; this.text = new ArrayList(); @@ -31,13 +31,11 @@ public StringComponent(String text, ClickGuiTab parent) { this.setHeight(strings * 30); } - this.bold = false; - this.parent = parent; } public StringComponent(String text, ClickGuiTab parent, boolean bold) { - super(); + super(parent); this.originalText = text; this.text = new ArrayList(); @@ -57,7 +55,6 @@ public StringComponent(String text, ClickGuiTab parent, boolean bold) { } this.bold = bold; - this.parent = parent; } @Override diff --git a/src/main/java/net/aoba/mixin/MinecraftClientMixin.java b/src/main/java/net/aoba/mixin/MinecraftClientMixin.java index a492126d..1014e821 100644 --- a/src/main/java/net/aoba/mixin/MinecraftClientMixin.java +++ b/src/main/java/net/aoba/mixin/MinecraftClientMixin.java @@ -34,8 +34,7 @@ public abstract class MinecraftClientMixin extends ReentrantThreadExecutor cir) { - int mouseX = (int) Math.ceil(mouse.getX()); - int mouseY = (int) Math.ceil(mouse.getY()); + double mouseX = Math.ceil(mouse.getX()); + double mouseY = Math.ceil(mouse.getY()); + System.out.println("DOuble Click?"); MouseLeftClickEvent event = new MouseLeftClickEvent(mouseX, mouseY); Aoba.getInstance().eventManager.Fire(event);