center names and shrink when a name is fully faded out

This commit is contained in:
yugecin 2017-12-22 22:22:16 +01:00
parent b4498333df
commit 8471c43ed5
2 changed files with 27 additions and 8 deletions

View File

@ -720,13 +720,21 @@ public class Game extends ComplexOpsuState {
UI.draw(g);
int i = 0;
//g.setColor(new Color(0.2f, 0.2f, 0.2f));
//g.fillRect(0, 0, ReplayPlayback.SQSIZE * 2, displayContainer.height);
//g.setColor(Color.black);
//g.fillRect(ReplayPlayback.SQSIZE * 2, 0, ReplayPlayback.SQSIZE * 2, displayContainer.height);
float totalHeight = 0f;
for (ReplayPlayback replayPlayback : replays) {
replayPlayback.render(beatmap, hitResultOffset, displayContainer.renderDelta, g, i++, trackPosition);
totalHeight += replayPlayback.getHeight();
}
float ypos = (displayContainer.height - totalHeight) / 2 - ReplayPlayback.UNITHEIGHT;
for (ReplayPlayback replayPlayback : replays) {
float h = replayPlayback.getHeight();
ypos += h;
//if (h > 0f) {
replayPlayback.render(beatmap, hitResultOffset, displayContainer.renderDelta, g, ypos, trackPosition);
//}
}
super.render(g);

View File

@ -43,6 +43,7 @@ public class ReplayPlayback {
public Cursor cursor;
private int keydelay[];
public static final int SQSIZE = 15;
public static final int UNITHEIGHT = SQSIZE + 5;
private boolean hr;
private String player;
private String mods;
@ -152,8 +153,9 @@ public class ReplayPlayback {
private int HITIMAGETIMERFADESTART = 500;
private int HITIMAGETIMERFADEEND = 700;
private float HITIMAGETIMERFADEDELTA = HITIMAGETIMERFADEEND - HITIMAGETIMERFADESTART;
private int HITIMAGEDEADFADE = 15000;
private void showHitImage(int renderdelta, int ypos) {
private int HITIMAGEDEADFADE = 10000;
private float SHRINKTIME = 500f;
private void showHitImage(int renderdelta, float ypos) {
if (hitImage == null) {
return;
}
@ -172,19 +174,29 @@ public class ReplayPlayback {
if (hitImageTimer > HITIMAGEDEADFADE) {
this.color.a = color.a = 0f;
} else {
this.color.a = color.a = 1f - (float) hitImageTimer / HITIMAGEDEADFADE;
this.color.a = color.a = 1f - AnimationEquation.IN_CIRC.calc((float) hitImageTimer / HITIMAGEDEADFADE);
}
}
float scale = 1f;
float offset = 0f;
if (hitImageTimer < HITIMAGETIMEREXPAND) {
scale = AnimationEquation.OUT_EXPO.calc((float) hitImageTimer / HITIMAGETIMEREXPAND);
offset = (SQSIZE + 5f) / 2f * (1f - scale);
offset = UNITHEIGHT / 2f * (1f - scale);
}
hitImage.draw(SQSIZE * 5 + textwidth + SQSIZE + offset, ypos + offset, scale, color);
}
public void render(Beatmap beatmap, int[] hitResultOffset, int renderdelta, Graphics g, int ypos, int time) {
public float getHeight() {
if (hitImageTimer < HITIMAGEDEADFADE) {
return UNITHEIGHT;
}
if (hitImageTimer >= HITIMAGEDEADFADE + SHRINKTIME) {
return 0f;
}
return UNITHEIGHT * (1f - AnimationEquation.OUT_QUART.calc((hitImageTimer - HITIMAGEDEADFADE) / SHRINKTIME));
}
public void render(Beatmap beatmap, int[] hitResultOffset, int renderdelta, Graphics g, float ypos, int time) {
if (objectIndex >= gameObjects.length) {
return;
}
@ -210,7 +222,6 @@ public class ReplayPlayback {
nextFrame = replay.frames[frameIndex];
}
processKeys();
ypos *= (SQSIZE + 5);
g.setColor(color);
if (!missed) {
for (int i = 0; i < 4; i++) {