diff options
Diffstat (limited to 'src/main/java/cc')
3 files changed, 20 insertions, 11 deletions
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); } |