Merge pull request #38 from fluddokt/omaster

Next track on trackEnded
This commit is contained in:
Jeffrey Han 2015-03-07 18:43:58 -05:00
commit 447fd93e60
4 changed files with 13 additions and 4 deletions

View File

@ -161,6 +161,7 @@ public class Opsu extends StateBasedGame {
String[] icons = { "icon16.png", "icon32.png" }; String[] icons = { "icon16.png", "icon32.png" };
app.setIcons(icons); app.setIcons(icons);
app.setForceExit(true); app.setForceExit(true);
app.setUpdateOnlyWhenVisible(false);
app.start(); app.start();

View File

@ -70,8 +70,9 @@ public class MusicController {
* @param osu the OsuFile to play * @param osu the OsuFile to play
* @param loop whether or not to loop the track * @param loop whether or not to loop the track
* @param preview whether to start at the preview time (true) or beginning (false) * @param preview whether to start at the preview time (true) or beginning (false)
* @param reset plays at the preview time even if it has the same preview time as the last
*/ */
public static void play(final OsuFile osu, final boolean loop, final boolean preview) { public static void play(final OsuFile osu, final boolean loop, final boolean preview, final boolean reset) {
// new track: load and play // new track: load and play
if (lastOsu == null || !osu.audioFilename.equals(lastOsu.audioFilename)) { if (lastOsu == null || !osu.audioFilename.equals(lastOsu.audioFilename)) {
reset(); reset();
@ -94,7 +95,7 @@ public class MusicController {
} }
// new track position: play at position // new track position: play at position
else if (osu.previewTime != lastOsu.previewTime) else if (osu.previewTime != lastOsu.previewTime || reset)
playAt(osu.previewTime, loop); playAt(osu.previewTime, loop);
lastOsu = osu; lastOsu = osu;
@ -282,7 +283,7 @@ public class MusicController {
public static void playThemeSong() { public static void playThemeSong() {
OsuFile osu = Options.getOsuTheme(); OsuFile osu = Options.getOsuTheme();
if (osu != null) { if (osu != null) {
play(osu, true, false); play(osu, true, false, false);
themePlaying = true; themePlaying = true;
} }
} }

View File

@ -377,6 +377,9 @@ public class MainMenu extends BasicGameState {
logo.setX(container.getWidth() / 2); logo.setX(container.getWidth() / 2);
} }
} }
if (MusicController.trackEnded())
nextTrack();
} }
@Override @Override

View File

@ -566,6 +566,10 @@ public class SongMenu extends BasicGameState {
hoverOffset = 0f; hoverOffset = 0f;
hoverIndex = -1; hoverIndex = -1;
} }
if (MusicController.trackEnded()) {
OsuFile osu = focusNode.osuFiles.get(focusNode.osuFileIndex);
MusicController.play(osu, false, true, true);
}
} }
@Override @Override
@ -1163,7 +1167,7 @@ public class SongMenu extends BasicGameState {
startNode = node; startNode = node;
focusNode = OsuGroupList.get().getNode(node, osuFileIndex); focusNode = OsuGroupList.get().getNode(node, osuFileIndex);
OsuFile osu = focusNode.osuFiles.get(focusNode.osuFileIndex); OsuFile osu = focusNode.osuFiles.get(focusNode.osuFileIndex);
MusicController.play(osu, true, preview); MusicController.play(osu, false, preview, false);
Utils.loadGlyphs(osu); Utils.loadGlyphs(osu);
// load scores // load scores