Follow-up to #38: loop tracks on states by default.
Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
447fd93e60
commit
8c24ef97c7
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,7 +4,7 @@
|
|||
/Songs/
|
||||
/.opsu.log
|
||||
/.opsu.cfg
|
||||
/.opsu.db
|
||||
/.opsu.db*
|
||||
/.opsu_scores.db
|
||||
|
||||
# Eclipse
|
||||
|
|
|
@ -161,7 +161,6 @@ public class Opsu extends StateBasedGame {
|
|||
String[] icons = { "icon16.png", "icon32.png" };
|
||||
app.setIcons(icons);
|
||||
app.setForceExit(true);
|
||||
app.setUpdateOnlyWhenVisible(false);
|
||||
|
||||
app.start();
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@ public class Utils {
|
|||
container.setShowFPS(false);
|
||||
container.getInput().enableKeyRepeat();
|
||||
container.setAlwaysRender(true);
|
||||
container.setUpdateOnlyWhenVisible(false);
|
||||
|
||||
int width = container.getWidth();
|
||||
int height = container.getHeight();
|
||||
|
|
|
@ -70,9 +70,8 @@ public class MusicController {
|
|||
* @param osu the OsuFile to play
|
||||
* @param loop whether or not to loop the track
|
||||
* @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, final boolean reset) {
|
||||
public static void play(final OsuFile osu, final boolean loop, final boolean preview) {
|
||||
// new track: load and play
|
||||
if (lastOsu == null || !osu.audioFilename.equals(lastOsu.audioFilename)) {
|
||||
reset();
|
||||
|
@ -95,7 +94,7 @@ public class MusicController {
|
|||
}
|
||||
|
||||
// new track position: play at position
|
||||
else if (osu.previewTime != lastOsu.previewTime || reset)
|
||||
else if (osu.previewTime != lastOsu.previewTime)
|
||||
playAt(osu.previewTime, loop);
|
||||
|
||||
lastOsu = osu;
|
||||
|
@ -277,13 +276,22 @@ public class MusicController {
|
|||
*/
|
||||
public static boolean trackEnded() { return trackEnded; }
|
||||
|
||||
/**
|
||||
* Loops the current track if it has ended.
|
||||
* @param preview whether to start at the preview time (true) or beginning (false)
|
||||
*/
|
||||
public static void loopTrackIfEnded(boolean preview) {
|
||||
if (trackEnded && trackExists())
|
||||
playAt((preview) ? lastOsu.previewTime : 0, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays the theme song.
|
||||
*/
|
||||
public static void playThemeSong() {
|
||||
OsuFile osu = Options.getOsuTheme();
|
||||
if (osu != null) {
|
||||
play(osu, true, false, false);
|
||||
play(osu, true, false);
|
||||
themePlaying = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import itdelatrisu.opsu.OsuGroupNode;
|
|||
import itdelatrisu.opsu.ScoreData;
|
||||
import itdelatrisu.opsu.UI;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
|
||||
|
@ -584,6 +585,7 @@ public class ButtonMenu extends BasicGameState {
|
|||
public void update(GameContainer container, StateBasedGame game, int delta)
|
||||
throws SlickException {
|
||||
UI.update(delta);
|
||||
MusicController.loopTrackIfEnded(false);
|
||||
if (menuState != null)
|
||||
menuState.update(container, delta, input.getMouseX(), input.getMouseY());
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import itdelatrisu.opsu.OsuParser;
|
|||
import itdelatrisu.opsu.OszUnpacker;
|
||||
import itdelatrisu.opsu.UI;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
import itdelatrisu.opsu.downloads.BloodcatServer;
|
||||
|
@ -319,6 +320,7 @@ public class DownloadsMenu extends BasicGameState {
|
|||
public void update(GameContainer container, StateBasedGame game, int delta)
|
||||
throws SlickException {
|
||||
UI.update(delta);
|
||||
MusicController.loopTrackIfEnded(false);
|
||||
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
|
||||
prevPage.hoverUpdate(delta, mouseX, mouseY);
|
||||
|
|
|
@ -125,7 +125,8 @@ public class GameRanking extends BasicGameState {
|
|||
if (data.isGameplay()) {
|
||||
retryButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
exitButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
}
|
||||
} else
|
||||
MusicController.loopTrackIfEnded(true);
|
||||
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
|
|
@ -312,6 +312,8 @@ public class MainMenu extends BasicGameState {
|
|||
public void update(GameContainer container, StateBasedGame game, int delta)
|
||||
throws SlickException {
|
||||
UI.update(delta);
|
||||
if (MusicController.trackEnded())
|
||||
nextTrack(); // end of track: go to next track
|
||||
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||
logo.hoverUpdate(delta, mouseX, mouseY, 0.25f);
|
||||
playButton.hoverUpdate(delta, mouseX, mouseY, 0.25f);
|
||||
|
@ -377,9 +379,6 @@ public class MainMenu extends BasicGameState {
|
|||
logo.setX(container.getWidth() / 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (MusicController.trackEnded())
|
||||
nextTrack();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import itdelatrisu.opsu.Options;
|
|||
import itdelatrisu.opsu.Options.GameOption;
|
||||
import itdelatrisu.opsu.UI;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
|
||||
|
@ -259,6 +260,7 @@ public class OptionsMenu extends BasicGameState {
|
|||
public void update(GameContainer container, StateBasedGame game, int delta)
|
||||
throws SlickException {
|
||||
UI.update(delta);
|
||||
MusicController.loopTrackIfEnded(false);
|
||||
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
|
||||
}
|
||||
|
|
|
@ -460,6 +460,7 @@ public class SongMenu extends BasicGameState {
|
|||
public void update(GameContainer container, StateBasedGame game, int delta)
|
||||
throws SlickException {
|
||||
UI.update(delta);
|
||||
MusicController.loopTrackIfEnded(true);
|
||||
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
|
||||
selectModsButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
|
@ -566,10 +567,6 @@ public class SongMenu extends BasicGameState {
|
|||
hoverOffset = 0f;
|
||||
hoverIndex = -1;
|
||||
}
|
||||
if (MusicController.trackEnded()) {
|
||||
OsuFile osu = focusNode.osuFiles.get(focusNode.osuFileIndex);
|
||||
MusicController.play(osu, false, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1167,7 +1164,7 @@ public class SongMenu extends BasicGameState {
|
|||
startNode = node;
|
||||
focusNode = OsuGroupList.get().getNode(node, osuFileIndex);
|
||||
OsuFile osu = focusNode.osuFiles.get(focusNode.osuFileIndex);
|
||||
MusicController.play(osu, false, preview, false);
|
||||
MusicController.play(osu, false, preview);
|
||||
Utils.loadGlyphs(osu);
|
||||
|
||||
// load scores
|
||||
|
|
Loading…
Reference in New Issue
Block a user