Added a few missing keyboard shortcuts.

- Main Menu: "P" (play), "Q" (quit)
- Game: Ctrl + "R" (restart)

Other changes:
- Song Menu search textfield no longer retains focus in different states.
This commit is contained in:
Jeffrey Han 2014-07-05 14:29:48 -04:00
parent 83f13a8879
commit 0dbfd18c5f
3 changed files with 33 additions and 1 deletions

View File

@ -559,6 +559,17 @@ public class Game extends BasicGameState {
// skip
skipIntro();
break;
case Input.KEY_R:
if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) {
try {
restart = RESTART_MANUAL;
enter(container, game);
skipIntro();
} catch (SlickException e) {
Log.error("Failed to restart game.", e);
}
}
break;
case Input.KEY_Z:
// left-click
if (!Keyboard.isRepeatEvent())

View File

@ -341,6 +341,21 @@ public class MainMenu extends BasicGameState {
else
game.enterState(Opsu.STATE_MAINMENUEXIT);
break;
case Input.KEY_Q:
game.enterState(Opsu.STATE_MAINMENUEXIT);
break;
case Input.KEY_P:
if (!logoClicked) {
logoClicked = true;
logoTimer = 0;
playButton.getImage().setAlpha(0f);
exitButton.getImage().setAlpha(0f);
SoundController.playSound(SoundController.SOUND_MENUHIT);
} else {
SoundController.playSound(SoundController.SOUND_MENUHIT);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
}
break;
case Input.KEY_F12:
Utils.takeScreenShot();
break;

View File

@ -281,7 +281,6 @@ public class SongMenu extends BasicGameState {
public void update(GameContainer container, StateBasedGame game, int delta)
throws SlickException {
// search
search.setFocus(true);
searchTimer += delta;
if (searchTimer >= SEARCH_DELAY) {
searchTimer = 0;
@ -524,6 +523,13 @@ public class SongMenu extends BasicGameState {
public void enter(GameContainer container, StateBasedGame game)
throws SlickException {
Display.setTitle(game.getTitle());
search.setFocus(true);
}
@Override
public void leave(GameContainer container, StateBasedGame game)
throws SlickException {
search.setFocus(false);
}
/**