From 92dc59f7b6d9a8f2de9a38edd8754e3ab086ea6c Mon Sep 17 00:00:00 2001 From: yugecin Date: Fri, 22 Dec 2017 00:10:15 +0100 Subject: [PATCH] show non-300 hit results next to player's name with small animations --- src/yugecin/opsudance/ReplayPlayback.java | 41 +++++++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/yugecin/opsudance/ReplayPlayback.java b/src/yugecin/opsudance/ReplayPlayback.java index d1c7cc12..40e7069d 100644 --- a/src/yugecin/opsudance/ReplayPlayback.java +++ b/src/yugecin/opsudance/ReplayPlayback.java @@ -26,6 +26,7 @@ import itdelatrisu.opsu.replay.Replay; import itdelatrisu.opsu.replay.ReplayFrame; import itdelatrisu.opsu.ui.Cursor; import itdelatrisu.opsu.ui.Fonts; +import itdelatrisu.opsu.ui.animations.AnimationEquation; import org.newdawn.slick.Color; import org.newdawn.slick.Graphics; import org.newdawn.slick.Image; @@ -138,6 +139,35 @@ public class ReplayPlayback { } } + private int HITIMAGETIMEREXPAND = 200; + private int HITIMAGETIMERFADESTART = 500; + private int HITIMAGETIMERFADEEND = 700; + private float HITIMAGETIMERFADEDELTA = HITIMAGETIMERFADEEND - HITIMAGETIMERFADESTART; + private void showHitImage(int renderdelta, int ypos) { + if (hitImage == null) { + return; + } + + hitImageTimer += renderdelta; + if (hitImageTimer > HITIMAGETIMERFADEEND) { + hitImage = null; + return; + } + + int namewidth = Fonts.SMALLBOLD.getWidth(this.player); + Color color = new Color(1f, 1f, 1f, 1f); + if (hitImageTimer > HITIMAGETIMERFADESTART) { + color.a = (HITIMAGETIMERFADEEND - hitImageTimer) / HITIMAGETIMERFADEDELTA; + } + float scale = 1f; + float offset = 0f; + if (hitImageTimer < HITIMAGETIMEREXPAND) { + scale = AnimationEquation.OUT_EXPO.calc((float) hitImageTimer / HITIMAGETIMEREXPAND); + offset = (SQSIZE + 5f) / 2f * (1f - scale); + } + hitImage.draw(SQSIZE * 5 + namewidth + SQSIZE + offset, ypos + offset, scale, color); + } + public void render(Beatmap beatmap, int[] hitResultOffset, int renderdelta, Graphics g, int ypos, int time) { if (objectIndex >= gameObjects.length) { return; @@ -171,11 +201,8 @@ public class ReplayPlayback { } keydelay[i] -= renderdelta; } - Fonts.SMALLBOLD.drawString(SQSIZE * 5, ypos, this.player + " " + this.objectIndex, color); - int namewidth = Fonts.SMALLBOLD.getWidth(this.player); - if (hitImage != null) { - hitImage.draw(SQSIZE * 5 + namewidth + SQSIZE * 2, ypos); - } + Fonts.SMALLBOLD.drawString(SQSIZE * 5, ypos, this.player, color); + showHitImage(renderdelta, ypos); int y = currentFrame.getScaledY(); if (hr) { y = container.height - y; @@ -233,12 +260,12 @@ public class ReplayPlayback { @Override public void sendHitResult(int time, int result, float x, float y, Color color, boolean end, HitObject hitObject, HitObjectType hitResultType, boolean expand, int repeat, Curve curve, boolean sliderHeldToEnd, boolean handleResult) { if ((result == HIT_300)) { - //return; + return; } if (result < hitResults.length) { hitImageTimer = 0; - hitImage = hitResults[result].getScaledCopy(SQSIZE, SQSIZE); + hitImage = hitResults[result].getScaledCopy(SQSIZE + 5, SQSIZE + 5); } }