Skip to content

Commit

Permalink
Merge pull request #286 from reco1I/personal-best2
Browse files Browse the repository at this point in the history
Prepend personal best on top in the global leaderboard
  • Loading branch information
Rian8337 authored Sep 22, 2023
2 parents 886d181 + e9ff5bc commit db72b88
Showing 1 changed file with 46 additions and 9 deletions.
55 changes: 46 additions & 9 deletions src/ru/nsu/ccfit/zuev/osu/menu/ScoreBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ public void run() {
if (!isActive())
return;

attachChild(new ScoreItem(avatarExecutor, titleStr, accStr, mark, true, scoreID, avatarURL, playerName));
var sprite = new ScoreItem(avatarExecutor, titleStr, accStr, data[4], true, scoreID, data[7], data[1], isPersonalBest);

if (isPersonalBest)
attachChild(sprite, 0);
else
attachChild(sprite);

ScoreBoardItem item = new ScoreBoardItem();
item.set(beatmapRank, playerName, combo, currentTotalScore, scoreID);
Expand Down Expand Up @@ -309,7 +314,7 @@ public void run() {
if (!isActive())
return;

attachChild(new ScoreItem(avatarExecutor, titleStr, accStr, scoreSet.getString(scoreSet.getColumnIndexOrThrow("mark")), false, scoreID, null, null));
attachChild(new ScoreItem(avatarExecutor, titleStr, accStr, scoreSet.getString(scoreSet.getColumnIndexOrThrow("mark")), false, scoreID, null, null, false));

var item = new ScoreBoardItem();
item.set(i + 1, scoreSet.getString(scoreSet.getColumnIndexOrThrow("playername")), scoreSet.getInt(scoreSet.getColumnIndexOrThrow("combo")), scoreSet.getInt(scoreSet.getColumnIndexOrThrow("score")), scoreID);
Expand Down Expand Up @@ -537,16 +542,47 @@ private class ScoreItem extends Sprite {
private final boolean showOnline;


private ScoreItem(ExecutorService avatarExecutor, String title, String acc, String markStr, boolean showOnline, int scoreID, String avaURL, String username) {
private ScoreItem(
ExecutorService avatarExecutor,
String title,
String acc,
String markStr,
boolean showOnline,
int scoreID,
String avaURL,
String username,
boolean isPersonalBest) {
super(-150, 40, ResourceManager.getInstance().getTexture("menu-button-background").deepCopy());

this.avatarExecutor = avatarExecutor;
this.showOnline = showOnline;
this.username = username;
this.scoreID = scoreID;

setHeight(107);
setScale(0.65f);
var baseY = 0f;
setWidth(724 * 1.1f);

if (isPersonalBest) {

var topText = new Text(
getWidth() / 2f,
0f,
ResourceManager.getInstance().getFont("strokeFont"),
"Personal Best");

attachChild(topText);
baseY = topText.getHeight() + 5;

topText.setScale(0.8f);
topText.setPosition((getWidth() - topText.getWidthScaled()) / 2f, 20f);

setHeight(baseY + 120);

} else {
setHeight(107);
}

setScale(0.65f);
camY = -146;

setColor(0, 0, 0);
Expand All @@ -557,6 +593,7 @@ private ScoreItem(ExecutorService avatarExecutor, String title, String acc, Stri
&& avaURL != null
&& avatarExecutor != null;

float finalBaseY = baseY;
avatarTask = shouldLoadAvatar ? new Runnable() {

@Override
Expand All @@ -574,7 +611,7 @@ public void run() {
onDetached();
return;
}
attachChild(new Sprite(55, 12, 90, 90, texture));
attachChild(new Sprite(55, finalBaseY + 12, 90, 90, texture));

if (currentAvatarTask == this)
currentAvatarTask = null;
Expand All @@ -583,9 +620,9 @@ public void run() {

int pos = shouldLoadAvatar ? 90 : 0;

var text = new Text(pos + 160, 20, ResourceManager.getInstance().getFont("font"), title);
var accText = new Text(670, 12, ResourceManager.getInstance().getFont("smallFont"), acc);
var mark = new Sprite(pos + 80, 35, ResourceManager.getInstance().getTexture("ranking-" + markStr + "-small"));
var text = new Text(pos + 160, baseY + 20, ResourceManager.getInstance().getFont("font"), title);
var accText = new Text(670, baseY + 12, ResourceManager.getInstance().getFont("smallFont"), acc);
var mark = new Sprite(pos + 80, baseY + 35, ResourceManager.getInstance().getTexture("ranking-" + markStr + "-small"));

text.setScale(1.2f);
mark.setScale(1.5f);
Expand Down

0 comments on commit db72b88

Please sign in to comment.