diff options
author | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-04-21 14:19:44 +0100 |
---|---|---|
committer | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-04-21 14:19:44 +0100 |
commit | 260d48126cbedb4341c5c5865bfd8e605f90955a (patch) | |
tree | 563f65d65d708f24df33759c411b0f2338c1933e /src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java | |
parent | 30df910cf3b2f5b0683ce01e391c35829d8a5850 (diff) | |
download | OneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.tar.gz OneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.tar.bz2 OneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.zip |
more gui things like text field and button
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java')
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java index 0b7d604..765a271 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java @@ -6,19 +6,14 @@ import net.minecraft.client.Minecraft; import org.lwjgl.input.Mouse; public class BasicElement { - private int width; - private int height; - private int colorPalette; - - private int hitBoxX, hitBoxY; - - private final boolean hoverFx; - - private boolean hovered = false; - private boolean clicked = false; - private boolean toggled = false; - - private int currentColor; + protected int width, height; + protected int colorPalette; + protected int hitBoxX, hitBoxY; + protected final boolean hoverFx; + protected boolean hovered = false; + protected boolean clicked = false; + protected boolean toggled = false; + protected int currentColor; public BasicElement(int width, int height, int colorPalette, boolean hoverFx) { this.height = height; @@ -37,6 +32,14 @@ public class BasicElement { public void draw(long vg, int x, int y) { RenderManager.drawRectangle(vg, x, y, width, height, currentColor); + + update(x, y); + if (hoverFx) { + currentColor = ColorUtils.getColor(currentColor, colorPalette, hovered, clicked); + } + } + + public void update(int x, int y) { int mouseX = Mouse.getX(); int mouseY = Minecraft.getMinecraft().displayHeight - Math.abs(Mouse.getY()); int buttonRight = x + width; @@ -47,10 +50,6 @@ public class BasicElement { toggled = !toggled; } clicked = Mouse.isButtonDown(0) && hovered; - - if (hoverFx) { - currentColor = ColorUtils.getColor(currentColor, colorPalette, hovered, clicked); - } } |