diff --git a/src/main/java/com/tanishisherewith/dynamichud/newTrial/DynamicHudTestTWO.java b/src/main/java/com/tanishisherewith/dynamichud/newTrial/DynamicHudTestTWO.java index 59f0b34..a449c5e 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/newTrial/DynamicHudTestTWO.java +++ b/src/main/java/com/tanishisherewith/dynamichud/newTrial/DynamicHudTestTWO.java @@ -20,7 +20,7 @@ import java.util.List; public class DynamicHudTestTWO implements DynamicHudIntegration { - TextWidget textWidget; + TextWidget exampleWidget; WidgetRenderer renderer; @Override public void init() { @@ -28,7 +28,7 @@ public void init() { DynamicValueRegistry.registerGlobal("CPS",() -> "NOT FPS"); - textWidget = new TextWidget.Builder() + exampleWidget = new TextWidget.Builder() .setX(150) .setY(100) .setDraggable(true) @@ -56,7 +56,7 @@ public File getWidgetsFile() { @Override public void addWidgets() { - WidgetManager.addWidget(textWidget); + WidgetManager.addWidget(exampleWidget); } public void initAfter(){ List widgets = WidgetManager.getWidgetsForMod("CustomMod"); diff --git a/src/main/java/com/tanishisherewith/dynamichud/newTrial/screens/AbstractMoveableScreen.java b/src/main/java/com/tanishisherewith/dynamichud/newTrial/screens/AbstractMoveableScreen.java index bc4a43d..ef22c98 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/newTrial/screens/AbstractMoveableScreen.java +++ b/src/main/java/com/tanishisherewith/dynamichud/newTrial/screens/AbstractMoveableScreen.java @@ -1,12 +1,12 @@ package com.tanishisherewith.dynamichud.newTrial.screens; import com.tanishisherewith.dynamichud.newTrial.widget.WidgetRenderer; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; + public abstract class AbstractMoveableScreen extends Screen { - protected boolean ShouldPause = false; // To pause if the screen is opened or not + protected boolean shouldPause = false; // To pause if the screen is opened or not public final WidgetRenderer widgetRenderer; public int snapSize = 100; @@ -81,18 +81,12 @@ public void close() { } public void setShouldPause(boolean shouldPause) { - this.ShouldPause = shouldPause; - } - - - @Override - public void resize(MinecraftClient client, int width, int height) { - super.resize(client, width, height); + this.shouldPause = shouldPause; } @Override public boolean shouldPause() { - return ShouldPause; + return shouldPause; } public void setSnapSize(int size){ this.snapSize = size; diff --git a/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/ColorGradientPicker.java b/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/ColorGradientPicker.java index 379060e..afc4880 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/ColorGradientPicker.java +++ b/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/ColorGradientPicker.java @@ -38,7 +38,7 @@ public ColorGradientPicker(int x, int y, Color initialColor, Consumer onC this.gradientBox.setValue(hsv[2]); this.alphaSlider = new AlphaSlider(x,y,10,boxSize,initialColor); - this.colorPickerButton = new ColorPickerButton(x + boxSize + 8, y + 20, 35, 20); + this.colorPickerButton = new ColorPickerButton(x + boxSize + 8, y + 20, 30, 18); } public void setPos(int x, int y){ this.x = x; @@ -50,22 +50,12 @@ public void display() { public void close() { display = false; } - public void tick() { - gradientSlider.tick(); - gradientBox.tick(); - } - public void defaultValues(){ - gradientSlider.defaultValues(); - gradientBox.defaultValues(); - } public void render(DrawContext drawContext, int x1, int y1) { setPos(x1,y1); if(!display){ - defaultValues(); return; } - tick(); gradientSlider.render(drawContext,x + 30, y +client.textRenderer.fontHeight + 4); gradientBox.render(drawContext,x + 30, y + client.textRenderer.fontHeight + gradientSlider.getHeight() + 10); colorPickerButton.render(drawContext,x+ 55 + boxSize,y + client.textRenderer.fontHeight + gradientSlider.getHeight() + 8); diff --git a/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/ColorOption.java b/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/ColorOption.java index f32c4e5..bf870c6 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/ColorOption.java +++ b/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/ColorOption.java @@ -25,7 +25,6 @@ public ColorOption(String name,ContextMenu parentMenu, Supplier getter, C @Override public void render(DrawContext drawContext, int x, int y) { super.render(drawContext, x, y); - System.out.println(value.getAlpha()); int color = isVisible ? Color.GREEN.getRGB() : Color.RED.getRGB(); this.height = mc.textRenderer.fontHeight; @@ -42,7 +41,7 @@ public void render(DrawContext drawContext, int x, int y) { 1, 1 ); - colorPicker.render(drawContext,this.x + parentMenu.width + 10,y - 10); + colorPicker.render(drawContext,this.x + width/3 + parentMenu.width + 10,y - 10); } @Override diff --git a/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/GradientBox.java b/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/GradientBox.java index 844be56..e1b5fc8 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/GradientBox.java +++ b/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/GradientBox.java @@ -9,14 +9,12 @@ public class GradientBox { private final int size; - private final float alphaSpeed = 0.05f; private int x; private int y; private float hue = 0.0f; private float saturation = 1.0f; private float value = 1.0f; private boolean isDragging = false; - private float alpha = 0.0f; public GradientBox(int x, int y, int size) { @@ -24,15 +22,6 @@ public GradientBox(int x, int y, int size) { this.y = y; this.size = size; } - - public void tick() { - // Update the alpha - alpha += alphaSpeed; - if (alpha > 1.0f) { - alpha = 1.0f; - } - } - public void render(DrawContext drawContext, int x, int y) { setPosition(x,y); drawContext.getMatrices().push(); @@ -41,16 +30,6 @@ public void render(DrawContext drawContext, int x, int y) { // Draw the gradient com.tanishisherewith.dynamichud.newTrial.helpers.DrawHelper.drawRoundedGradientRectangle(drawContext.getMatrices().peek().getPositionMatrix(), Color.BLACK, Color.BLACK, Color.getHSBColor(hue, 1.0f, 1.0f), Color.WHITE, x, y, size, size,2); - /* for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - float saturation = (float) i / size; - float value = 1.0f - (float) j / size; - int color = Color.HSBtoRGB(hue, saturation, value); - color = (color & 0x00FFFFFF) | ((int) (alpha * 255) << 24); - drawContext.fill(x + i, y + j, x + i + 1, y + j + 1, color); - } - } - */ // Draw the handle float handleSize = 3; @@ -60,9 +39,6 @@ public void render(DrawContext drawContext, int x, int y) { DrawHelper.fillRoundedRect(drawContext, (int) handleX, (int) handleY, (int) (handleX + handleSize), (int) (handleY + handleSize), -1); drawContext.getMatrices().pop(); } - public void defaultValues(){ - alpha = 0.0f; - } /** diff --git a/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/GradientSlider.java b/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/GradientSlider.java index b0e396b..8aa7e32 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/GradientSlider.java +++ b/src/main/java/com/tanishisherewith/dynamichud/newTrial/utils/contextmenu/options/coloroption/GradientSlider.java @@ -10,14 +10,10 @@ public class GradientSlider { private final int width; private final int height; - private final float progressSpeed = 0.1f; - private final float alphaSpeed = 0.05f; private int x; private int y; private float hue = 0.0f; - private float progress = 0.0f; private boolean isDragging = false; - private float alpha = 0.0f; public GradientSlider(int x, int y, int width, int height) { this.x = x; @@ -26,23 +22,6 @@ public GradientSlider(int x, int y, int width, int height) { this.height = height; } - public void tick() { - // Update the progress - progress += progressSpeed; - if (progress > 1.0f) { - progress = 1.0f; - } - - // Update the alpha - alpha += alphaSpeed; - if (alpha > 1.0f) { - alpha = 1.0f; - } - } - public void defaultValues(){ - progress = 0.0f; - alpha = 0.0f; - } /** * Sets position. @@ -66,20 +45,18 @@ public void render(DrawContext drawContext, int x, int y) { for (int i = 0; i < width; i++) { float hue = (float) i / width; int color = Color.HSBtoRGB(hue, 1.0f, 1.0f); - color = (color & 0x00FFFFFF) | ((int) (alpha * 255) << 24); + color = (color & 0x00FFFFFF) | (255 << 24); drawContext.fill(x + i, y, x + i + 1, y + height, color); } // Draw the handle - if (progress >= 1.0f) { float handleWidth = 3; float handleHeight = height + 4; float handleX = x + hue * width - handleWidth / 2.0f; float handleY = y - (handleHeight - height) / 2.0f; DrawHelper.fillRoundedRect(drawContext, (int) handleX, (int) handleY, (int) (handleX + handleWidth), (int) (handleY + handleHeight), -1); - } drawContext.getMatrices().pop(); } diff --git a/src/main/java/com/tanishisherewith/dynamichud/newTrial/widget/Widget.java b/src/main/java/com/tanishisherewith/dynamichud/newTrial/widget/Widget.java index 6b97669..a5abc47 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/newTrial/widget/Widget.java +++ b/src/main/java/com/tanishisherewith/dynamichud/newTrial/widget/Widget.java @@ -1,10 +1,9 @@ package com.tanishisherewith.dynamichud.newTrial.widget; -import com.tanishisherewith.dynamichud.helpers.ColorHelper; -import com.tanishisherewith.dynamichud.helpers.DrawHelper; import com.tanishisherewith.dynamichud.newTrial.config.GlobalConfig; +import com.tanishisherewith.dynamichud.newTrial.helpers.ColorHelper; +import com.tanishisherewith.dynamichud.newTrial.helpers.DrawHelper; import com.tanishisherewith.dynamichud.newTrial.utils.UID; -import com.tanishisherewith.dynamichud.widget.WidgetBox; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.nbt.NbtCompound; @@ -34,9 +33,6 @@ public abstract class Widget { //To enable/disable snapping public boolean shiftDown = false; - public int snapBoxWidth,snapBoxHeight; - public static int snapSize = 1; - // Used for dragging and snapping int startX, startY; // Absolute position of the widget on screen in pixels. @@ -69,7 +65,7 @@ public abstract class Widget { public Widget(WidgetData DATA, String modId) { Widget.DATA = DATA; - widgetBox = new WidgetBox(0, 0, 0, 0, 1); + widgetBox = new WidgetBox(0, 0, 0, 0); this.modId = modId; init(); } @@ -108,8 +104,8 @@ public float getHeight() { } public void setPosition(int x, int y) { - this.x = x; - this.y = y; + this.x = x; + this.y = y; } public void setDraggable(boolean draggable) { @@ -152,22 +148,17 @@ public void render(DrawContext drawContext, int mouseX, int mouseY) { * Renders the widget on the editor screen. */ public void renderInEditor(DrawContext drawContext, int mouseX, int mouseY) { + displayBg(drawContext); + if (shouldScale) { DrawHelper.scaleAndPosition(drawContext.getMatrices(), getX(), getY(),GlobalConfig.get().scale); } - // Calculate the size of each snap box - snapBoxWidth = mc.getWindow().getScaledWidth() / snapSize; - snapBoxHeight = mc.getWindow().getScaledHeight() / snapSize; - renderWidgetInEditor(drawContext,mouseX,mouseY); if (shouldScale) { DrawHelper.stopScaling(drawContext.getMatrices()); } } - protected void updateWidgetBox(){ - widgetBox.setSizeAndPosition(x,y,getWidth(),getHeight()); - } /** @@ -191,7 +182,7 @@ protected void updateWidgetBox(){ * @param context */ private void renderWidgetInEditor(DrawContext context,int mouseX, int mouseY) { - displayBg(context); + //displayBg(context); renderWidget(context,mouseX,mouseY); } @@ -208,7 +199,6 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { } public boolean mouseDragged(double mouseX, double mouseY, int button, int snapSize) { - Widget.snapSize = snapSize; if (dragging && button == GLFW.GLFW_MOUSE_BUTTON_LEFT) { int newX = (int) (mouseX - startX); int newY = (int) (mouseY - startY); @@ -216,21 +206,21 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, int snapSi // Divides the screen into several "grid boxes" which the elements snap to. // Higher the snapSize, more the grid boxes if (this.shiftDown) { - // Calculate the index of the snap box that the new position would be in - int snapBoxX = newX / snapBoxWidth; - int snapBoxY = newY / snapBoxHeight; - - // Snap the new position to the top-left corner of the snap box - newX = snapBoxX * snapBoxWidth; - newY = snapBoxY * snapBoxHeight; + // Calculate the size of each snap box + int snapBoxWidth = mc.getWindow().getScaledWidth() / snapSize; + int snapBoxHeight = mc.getWindow().getScaledHeight() / snapSize; + + // Calculate the index of the snap box that the new position would be in and + // snap the new position to the top-left corner of the snap box + newX = (newX / snapBoxWidth) * snapBoxWidth; + newY = (newY / snapBoxHeight) * snapBoxHeight; } this.x = (int) MathHelper.clamp(newX, 0, mc.getWindow().getScaledWidth() - getWidth()); this.y = (int) MathHelper.clamp(newY, 0, mc.getWindow().getScaledHeight() - getHeight()); - - this.xPercent = (float) this.getX() / mc.getWindow().getScaledWidth(); - this.yPercent = (float) this.getY() / mc.getWindow().getScaledHeight(); + this.xPercent = (float) this.x / mc.getWindow().getScaledWidth(); + this.yPercent = (float) this.y / mc.getWindow().getScaledHeight(); return true; } @@ -267,7 +257,12 @@ public void onClose(){ protected void displayBg(DrawContext context) { int backgroundColor = this.shouldDisplay() ? ColorHelper.getColor(0, 0, 0, 128) : ColorHelper.getColor(255, 0, 0, 128); WidgetBox box = this.getWidgetBox(); - DrawHelper.fill(context, (int) box.x1, (int) box.y1, (int) box.x2, (int) box.y2, backgroundColor); + DrawHelper.drawRectangle(context.getMatrices().peek().getPositionMatrix(), + box.x, + box.y, + box.getWidth(), + box.getHeight(), + backgroundColor); } diff --git a/src/main/java/com/tanishisherewith/dynamichud/newTrial/widget/WidgetBox.java b/src/main/java/com/tanishisherewith/dynamichud/newTrial/widget/WidgetBox.java new file mode 100644 index 0000000..4ac9f25 --- /dev/null +++ b/src/main/java/com/tanishisherewith/dynamichud/newTrial/widget/WidgetBox.java @@ -0,0 +1,66 @@ +package com.tanishisherewith.dynamichud.newTrial.widget; + +public class WidgetBox { + private float width; + private float height; + public float x = 0, y = 0; + + public WidgetBox(int x, int y, int width, int height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + public boolean isMouseOver(double mouseX, double mouseY) { + return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height; + } + + public float getWidth() { + return width; + } + + public float getHeight() { + return height; + } + + public boolean intersects(WidgetBox other) { + // Check if this box is to the right of the other box + if (this.x > other.x + other.width) { + return false; + } + + // Check if this box is to the left of the other box + if (this.x + this.width < other.x) { + return false; + } + + // Check if this box is below the other box + if (this.y > other.y + other.height) { + return false; + } + + // Check if this box is above the other box + // If none of the above conditions are met, the boxes must intersect + return !(this.y + this.height < other.y); + } + + public void setSizeAndPosition(float x, float y, float width, float height){ + this.x = x; + this.y = y; + this.height = height; + this.width = width; + } + public void setSizeAndPosition(float x, float y, float width, float height,boolean shouldScale, float scale){ + this.x = x; + this.y = y; + this.height = height * (shouldScale? scale : 1.0f); + this.width = width * (shouldScale? scale : 1.0f); + } + public void setSize(double width, double height,boolean shouldScale, float scale) { + if (width >= 0) + this.width = (int) Math.ceil(width * (shouldScale? scale : 1.0f)); + if (height >= 0) + this.height = (int) Math.ceil(height * (shouldScale? scale : 1.0f)); + } +} diff --git a/src/main/java/com/tanishisherewith/dynamichud/newTrial/widget/WidgetManager.java b/src/main/java/com/tanishisherewith/dynamichud/newTrial/widget/WidgetManager.java index 6feb340..08758df 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/newTrial/widget/WidgetManager.java +++ b/src/main/java/com/tanishisherewith/dynamichud/newTrial/widget/WidgetManager.java @@ -118,23 +118,24 @@ public static void removeWidget(Widget widget) { public static void onScreenResized(int newWidth, int newHeight, int previousWidth, int previousHeight) { for (Widget widget : widgets) { // To ensure that infinite coords is not returned - if(widget.xPercent <= 0f){ + if(widget.xPercent <= 0.0f){ widget.xPercent = (float) widget.getX()/previousWidth; } - if(widget.yPercent <= 0f){ + if(widget.yPercent <= 0.0f){ widget.yPercent = (float) widget.getY()/previousHeight; } // Use the stored percentages to calculate the new position - int newX = (int) (widget.xPercent * newWidth); - int newY = (int) (widget.yPercent * newHeight); + float newX = widget.xPercent * newWidth; + float newY = widget.yPercent * newHeight; // Ensure the widget is within the screen bounds - newX = (int) MathHelper.clamp(newX, 0, newWidth - widget.getWidth()); - newY = (int) MathHelper.clamp(newY, 0, newHeight - widget.getHeight()); + newX = MathHelper.clamp(newX, 0, newWidth - widget.getWidth()); + newY = MathHelper.clamp(newY, 0, newHeight - widget.getHeight()); // Update the widget's position - widget.setPosition(newX, newY); + widget.setPosition((int) newX, (int) newY); + // Update the stored percentages with the new screen size (after resize). widget.xPercent = (float) widget.getX() / newWidth; widget.yPercent = (float) widget.getY() / newHeight; diff --git a/src/main/java/com/tanishisherewith/dynamichud/newTrial/widgets/TextWidget.java b/src/main/java/com/tanishisherewith/dynamichud/newTrial/widgets/TextWidget.java index df53480..a75269f 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/newTrial/widgets/TextWidget.java +++ b/src/main/java/com/tanishisherewith/dynamichud/newTrial/widgets/TextWidget.java @@ -1,6 +1,7 @@ package com.tanishisherewith.dynamichud.newTrial.widgets; import com.tanishisherewith.dynamichud.helpers.ColorHelper; +import com.tanishisherewith.dynamichud.newTrial.config.GlobalConfig; import com.tanishisherewith.dynamichud.newTrial.utils.DynamicValueRegistry; import com.tanishisherewith.dynamichud.newTrial.utils.contextmenu.ContextMenu; import com.tanishisherewith.dynamichud.newTrial.utils.contextmenu.options.*; @@ -8,6 +9,7 @@ import com.tanishisherewith.dynamichud.newTrial.widget.Widget; import com.tanishisherewith.dynamichud.newTrial.widget.WidgetData; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.nbt.NbtCompound; import org.lwjgl.glfw.GLFW; @@ -73,28 +75,29 @@ public void createMenu(){ menu.addOption(new BooleanOption("Rainbow",()->this.rainbow,value-> this.rainbow = value)); menu.addOption(new ColorOption("TextColor",menu,()-> textColor, value -> textColor = value)); menu.addOption(new DoubleOption("RainbowSpeed",1,4,1.0f, ()->(double)this.rainbowSpeed, value-> this.rainbowSpeed = value.intValue())); - AtomicReference testss = new AtomicReference<>(test.TEST); - List options = Arrays.asList("TEST","TEST2","TEST23"); - AtomicReference option = new AtomicReference<>("TEST"); - AtomicReference testColor = new AtomicReference<>(new Color(102)); - menu.addOption(new EnumOption("Test", testss::get, testss::set,test.values())); - menu.addOption(new ListOption("New", option::get, option::set,options )); + /* TEST */ + AtomicReference enums = new AtomicReference<>(Enum.Enum1); + AtomicReference option = new AtomicReference<>("Enum1"); + menu.addOption(new EnumOption<>("Enum", enums::get, enums::set, Enum.values())); + + List options = Arrays.asList("List1","List2","List3"); + menu.addOption(new ListOption<>("List", option::get, option::set, options)); } - public enum test{ - TEST, - TEST_2, - TEST_3 + public enum Enum{ + Enum1, + Enum2, + Enum3 } @Override public void renderWidget(DrawContext drawContext,int mouseX, int mouseY) { - menu.render(drawContext, getX() - 2, getY(), (int) Math.ceil(getHeight())); int color = rainbow ? ColorHelper.getColorFromHue((System.currentTimeMillis() % (5000 * rainbowSpeed) / (5000f * rainbowSpeed))) : textColor.getRGB(); if (textSupplier != null) { String text = textSupplier.get(); - drawContext.drawText(mc.textRenderer, text,getX(), getY(), color, shadow); - widgetBox.setSizeAndPosition(getX() - 2, getY() - 2, mc.textRenderer.getWidth(text) + 3, mc.textRenderer.fontHeight + 2); + drawContext.drawText(mc.textRenderer, text,getX() + 2, getY() + 2, color, shadow); + widgetBox.setSizeAndPosition(getX(), getY(), mc.textRenderer.getWidth(text) + 3, mc.textRenderer.fontHeight + 2,this.shouldScale,GlobalConfig.get().scale); } + menu.render(drawContext, getX() - 2, getY(), (int) Math.ceil(getHeight())); } @Override @@ -114,7 +117,7 @@ public void mouseReleased(double mouseX, double mouseY, int button) { @Override public boolean mouseDragged(double mouseX, double mouseY, int button, int snapSize) { - menu.mouseDragged(mouseX,mouseY,button); + menu.mouseDragged(mouseX, mouseY, button); return super.mouseDragged(mouseX, mouseY, button, snapSize); } diff --git a/src/main/java/com/tanishisherewith/dynamichud/widget/Widget.java b/src/main/java/com/tanishisherewith/dynamichud/widget/Widget.java index 6633a4e..30927be 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/widget/Widget.java +++ b/src/main/java/com/tanishisherewith/dynamichud/widget/Widget.java @@ -117,7 +117,7 @@ public static void setScale(float scale) { public void setX(float x) { int screenWidth = client.getWindow().getScaledWidth(); if (x < 0) { - x = (0); + x = 0; } else if (x + getWidgetBox().getWidth() > screenWidth) { x = screenWidth - getWidgetBox().getWidth(); } diff --git a/src/main/java/com/tanishisherewith/dynamichud/widget/WidgetBox.java b/src/main/java/com/tanishisherewith/dynamichud/widget/WidgetBox.java index f44e8af..a61db70 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/widget/WidgetBox.java +++ b/src/main/java/com/tanishisherewith/dynamichud/widget/WidgetBox.java @@ -37,7 +37,7 @@ public boolean intersects(float otherX1, float otherY1, float otherX2, float oth return !(otherX1 > x2 || otherX2 < x1 || otherY1 > y2 || otherY2 < y1); } public boolean isMouseOver(double mouseX, double mouseY) { - return mouseX >= x1 && mouseX <= x2 && mouseY >= y1 && mouseY <= y2; + return mouseX >= x1 && mouseX <= x1 + width && mouseY >= y1 && mouseY <= y2 + height; } public float getWidth() { @@ -47,14 +47,19 @@ public float getWidth() { public float getHeight() { return height; } + public void setSizeAndPosition(float x, float y, float width, float height){ this.x1 = x; - this.x2 = x + width; this.y1 = y; - this.y2 = y + height; this.height = height; this.width = width; } + public void setSizeAndPosition(float x, float y, float width, float height,boolean shouldScale, float scale){ + this.x1 = x; + this.y1 = y; + this.height = height * (shouldScale? scale : 1.0f); + this.width = width * (shouldScale? scale : 1.0f); + } public void setSize(double width, double height) { if (width >= 0) this.width = (int) Math.ceil(width); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 616fb5f..cb56d52 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -22,8 +22,7 @@ "com.tanishisherewith.dynamichud.newTrial.DynamicHUD" ], "dynamicHud": [ - "com.tanishisherewith.dynamichud.newTrial.DynamicHudTest", - "com.tanishisherewith.dynamichud.newTrial.DynamicHudTestTWO" + "com.tanishisherewith.dynamichud.newTrial.DynamicHudTest" ], "modmenu": [ "com.tanishisherewith.dynamichud.ModMenuIntegration"