Restore intro guide flow
All checks were successful
Build / build (push) Successful in 10m5s

This commit is contained in:
MrSphay
2026-05-08 00:33:17 +02:00
parent 062d69fcd5
commit 5bcf77137b
3 changed files with 280 additions and 70 deletions

View File

@@ -2,101 +2,149 @@ package com.vinlanx.explosionoverhaul.client;
import com.vinlanx.explosionoverhaul.Config;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
public class FirstTimeScreen extends Screen {
private static final ResourceLocation REALISTIC = ResourceLocation.fromNamespaceAndPath("explosionoverhaul", "intro_gui/gui_screen_1.png");
private static final ResourceLocation VANILLA = ResourceLocation.fromNamespaceAndPath("explosionoverhaul", "intro_gui/gui_screen_2.png");
private static final ResourceLocation REALISTIC_2 = ResourceLocation.fromNamespaceAndPath("explosionoverhaul", "intro_gui/gui_screen_3.png");
private static final ResourceLocation QUALITY_64 = ResourceLocation.fromNamespaceAndPath("explosionoverhaul", "intro_gui/gui_screen_4.png");
private static final int FRAME_WIDTH = 854;
private static final int FRAME_HEIGHT = 480;
private static final int COLUMNS = 10;
private static final int ROWS = 10;
private static final int FRAME_COUNT = COLUMNS * ROWS;
private static final int BORDER = 0xFFFF7A70;
private static final int BORDER_HOVER = 0xFFFF9B91;
private static final Choice[] CHOICES = new Choice[] {
new Choice("gui_screen_1.png", 42, "REALISTIC", Config.Client.ParticleRenderMode.REALISTIC),
new Choice("gui_screen_2.png", 42, "VANILLA-LIKE", Config.Client.ParticleRenderMode.VANILA),
new Choice("gui_screen_3.png", 42, "REALISTIC 2", Config.Client.ParticleRenderMode.REALISTIC_2)
};
private Config.Client.ParticleRenderMode selectedMode = Config.Client.ParticleRenderMode.REALISTIC;
private Config.Client.GlowTextureQuality selectedQuality = Config.Client.GlowTextureQuality.QUALITY_256;
private boolean choosingQuality;
private final Rect[] cardRects = new Rect[] { Rect.empty(), Rect.empty(), Rect.empty() };
public FirstTimeScreen() {
super(Component.literal("Explosion Overhaul Setup"));
}
@Override
protected void init() {
this.rebuildButtons();
}
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
graphics.fill(0, 0, this.width, this.height, 0xFF050506);
this.drawAmbient(graphics);
private void rebuildButtons() {
this.clearWidgets();
int cardW = Math.max(160, this.width / 5);
int cardH = 28;
int y = this.height - 86;
if (!this.choosingQuality) {
int gap = 12;
int startX = (this.width - cardW * 3 - gap * 2) / 2;
this.addRenderableWidget(Button.builder(Component.literal("Realistic"), button -> {
this.selectedMode = Config.Client.ParticleRenderMode.REALISTIC;
this.choosingQuality = true;
this.rebuildButtons();
}).bounds(startX, y, cardW, cardH).build());
this.addRenderableWidget(Button.builder(Component.literal("Vanilla Performance"), button -> {
this.selectedMode = Config.Client.ParticleRenderMode.VANILA;
this.choosingQuality = true;
this.rebuildButtons();
}).bounds(startX + cardW + gap, y, cardW, cardH).build());
this.addRenderableWidget(Button.builder(Component.literal("Realistic 2"), button -> {
this.selectedMode = Config.Client.ParticleRenderMode.REALISTIC_2;
this.choosingQuality = true;
this.rebuildButtons();
}).bounds(startX + (cardW + gap) * 2, y, cardW, cardH).build());
} else {
int gap = 16;
int startX = (this.width - cardW * 2 - gap) / 2;
this.addRenderableWidget(Button.builder(Component.literal("256p Quality"), button -> this.finish(Config.Client.GlowTextureQuality.QUALITY_256)).bounds(startX, y, cardW, cardH).build());
this.addRenderableWidget(Button.builder(Component.literal("64p Performance"), button -> this.finish(Config.Client.GlowTextureQuality.QUALITY_64)).bounds(startX + cardW + gap, y, cardW, cardH).build());
this.addRenderableWidget(Button.builder(Component.literal("Back"), button -> {
this.choosingQuality = false;
this.rebuildButtons();
}).bounds(16, this.height - 40, 80, 24).build());
int top = Math.max(34, this.height / 6);
graphics.drawCenteredString(this.font, Component.literal("Choose Your Explosion Style."), this.width / 2, top, 0xFFFF9900);
graphics.drawCenteredString(this.font, Component.literal("You can change this anytime in the config"), this.width / 2, top + 25, 0xFFE5E5E5);
graphics.drawCenteredString(this.font, Component.literal("The game may differ from the animations because compression has altered them."), this.width / 2, top + 48, 0xFF9C9C9C);
int cardW = Math.min(420, Math.max(220, (this.width - 170) / 2));
int cardH = cardW * FRAME_HEIGHT / FRAME_WIDTH;
int gap = Math.max(34, this.width / 28);
int firstX = this.width / 2 - cardW - gap / 2;
int secondX = this.width / 2 + gap / 2;
int firstRowY = top + 88;
int secondRowY = firstRowY + cardH + 84;
this.cardRects[0] = new Rect(firstX, firstRowY, cardW, cardH + 58);
this.cardRects[1] = new Rect(secondX, firstRowY, cardW, cardH + 58);
this.cardRects[2] = new Rect((this.width - cardW) / 2, secondRowY, cardW, cardH + 58);
for (int i = 0; i < CHOICES.length; ++i) {
this.drawChoice(graphics, CHOICES[i], this.cardRects[i], this.cardRects[i].contains(mouseX, mouseY));
}
}
private void finish(Config.Client.GlowTextureQuality quality) {
this.selectedQuality = quality;
Config.CLIENT.particleRenderMode.set(this.selectedMode);
Config.CLIENT.glowTextureQuality.set(this.selectedQuality);
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (button == 0) {
for (int i = 0; i < this.cardRects.length; ++i) {
if (this.cardRects[i].contains(mouseX, mouseY)) {
this.finish(CHOICES[i]);
return true;
}
}
}
return super.mouseClicked(mouseX, mouseY, button);
}
private void finish(Choice choice) {
Config.CLIENT.particleRenderMode.set(choice.mode);
Config.CLIENT.glowTextureQuality.set(Config.Client.GlowTextureQuality.QUALITY_256);
Config.CLIENT.firstLaunchComplete.set(true);
Config.CLIENT.introSetupComplete.set(true);
Config.CLIENT_SPEC.save();
this.onClose();
}
@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
this.renderBackground(graphics, mouseX, mouseY, partialTick);
graphics.fill(0, 0, this.width, this.height, 0xE0101117);
graphics.drawCenteredString(this.font, Component.literal("Explosion Overhaul"), this.width / 2, 28, 0xFFFFFF);
graphics.drawCenteredString(this.font, this.choosingQuality ? Component.literal("Choose texture quality") : Component.literal("Choose explosion render mode"), this.width / 2, 48, 0xFFB35C);
if (this.choosingQuality) {
this.drawPreview(graphics, REALISTIC, this.width / 2 - 270, 82, 250, 141, "256p Quality");
this.drawPreview(graphics, QUALITY_64, this.width / 2 + 20, 82, 250, 141, "64p Performance");
} else {
this.drawPreview(graphics, REALISTIC, this.width / 2 - 390, 82, 240, 135, "Realistic");
this.drawPreview(graphics, VANILLA, this.width / 2 - 120, 82, 240, 135, "Vanilla Performance");
this.drawPreview(graphics, REALISTIC_2, this.width / 2 + 150, 82, 240, 135, "Realistic 2");
}
super.render(graphics, mouseX, mouseY, partialTick);
private void drawChoice(GuiGraphics graphics, Choice choice, Rect rect, boolean hovered) {
int imageX = rect.x;
int imageY = rect.y;
int imageW = rect.w;
int imageH = rect.w * FRAME_HEIGHT / FRAME_WIDTH;
graphics.fill(imageX - 6, imageY - 6, imageX + imageW + 6, imageY + imageH + 6, hovered ? BORDER_HOVER : BORDER);
this.drawSheetFrame(graphics, choice.texture, choice.frame, imageX, imageY, imageW, imageH);
graphics.drawCenteredString(this.font, Component.literal(choice.label), imageX + imageW / 2, imageY + imageH + 28, 0xFFFFFFFF);
}
private void drawPreview(GuiGraphics graphics, ResourceLocation texture, int x, int y, int w, int h, String label) {
graphics.fill(x - 2, y - 2, x + w + 2, y + h + 20, 0xAA000000);
graphics.blit(texture, x, y, 0.0f, 0.0f, w, h, 854, 480);
graphics.drawCenteredString(this.font, Component.literal(label), x + w / 2, y + h + 7, 0xFFFFFF);
private void drawSheetFrame(GuiGraphics graphics, ResourceLocation texture, int frame, int x, int y, int width, int height) {
int clamped = Math.max(0, Math.min(frame, FRAME_COUNT - 1));
int u = clamped % COLUMNS * FRAME_WIDTH;
int v = clamped / COLUMNS * FRAME_HEIGHT;
float scaleX = (float)width / (float)FRAME_WIDTH;
float scaleY = (float)height / (float)FRAME_HEIGHT;
graphics.pose().pushPose();
graphics.pose().translate(x, y, 0.0F);
graphics.pose().scale(scaleX, scaleY, 1.0F);
graphics.blit(texture, 0, 0, (float)u, (float)v, FRAME_WIDTH, FRAME_HEIGHT, FRAME_WIDTH * COLUMNS, FRAME_HEIGHT * ROWS);
graphics.pose().popPose();
}
private void drawAmbient(GuiGraphics graphics) {
for (int i = 0; i < 96; ++i) {
int x = Math.floorMod(i * 173 + 19, Math.max(1, this.width));
int y = Math.floorMod(i * 97 + 53, Math.max(1, this.height));
int color = i % 7 == 0 ? 0xFFFFB347 : 0xFF414141;
graphics.fill(x, y, x + 2, y + 2, color);
}
}
@Override
public boolean shouldCloseOnEsc() {
return false;
}
private static final class Choice {
private final ResourceLocation texture;
private final int frame;
private final String label;
private final Config.Client.ParticleRenderMode mode;
private Choice(String fileName, int frame, String label, Config.Client.ParticleRenderMode mode) {
this.texture = ResourceLocation.fromNamespaceAndPath("explosionoverhaul", "intro_gui/" + fileName);
this.frame = frame;
this.label = label;
this.mode = mode;
}
}
private static final class Rect {
private final int x;
private final int y;
private final int w;
private final int h;
private Rect(int x, int y, int w, int h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
private static Rect empty() {
return new Rect(0, 0, 0, 0);
}
private boolean contains(double mouseX, double mouseY) {
return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.w && mouseY < this.y + this.h;
}
}
}