Draw star rating stars in the song menu inside each song node.

Star image was taken from XinCrin's "Fantasy's Skin".

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-09-02 23:10:31 -05:00
parent c785a1261c
commit a2eaf35664
3 changed files with 52 additions and 3 deletions

BIN
res/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -292,6 +292,12 @@ public enum GameImage {
MENU_BUTTON_MID ("button-middle", "png", false, false), MENU_BUTTON_MID ("button-middle", "png", false, false),
MENU_BUTTON_LEFT ("button-left", "png", false, false), MENU_BUTTON_LEFT ("button-left", "png", false, false),
MENU_BUTTON_RIGHT ("button-right", "png", false, false), MENU_BUTTON_RIGHT ("button-right", "png", false, false),
STAR ("star", "png", false, false) {
@Override
protected Image process_sub(Image img, int w, int h) {
return img.getScaledCopy((MENU_BUTTON_BG.getImage().getHeight() * 0.16f) / img.getHeight());
}
},
// Music Player Buttons // Music Player Buttons
MUSIC_PLAY ("music-play", "png", false, false), MUSIC_PLAY ("music-play", "png", false, false),

View File

@ -88,7 +88,7 @@ public class BeatmapSetNode {
bg.draw(x, y, bgColor); bg.draw(x, y, bgColor);
float cx = x + (bg.getWidth() * 0.043f); float cx = x + (bg.getWidth() * 0.043f);
float cy = y + (bg.getHeight() * 0.2f) - 3; float cy = y + (bg.getHeight() * 0.18f) - 3;
// draw grade // draw grade
if (grade != Grade.NULL) { if (grade != Grade.NULL) {
@ -103,11 +103,54 @@ public class BeatmapSetNode {
Fonts.loadGlyphs(Fonts.DEFAULT, beatmap.artistUnicode); Fonts.loadGlyphs(Fonts.DEFAULT, beatmap.artistUnicode);
} }
Fonts.MEDIUM.drawString(cx, cy, beatmap.getTitle(), textColor); Fonts.MEDIUM.drawString(cx, cy, beatmap.getTitle(), textColor);
Fonts.DEFAULT.drawString(cx, cy + Fonts.MEDIUM.getLineHeight() - 2, Fonts.DEFAULT.drawString(cx, cy + Fonts.MEDIUM.getLineHeight() - 3,
String.format("%s // %s", beatmap.getArtist(), beatmap.creator), textColor); String.format("%s // %s", beatmap.getArtist(), beatmap.creator), textColor);
if (expanded || beatmapSet.size() == 1) if (expanded || beatmapSet.size() == 1)
Fonts.BOLD.drawString(cx, cy + Fonts.MEDIUM.getLineHeight() + Fonts.DEFAULT.getLineHeight() - 4, Fonts.BOLD.drawString(cx, cy + Fonts.MEDIUM.getLineHeight() + Fonts.DEFAULT.getLineHeight() - 6,
beatmap.version, textColor); beatmap.version, textColor);
// draw stars
// (note: in osu!, stars are also drawn for beatmap sets of size 1)
if (expanded) {
if (beatmap.starRating >= 0) {
Image star = GameImage.STAR.getImage();
float starOffset = star.getWidth() * 1.7f;
float starX = cx + starOffset * 0.04f;
float starY = cy + Fonts.MEDIUM.getLineHeight() + Fonts.DEFAULT.getLineHeight() * 2 - 10f * GameImage.getUIscale();
float starCenterY = starY + star.getHeight() / 2f;
final float baseAlpha = focus ? 1f : 0.8f;
final float smallStarScale = 0.4f;
star.setAlpha(baseAlpha);
int i = 1;
for (; i < beatmap.starRating && i <= 5; i++) {
if (focus)
star.drawFlash(starX + (i - 1) * starOffset, starY, star.getWidth(), star.getHeight(), textColor);
else
star.draw(starX + (i - 1) * starOffset, starY);
}
if (i <= 5) {
float partialStarScale = smallStarScale + (float) (beatmap.starRating - i + 1) * (1f - smallStarScale);
Image partialStar = star.getScaledCopy(partialStarScale);
partialStar.setAlpha(baseAlpha);
float partialStarY = starCenterY - partialStar.getHeight() / 2f;
if (focus)
partialStar.drawFlash(starX + (i - 1) * starOffset, partialStarY, partialStar.getWidth(), partialStar.getHeight(), textColor);
else
partialStar.draw(starX + (i - 1) * starOffset, partialStarY);
}
if (++i <= 5) {
Image smallStar = star.getScaledCopy(smallStarScale);
smallStar.setAlpha(0.5f);
float smallStarY = starCenterY - smallStar.getHeight() / 2f;
for (; i <= 5; i++) {
if (focus)
smallStar.drawFlash(starX + (i - 1) * starOffset, smallStarY, smallStar.getWidth(), smallStar.getHeight(), textColor);
else
smallStar.draw(starX + (i - 1) * starOffset, smallStarY);
}
}
}
}
} }
/** /**