Allow showing a replay after a game.
Added a pause-replay image by XinCrin, and deleted ranking-retry/ranking-exit images. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -29,6 +29,7 @@ import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
import itdelatrisu.opsu.replay.Replay;
|
||||
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.newdawn.slick.Color;
|
||||
@@ -46,7 +47,7 @@ import org.newdawn.slick.state.transition.FadeOutTransition;
|
||||
* "Game Ranking" (score card) state.
|
||||
* <ul>
|
||||
* <li>[Retry] - restart game (return to game state)
|
||||
* <li>[Exit] - return to main menu state
|
||||
* <li>[Replay] - watch replay (return to game state)
|
||||
* <li>[Back] - return to song menu state
|
||||
* </ul>
|
||||
*/
|
||||
@@ -54,8 +55,11 @@ public class GameRanking extends BasicGameState {
|
||||
/** Associated GameData object. */
|
||||
private GameData data;
|
||||
|
||||
/** "Retry" and "Exit" buttons. */
|
||||
private MenuButton retryButton, exitButton;
|
||||
/** "Retry" and "Replay" buttons. */
|
||||
private MenuButton retryButton, replayButton;
|
||||
|
||||
/** Button coordinates. */
|
||||
private float retryY, replayY;
|
||||
|
||||
// game-related variables
|
||||
private GameContainer container;
|
||||
@@ -78,18 +82,14 @@ public class GameRanking extends BasicGameState {
|
||||
int height = container.getHeight();
|
||||
|
||||
// buttons
|
||||
Image retry = GameImage.RANKING_RETRY.getImage();
|
||||
Image exit = GameImage.RANKING_EXIT.getImage();
|
||||
retryButton = new MenuButton(retry,
|
||||
width - (retry.getWidth() / 2f),
|
||||
(height * 0.97f) - (exit.getHeight() * 1.5f)
|
||||
);
|
||||
exitButton = new MenuButton(exit,
|
||||
width - (exit.getWidth() / 2f),
|
||||
(height * 0.97f) - (exit.getHeight() / 2f)
|
||||
);
|
||||
retryButton.setHoverFade(0.6f);
|
||||
exitButton.setHoverFade(0.6f);
|
||||
Image retry = GameImage.PAUSE_RETRY.getImage();
|
||||
Image replay = GameImage.PAUSE_REPLAY.getImage();
|
||||
replayY = (height * 0.985f) - replay.getHeight() / 2f;
|
||||
retryY = replayY - (replay.getHeight() / 2f) - (retry.getHeight() / 1.975f);
|
||||
retryButton = new MenuButton(retry, width - (retry.getWidth() / 2f), retryY);
|
||||
replayButton = new MenuButton(replay, width - (replay.getWidth() / 2f), replayY);
|
||||
retryButton.setHoverFade();
|
||||
replayButton.setHoverFade();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,10 +108,9 @@ public class GameRanking extends BasicGameState {
|
||||
data.drawRankingElements(g, osu);
|
||||
|
||||
// buttons
|
||||
if (data.isGameplay()) {
|
||||
replayButton.draw();
|
||||
if (data.isGameplay())
|
||||
retryButton.draw();
|
||||
exitButton.draw();
|
||||
}
|
||||
UI.getBackButton().draw();
|
||||
|
||||
UI.draw(g);
|
||||
@@ -122,10 +121,10 @@ public class GameRanking extends BasicGameState {
|
||||
throws SlickException {
|
||||
UI.update(delta);
|
||||
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
||||
if (data.isGameplay()) {
|
||||
replayButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
if (data.isGameplay())
|
||||
retryButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
exitButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
} else
|
||||
else
|
||||
MusicController.loopTrackIfEnded(true);
|
||||
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
|
||||
}
|
||||
@@ -157,27 +156,38 @@ public class GameRanking extends BasicGameState {
|
||||
if (button == Input.MOUSE_MIDDLE_BUTTON)
|
||||
return;
|
||||
|
||||
if (data.isGameplay()) {
|
||||
if (retryButton.contains(x, y)) {
|
||||
OsuFile osu = MusicController.getOsuFile();
|
||||
Display.setTitle(String.format("%s - %s", game.getTitle(), osu.toString()));
|
||||
((Game) game.getState(Opsu.STATE_GAME)).setRestart(Game.Restart.MANUAL);
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
return;
|
||||
} else if (exitButton.contains(x, y)) {
|
||||
SoundController.playSound(SoundEffect.MENUBACK);
|
||||
((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset();
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
|
||||
UI.resetCursor();
|
||||
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
return;
|
||||
}
|
||||
}
|
||||
// back to menu
|
||||
if (UI.getBackButton().contains(x, y)) {
|
||||
returnToSongMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
// replay
|
||||
boolean returnToGame = false;
|
||||
if (replayButton.contains(x, y)) {
|
||||
Replay r = data.getReplay(null);
|
||||
if (r != null) {
|
||||
r.load();
|
||||
((Game) game.getState(Opsu.STATE_GAME)).setReplay(r);
|
||||
((Game) game.getState(Opsu.STATE_GAME)).setRestart(Game.Restart.REPLAY);
|
||||
returnToGame = true;
|
||||
}
|
||||
}
|
||||
|
||||
// retry
|
||||
else if (data.isGameplay() && retryButton.contains(x, y)) {
|
||||
((Game) game.getState(Opsu.STATE_GAME)).setReplay(null);
|
||||
((Game) game.getState(Opsu.STATE_GAME)).setRestart(Game.Restart.MANUAL);
|
||||
returnToGame = true;
|
||||
}
|
||||
|
||||
if (returnToGame) {
|
||||
OsuFile osu = MusicController.getOsuFile();
|
||||
Display.setTitle(String.format("%s - %s", game.getTitle(), osu.toString()));
|
||||
SoundController.playSound(SoundEffect.MENUHIT);
|
||||
game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,11 +198,13 @@ public class GameRanking extends BasicGameState {
|
||||
if (!data.isGameplay()) {
|
||||
if (!MusicController.isTrackDimmed())
|
||||
MusicController.toggleTrackDimmed(0.5f);
|
||||
replayButton.setY(retryY);
|
||||
} else {
|
||||
SoundController.playSound(SoundEffect.APPLAUSE);
|
||||
retryButton.resetHover();
|
||||
exitButton.resetHover();
|
||||
replayButton.setY(replayY);
|
||||
}
|
||||
replayButton.resetHover();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user