Implemented curves for all animations
This commit is contained in:
@@ -6,8 +6,8 @@ import org.saturnclient.saturnclient.config.manager.Property;
|
||||
public class AnimationConfig {
|
||||
public static ConfigManager config;
|
||||
|
||||
// Logo duration
|
||||
public static final Property<Integer> logoDuration = Property.integer(700);
|
||||
// Logo
|
||||
public static final AnimationConfig logo = new AnimationConfig(true, 700, 0);
|
||||
|
||||
// Main menu
|
||||
public static final AnimationConfig mainMenu = new AnimationConfig(true, 700, 120);
|
||||
@@ -20,8 +20,8 @@ public class AnimationConfig {
|
||||
|
||||
public static void init(ConfigManager parent) {
|
||||
config = new ConfigManager(parent, "Animations");
|
||||
config.property("Logo Duration", logoDuration);
|
||||
|
||||
logo.init("Logo");
|
||||
mainMenu.init("Main Menu");
|
||||
modMenu.init("Mod Menu");
|
||||
shiftMenu.init("Shift Menu");
|
||||
@@ -42,5 +42,6 @@ public class AnimationConfig {
|
||||
// config.property("Enable " + name + " Animations", this.enabled);
|
||||
config.property(name + " Duration", this.duration);
|
||||
config.property(name + " Stagger", this.stagger);
|
||||
config.property(name + " Curve", this.curve);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public class Curve {
|
||||
}
|
||||
|
||||
public static double easeInOutBack(double x) {
|
||||
double c1 = 1.70158;
|
||||
double c1 = 2.5;
|
||||
double c2 = c1 * 1.525;
|
||||
|
||||
if (x < 0.5) {
|
||||
|
||||
@@ -13,8 +13,10 @@ public class SlideFade extends Animation {
|
||||
this.slideY = new SlideY(duration, offset);
|
||||
}
|
||||
|
||||
public SlideFade(AnimationConfig config) {
|
||||
public SlideFade(AnimationConfig config, int offset) {
|
||||
super(config);
|
||||
this.fade = new Fade(duration);
|
||||
this.slideY = new SlideY(duration, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.saturnclient.ui2.elements;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.saturnclient.saturnclient.config.AnimationConfig;
|
||||
import org.saturnclient.saturnclient.config.Config;
|
||||
import org.saturnclient.ui2.Element;
|
||||
import org.saturnclient.ui2.ElementContext;
|
||||
@@ -17,6 +18,10 @@ public class AnimationStagger extends Element {
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public AnimationStagger(AnimationConfig config) {
|
||||
this.delay = config.stagger.value;
|
||||
}
|
||||
|
||||
public void draw(Element element) {
|
||||
if (!Config.stagger.value) {
|
||||
element.animation = null;
|
||||
@@ -29,10 +34,9 @@ public class AnimationStagger extends Element {
|
||||
ElementRenderer.draw(children, element);
|
||||
|
||||
this.height = Math.max(this.height, element.y + element.height);
|
||||
this.width = Math.max(this.width, element.x + element.width);
|
||||
this.width = Math.max(this.width, element.x + element.width);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||
ElementRenderer.render(children, ctx.elapsed, renderScope,
|
||||
|
||||
@@ -31,9 +31,9 @@ public class EmoteWheel extends SaturnScreen {
|
||||
int col = 0;
|
||||
|
||||
draw(new ImageTexture(Textures.LOGO_TEXT).dimensions(98, 10).centerOffset(width, height, 0, -105)
|
||||
.animation(new Fade(AnimationConfig.logoDuration.value)));
|
||||
.animation(new Fade(AnimationConfig.logo.duration.value)));
|
||||
draw(new ImageTexture(Config.getLogo()).dimensions(98, 98).centerOffset(width, height, 0, -149)
|
||||
.animation(new SlideY(AnimationConfig.logoDuration.value, -20)));
|
||||
.animation(new SlideY(AnimationConfig.logo, -20)));
|
||||
|
||||
draw(new TextureButton(Textures.LEFT, () -> {
|
||||
if (page > 1) {
|
||||
|
||||
@@ -27,13 +27,13 @@ public class ModMenu extends SaturnScreen {
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
|
||||
AnimationStagger moduleStagger = new AnimationStagger(AnimationConfig.modMenu.stagger.value);
|
||||
AnimationStagger moduleStagger = new AnimationStagger(AnimationConfig.modMenu);
|
||||
|
||||
for (Module mod : ModManager.ALL_MODS) {
|
||||
moduleStagger.draw(
|
||||
new SaturnModule(mod)
|
||||
.position((160 + g) * col, (50 + g) * row)
|
||||
.animation(new SlideFade(AnimationConfig.modMenu.duration.value, -12)));
|
||||
.animation(new SlideFade(AnimationConfig.modMenu, -12)));
|
||||
|
||||
if (col == 2) {
|
||||
col = 0;
|
||||
|
||||
@@ -25,12 +25,12 @@ public class ShiftMenu extends SaturnScreen {
|
||||
draw(new ImageTexture(Textures.LOGO_TEXT)
|
||||
.dimensions(98, 10)
|
||||
.centerOffset(width, height, 0, -36)
|
||||
.animation(new Fade(AnimationConfig.logoDuration.value)));
|
||||
.animation(new Fade(AnimationConfig.logo.duration.value)));
|
||||
|
||||
draw(new ImageTexture(Config.getLogo())
|
||||
.dimensions(98, 98)
|
||||
.centerOffset(width, height, 0, -80)
|
||||
.animation(new SlideY(AnimationConfig.logoDuration.value, -20)));
|
||||
.animation(new SlideY(AnimationConfig.logo, -20)));
|
||||
|
||||
// Spacing and sizes
|
||||
int btnWidth = 120;
|
||||
@@ -44,17 +44,17 @@ public class ShiftMenu extends SaturnScreen {
|
||||
stagger.draw(new TextureButton(Textures.HUD_ICON, () -> {
|
||||
client.setScreen(new HudEditor());
|
||||
}).dimensions(btnHeight, btnHeight).position(0, 0)
|
||||
.animation(new Fade(AnimationConfig.shiftMenu.duration.value)));
|
||||
.animation(new Fade(AnimationConfig.shiftMenu)));
|
||||
|
||||
stagger.draw(new Button("Settings", () -> {
|
||||
SaturnClient.client.setScreen(new ModMenu());
|
||||
}).dimensions(btnWidth, btnHeight).position(btnHeight + spacing, 0)
|
||||
.animation(new Fade(AnimationConfig.shiftMenu.duration.value)));
|
||||
.animation(new Fade(AnimationConfig.shiftMenu)));
|
||||
|
||||
stagger.draw(new TextureButton(Textures.COSMETICS, () -> {
|
||||
client.setScreen(new CloakMenu());
|
||||
}).dimensions(btnHeight, btnHeight).position(btnWidth + btnHeight + (spacing * 2), 0)
|
||||
.animation(new Fade(AnimationConfig.shiftMenu.duration.value)));
|
||||
.animation(new Fade(AnimationConfig.shiftMenu)));
|
||||
|
||||
// Draw the stagger at the absolute center of the screen
|
||||
draw(stagger.dimensions(btnWidth + (btnHeight * 2) + (spacing * 2), btnHeight).centerOffset(width, height, 0,
|
||||
|
||||
@@ -29,32 +29,32 @@ public class TitleMenu extends SaturnScreen {
|
||||
public void ui() {
|
||||
backgroundBlur = 0;
|
||||
|
||||
draw(new ImageTexture(Textures.LOGO_TEXT).dimensions(98, 10).centerOffset(width, height, 0, -36)
|
||||
.animation(new Fade(700)));
|
||||
draw(new ImageTexture(Config.getLogo()).dimensions(98, 98).centerOffset(width, height, 0, -82)
|
||||
.animation(new SlideY(700, -20)));
|
||||
draw(new ImageTexture(Textures.LOGO_TEXT).dimensions(98, 10).centerOffset(width, height, 0, -105)
|
||||
.animation(new Fade(AnimationConfig.logo.duration.value)));
|
||||
draw(new ImageTexture(Config.getLogo()).dimensions(98, 98).centerOffset(width, height, 0, -149)
|
||||
.animation(new SlideY(AnimationConfig.logo, -20)));
|
||||
|
||||
AnimationStagger mainButtonStagger = new AnimationStagger(AnimationConfig.mainMenu.stagger.value);
|
||||
AnimationStagger mainButtonStagger = new AnimationStagger(AnimationConfig.mainMenu);
|
||||
|
||||
mainButtonStagger.draw(new Button("SINGLEPLAYER", () -> {
|
||||
client.setScreen(new SelectWorldScreen(new TitleMenu()));
|
||||
}).scale(0.69f).dimensions(420, 52).position(0, 0)
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu.duration.value, -10)));
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu, -10)));
|
||||
|
||||
mainButtonStagger.draw(new Button("MULTIPLAYER", () -> {
|
||||
client.setScreen(new MultiplayerScreen(new TitleMenu()));
|
||||
}).scale(0.69f).dimensions(420, 52).position(0, 40)
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu.duration.value, -10)));
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu, -10)));
|
||||
|
||||
mainButtonStagger.draw(new Button("OPTIONS", () -> {
|
||||
client.setScreen(new OptionsScreen(new TitleMenu(), SaturnClient.client.options));
|
||||
}).scale(0.69f).dimensions(206, 52).position(0, 80)
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu.duration.value, -10)));
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu, -10)));
|
||||
|
||||
mainButtonStagger.draw(new Button("QUIT", () -> {
|
||||
client.scheduleStop();
|
||||
}).scale(0.69f).dimensions(206, 52).position(146, 80)
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu.duration.value, -10)));
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu, -10)));
|
||||
|
||||
draw(mainButtonStagger.dimensions(289, 143).centerOffset(width, height, 0, 60));
|
||||
|
||||
@@ -64,17 +64,17 @@ public class TitleMenu extends SaturnScreen {
|
||||
|
||||
saturnStagger.draw(new TextureButton(Textures.HUD_ICON, () -> {
|
||||
client.setScreen(new HudEditor());
|
||||
}).dimensions(s, s).position(0, 0).animation(new SlideFade(AnimationConfig.mainMenu.duration.value, s + 8)));
|
||||
}).dimensions(s, s).position(0, 0).animation(new SlideFade(AnimationConfig.mainMenu, s + 8)));
|
||||
|
||||
saturnStagger.draw(new TextureButton(Textures.SETTINGS, () -> {
|
||||
SaturnClient.client.setScreen(new ModMenu());
|
||||
}).dimensions(s, s).position(s + 2, 0)
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu.duration.value, s + 8)));
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu, s + 8)));
|
||||
|
||||
saturnStagger.draw(new TextureButton(Textures.CLOAK, () -> {
|
||||
client.setScreen(new CloakMenu());
|
||||
}).dimensions(s, s).position((s + 2) * 2, 0)
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu.duration.value, s + 8)));
|
||||
.animation(new SlideFade(AnimationConfig.mainMenu, s + 8)));
|
||||
|
||||
draw(saturnStagger.dimensions(((s + 2) * 2) + s, s).centerHorizontal(width, height, 0, 8));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user