From 06a5deb3a158911c39849a51fdcb5ecc8fa4e583 Mon Sep 17 00:00:00 2001 From: yugecin Date: Wed, 18 Jan 2017 22:46:45 +0100 Subject: [PATCH] process common hotkeys in base state --- src/itdelatrisu/opsu/Options.java | 6 +++--- src/itdelatrisu/opsu/states/ButtonMenu.java | 20 +++++++------------ .../opsu/states/DownloadsMenu.java | 12 +---------- src/itdelatrisu/opsu/states/MainMenu.java | 13 ++++-------- src/itdelatrisu/opsu/states/SongMenu.java | 16 +++++---------- .../opsudance/core/state/BaseOpsuState.java | 15 ++++++++++++++ .../core/state/ComplexOpsuState.java | 3 +++ 7 files changed, 38 insertions(+), 47 deletions(-) diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index 2c033336..272b3057 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -395,8 +395,7 @@ public class Options { @Override public void clickListItem(int index) { targetFPSindex = index; - Container.instance.setTargetFrameRate(targetFPS[index]); - Container.instance.setVSync(targetFPS[index] == 60); + displayContainer.setFPS(targetFPS[index]); } @Override @@ -985,6 +984,7 @@ public class Options { PIPPI_SLIDER_FOLLOW_EXPAND ("Followcircle expand", "PippiFollowExpand", "Increase radius in followcircles", false), PIPPI_PREVENT_WOBBLY_STREAMS ("Prevent wobbly streams", "PippiPreventWobblyStreams", "Force linear mover while doing streams to prevent wobbly pippi", true); + public static DisplayContainer displayContainer; /** Option name. */ private final String name; @@ -1283,9 +1283,9 @@ public class Options { * bar notification about the action. */ public static void setNextFPS(DisplayContainer displayContainer) { + GameOption.displayContainer = displayContainer; // TODO dirty shit GameOption.TARGET_FPS.clickListItem((targetFPSindex + 1) % targetFPS.length); UI.sendBarNotification(String.format("Frame limiter: %s", GameOption.TARGET_FPS.getValueString())); - displayContainer.setFPS(GameOption.TARGET_FPS.val); } /** diff --git a/src/itdelatrisu/opsu/states/ButtonMenu.java b/src/itdelatrisu/opsu/states/ButtonMenu.java index 8533dbf9..ca899a0d 100644 --- a/src/itdelatrisu/opsu/states/ButtonMenu.java +++ b/src/itdelatrisu/opsu/states/ButtonMenu.java @@ -667,21 +667,15 @@ public class ButtonMenu extends BaseOpsuState { @Override public boolean keyPressed(int key, char c) { - switch (key) { - case Input.KEY_ESCAPE: - menuState.leave(); - return true; - case Input.KEY_F7: - // TODO - //Options.setNextFPS(displayContainer); - return true; - case Input.KEY_F10: - Options.toggleMouseDisabled(); - return true; - case Input.KEY_F12: - Utils.takeScreenShot(); + if (super.keyPressed(key, c)) { return true; } + + if (key == Input.KEY_ESCAPE) { + menuState.leave(); + return true; + } + menuState.keyPressed(key, c); return true; } diff --git a/src/itdelatrisu/opsu/states/DownloadsMenu.java b/src/itdelatrisu/opsu/states/DownloadsMenu.java index ed6e47ec..6a2e7c89 100644 --- a/src/itdelatrisu/opsu/states/DownloadsMenu.java +++ b/src/itdelatrisu/opsu/states/DownloadsMenu.java @@ -893,7 +893,7 @@ public class DownloadsMenu extends ComplexOpsuState { } // block input during beatmap importing - if (importThread != null && !(key == Input.KEY_ESCAPE || key == Input.KEY_F12)) { + if (importThread != null && key != Input.KEY_ESCAPE) { return true; } @@ -928,16 +928,6 @@ public class DownloadsMenu extends ComplexOpsuState { searchQuery.interrupt(); resetSearchTimer(); return true; - case Input.KEY_F7: - // TODO d - //Options.setNextFPS(container); - return true; - case Input.KEY_F10: - Options.toggleMouseDisabled(); - return true; - case Input.KEY_F12: - Utils.takeScreenShot(); - return true; } // wait for user to finish typing if (Character.isLetterOrDigit(c) || key == Input.KEY_BACK) { diff --git a/src/itdelatrisu/opsu/states/MainMenu.java b/src/itdelatrisu/opsu/states/MainMenu.java index d1f63a9e..8bf821c0 100644 --- a/src/itdelatrisu/opsu/states/MainMenu.java +++ b/src/itdelatrisu/opsu/states/MainMenu.java @@ -634,6 +634,10 @@ public class MainMenu extends BaseOpsuState { @Override public boolean keyPressed(int key, char c) { + if (super.keyPressed(key, c)) { + return true; + } + switch (key) { case Input.KEY_ESCAPE: case Input.KEY_Q: @@ -670,15 +674,6 @@ public class MainMenu extends BaseOpsuState { case Input.KEY_DOWN: UI.changeVolume(-1); return true; - case Input.KEY_F7: - Options.setNextFPS(displayContainer); - return true; - case Input.KEY_F10: - Options.toggleMouseDisabled(); - return true; - case Input.KEY_F12: - Utils.takeScreenShot(); - return true; } return false; } diff --git a/src/itdelatrisu/opsu/states/SongMenu.java b/src/itdelatrisu/opsu/states/SongMenu.java index 3741aab4..788fb9a8 100644 --- a/src/itdelatrisu/opsu/states/SongMenu.java +++ b/src/itdelatrisu/opsu/states/SongMenu.java @@ -1064,8 +1064,12 @@ public class SongMenu extends BaseOpsuState { @Override public boolean keyPressed(int key, char c) { + if (super.keyPressed(key, c)) { + return true; + } + // block input - if ((reloadThread != null && !(key == Input.KEY_ESCAPE || key == Input.KEY_F12)) || beatmapMenuTimer > -1 || isScrollingToFocusNode) { + if ((reloadThread != null && key != Input.KEY_ESCAPE) || beatmapMenuTimer > -1 || isScrollingToFocusNode) { return true; } @@ -1145,16 +1149,6 @@ public class SongMenu extends BaseOpsuState { displayContainer.switchState(ButtonMenu.class); } return true; - case Input.KEY_F7: - // TODO d - //Options.setNextFPS(container); - return true; - case Input.KEY_F10: - Options.toggleMouseDisabled(); - return true; - case Input.KEY_F12: - Utils.takeScreenShot(); - return true; case Input.KEY_ENTER: if (focusNode == null) break; diff --git a/src/yugecin/opsudance/core/state/BaseOpsuState.java b/src/yugecin/opsudance/core/state/BaseOpsuState.java index 8c13315d..86bdfb9c 100644 --- a/src/yugecin/opsudance/core/state/BaseOpsuState.java +++ b/src/yugecin/opsudance/core/state/BaseOpsuState.java @@ -17,7 +17,10 @@ */ package yugecin.opsudance.core.state; +import itdelatrisu.opsu.Options; +import itdelatrisu.opsu.Utils; import org.newdawn.slick.Graphics; +import org.newdawn.slick.Input; import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.events.EventListener; import yugecin.opsudance.events.ResolutionChangedEvent; @@ -89,6 +92,18 @@ public abstract class BaseOpsuState implements OpsuState, EventListener