prevent a nullpointer, save a life

This commit is contained in:
yugecin 2018-07-01 22:51:14 +02:00
parent 7c763f4f66
commit 413e937c13
No known key found for this signature in database
GPG Key ID: 2C5AC035A7068E44

View File

@ -344,7 +344,12 @@ public class MainMenu extends BaseOpsuState {
Fonts.loadGlyphs(Fonts.MEDIUM, beatmap.artistUnicode); Fonts.loadGlyphs(Fonts.MEDIUM, beatmap.artistUnicode);
} }
final Image np = GameImage.MUSIC_NOWPLAYING.getImage(); final Image np = GameImage.MUSIC_NOWPLAYING.getImage();
final String trackText = beatmap.getArtist() + ": " + beatmap.getTitle(); final String trackText;
if (beatmap != null) {
trackText = beatmap.getArtist() + ": " + beatmap.getTitle();
} else {
trackText = "Loading...";
}
final float textWidth = Fonts.MEDIUM.getWidth(trackText); final float textWidth = Fonts.MEDIUM.getWidth(trackText);
final float npheight = Fonts.MEDIUM.getLineHeight() * 1.15f; final float npheight = Fonts.MEDIUM.getLineHeight() * 1.15f;
final float npscale = npheight / np.getHeight(); final float npscale = npheight / np.getHeight();