Skip to content

Commit

Permalink
Added more osu! main menu shortcuts (music control, FPS counter).
Browse files Browse the repository at this point in the history
New shortcuts:
- "F": Toggle FPS counter display.
- "Z": Previous track.
- "X": Play track.
- "C": Pause track.
- "V": Next track.

Also changed "previous track" behavior to not restart the track if the stack is empty (as in osu!).

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
  • Loading branch information
itdelatrisu committed Jan 30, 2017
1 parent 5dee12b commit 7c6e9fa
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/itdelatrisu/opsu/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,11 @@ public static void setDisplayMode(Container app) {
*/
public static boolean isFPSCounterEnabled() { return GameOption.SHOW_FPS.getBooleanValue(); }

/**
* Toggles the FPS counter display.
*/
public static void toggleFPSCounter() { GameOption.SHOW_FPS.toggle(null); }

/**
* Returns whether or not hit lighting effects are enabled.
* @return true if enabled
Expand Down
54 changes: 44 additions & 10 deletions src/itdelatrisu/opsu/states/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -624,16 +624,8 @@ public void mousePressed(int button, int x, int y) {
UI.getNotificationManager().sendBarNotification(">> Next");
return;
} else if (musicPrevious.contains(x, y)) {
lastMeasureProgress = 0f;
if (!previous.isEmpty()) {
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
menu.setFocus(BeatmapSetList.get().getBaseNode(previous.pop()), -1, true, false);
if (Options.isDynamicBackgroundEnabled())
bgAlpha.setTime(0);
} else
MusicController.setPosition(0);
musicInfoProgress.setTime(0);
UI.getNotificationManager().sendBarNotification("<< Previous");
previousTrack();
UI.getNotificationManager().sendBarNotification("<< Prev");
return;
}

Expand Down Expand Up @@ -726,6 +718,34 @@ public void keyPressed(int key, char c) {
SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition());
break;
case Input.KEY_F:
Options.toggleFPSCounter();
break;
case Input.KEY_Z:
previousTrack();
UI.getNotificationManager().sendBarNotification("<< Prev");
break;
case Input.KEY_X:
if (MusicController.isPlaying()) {
lastMeasureProgress = 0f;
MusicController.setPosition(0);
} else if (!MusicController.isTrackLoading())
MusicController.resume();
UI.getNotificationManager().sendBarNotification("Play");
break;
case Input.KEY_C:
if (MusicController.isPlaying()) {
MusicController.pause();
UI.getNotificationManager().sendBarNotification("Pause");
} else if (!MusicController.isTrackLoading()) {
MusicController.resume();
UI.getNotificationManager().sendBarNotification("Unpause");
}
break;
case Input.KEY_V:
nextTrack(true);
UI.getNotificationManager().sendBarNotification(">> Next");
break;
case Input.KEY_R:
nextTrack(true);
break;
Expand Down Expand Up @@ -810,6 +830,20 @@ private void nextTrack(boolean user) {
musicInfoProgress.setTime(0);
}

/**
* Plays the previous track, or does nothing if the stack is empty.
*/
private void previousTrack() {
if (!previous.isEmpty()) {
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
menu.setFocus(BeatmapSetList.get().getBaseNode(previous.pop()), -1, true, false);
lastMeasureProgress = 0f;
if (Options.isDynamicBackgroundEnabled())
bgAlpha.setTime(0);
}
musicInfoProgress.setTime(0);
}

/**
* Enters the song menu, or the downloads menu if no beatmaps are loaded.
*/
Expand Down

0 comments on commit 7c6e9fa

Please sign in to comment.