From daed9569a0f1d2231c4f824f6cffd72d5f8ae8bd Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Wed, 24 Aug 2022 22:51:58 +0200 Subject: Notifs (#111) * Start on notifications * Finish notifications (pog) * oop * internalizing * misc: set default duration to 4000ms * Scaling notifs stuff Co-authored-by: Wyvest <45589059+Wyvest@users.noreply.github.com> --- .../oneconfig/gui/animations/DummyAnimation.java | 37 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java') diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java index ca9bc17..62cbed7 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java @@ -26,22 +26,55 @@ package cc.polyfrost.oneconfig.gui.animations; +import java.util.concurrent.Callable; + public class DummyAnimation extends Animation { protected final float value; + protected Callable done = null; /** * @param value The value that is returned + * @param done A callable that returns if the animation is finished */ - public DummyAnimation(float value) { - super(value, value, value, false); + public DummyAnimation(float value, Callable done) { + super(0, value, value, false); + this.value = value; + this.done = done; + } + + /** + * @param value The value that is returned + * @param duration The duration of the animation + */ + public DummyAnimation(float value, float duration) { + super(duration, value, value, false); this.value = value; } + /** + * @param value The value that is returned + */ + public DummyAnimation(float value) { + this(value, 0); + } + @Override public float get(float deltaTime) { + timePassed += deltaTime; return value; } + @Override + public boolean isFinished() { + if (done != null) { + try { + return done.call(); + } catch (Exception ignored) { + } + } + return super.isFinished(); + } + @Override protected float animate(float x) { return x; -- cgit