Fixes and implemented animation curves
This commit is contained in:
@@ -7,19 +7,19 @@ public class AnimationConfig {
|
||||
public static ConfigManager config;
|
||||
|
||||
// Animation curve
|
||||
public static final Property<Integer> animationCurve = Property.select(1, "Ease In Out", "Ease Out");
|
||||
public static final Property<Integer> animationCurve = Property.select(1, "Ease In Out Cubic", "Ease Out Cubic", "Ease In Out Back");
|
||||
|
||||
// Logo duration
|
||||
public static final Property<Integer> logoDuration = Property.integer(700);
|
||||
|
||||
// Main menu
|
||||
public static final AnimationConfig mainMenu = new AnimationConfig(true, 600, 120);
|
||||
public static final AnimationConfig mainMenu = new AnimationConfig(true, 700, 120);
|
||||
|
||||
// Mod menu
|
||||
public static final AnimationConfig modMenu = new AnimationConfig(true, 600, 40);
|
||||
public static final AnimationConfig modMenu = new AnimationConfig(true, 700, 30);
|
||||
|
||||
// Shift menu
|
||||
public static final AnimationConfig shiftMenu = new AnimationConfig(true, 300, 50);
|
||||
public static final AnimationConfig shiftMenu = new AnimationConfig(true, 300, 120);
|
||||
|
||||
public static void init(ConfigManager parent) {
|
||||
config = new ConfigManager(parent, "Animations");
|
||||
@@ -28,17 +28,15 @@ public class AnimationConfig {
|
||||
config.property("Logo Duration", logoDuration);
|
||||
|
||||
mainMenu.init("Main Menu");
|
||||
mainMenu.init("Mod Menu");
|
||||
mainMenu.init("Shift Menu");
|
||||
modMenu.init("Mod Menu");
|
||||
shiftMenu.init("Shift Menu");
|
||||
}
|
||||
|
||||
// Animation properties
|
||||
// public final Property<Boolean> enabled;
|
||||
public final Property<Integer> duration;
|
||||
public final Property<Integer> stagger;
|
||||
|
||||
public AnimationConfig(boolean enabled, int delay, int stagger) {
|
||||
// this.enabled = Property.bool(enabled);
|
||||
this.duration = Property.integer(delay);
|
||||
this.stagger = Property.integer(stagger);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.saturnclient.ui2;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.saturnclient.saturnclient.config.AnimationConfig;
|
||||
import org.saturnclient.ui2.anim.Animation;
|
||||
import org.saturnclient.ui2.anim.Curve;
|
||||
|
||||
@@ -83,6 +84,16 @@ public class Element {
|
||||
|
||||
public Element animation(Animation animation) {
|
||||
this.animation = animation;
|
||||
switch (AnimationConfig.animationCurve.value) {
|
||||
case 0:
|
||||
this.curve = Curve::easeInOutCubic;
|
||||
case 1:
|
||||
this.curve = Curve::easeOutCubic;
|
||||
case 2:
|
||||
this.curve = Curve::easeInOutBack;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,6 @@ public class Curve {
|
||||
return (x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2);
|
||||
}
|
||||
|
||||
public static double easeInOutCubicReverse(double x) {
|
||||
return -(x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2);
|
||||
}
|
||||
|
||||
public static double easeInOutBack(double x) {
|
||||
double c1 = 1.70158;
|
||||
double c2 = c1 * 1.525;
|
||||
|
||||
Reference in New Issue
Block a user