diff options
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java | 37 |
1 files changed, 35 insertions, 2 deletions
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,23 +26,56 @@ package cc.polyfrost.oneconfig.gui.animations; +import java.util.concurrent.Callable; + public class DummyAnimation extends Animation { protected final float value; + protected Callable<Boolean> 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<Boolean> 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; } |