From 07741d92fa6ea636b8292bb35706c25e5e6a72cc Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Fri, 3 Jun 2022 20:50:15 +0200 Subject: OC-66 almost done --- .../oneconfig/gui/animations/ColorAnimation.java | 7 +++++++ .../oneconfig/gui/elements/BasicButton.java | 4 ++-- .../oneconfig/gui/elements/BasicElement.java | 20 +++++++++++--------- 3 files changed, 20 insertions(+), 11 deletions(-) (limited to 'src/main/java/cc/polyfrost/oneconfig/gui') diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java index 420f1d0..39130f0 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java @@ -46,4 +46,11 @@ public class ColorAnimation { this.palette = palette; prevState = 3; } + + public void setColors(float[] colors) { + redAnimation = new DummyAnimation(colors[0]); + greenAnimation = new DummyAnimation(colors[1]); + blueAnimation = new DummyAnimation(colors[2]); + alphaAnimation = new DummyAnimation(colors[3]); + } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java index bc2bcae..afccbe3 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java @@ -122,8 +122,8 @@ public class BasicButton extends BasicElement { } else if (this.runnable != null) { runnable.run(); } - if (toggleable && toggled) colorPalette = ColorPalette.PRIMARY; - else if (toggleable) colorPalette = ColorPalette.SECONDARY; + if (toggleable && toggled) setColorPalette(ColorPalette.PRIMARY); + else if (toggleable) setColorPalette(ColorPalette.SECONDARY); } /*@Override diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java index c146742..3ff61a1 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java @@ -47,19 +47,19 @@ public class BasicElement { hovered = false; pressed = false; clicked = false; - return; + } else { + hovered = InputUtils.isAreaHovered(x - hitBoxX, y - hitBoxY, width + hitBoxX, height + hitBoxY); + pressed = hovered && Mouse.isButtonDown(0); + clicked = InputUtils.isClicked(block) && hovered; + + if (clicked) { + toggled = !toggled; + onClick(); + } } - hovered = InputUtils.isAreaHovered(x - hitBoxX, y - hitBoxY, width + hitBoxX, height + hitBoxY); - pressed = hovered && Mouse.isButtonDown(0); - clicked = InputUtils.isClicked(block) && hovered; if (hoverFx) currentColor = colorAnimation.getColor(hovered, pressed); else currentColor = colorAnimation.getColor(false, false); - - if (clicked) { - toggled = !toggled; - onClick(); - } } public void ignoreBlockedTouches(boolean state) { @@ -85,6 +85,8 @@ public class BasicElement { } public void setColorPalette(ColorPalette colorPalette) { + if (this.colorPalette.equals(ColorPalette.TERTIARY) || this.colorPalette.equals(ColorPalette.TERTIARY_DESTRUCTIVE)) + this.colorAnimation.setColors(colorPalette.getNormalColorf()); this.colorPalette = colorPalette; this.colorAnimation.setPalette(colorPalette); } -- cgit