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