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]; }
/**
* 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.
* @return the volume [0, 1]
@ -697,6 +707,16 @@ public class Options {
*/
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.
* @return the left key code

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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