color players grey and stop updating when they miss

This commit is contained in:
yugecin 2017-12-22 00:47:38 +01:00
parent 92dc59f7b6
commit eaa46bddd9

View File

@ -52,6 +52,9 @@ public class ReplayPlayback {
private Image hitImage; private Image hitImage;
private int hitImageTimer = 0; private int hitImageTimer = 0;
public GData gdata = new GData(); public GData gdata = new GData();
private boolean missed;
private static final Color missedColor = new Color(0.4f, 0.4f, 0.4f, 1f);
public ReplayPlayback(DisplayContainer container, Replay replay, Color color) { public ReplayPlayback(DisplayContainer container, Replay replay, Color color) {
this.container = container; this.container = container;
@ -149,14 +152,14 @@ public class ReplayPlayback {
} }
hitImageTimer += renderdelta; hitImageTimer += renderdelta;
if (hitImageTimer > HITIMAGETIMERFADEEND) { if (!missed && hitImageTimer > HITIMAGETIMERFADEEND) {
hitImage = null; hitImage = null;
return; return;
} }
int namewidth = Fonts.SMALLBOLD.getWidth(this.player); int namewidth = Fonts.SMALLBOLD.getWidth(this.player);
Color color = new Color(1f, 1f, 1f, 1f); Color color = new Color(1f, 1f, 1f, 1f);
if (hitImageTimer > HITIMAGETIMERFADESTART) { if (!missed && hitImageTimer > HITIMAGETIMERFADESTART) {
color.a = (HITIMAGETIMERFADEEND - hitImageTimer) / HITIMAGETIMERFADEDELTA; color.a = (HITIMAGETIMERFADEEND - hitImageTimer) / HITIMAGETIMERFADEDELTA;
} }
float scale = 1f; float scale = 1f;
@ -193,16 +196,21 @@ public class ReplayPlayback {
} }
nextFrame = replay.frames[frameIndex]; nextFrame = replay.frames[frameIndex];
} }
g.setColor(color);
ypos *= (SQSIZE + 5); ypos *= (SQSIZE + 5);
for (int i = 0; i < 4; i++) { g.setColor(color);
if (keydelay[i] > 0) { if (!missed) {
g.fillRect(SQSIZE * i, ypos + 5, SQSIZE, SQSIZE); for (int i = 0; i < 4; i++) {
if (keydelay[i] > 0) {
g.fillRect(SQSIZE * i, ypos + 5, SQSIZE, SQSIZE);
}
keydelay[i] -= renderdelta;
} }
keydelay[i] -= renderdelta;
} }
Fonts.SMALLBOLD.drawString(SQSIZE * 5, ypos, this.player, color); Fonts.SMALLBOLD.drawString(SQSIZE * 5, ypos, this.player, color);
showHitImage(renderdelta, ypos); showHitImage(renderdelta, ypos);
if (missed) {
return;
}
int y = currentFrame.getScaledY(); int y = currentFrame.getScaledY();
if (hr) { if (hr) {
y = container.height - y; y = container.height - y;
@ -259,10 +267,15 @@ public class ReplayPlayback {
@Override @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) { 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)) { if (missed || result == HIT_300) {
return; return;
} }
if (result == HIT_MISS) {
missed = true;
ReplayPlayback.this.color = missedColor;
}
if (result < hitResults.length) { if (result < hitResults.length) {
hitImageTimer = 0; hitImageTimer = 0;
hitImage = hitResults[result].getScaledCopy(SQSIZE + 5, SQSIZE + 5); hitImage = hitResults[result].getScaledCopy(SQSIZE + 5, SQSIZE + 5);