The account chip and a quit button go in the top corners and the version in the bottom left, now smaller and fainter. Minecraft's options and Saturn's settings take the HUD editor's place in the dock, and the intro brings the menus and edges in after the logo. Faded elements now start hidden instead of at 10% opacity. Co-Authored-By: Claude Opus 5.5 <[email protected]>
106 lines
4.0 KiB
Java
106 lines
4.0 KiB
Java
package org.saturnclient.ui;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class ElementRenderer {
|
|
public static void draw(List<Element> elements, Element element) {
|
|
synchronized (elements) {
|
|
elements.add(element);
|
|
}
|
|
|
|
if (element.animation != null) {
|
|
element.animation.init(element);
|
|
}
|
|
}
|
|
|
|
public static void render(List<Element> elements, long elapsed, RenderScope renderScope, int mouseX, int mouseY) {
|
|
render(elements, elapsed, renderScope, mouseX, mouseY, ElementContext.Frame.SCREEN);
|
|
}
|
|
|
|
/**
|
|
* Renders a container's children within its {@code frame}.
|
|
*/
|
|
public static void render(List<Element> elements, long elapsed, RenderScope renderScope, int mouseX, int mouseY,
|
|
ElementContext.Frame frame) {
|
|
for (Element element : elements) {
|
|
element.playAnimationFrame(elapsed);
|
|
|
|
// Not faded in yet
|
|
if (element.opacity <= 0) {
|
|
continue;
|
|
}
|
|
|
|
renderScope.getMatrixStack().push();
|
|
renderScope.setOpacity(element.opacity);
|
|
renderScope.getMatrixStack().translate(element.x, element.y);
|
|
renderScope.getMatrixStack().scale(element.scale, element.scale);
|
|
element.render(renderScope, new ElementContext(elapsed, mouseX, mouseY, frame, element));
|
|
renderScope.getMatrixStack().pop();
|
|
}
|
|
}
|
|
|
|
public static void mouseClicked(List<Element> elements, double mouseX, double mouseY, int button) {
|
|
if (button == 0) {
|
|
for (Element element : new ArrayList<>(elements)) {
|
|
element.focused = false;
|
|
|
|
int adjustedMouseX = (int) mouseX - element.x;
|
|
int adjustedMouseY = (int) mouseY - element.y;
|
|
|
|
element.mouseClicked(adjustedMouseX * element.scale, adjustedMouseY * element.scale, button);
|
|
|
|
if (element.opacity > 0 && Utils.isHovering(adjustedMouseX, adjustedMouseY, element.width,
|
|
element.height, element.scale)) {
|
|
element.focused = true;
|
|
element.click((int) (adjustedMouseX * element.scale), (int) (adjustedMouseY * element.scale));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void mouseScrolled(
|
|
List<Element> elements,
|
|
double mouseX,
|
|
double mouseY,
|
|
double horizontalAmount,
|
|
double verticalAmount) {
|
|
for (Element element : new ArrayList<>(elements)) {
|
|
if (Utils.isHovering((int) mouseX - element.x, (int) mouseY - element.y, element.width, element.height,
|
|
element.scale)) {
|
|
element.scroll(
|
|
(int) mouseX - element.x,
|
|
(int) mouseY - element.y,
|
|
horizontalAmount,
|
|
verticalAmount);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void keyPressed(List<Element> elements, int keyCode, int scanCode, int modifiers) {
|
|
for (Element element : new ArrayList<>(elements)) {
|
|
if (element.focused && element.opacity > 0) {
|
|
element.keyPressed(keyCode, scanCode, modifiers);
|
|
|
|
char typedChar = Utils.getCharFromKey(keyCode, modifiers);
|
|
if (typedChar != '\0') {
|
|
element.charTyped(typedChar);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void mouseDragged(List<Element> elements, double mouseX, double mouseY, int button, double deltaX,
|
|
double deltaY) {
|
|
for (Element element : new ArrayList<>(elements)) {
|
|
element.mouseDragged(mouseX - element.x, mouseY - element.y, button, deltaX, deltaY);
|
|
}
|
|
}
|
|
|
|
public static void mouseReleased(List<Element> elements, double mouseX, double mouseY, int button) {
|
|
for (Element element : new ArrayList<>(elements)) {
|
|
element.mouseReleased(mouseX - element.x, mouseY - element.y, button);
|
|
}
|
|
}
|
|
}
|