Glyph loading fixes and improvements (for Unicode fonts).
- Glyphs are now loaded for specific fonts as needed, not for all of them at once. This reduces lag and saves memory. - Fixed glyphs not being loaded in the downloads menu. - Moved Utils.loadGlyphs() calls directly above text drawing code (easier to maintain, and fixes a bug with text flickering once). Also removed MusicController methods 'getTrackName()' and 'getArtistName()' (not needed). Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -276,11 +276,10 @@ public class MainMenu extends BasicGameState {
|
||||
if (MusicController.isTrackLoading())
|
||||
g.drawString("Track loading...", marginX, marginY + lineHeight);
|
||||
else if (MusicController.trackExists()) {
|
||||
if (Options.useUnicodeMetadata()) // load glyphs
|
||||
Utils.loadGlyphs(Utils.FONT_MEDIUM, osu.titleUnicode, osu.artistUnicode);
|
||||
g.drawString((MusicController.isPlaying()) ? "Now Playing:" : "Paused:", marginX, marginY + lineHeight);
|
||||
g.drawString(String.format("%s: %s",
|
||||
MusicController.getArtistName(),
|
||||
MusicController.getTrackName()),
|
||||
marginX + 25, marginY + (lineHeight * 2));
|
||||
g.drawString(String.format("%s: %s", osu.getArtist(), osu.getTitle()), marginX + 25, marginY + (lineHeight * 2));
|
||||
}
|
||||
long time = System.currentTimeMillis() - osuStartTime;
|
||||
g.drawString(String.format("opsu! has been running for %d minutes, %d seconds.",
|
||||
|
||||
@@ -311,9 +311,6 @@ public class SongMenu extends BasicGameState {
|
||||
ScoreData[] scores = getScoreDataForNode(node, false);
|
||||
node.draw(buttonX - offset, buttonY + (i*buttonOffset) + DIVIDER_LINE_WIDTH / 2,
|
||||
(scores == null) ? Grade.NULL : scores[0].getGrade(), (node == focusNode));
|
||||
|
||||
// load glyphs
|
||||
Utils.loadGlyphs(node.osuFiles.get(0));
|
||||
}
|
||||
g.clearClip();
|
||||
|
||||
@@ -329,6 +326,7 @@ public class SongMenu extends BasicGameState {
|
||||
|
||||
// header
|
||||
if (focusNode != null) {
|
||||
// music/loader icon
|
||||
float marginX = width * 0.005f, marginY = height * 0.005f;
|
||||
Image musicNote = GameImage.MENU_MUSICNOTE.getImage();
|
||||
if (MusicController.isTrackLoading())
|
||||
@@ -337,8 +335,14 @@ public class SongMenu extends BasicGameState {
|
||||
musicNote.draw(marginX, marginY);
|
||||
int iconWidth = musicNote.getWidth();
|
||||
|
||||
if (songInfo == null)
|
||||
// song info text
|
||||
if (songInfo == null) {
|
||||
songInfo = focusNode.getInfo();
|
||||
if (Options.useUnicodeMetadata()) { // load glyphs
|
||||
OsuFile osu = focusNode.osuFiles.get(0);
|
||||
Utils.loadGlyphs(Utils.FONT_LARGE, osu.titleUnicode, osu.artistUnicode);
|
||||
}
|
||||
}
|
||||
marginX += 5;
|
||||
float headerTextY = marginY;
|
||||
Utils.FONT_LARGE.drawString(marginX + iconWidth * 1.05f, headerTextY, songInfo[0], Color.white);
|
||||
@@ -1183,7 +1187,6 @@ public class SongMenu extends BasicGameState {
|
||||
focusNode = OsuGroupList.get().getNode(node, osuFileIndex);
|
||||
OsuFile osu = focusNode.osuFiles.get(focusNode.osuFileIndex);
|
||||
MusicController.play(osu, false, preview);
|
||||
Utils.loadGlyphs(osu);
|
||||
|
||||
// load scores
|
||||
scoreMap = ScoreDB.getMapSetScores(osu);
|
||||
|
||||
Reference in New Issue
Block a user