From 068a844e1ff48e61cf755ca8015a6599ed907d7f Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Wed, 24 Dec 2014 00:25:26 -0500 Subject: [PATCH] Fixed music player issues with handling repeat tracks. When pressing the "next" button, songs will only be pushed when a new track plays. Fixes a potential null pointer crash. Signed-off-by: Jeffrey Han --- src/itdelatrisu/opsu/states/Game.java | 2 +- src/itdelatrisu/opsu/states/MainMenu.java | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index e67a650c..e8d4d03f 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -251,7 +251,7 @@ public class Game extends BasicGameState { if (checkpointLoaded) { int checkpoint = Options.getCheckpoint(); String checkpointText = String.format( - "~ Playing from checkpoint at %02d:%02d. ~", + "Playing from checkpoint at %02d:%02d.", TimeUnit.MILLISECONDS.toMinutes(checkpoint), TimeUnit.MILLISECONDS.toSeconds(checkpoint) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(checkpoint)) diff --git a/src/itdelatrisu/opsu/states/MainMenu.java b/src/itdelatrisu/opsu/states/MainMenu.java index ccf153c6..3183ca2d 100644 --- a/src/itdelatrisu/opsu/states/MainMenu.java +++ b/src/itdelatrisu/opsu/states/MainMenu.java @@ -322,10 +322,13 @@ public class MainMenu extends BasicGameState { boolean isTheme = MusicController.isThemePlaying(); SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU); OsuGroupNode node = menu.setFocus(Opsu.groups.getRandomNode(), -1, true); - if (node != null && !isTheme) - previous.add(node.index); - if (Options.isDynamicBackgroundEnabled() && - MusicController.getOsuFile() != null && !MusicController.isThemePlaying()) + boolean sameAudio = false; + if (node != null) { + sameAudio = MusicController.getOsuFile().audioFilename.equals(node.osuFiles.get(0).audioFilename); + if (!isTheme && !sameAudio) + previous.add(node.index); + } + if (Options.isDynamicBackgroundEnabled() && !sameAudio && !MusicController.isThemePlaying()) bgAlpha = 0f; } else if (musicPrevious.contains(x, y)) { if (!previous.isEmpty()) {