Scoreboard improvements

This commit is contained in:
MatteoS 2015-11-30 16:19:25 +01:00
parent 6f685cf5c7
commit 4b76d2c3cf
2 changed files with 34 additions and 13 deletions

View File

@ -30,6 +30,7 @@ import java.sql.SQLException;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
@ -343,7 +344,8 @@ public class ScoreData implements Comparable<ScoreData> {
int rectHeight = data.getScoreSymbolImage('0').getHeight(); int rectHeight = data.getScoreSymbolImage('0').getHeight();
int vertDistance = rectHeight + 10; int vertDistance = rectHeight + 10;
int yPos = (int)(vPos + position * vertDistance - rectHeight/2); int yPos = (int)(vPos + position * vertDistance - rectHeight/2);
String scoreString = String.format("%d (%dx)", score, combo); String scoreString = String.format(Locale.US, "%,d", score);
String comboString = String.format("%dx", combo);
String rankString = String.format("%d", rank); String rankString = String.format("%d", rank);
int rectWidth = (int) (170 * GameImage.getUIscale()); int rectWidth = (int) (170 * GameImage.getUIscale());
@ -352,13 +354,14 @@ public class ScoreData implements Comparable<ScoreData> {
g.setColor(rectColor); g.setColor(rectColor);
g.fillRect(0, yPos, rectWidth, rectHeight); g.fillRect(0, yPos, rectWidth, rectHeight);
data.drawSymbolString(rankString, rectWidth, yPos, 1.0f, 0.5f*alpha, true); data.drawSymbolString(rankString, rectWidth, yPos, 1.0f, 0.25f*alpha, true);
if (playerName != null) { if (playerName != null) {
Colors.WHITE_ALPHA.a = 0.5f * alpha; Colors.WHITE_ALPHA.a = 0.5f * alpha;
Fonts.MEDIUM.drawString(0, yPos, playerName, Colors.WHITE_ALPHA); Fonts.MEDIUM.drawString(0, yPos, playerName, Colors.WHITE_ALPHA);
} }
Colors.WHITE_ALPHA.a = alpha; Colors.WHITE_ALPHA.a = alpha;
Fonts.MEDIUMBOLD.drawString(0, yPos + rectHeight - Fonts.MEDIUM.getLineHeight(), scoreString, Colors.WHITE_ALPHA); Fonts.MEDIUMBOLD.drawString(0, yPos + rectHeight - Fonts.MEDIUMBOLD.getLineHeight(), scoreString, Colors.WHITE_ALPHA);
Fonts.MEDIUMBOLD.drawString(rectWidth - Fonts.MEDIUMBOLD.getWidth(comboString), yPos + rectHeight - Fonts.MEDIUMBOLD.getLineHeight(), comboString, Colors.WHITE_ALPHA);
} }

View File

@ -274,6 +274,9 @@ public class Game extends BasicGameState {
/** Is the scoreboard visible? */ /** Is the scoreboard visible? */
private boolean scoreboardVisible; private boolean scoreboardVisible;
/** The current aplha of the scoreboard. */
private float currentScoreboardAlpha;
/** Music position bar background colors. */ /** Music position bar background colors. */
private static final Color private static final Color
MUSICBAR_NORMAL = new Color(12, 9, 10, 0.25f), MUSICBAR_NORMAL = new Color(12, 9, 10, 0.25f),
@ -582,7 +585,7 @@ public class Game extends BasicGameState {
drawHitObjects(g, trackPosition); drawHitObjects(g, trackPosition);
} }
if (previousScores != null && trackPosition >= firstObjectTime && !GameMod.RELAX.isActive() && !GameMod.AUTOPILOT.isActive() && scoreboardVisible) { if (previousScores != null && trackPosition >= firstObjectTime && !GameMod.RELAX.isActive() && !GameMod.AUTOPILOT.isActive()) {
ScoreData currentScore = data.getScoreData(beatmap); ScoreData currentScore = data.getScoreData(beatmap);
while (currentRank > 0 && previousScores[currentRank-1].score < currentScore.score) { while (currentRank > 0 && previousScores[currentRank-1].score < currentScore.score) {
currentRank--; currentRank--;
@ -590,7 +593,6 @@ public class Game extends BasicGameState {
} }
float animation = AnimationEquation.IN_OUT_QUAD.calc(Utils.clamp((trackPosition - lastRankUpdateTime) / SCOREBOARD_ANIMATION_TIME, 0f, 1f)); float animation = AnimationEquation.IN_OUT_QUAD.calc(Utils.clamp((trackPosition - lastRankUpdateTime) / SCOREBOARD_ANIMATION_TIME, 0f, 1f));
float fadeIn = Utils.clamp((trackPosition - firstObjectTime) / SCOREBOARD_FADE_IN_TIME, 0f, 1f);
int scoreboardPosition = 2 * container.getHeight() / 3; int scoreboardPosition = 2 * container.getHeight() / 3;
if (currentRank < 4) { if (currentRank < 4) {
@ -598,18 +600,18 @@ public class Game extends BasicGameState {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
int ii = i + (i>=currentRank ? 1 : 0); int ii = i + (i>=currentRank ? 1 : 0);
if (i < previousScores.length) if (i < previousScores.length)
previousScores[i].drawSmall(g, scoreboardPosition, ii + 1, ii + (i==currentRank ? animation-3f : -2f), data, fadeIn, false); previousScores[i].drawSmall(g, scoreboardPosition, ii + 1, ii + (i==currentRank ? animation-3f : -2f), data, currentScoreboardAlpha, false);
} }
currentScore.drawSmall(g, scoreboardPosition, currentRank + 1, currentRank - 1f - animation, data, fadeIn, true); currentScore.drawSmall(g, scoreboardPosition, currentRank + 1, currentRank - 1f - animation, data, currentScoreboardAlpha, true);
} else { } else {
//draw the top 2 and next 2 ranks //draw the top 2 and next 2 ranks
previousScores[0].drawSmall(g, scoreboardPosition, 1, -2f, data, fadeIn, false); previousScores[0].drawSmall(g, scoreboardPosition, 1, -2f, data, currentScoreboardAlpha, false);
previousScores[1].drawSmall(g, scoreboardPosition, 2, -1f, data, fadeIn, false); previousScores[1].drawSmall(g, scoreboardPosition, 2, -1f, data, currentScoreboardAlpha, false);
previousScores[currentRank-2].drawSmall(g, scoreboardPosition, currentRank - 1, animation - 1f, data, fadeIn*animation, false); previousScores[currentRank-2].drawSmall(g, scoreboardPosition, currentRank - 1, animation - 1f, data, currentScoreboardAlpha*animation, false);
previousScores[currentRank-1].drawSmall(g, scoreboardPosition, currentRank, animation, data, fadeIn, false); previousScores[currentRank-1].drawSmall(g, scoreboardPosition, currentRank, animation, data, currentScoreboardAlpha, false);
currentScore.drawSmall(g, scoreboardPosition, currentRank + 1, 2f, data, fadeIn, true); currentScore.drawSmall(g, scoreboardPosition, currentRank + 1, 2f, data, currentScoreboardAlpha, true);
if (animation < 1.0f && currentRank < previousScores.length) { if (animation < 1.0f && currentRank < previousScores.length) {
previousScores[currentRank].drawSmall(g, scoreboardPosition, currentRank + 2, 1f + 5 * animation, data, fadeIn*(1f - animation), false); previousScores[currentRank].drawSmall(g, scoreboardPosition, currentRank + 2, 1f + 5 * animation, data, currentScoreboardAlpha*(1f - animation), false);
} }
} }
} }
@ -668,6 +670,21 @@ public class Game extends BasicGameState {
if (isReplay || GameMod.AUTO.isActive()) if (isReplay || GameMod.AUTO.isActive())
playbackSpeed.getButton().hoverUpdate(delta, mouseX, mouseY); playbackSpeed.getButton().hoverUpdate(delta, mouseX, mouseY);
int trackPosition = MusicController.getPosition(); int trackPosition = MusicController.getPosition();
int firstObjectTime = beatmap.objects[0].getTime();
if (previousScores != null && trackPosition > firstObjectTime) {
// show scoreboard when in break
if (scoreboardVisible || breakTime > 0) {
currentScoreboardAlpha += 1f/SCOREBOARD_FADE_IN_TIME * delta;
if (currentScoreboardAlpha > 1f)
currentScoreboardAlpha = 1f;
} else {
currentScoreboardAlpha -= 1f/SCOREBOARD_FADE_IN_TIME * delta;
if (currentScoreboardAlpha < 0f)
currentScoreboardAlpha = 0f;
}
}
// returning from pause screen: must click previous mouse position // returning from pause screen: must click previous mouse position
if (pauseTime > -1) { if (pauseTime > -1) {
@ -1198,6 +1215,7 @@ public class Game extends BasicGameState {
if (previousScores != null) if (previousScores != null)
currentRank = previousScores.length; currentRank = previousScores.length;
scoreboardVisible = true; scoreboardVisible = true;
currentScoreboardAlpha = 0f;
// free all previously cached hitobject to framebuffer mappings if some still exist // free all previously cached hitobject to framebuffer mappings if some still exist
FrameBufferCache.getInstance().freeMap(); FrameBufferCache.getInstance().freeMap();