diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index 43ce5b27..f43e1365 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -735,14 +735,13 @@ public class Options { /** * Sets the left game key. - * This will not be set to the same key as the right game key, nor to reserved keys like ESCAPE. + * This will not be set to the same key as the right game key, nor to any + * reserved keys (see {@link #isValidGameKey(int)}). * @param key the keyboard key * @return {@code true} if the key was set, {@code false} if it was rejected */ public static boolean setGameKeyLeft(int key) { - if (key == keyRight && key != Keyboard.KEY_NONE) - return false; - if (!isValidClickKey(key)) + if ((key == keyRight && key != Keyboard.KEY_NONE) || !isValidGameKey(key)) return false; keyLeft = key; return true; @@ -750,19 +749,29 @@ public class Options { /** * Sets the right game key. - * This will not be set to the same key as the left game key, nor to reserved keys like ESCAPE. + * This will not be set to the same key as the left game key, nor to any + * reserved keys (see {@link #isValidGameKey(int)}). * @param key the keyboard key * @return {@code true} if the key was set, {@code false} if it was rejected */ public static boolean setGameKeyRight(int key) { - if (key == keyLeft && key != Keyboard.KEY_NONE) - return false; - if (!isValidClickKey(key)) + if ((key == keyLeft && key != Keyboard.KEY_NONE) || !isValidGameKey(key)) return false; keyRight = key; return true; } + /** + * Checks if the given key is a valid game key. + * @param key the keyboard key + * @return {@code true} if valid, {@code false} otherwise + */ + private static boolean isValidGameKey(int key) { + return (key != Keyboard.KEY_ESCAPE && key != Keyboard.KEY_SPACE && + key != Keyboard.KEY_UP && key != Keyboard.KEY_DOWN && + key != Keyboard.KEY_F7 && key != Keyboard.KEY_F10 && key != Keyboard.KEY_F12); + } + /** * Returns the beatmap directory. * If invalid, this will attempt to search for the directory, @@ -849,10 +858,6 @@ public class Options { return osu; } - public static boolean isValidClickKey(int keyCode) { - return keyCode != Keyboard.KEY_ESCAPE; - } - /** * Reads user options from the options file, if it exists. */ diff --git a/src/itdelatrisu/opsu/states/OptionsMenu.java b/src/itdelatrisu/opsu/states/OptionsMenu.java index e8e127e7..3934f572 100644 --- a/src/itdelatrisu/opsu/states/OptionsMenu.java +++ b/src/itdelatrisu/opsu/states/OptionsMenu.java @@ -243,14 +243,9 @@ public class OptionsMenu extends BasicGameState { g.setColor(Utils.COLOR_BLACK_ALPHA); g.fillRect(0, 0, width, height); g.setColor(Color.white); - - String prompt; - if (keyEntryLeft) { - prompt = "Please press the new left-click key"; - } else { - prompt = "Please press the new right-click key"; - } - + String prompt = (keyEntryLeft) ? + "Please press the new left-click key." : + "Please press the new right-click key."; Utils.FONT_LARGE.drawString( (width / 2) - (Utils.FONT_LARGE.getWidth(prompt) / 2), (height / 2) - Utils.FONT_LARGE.getLineHeight(), prompt