Don't reset track to preview position unless game is complete.

(conforming to osu! behavior)

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-01-23 16:06:57 -05:00
parent 423866c222
commit 924f528881
3 changed files with 12 additions and 10 deletions

View File

@ -52,7 +52,7 @@ public class Container extends AppGameContainer {
* @throws SlickException Indicates a failure to initialise the display * @throws SlickException Indicates a failure to initialise the display
*/ */
public Container(Game game, int width, int height, boolean fullscreen) throws SlickException { public Container(Game game, int width, int height, boolean fullscreen) throws SlickException {
super(game); super(game, width, height, fullscreen);
} }
@Override @Override

View File

@ -18,6 +18,7 @@
package itdelatrisu.opsu; package itdelatrisu.opsu;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.states.Game; import itdelatrisu.opsu.states.Game;
import itdelatrisu.opsu.states.GamePauseMenu; import itdelatrisu.opsu.states.GamePauseMenu;
import itdelatrisu.opsu.states.GameRanking; import itdelatrisu.opsu.states.GameRanking;
@ -168,9 +169,9 @@ public class Opsu extends StateBasedGame {
// intercept close requests in game-related states and return to song menu // intercept close requests in game-related states and return to song menu
if (id == STATE_GAME || id == STATE_GAMEPAUSEMENU || id == STATE_GAMERANKING) { if (id == STATE_GAME || id == STATE_GAMEPAUSEMENU || id == STATE_GAMERANKING) {
// start playing track at preview position // start playing track at preview position
SongMenu songMenu = (SongMenu) this.getState(Opsu.STATE_SONGMENU); ((SongMenu) this.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
songMenu.resetGameDataOnLoad(); MusicController.pause();
songMenu.resetTrackOnLoad(); MusicController.resume();
this.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); this.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
return false; return false;
} }

View File

@ -133,9 +133,8 @@ public class GamePauseMenu extends BasicGameState {
// 'esc' will normally unpause, but will return to song menu if health is zero // 'esc' will normally unpause, but will return to song menu if health is zero
if (gameState.getRestart() == Game.Restart.LOSE) { if (gameState.getRestart() == Game.Restart.LOSE) {
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
SongMenu songMenu = (SongMenu) game.getState(Opsu.STATE_SONGMENU); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
songMenu.resetGameDataOnLoad(); MusicController.playAt(MusicController.getOsuFile().previewTime, true);
songMenu.resetTrackOnLoad();
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} else { } else {
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
@ -177,9 +176,11 @@ public class GamePauseMenu extends BasicGameState {
game.enterState(Opsu.STATE_GAME); game.enterState(Opsu.STATE_GAME);
} else if (backButton.contains(x, y)) { } else if (backButton.contains(x, y)) {
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
SongMenu songMenu = (SongMenu) game.getState(Opsu.STATE_SONGMENU); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
songMenu.resetGameDataOnLoad(); if (loseState)
songMenu.resetTrackOnLoad(); MusicController.playAt(MusicController.getOsuFile().previewTime, true);
else
MusicController.resume();
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} }
} }