diff --git a/src/main/java/com/vinlanx/explosionoverhaul/client/FirstTimeScreen.java b/src/main/java/com/vinlanx/explosionoverhaul/client/FirstTimeScreen.java index acc6b1f..fcd1190 100644 --- a/src/main/java/com/vinlanx/explosionoverhaul/client/FirstTimeScreen.java +++ b/src/main/java/com/vinlanx/explosionoverhaul/client/FirstTimeScreen.java @@ -7,17 +7,17 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; public class FirstTimeScreen extends Screen { - private static final int FRAME_WIDTH = 854; - private static final int FRAME_HEIGHT = 480; + private static final int FRAME_WIDTH = 256; + private static final int FRAME_HEIGHT = 144; 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) + new Choice("gui_screen_1.png", 12, "REALISTIC", Config.Client.ParticleRenderMode.REALISTIC), + new Choice("gui_screen_2.png", 28, "VANILLA-LIKE", Config.Client.ParticleRenderMode.VANILA), + new Choice("gui_screen_3.png", 44, "REALISTIC 2", Config.Client.ParticleRenderMode.REALISTIC_2) }; private final Rect[] cardRects = new Rect[] { Rect.empty(), Rect.empty(), Rect.empty() }; @@ -31,18 +31,20 @@ public class FirstTimeScreen extends Screen { graphics.fill(0, 0, this.width, this.height, 0xFF050506); this.drawAmbient(graphics); - int top = Math.max(34, this.height / 6); + int top = Math.max(28, this.height / 9); 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 availableCardH = Math.max(78, (this.height - top - 188) / 2); + int cardW = Math.min(360, Math.max(150, (this.width - 170) / 2)); + cardW = Math.min(cardW, availableCardH * FRAME_WIDTH / FRAME_HEIGHT); 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; + int firstRowY = top + 92; + int secondRowY = firstRowY + cardH + 60; this.cardRects[0] = new Rect(firstX, firstRowY, cardW, cardH + 58); this.cardRects[1] = new Rect(secondX, firstRowY, cardW, cardH + 58); @@ -81,7 +83,7 @@ public class FirstTimeScreen extends Screen { 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); + this.drawSheetFrame(graphics, choice.texture, (this.currentFrame(65L) + choice.frameOffset) % FRAME_COUNT, imageX, imageY, imageW, imageH); graphics.drawCenteredString(this.font, Component.literal(choice.label), imageX + imageW / 2, imageY + imageH + 28, 0xFFFFFFFF); } @@ -98,12 +100,16 @@ public class FirstTimeScreen extends Screen { graphics.pose().popPose(); } + private int currentFrame(long frameTimeMillis) { + return (int)((System.currentTimeMillis() / frameTimeMillis) % FRAME_COUNT); + } + private void drawAmbient(GuiGraphics graphics) { - for (int i = 0; i < 96; ++i) { + for (int i = 0; i < 48; ++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); + graphics.fill(x, y, x + 1, y + 1, color); } } @@ -114,13 +120,13 @@ public class FirstTimeScreen extends Screen { private static final class Choice { private final ResourceLocation texture; - private final int frame; + private final int frameOffset; 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; + private Choice(String fileName, int frameOffset, String label, Config.Client.ParticleRenderMode mode) { + this.texture = ResourceLocation.fromNamespaceAndPath("explosionoverhaul", "intro_gui/preview/" + fileName); + this.frameOffset = frameOffset; this.label = label; this.mode = mode; } diff --git a/src/main/java/com/vinlanx/explosionoverhaul/client/GuideSlidesScreen.java b/src/main/java/com/vinlanx/explosionoverhaul/client/GuideSlidesScreen.java index defeb46..cee5f2f 100644 --- a/src/main/java/com/vinlanx/explosionoverhaul/client/GuideSlidesScreen.java +++ b/src/main/java/com/vinlanx/explosionoverhaul/client/GuideSlidesScreen.java @@ -8,8 +8,8 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.util.FormattedCharSequence; public class GuideSlidesScreen extends Screen { - private static final int FRAME_WIDTH = 854; - private static final int FRAME_HEIGHT = 480; + private static final int FRAME_WIDTH = 256; + private static final int FRAME_HEIGHT = 144; private static final int COLUMNS = 14; private static final int ROWS = 14; private static final int FRAME_COUNT = COLUMNS * ROWS; @@ -17,11 +17,11 @@ public class GuideSlidesScreen extends Screen { private static final int RED = 0xFF561818; private static final int RED_HOVER = 0xFF752020; private static final Slide[] SLIDES = new Slide[] { - new Slide("claster_slide.png", 82, "Cluster TNT - If you place more than two TNT blocks next to each other, the explosion will be much stronger!"), - new Slide("cave_slide.png", 64, "Caves - If an explosion happens on the surface while you're underground, you'll hear a terrifying rumble, and the ground and dripstones will start to crumble!"), - new Slide("glass_slide.png", 56, "Glass Shattering - Explosions create shockwaves! Be careful when working with explosives near settlements."), - new Slide("lamp_slide.png", 74, "Lamp Flickering - If an explosion happens near lamps, the lights will start to flicker."), - new Slide("speed_of_sound_slide.png", 78, "Speed of Sound - Explosions travel at the speed of sound. You can also enable \"Epic Mode\" in the settings!") + new Slide("claster_slide.png", 177, "Cluster TNT - If you place more than two TNT blocks next to each other, the explosion will be much stronger!"), + new Slide("cave_slide.png", 121, "Caves - If an explosion happens on the surface while you're underground, you'll hear a terrifying rumble, and the ground and dripstones will start to crumble!"), + new Slide("glass_slide.png", 98, "Glass Shattering - Explosions create shockwaves! Be careful when working with explosives near settlements."), + new Slide("lamp_slide.png", 154, "Lamp Flickering - If an explosion happens near lamps, the lights will start to flicker."), + new Slide("speed_of_sound_slide.png", 140, "Speed of Sound - Explosions travel at the speed of sound. You can also enable \"Epic Mode\" in the settings!") }; private int slideIndex; @@ -38,27 +38,29 @@ public class GuideSlidesScreen extends Screen { graphics.fill(0, 0, this.width, this.height, 0xFF070708); this.drawAmbient(graphics); - int imageW = Math.min(this.width - 220, 1100); + int imageW = Math.min(this.width - 220, 1080); int imageH = imageW * FRAME_HEIGHT / FRAME_WIDTH; - int maxImageH = Math.max(180, this.height / 3); + int imageY = Math.max(28, this.height / 9); + int maxImageH = Math.max(120, this.height - imageY - 220); if (imageH > maxImageH) { - imageH = maxImageH; + imageH = Math.max(120, maxImageH); imageW = imageH * FRAME_WIDTH / FRAME_HEIGHT; } int imageX = (this.width - imageW) / 2; - int imageY = Math.max(42, this.height / 8); graphics.fill(imageX - 8, imageY - 8, imageX + imageW + 8, imageY + imageH + 8, 0xFF1E1205); graphics.fill(imageX - 4, imageY - 4, imageX + imageW + 4, imageY + imageH + 4, 0xFF3D270E); - this.drawSheetFrame(graphics, SLIDES[this.slideIndex].texture, SLIDES[this.slideIndex].frame, imageX, imageY, imageW, imageH); + Slide slide = SLIDES[this.slideIndex]; + this.drawSheetFrame(graphics, slide.texture, this.currentFrame(slide.frameCount, 55L), imageX, imageY, imageW, imageH); int textWidth = Math.min(this.width - 240, 1040); int textY = imageY + imageH + 44; - this.drawCenteredWrappedText(graphics, SLIDES[this.slideIndex].text, this.width / 2, textY, textWidth, 0xFFFFFFFF); + this.drawCenteredWrappedText(graphics, slide.text, this.width / 2, textY, textWidth, 0xFFFFFFFF); - int arrowY = imageY + imageH / 2 - 46; - this.leftArrow = new Rect(Math.max(16, imageX / 2 - 46), arrowY, 92, 92); - this.rightArrow = new Rect(Math.min(this.width - 108, imageX + imageW + (this.width - imageX - imageW) / 2 - 46), arrowY, 92, 92); + int arrowSize = 74; + int arrowY = imageY + imageH / 2 - arrowSize / 2; + this.leftArrow = new Rect(Math.max(18, imageX / 2 - arrowSize / 2), arrowY, arrowSize, arrowSize); + this.rightArrow = new Rect(Math.min(this.width - arrowSize - 18, imageX + imageW + (this.width - imageX - imageW) / 2 - arrowSize / 2), arrowY, arrowSize, arrowSize); if (this.slideIndex > 0) { this.drawArrow(graphics, this.leftArrow, "<", this.leftArrow.contains(mouseX, mouseY)); } @@ -66,9 +68,9 @@ public class GuideSlidesScreen extends Screen { this.drawArrow(graphics, this.rightArrow, ">", this.rightArrow.contains(mouseX, mouseY)); } - int skipW = 156; - int skipH = 44; - this.skipButton = new Rect((this.width - skipW) / 2, this.height - 84, skipW, skipH); + int skipW = 142; + int skipH = 38; + this.skipButton = new Rect((this.width - skipW) / 2, this.height - 58, skipW, skipH); this.drawFlatButton(graphics, this.skipButton, "Skip Guide", this.skipButton.contains(mouseX, mouseY)); } @@ -110,6 +112,11 @@ public class GuideSlidesScreen extends Screen { graphics.pose().popPose(); } + private int currentFrame(int frameCount, long frameTimeMillis) { + int maxFrame = Math.max(1, Math.min(frameCount, FRAME_COUNT)); + return (int)((System.currentTimeMillis() / frameTimeMillis) % maxFrame); + } + private void drawCenteredWrappedText(GuiGraphics graphics, String text, int centerX, int y, int maxWidth, int color) { List lines = this.font.split(Component.literal(text), maxWidth); int lineY = y; @@ -120,8 +127,8 @@ public class GuideSlidesScreen extends Screen { } private void drawArrow(GuiGraphics graphics, Rect rect, String text, boolean hovered) { - graphics.fill(rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, hovered ? RED_HOVER : RED); - graphics.drawCenteredString(this.font, Component.literal(text), rect.x + rect.w / 2, rect.y + 36, 0xFFFFFFFF); + this.drawDisc(graphics, rect.centerX(), rect.centerY(), rect.w / 2, hovered ? RED_HOVER : RED); + graphics.drawCenteredString(this.font, Component.literal(text), rect.centerX(), rect.centerY() - 4, 0xFFFFFFFF); } private void drawFlatButton(GuiGraphics graphics, Rect rect, String text, boolean hovered) { @@ -130,11 +137,18 @@ public class GuideSlidesScreen extends Screen { } private void drawAmbient(GuiGraphics graphics) { - for (int i = 0; i < 72; ++i) { + for (int i = 0; i < 42; ++i) { int x = Math.floorMod(i * 131 + 17, Math.max(1, this.width)); int y = Math.floorMod(i * 71 + 41, Math.max(1, this.height)); int color = i % 5 == 0 ? ACCENT : 0xFF444444; - graphics.fill(x, y, x + 2, y + 2, color); + graphics.fill(x, y, x + 1, y + 1, color); + } + } + + private void drawDisc(GuiGraphics graphics, int centerX, int centerY, int radius, int color) { + for (int y = -radius; y <= radius; ++y) { + int halfWidth = (int)Math.sqrt(radius * radius - y * y); + graphics.fill(centerX - halfWidth, centerY + y, centerX + halfWidth + 1, centerY + y + 1, color); } } @@ -145,12 +159,12 @@ public class GuideSlidesScreen extends Screen { private static final class Slide { private final ResourceLocation texture; - private final int frame; + private final int frameCount; private final String text; - private Slide(String fileName, int frame, String text) { - this.texture = ResourceLocation.fromNamespaceAndPath("explosionoverhaul", "intro_gui/" + fileName); - this.frame = frame; + private Slide(String fileName, int frameCount, String text) { + this.texture = ResourceLocation.fromNamespaceAndPath("explosionoverhaul", "intro_gui/preview/" + fileName); + this.frameCount = frameCount; this.text = text; } } @@ -175,5 +189,13 @@ public class GuideSlidesScreen extends Screen { private boolean contains(double mouseX, double mouseY) { return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.w && mouseY < this.y + this.h; } + + private int centerX() { + return this.x + this.w / 2; + } + + private int centerY() { + return this.y + this.h / 2; + } } } diff --git a/src/main/resources/assets/explosionoverhaul/intro_gui/preview/cave_slide.png b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/cave_slide.png new file mode 100644 index 0000000..f3af90c Binary files /dev/null and b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/cave_slide.png differ diff --git a/src/main/resources/assets/explosionoverhaul/intro_gui/preview/claster_slide.png b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/claster_slide.png new file mode 100644 index 0000000..2e5f0a3 Binary files /dev/null and b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/claster_slide.png differ diff --git a/src/main/resources/assets/explosionoverhaul/intro_gui/preview/glass_slide.png b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/glass_slide.png new file mode 100644 index 0000000..63bb9aa Binary files /dev/null and b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/glass_slide.png differ diff --git a/src/main/resources/assets/explosionoverhaul/intro_gui/preview/gui_screen_1.png b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/gui_screen_1.png new file mode 100644 index 0000000..87d7e69 Binary files /dev/null and b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/gui_screen_1.png differ diff --git a/src/main/resources/assets/explosionoverhaul/intro_gui/preview/gui_screen_2.png b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/gui_screen_2.png new file mode 100644 index 0000000..5a82383 Binary files /dev/null and b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/gui_screen_2.png differ diff --git a/src/main/resources/assets/explosionoverhaul/intro_gui/preview/gui_screen_3.png b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/gui_screen_3.png new file mode 100644 index 0000000..ddb2446 Binary files /dev/null and b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/gui_screen_3.png differ diff --git a/src/main/resources/assets/explosionoverhaul/intro_gui/preview/lamp_slide.png b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/lamp_slide.png new file mode 100644 index 0000000..3ac769c Binary files /dev/null and b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/lamp_slide.png differ diff --git a/src/main/resources/assets/explosionoverhaul/intro_gui/preview/speed_of_sound_slide.png b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/speed_of_sound_slide.png new file mode 100644 index 0000000..9012390 Binary files /dev/null and b/src/main/resources/assets/explosionoverhaul/intro_gui/preview/speed_of_sound_slide.png differ