generated from MrSphay/codex-agent-repository-kit
Reset intro video playback per page
All checks were successful
Build / build (push) Successful in 14m7s
All checks were successful
Build / build (push) Successful in 14m7s
This commit is contained in:
@@ -21,6 +21,8 @@ public class FirstTimeScreen extends Screen {
|
||||
};
|
||||
|
||||
private final Rect[] cardRects = new Rect[] { Rect.empty(), Rect.empty(), Rect.empty() };
|
||||
private long animationStartedAt;
|
||||
private boolean resetAnimationTimer = true;
|
||||
|
||||
public FirstTimeScreen() {
|
||||
super(Component.literal("Explosion Overhaul Setup"));
|
||||
@@ -50,8 +52,13 @@ public class FirstTimeScreen extends Screen {
|
||||
this.cardRects[1] = new Rect(secondX, firstRowY, cardW, cardH + 34);
|
||||
this.cardRects[2] = new Rect((this.width - cardW) / 2, secondRowY, cardW, cardH + 34);
|
||||
|
||||
long elapsed = this.resetAnimationTimer ? 0L : Math.max(0L, System.currentTimeMillis() - this.animationStartedAt);
|
||||
for (int i = 0; i < CHOICES.length; ++i) {
|
||||
this.drawChoice(graphics, CHOICES[i], this.cardRects[i], this.cardRects[i].contains(mouseX, mouseY));
|
||||
this.drawChoice(graphics, CHOICES[i], this.cardRects[i], this.cardRects[i].contains(mouseX, mouseY), elapsed);
|
||||
}
|
||||
if (this.resetAnimationTimer) {
|
||||
this.animationStartedAt = System.currentTimeMillis();
|
||||
this.resetAnimationTimer = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,17 +84,17 @@ public class FirstTimeScreen extends Screen {
|
||||
this.onClose();
|
||||
}
|
||||
|
||||
private void drawChoice(GuiGraphics graphics, Choice choice, Rect rect, boolean hovered) {
|
||||
private void drawChoice(GuiGraphics graphics, Choice choice, Rect rect, boolean hovered, long elapsedMillis) {
|
||||
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.currentFrame(65L), imageX, imageY, imageW, imageH);
|
||||
this.drawSheetFrame(graphics, choice, choice.currentFrame(elapsedMillis, 65L), imageX, imageY, imageW, imageH);
|
||||
graphics.drawCenteredString(this.font, Component.literal(choice.label), imageX + imageW / 2, imageY + imageH + 16, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
private void drawSheetFrame(GuiGraphics graphics, ResourceLocation texture, int frame, int x, int y, int width, int height) {
|
||||
private void drawSheetFrame(GuiGraphics graphics, Choice choice, 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;
|
||||
@@ -96,7 +103,7 @@ public class FirstTimeScreen extends Screen {
|
||||
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.blit(choice.texture, 0, 0, (float)u, (float)v, FRAME_WIDTH, FRAME_HEIGHT, FRAME_WIDTH * COLUMNS, FRAME_HEIGHT * ROWS);
|
||||
graphics.pose().popPose();
|
||||
}
|
||||
|
||||
@@ -129,9 +136,9 @@ public class FirstTimeScreen extends Screen {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
private int currentFrame(long frameTimeMillis) {
|
||||
private int currentFrame(long elapsedMillis, long frameTimeMillis) {
|
||||
int span = Math.max(1, this.lastFrameExclusive - this.firstFrame);
|
||||
return this.firstFrame + (int)((System.currentTimeMillis() / frameTimeMillis) % span);
|
||||
return this.firstFrame + (int)((elapsedMillis / frameTimeMillis) % span);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user