Follow-up to a6ece30: allow changing volume anywhere with ALT key.
The master volume can now be changed (using the mouse wheel) with the ALT key pressed in any menu, as in osu!. Also improved the handling of dimmed tracks. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -75,6 +75,13 @@ public class ButtonMenu extends BasicGameState {
|
||||
public void leave(GameContainer container, StateBasedGame game) {
|
||||
Button.CANCEL.click(container, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scroll(GameContainer container, StateBasedGame game, int newValue) {
|
||||
Input input = container.getInput();
|
||||
if (input.isKeyDown(Input.KEY_LALT) || input.isKeyDown(Input.KEY_RALT))
|
||||
super.scroll(container, game, newValue);
|
||||
}
|
||||
},
|
||||
BEATMAP_DELETE_SELECT (new Button[] { Button.DELETE_GROUP, Button.DELETE_SONG, Button.CANCEL_DELETE }) {
|
||||
@Override
|
||||
@@ -88,6 +95,11 @@ public class ButtonMenu extends BasicGameState {
|
||||
public void leave(GameContainer container, StateBasedGame game) {
|
||||
Button.CANCEL_DELETE.click(container, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scroll(GameContainer container, StateBasedGame game, int newValue) {
|
||||
MenuState.BEATMAP.scroll(container, game, newValue);
|
||||
}
|
||||
},
|
||||
BEATMAP_DELETE_CONFIRM (new Button[] { Button.DELETE_CONFIRM, Button.CANCEL_DELETE }) {
|
||||
@Override
|
||||
@@ -99,6 +111,11 @@ public class ButtonMenu extends BasicGameState {
|
||||
public void leave(GameContainer container, StateBasedGame game) {
|
||||
Button.CANCEL_DELETE.click(container, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scroll(GameContainer container, StateBasedGame game, int newValue) {
|
||||
MenuState.BEATMAP.scroll(container, game, newValue);
|
||||
}
|
||||
},
|
||||
RELOAD (new Button[] { Button.RELOAD_CONFIRM, Button.RELOAD_CANCEL }) {
|
||||
@Override
|
||||
@@ -114,6 +131,11 @@ public class ButtonMenu extends BasicGameState {
|
||||
public void leave(GameContainer container, StateBasedGame game) {
|
||||
Button.RELOAD_CANCEL.click(container, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scroll(GameContainer container, StateBasedGame game, int newValue) {
|
||||
MenuState.BEATMAP.scroll(container, game, newValue);
|
||||
}
|
||||
},
|
||||
SCORE (new Button[] { Button.DELETE_SCORE, Button.CLOSE }) {
|
||||
@Override
|
||||
@@ -125,6 +147,11 @@ public class ButtonMenu extends BasicGameState {
|
||||
public void leave(GameContainer container, StateBasedGame game) {
|
||||
Button.CLOSE.click(container, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scroll(GameContainer container, StateBasedGame game, int newValue) {
|
||||
MenuState.BEATMAP.scroll(container, game, newValue);
|
||||
}
|
||||
},
|
||||
MODS (new Button[] { Button.RESET_MODS, Button.CLOSE }) {
|
||||
@Override
|
||||
@@ -218,6 +245,11 @@ public class ButtonMenu extends BasicGameState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scroll(GameContainer container, StateBasedGame game, int newValue) {
|
||||
MenuState.BEATMAP.scroll(container, game, newValue);
|
||||
}
|
||||
};
|
||||
|
||||
/** The buttons in the state. */
|
||||
@@ -355,6 +387,16 @@ public class ButtonMenu extends BasicGameState {
|
||||
*/
|
||||
public String[] getTitle(GameContainer container, StateBasedGame game) { return new String[0]; }
|
||||
|
||||
/**
|
||||
* Processes a mouse wheel movement.
|
||||
* @param container the game container
|
||||
* @param game the game
|
||||
* @param newValue the amount that the mouse wheel moved
|
||||
*/
|
||||
public void scroll(GameContainer container, StateBasedGame game, int newValue) {
|
||||
UI.changeVolume((newValue < 0) ? -1 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a state enter request.
|
||||
* @param container the game container
|
||||
@@ -601,6 +643,12 @@ public class ButtonMenu extends BasicGameState {
|
||||
menuState.click(container, game, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(int newValue) {
|
||||
if (menuState != null)
|
||||
menuState.scroll(container, game, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(int key, char c) {
|
||||
switch (key) {
|
||||
|
||||
@@ -653,6 +653,12 @@ public class DownloadsMenu extends BasicGameState {
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(int newValue) {
|
||||
// change volume
|
||||
if (input.isKeyDown(Input.KEY_LALT) || input.isKeyDown(Input.KEY_RALT)) {
|
||||
UI.changeVolume((newValue < 0) ? -1 : 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// block input during beatmap importing
|
||||
if (importThread != null)
|
||||
return;
|
||||
|
||||
@@ -136,6 +136,12 @@ public class GameRanking extends BasicGameState {
|
||||
@Override
|
||||
public int getID() { return state; }
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(int newValue) {
|
||||
if (input.isKeyDown(Input.KEY_LALT) || input.isKeyDown(Input.KEY_RALT))
|
||||
UI.changeVolume((newValue < 0) ? -1 : 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(int key, char c) {
|
||||
switch (key) {
|
||||
|
||||
@@ -418,6 +418,13 @@ public class MainMenu extends BasicGameState {
|
||||
downloadsButton.resetHover();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leave(GameContainer container, StateBasedGame game)
|
||||
throws SlickException {
|
||||
if (MusicController.isTrackDimmed())
|
||||
MusicController.toggleTrackDimmed(1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
// check mouse button
|
||||
|
||||
@@ -342,6 +342,12 @@ public class OptionsMenu extends BasicGameState {
|
||||
option.drag(container, diff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(int newValue) {
|
||||
if (input.isKeyDown(Input.KEY_LALT) || input.isKeyDown(Input.KEY_RALT))
|
||||
UI.changeVolume((newValue < 0) ? -1 : 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(int key, char c) {
|
||||
// key entry state
|
||||
|
||||
@@ -898,6 +898,12 @@ public class SongMenu extends BasicGameState {
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(int newValue) {
|
||||
// change volume
|
||||
if (input.isKeyDown(Input.KEY_LALT) || input.isKeyDown(Input.KEY_RALT)) {
|
||||
UI.changeVolume((newValue < 0) ? -1 : 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// block input
|
||||
if (reloadThread != null || beatmapMenuTimer > -1)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user