Mimic osu! exit button

On osu!, clicking the exit button closes the game after clicking. Pressing ESC on osu! brings up the exit menu.
This commit is contained in:
Raymonf 2014-12-21 17:02:11 -05:00
parent bc7d19295b
commit 068b40a86a

View File

@ -101,6 +101,7 @@ public class MainMenu extends BasicGameState {
private float bgAlpha = 0f; private float bgAlpha = 0f;
// game-related variables // game-related variables
private GameContainer container;
private StateBasedGame game; private StateBasedGame game;
private int state; private int state;
@ -111,6 +112,7 @@ public class MainMenu extends BasicGameState {
@Override @Override
public void init(GameContainer container, StateBasedGame game) public void init(GameContainer container, StateBasedGame game)
throws SlickException { throws SlickException {
this.container = container;
this.game = game; this.game = game;
osuStartTime = System.currentTimeMillis(); osuStartTime = System.currentTimeMillis();
@ -329,7 +331,9 @@ public class MainMenu extends BasicGameState {
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 if (exitButton.contains(x, y)) { } else if (exitButton.contains(x, y)) {
SoundController.playSound(SoundController.SOUND_MENUHIT); SoundController.playSound(SoundController.SOUND_MENUHIT);
game.enterState(Opsu.STATE_MAINMENUEXIT); Options.saveOptions();
Opsu.closeSocket();
container.exit();
} }
} }
} }