diff --git a/earlydisplay/src/main/java/net/neoforged/fml/earlydisplay/error/Button.java b/earlydisplay/src/main/java/net/neoforged/fml/earlydisplay/error/Button.java index 9b7170083..77ad2de69 100644 --- a/earlydisplay/src/main/java/net/neoforged/fml/earlydisplay/error/Button.java +++ b/earlydisplay/src/main/java/net/neoforged/fml/earlydisplay/error/Button.java @@ -9,6 +9,7 @@ import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.List; +import java.util.function.Supplier; import net.neoforged.fml.earlydisplay.render.RenderContext; import net.neoforged.fml.earlydisplay.render.SimpleFont; import net.neoforged.fml.earlydisplay.render.Texture; @@ -25,11 +26,15 @@ final class Button { private final int width; private final int height; private final String text; - private final boolean active; + private final Supplier active; private final Runnable onPress; private boolean focused; Button(ErrorDisplayWindow window, int x, int y, int width, int height, String text, boolean active, Runnable onPress) { + this(window, x, y, width, height, text, () -> active, onPress); + } + + Button(ErrorDisplayWindow window, int x, int y, int width, int height, String text, Supplier active, Runnable onPress) { this.window = window; this.x = x; this.y = y; @@ -41,13 +46,13 @@ final class Button { } void render(RenderContext ctx, SimpleFont font, double mouseX, double mouseY) { - boolean highlighted = active && (focused || isMouseOver(mouseX, mouseY)); - Texture texture = active ? (highlighted ? window.buttonTextureHover : window.buttonTexture) : window.buttonTextureInactive; + boolean highlighted = isActive() && (focused || isMouseOver(mouseX, mouseY)); + Texture texture = isActive() ? (highlighted ? window.buttonTextureHover : window.buttonTexture) : window.buttonTextureInactive; ctx.blitTexture(texture, x, y, width, height); int w = font.stringWidth(text); float tx = x + width / 2F - w / 2F; - int textColor = active ? 0xFFFFFFFF : 0xFFA0A0A0; + int textColor = isActive() ? 0xFFFFFFFF : 0xFFA0A0A0; ctx.renderTextWithShadow(tx, y + 2, font, List.of(new SimpleFont.DisplayText(text, textColor))); } @@ -56,7 +61,7 @@ boolean isMouseOver(double mouseX, double mouseY) { } boolean isActive() { - return active; + return active.get(); } boolean isFocused() { @@ -72,7 +77,7 @@ void unfocus() { } void press() { - if (this.active) { + if (isActive()) { this.onPress.run(); } } diff --git a/earlydisplay/src/main/java/net/neoforged/fml/earlydisplay/error/ErrorDisplayWindow.java b/earlydisplay/src/main/java/net/neoforged/fml/earlydisplay/error/ErrorDisplayWindow.java index 76c67511a..7e327706d 100644 --- a/earlydisplay/src/main/java/net/neoforged/fml/earlydisplay/error/ErrorDisplayWindow.java +++ b/earlydisplay/src/main/java/net/neoforged/fml/earlydisplay/error/ErrorDisplayWindow.java @@ -5,6 +5,7 @@ package net.neoforged.fml.earlydisplay.error; +import java.io.IOException; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; @@ -21,6 +22,8 @@ import net.neoforged.fml.earlydisplay.render.Texture; import net.neoforged.fml.earlydisplay.theme.Theme; import net.neoforged.fml.i18n.FMLTranslations; +import net.neoforged.fml.loading.FMLPaths; +import net.neoforged.fml.loading.cache.CacheUtils; import org.jetbrains.annotations.Nullable; import org.lwjgl.glfw.GLFW; import org.lwjgl.opengl.GL11C; @@ -28,7 +31,8 @@ final class ErrorDisplayWindow { private static final int DISPLAY_WIDTH = 854; private static final int DISPLAY_HEIGHT = 480; - private static final int BUTTON_WIDTH = 320; + private static final int SMALL_BUTTON_WIDTH = 320; + private static final int LARGE_BUTTON_WIDTH = 2 * SMALL_BUTTON_WIDTH + 20; private static final int BUTTON_HEIGHT = 40; private static final int LIST_BORDER_HEIGHT = 2; private static final int SCROLLER_WIDTH = 15; @@ -36,14 +40,15 @@ final class ErrorDisplayWindow { private static final int ENTRY_PADDING = 10; private static final int HEADER_Y = 10; private static final int HEADER_LINE_HEIGHT = 18; - private static final int LEFT_BTN_X = DISPLAY_WIDTH / 2 - 10 - BUTTON_WIDTH; + private static final int LEFT_BTN_X = DISPLAY_WIDTH / 2 - 10 - SMALL_BUTTON_WIDTH; private static final int RIGHT_BTN_X = DISPLAY_WIDTH / 2 + 10; - private static final int TOP_BTN_Y = DISPLAY_HEIGHT - 92; + private static final int TOP_BTN_Y = DISPLAY_HEIGHT - 137; + private static final int MIDDLE_BTN_Y = DISPLAY_HEIGHT - 92; private static final int BOTTOM_BTN_Y = DISPLAY_HEIGHT - 47; private static final int LIST_Y_TOP = 70; - private static final int LIST_Y_BOTTOM = DISPLAY_HEIGHT - 100; + private static final int LIST_Y_BOTTOM = DISPLAY_HEIGHT - 145; private static final int LIST_CONTENT_Y_TOP = 74; - private static final int LIST_CONTENT_Y_BOTTOM = DISPLAY_HEIGHT - 102; + private static final int LIST_CONTENT_Y_BOTTOM = DISPLAY_HEIGHT - 147; private static final int LIST_BORDER_TOP_Y2 = LIST_Y_TOP - LIST_BORDER_HEIGHT; private static final int LIST_BORDER_TOP_Y1 = LIST_BORDER_TOP_Y2 - LIST_BORDER_HEIGHT; private static final int LIST_BORDER_BOTTOM_Y1 = LIST_Y_BOTTOM; @@ -64,9 +69,9 @@ final class ErrorDisplayWindow { final Texture buttonTextureHover; final Texture buttonTextureInactive; private final List