Added global F7 and F10 shortcuts.

- F7: cycles through FPS settings.
- F10: toggles mouse enable/disable state during gameplay.

Also added bar notifications for saving/loading checkpoints.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-03-05 14:40:57 -05:00
parent 235adc539e
commit cf9b22442f
9 changed files with 78 additions and 1 deletions

View File

@ -471,6 +471,16 @@ public class Options {
*/ */
public static int getTargetFPS() { return targetFPS[targetFPSindex]; } public static int getTargetFPS() { return targetFPS[targetFPSindex]; }
/**
* Sets the target frame rate to the next available option, and sends a
* bar notification about the action.
* @param container the game container
*/
public static void setNextFPS(GameContainer container) {
GameOption.TARGET_FPS.click(container);
UI.sendBarNotification(String.format("Frame limiter: %s", GameOption.TARGET_FPS.getValueString()));
}
/** /**
* Returns the master volume level. * Returns the master volume level.
* @return the volume [0, 1] * @return the volume [0, 1]
@ -697,6 +707,16 @@ public class Options {
*/ */
public static boolean isMouseDisabled() { return GameOption.DISABLE_MOUSE_BUTTONS.getBooleanValue(); } public static boolean isMouseDisabled() { return GameOption.DISABLE_MOUSE_BUTTONS.getBooleanValue(); }
/**
* Toggles the mouse button enabled/disabled state during gameplay and
* sends a bar notification about the action.
*/
public static void toggleMouseDisabled() {
GameOption.DISABLE_MOUSE_BUTTONS.click(null);
UI.sendBarNotification((GameOption.DISABLE_MOUSE_BUTTONS.getBooleanValue()) ?
"Mouse buttons are disabled." : "Mouse buttons are enabled.");
}
/** /**
* Returns the left game key. * Returns the left game key.
* @return the left key code * @return the left key code

View File

@ -22,6 +22,7 @@ import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod; import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.MenuButton; import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu; import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuGroupList; import itdelatrisu.opsu.OsuGroupList;
import itdelatrisu.opsu.OsuGroupNode; import itdelatrisu.opsu.OsuGroupNode;
import itdelatrisu.opsu.ScoreData; import itdelatrisu.opsu.ScoreData;
@ -607,6 +608,12 @@ public class ButtonMenu extends BasicGameState {
if (menuState != null) if (menuState != null)
menuState.leave(container, game); menuState.leave(container, game);
break; break;
case Input.KEY_F7:
Options.setNextFPS(container);
break;
case Input.KEY_F10:
Options.toggleMouseDisabled();
break;
case Input.KEY_F12: case Input.KEY_F12:
Utils.takeScreenShot(); Utils.takeScreenShot();
break; break;

View File

@ -137,6 +137,7 @@ public class DownloadsMenu extends BasicGameState {
private Thread importThread; private Thread importThread;
// game-related variables // game-related variables
private GameContainer container;
private StateBasedGame game; private StateBasedGame game;
private Input input; private Input input;
private int state; private int state;
@ -148,6 +149,7 @@ public class DownloadsMenu 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;
this.input = container.getInput(); this.input = container.getInput();
@ -636,6 +638,12 @@ public class DownloadsMenu extends BasicGameState {
pageDir = Page.CURRENT; pageDir = Page.CURRENT;
resetSearchTimer(); resetSearchTimer();
break; break;
case Input.KEY_F7:
Options.setNextFPS(container);
break;
case Input.KEY_F10:
Options.toggleMouseDisabled();
break;
case Input.KEY_F12: case Input.KEY_F12:
Utils.takeScreenShot(); Utils.takeScreenShot();
break; break;

View File

@ -578,8 +578,10 @@ public class Game extends BasicGameState {
break; break;
int position = (pauseTime > -1) ? pauseTime : trackPosition; int position = (pauseTime > -1) ? pauseTime : trackPosition;
if (Options.setCheckpoint(position / 1000)) if (Options.setCheckpoint(position / 1000)) {
SoundController.playSound(SoundEffect.MENUCLICK); SoundController.playSound(SoundEffect.MENUCLICK);
UI.sendBarNotification("Checkpoint saved.");
}
} }
break; break;
case Input.KEY_L: case Input.KEY_L:
@ -597,6 +599,7 @@ public class Game extends BasicGameState {
MusicController.resume(); MusicController.resume();
} }
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
UI.sendBarNotification("Checkpoint loaded.");
// skip to checkpoint // skip to checkpoint
MusicController.setPosition(checkpoint); MusicController.setPosition(checkpoint);
@ -615,6 +618,12 @@ public class Game extends BasicGameState {
case Input.KEY_DOWN: case Input.KEY_DOWN:
UI.changeVolume(-1); UI.changeVolume(-1);
break; break;
case Input.KEY_F7:
Options.setNextFPS(container);
break;
case Input.KEY_F10:
Options.toggleMouseDisabled();
break;
case Input.KEY_F12: case Input.KEY_F12:
Utils.takeScreenShot(); Utils.takeScreenShot();
break; break;

View File

@ -148,6 +148,12 @@ public class GamePauseMenu extends BasicGameState {
game.enterState(Opsu.STATE_GAME); game.enterState(Opsu.STATE_GAME);
} }
break; break;
case Input.KEY_F7:
Options.setNextFPS(container);
break;
case Input.KEY_F10:
Options.toggleMouseDisabled();
break;
case Input.KEY_F12: case Input.KEY_F12:
Utils.takeScreenShot(); Utils.takeScreenShot();
break; break;

View File

@ -22,6 +22,7 @@ import itdelatrisu.opsu.GameData;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.MenuButton; import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu; import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuFile; import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.UI; import itdelatrisu.opsu.UI;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
@ -57,6 +58,7 @@ public class GameRanking extends BasicGameState {
private MenuButton retryButton, exitButton; private MenuButton retryButton, exitButton;
// game-related variables // game-related variables
private GameContainer container;
private StateBasedGame game; private StateBasedGame game;
private int state; private int state;
private Input input; private Input input;
@ -68,6 +70,7 @@ public class GameRanking 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;
this.input = container.getInput(); this.input = container.getInput();
@ -135,6 +138,12 @@ public class GameRanking extends BasicGameState {
case Input.KEY_ESCAPE: case Input.KEY_ESCAPE:
returnToSongMenu(); returnToSongMenu();
break; break;
case Input.KEY_F7:
Options.setNextFPS(container);
break;
case Input.KEY_F10:
Options.toggleMouseDisabled();
break;
case Input.KEY_F12: case Input.KEY_F12:
Utils.takeScreenShot(); Utils.takeScreenShot();
break; break;

View File

@ -486,6 +486,12 @@ public class MainMenu extends BasicGameState {
case Input.KEY_DOWN: case Input.KEY_DOWN:
UI.changeVolume(-1); UI.changeVolume(-1);
break; break;
case Input.KEY_F7:
Options.setNextFPS(container);
break;
case Input.KEY_F10:
Options.toggleMouseDisabled();
break;
case Input.KEY_F12: case Input.KEY_F12:
Utils.takeScreenShot(); Utils.takeScreenShot();
break; break;

View File

@ -362,6 +362,12 @@ public class OptionsMenu extends BasicGameState {
container.exit(); container.exit();
} }
break; break;
case Input.KEY_F7:
Options.setNextFPS(container);
break;
case Input.KEY_F10:
Options.toggleMouseDisabled();
break;
case Input.KEY_F12: case Input.KEY_F12:
Utils.takeScreenShot(); Utils.takeScreenShot();
break; break;

View File

@ -750,6 +750,12 @@ public class SongMenu extends BasicGameState {
((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(MenuState.RELOAD); ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(MenuState.RELOAD);
game.enterState(Opsu.STATE_BUTTONMENU); game.enterState(Opsu.STATE_BUTTONMENU);
break; break;
case Input.KEY_F7:
Options.setNextFPS(container);
break;
case Input.KEY_F10:
Options.toggleMouseDisabled();
break;
case Input.KEY_F12: case Input.KEY_F12:
Utils.takeScreenShot(); Utils.takeScreenShot();
break; break;