Fixes and implemented animation curves

This commit is contained in:
2026-02-25 00:39:48 +01:00
parent 246e49e521
commit 6689919b3b
3 changed files with 17 additions and 12 deletions
@@ -7,19 +7,19 @@ public class AnimationConfig {
public static ConfigManager config; public static ConfigManager config;
// Animation curve // 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 // Logo duration
public static final Property<Integer> logoDuration = Property.integer(700); public static final Property<Integer> logoDuration = Property.integer(700);
// Main menu // Main menu
public static final AnimationConfig mainMenu = new AnimationConfig(true, 600, 120); public static final AnimationConfig mainMenu = new AnimationConfig(true, 700, 120);
// Mod menu // Mod menu
public static final AnimationConfig modMenu = new AnimationConfig(true, 600, 40); public static final AnimationConfig modMenu = new AnimationConfig(true, 700, 30);
// Shift menu // 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) { public static void init(ConfigManager parent) {
config = new ConfigManager(parent, "Animations"); config = new ConfigManager(parent, "Animations");
@@ -28,17 +28,15 @@ public class AnimationConfig {
config.property("Logo Duration", logoDuration); config.property("Logo Duration", logoDuration);
mainMenu.init("Main Menu"); mainMenu.init("Main Menu");
mainMenu.init("Mod Menu"); modMenu.init("Mod Menu");
mainMenu.init("Shift Menu"); shiftMenu.init("Shift Menu");
} }
// Animation properties // Animation properties
// public final Property<Boolean> enabled;
public final Property<Integer> duration; public final Property<Integer> duration;
public final Property<Integer> stagger; public final Property<Integer> stagger;
public AnimationConfig(boolean enabled, int delay, int stagger) { public AnimationConfig(boolean enabled, int delay, int stagger) {
// this.enabled = Property.bool(enabled);
this.duration = Property.integer(delay); this.duration = Property.integer(delay);
this.stagger = Property.integer(stagger); this.stagger = Property.integer(stagger);
} }
@@ -2,6 +2,7 @@ package org.saturnclient.ui2;
import java.util.function.Function; import java.util.function.Function;
import org.saturnclient.saturnclient.config.AnimationConfig;
import org.saturnclient.ui2.anim.Animation; import org.saturnclient.ui2.anim.Animation;
import org.saturnclient.ui2.anim.Curve; import org.saturnclient.ui2.anim.Curve;
@@ -83,6 +84,16 @@ public class Element {
public Element animation(Animation animation) { public Element animation(Animation animation) {
this.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; 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); 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) { public static double easeInOutBack(double x) {
double c1 = 1.70158; double c1 = 1.70158;
double c2 = c1 * 1.525; double c2 = c1 * 1.525;