Animated mods
This commit is contained in:
@@ -16,6 +16,13 @@ public class AnimationStagger extends Element {
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public void draw(Element element) {
|
||||
if (element.animation != null) {
|
||||
element.animation.delay = delay * children.size();
|
||||
}
|
||||
ElementRenderer.draw(children, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||
ElementRenderer.render(children, ctx.elapsed, renderScope,
|
||||
@@ -24,15 +31,8 @@ public class AnimationStagger extends Element {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(int mouseX, int mouseY) {
|
||||
ElementRenderer.mouseClicked(children, mouseX, mouseY, 0);
|
||||
}
|
||||
|
||||
public void draw(Element element) {
|
||||
if (element.animation != null) {
|
||||
element.animation.delay = delay * children.size();
|
||||
}
|
||||
ElementRenderer.draw(children, element);
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
ElementRenderer.mouseClicked(children, mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,10 @@ public class Scroll extends Element {
|
||||
this.padding = padding;
|
||||
}
|
||||
|
||||
public void draw(Element element) {
|
||||
ElementRenderer.draw(children, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||
calculateMaxScroll();
|
||||
@@ -64,15 +68,6 @@ public class Scroll extends Element {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(int mouseX, int mouseY) {
|
||||
ElementRenderer.mouseClicked(children, mouseX - padding, mouseY - padding + scroll, 0);
|
||||
}
|
||||
|
||||
public void draw(Element element) {
|
||||
children.add(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element dimensions(int width, int height) {
|
||||
maxScroll = 0;
|
||||
@@ -118,6 +113,11 @@ public class Scroll extends Element {
|
||||
ElementRenderer.keyPressed(children, keyCode, scanCode, modifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
ElementRenderer.mouseClicked(children, mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
||||
ElementRenderer.mouseDragged(children, mouseX - padding, mouseY - padding + scroll, button, deltaX, deltaY);
|
||||
|
||||
@@ -3,8 +3,10 @@ package org.saturnclient.ui2.screens;
|
||||
import org.saturnclient.modules.ModManager;
|
||||
import org.saturnclient.modules.Module;
|
||||
import org.saturnclient.ui2.SaturnScreen;
|
||||
import org.saturnclient.ui2.anim.SlideFade;
|
||||
import org.saturnclient.ui2.components.SaturnModule;
|
||||
import org.saturnclient.ui2.components.Sidebar;
|
||||
import org.saturnclient.ui2.elements.AnimationStagger;
|
||||
import org.saturnclient.ui2.elements.ImageTexture;
|
||||
import org.saturnclient.ui2.elements.Scroll;
|
||||
import org.saturnclient.ui2.resources.Textures;
|
||||
@@ -24,8 +26,11 @@ public class ModMenu extends SaturnScreen {
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
|
||||
AnimationStagger moduleStagger = new AnimationStagger(80);
|
||||
|
||||
for (Module mod : ModManager.ALL_MODS) {
|
||||
scroll.draw(new SaturnModule(mod).position((160 + g) * col, (50 + g) * row));
|
||||
moduleStagger.draw(
|
||||
new SaturnModule(mod).position((160 + g) * col, (50 + g) * row).animation(new SlideFade(600, -12)));
|
||||
|
||||
if (col == 2) {
|
||||
col = 0;
|
||||
@@ -35,6 +40,8 @@ public class ModMenu extends SaturnScreen {
|
||||
}
|
||||
}
|
||||
|
||||
scroll.draw(moduleStagger);
|
||||
|
||||
int scrollWidth = 480 + 10 + (g * 2) + (p * 2);
|
||||
|
||||
draw(scroll.dimensions(scrollWidth, 350).center(width, height));
|
||||
|
||||
Reference in New Issue
Block a user