process common hotkeys in base state

This commit is contained in:
yugecin 2017-01-18 22:46:45 +01:00
parent 81b71d5703
commit 06a5deb3a1
7 changed files with 38 additions and 47 deletions

View File

@ -395,8 +395,7 @@ public class Options {
@Override @Override
public void clickListItem(int index) { public void clickListItem(int index) {
targetFPSindex = index; targetFPSindex = index;
Container.instance.setTargetFrameRate(targetFPS[index]); displayContainer.setFPS(targetFPS[index]);
Container.instance.setVSync(targetFPS[index] == 60);
} }
@Override @Override
@ -985,6 +984,7 @@ public class Options {
PIPPI_SLIDER_FOLLOW_EXPAND ("Followcircle expand", "PippiFollowExpand", "Increase radius in followcircles", false), 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); 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. */ /** Option name. */
private final String name; private final String name;
@ -1283,9 +1283,9 @@ public class Options {
* bar notification about the action. * bar notification about the action.
*/ */
public static void setNextFPS(DisplayContainer displayContainer) { public static void setNextFPS(DisplayContainer displayContainer) {
GameOption.displayContainer = displayContainer; // TODO dirty shit
GameOption.TARGET_FPS.clickListItem((targetFPSindex + 1) % targetFPS.length); GameOption.TARGET_FPS.clickListItem((targetFPSindex + 1) % targetFPS.length);
UI.sendBarNotification(String.format("Frame limiter: %s", GameOption.TARGET_FPS.getValueString())); UI.sendBarNotification(String.format("Frame limiter: %s", GameOption.TARGET_FPS.getValueString()));
displayContainer.setFPS(GameOption.TARGET_FPS.val);
} }
/** /**

View File

@ -667,21 +667,15 @@ public class ButtonMenu extends BaseOpsuState {
@Override @Override
public boolean keyPressed(int key, char c) { public boolean keyPressed(int key, char c) {
switch (key) { if (super.keyPressed(key, c)) {
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();
return true; return true;
} }
if (key == Input.KEY_ESCAPE) {
menuState.leave();
return true;
}
menuState.keyPressed(key, c); menuState.keyPressed(key, c);
return true; return true;
} }

View File

@ -893,7 +893,7 @@ public class DownloadsMenu extends ComplexOpsuState {
} }
// block input during beatmap importing // 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; return true;
} }
@ -928,16 +928,6 @@ public class DownloadsMenu extends ComplexOpsuState {
searchQuery.interrupt(); searchQuery.interrupt();
resetSearchTimer(); resetSearchTimer();
return true; 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 // wait for user to finish typing
if (Character.isLetterOrDigit(c) || key == Input.KEY_BACK) { if (Character.isLetterOrDigit(c) || key == Input.KEY_BACK) {

View File

@ -634,6 +634,10 @@ public class MainMenu extends BaseOpsuState {
@Override @Override
public boolean keyPressed(int key, char c) { public boolean keyPressed(int key, char c) {
if (super.keyPressed(key, c)) {
return true;
}
switch (key) { switch (key) {
case Input.KEY_ESCAPE: case Input.KEY_ESCAPE:
case Input.KEY_Q: case Input.KEY_Q:
@ -670,15 +674,6 @@ public class MainMenu extends BaseOpsuState {
case Input.KEY_DOWN: case Input.KEY_DOWN:
UI.changeVolume(-1); UI.changeVolume(-1);
return true; 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; return false;
} }

View File

@ -1064,8 +1064,12 @@ public class SongMenu extends BaseOpsuState {
@Override @Override
public boolean keyPressed(int key, char c) { public boolean keyPressed(int key, char c) {
if (super.keyPressed(key, c)) {
return true;
}
// block input // 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; return true;
} }
@ -1145,16 +1149,6 @@ public class SongMenu extends BaseOpsuState {
displayContainer.switchState(ButtonMenu.class); displayContainer.switchState(ButtonMenu.class);
} }
return true; 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: case Input.KEY_ENTER:
if (focusNode == null) if (focusNode == null)
break; break;

View File

@ -17,7 +17,10 @@
*/ */
package yugecin.opsudance.core.state; package yugecin.opsudance.core.state;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import yugecin.opsudance.core.DisplayContainer; import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventListener; import yugecin.opsudance.core.events.EventListener;
import yugecin.opsudance.events.ResolutionChangedEvent; import yugecin.opsudance.events.ResolutionChangedEvent;
@ -89,6 +92,18 @@ public abstract class BaseOpsuState implements OpsuState, EventListener<Resoluti
@Override @Override
public boolean keyReleased(int key, char c) { public boolean keyReleased(int key, char c) {
if (key == Input.KEY_F7) {
Options.setNextFPS(displayContainer);
return true;
}
if (key == Input.KEY_F10) {
Options.toggleMouseDisabled();
return true;
}
if (key == Input.KEY_F12) {
Utils.takeScreenShot();
return true;
}
return false; return false;
} }

View File

@ -95,6 +95,9 @@ public class ComplexOpsuState extends BaseOpsuState {
@Override @Override
public boolean keyReleased(int key, char c) { public boolean keyReleased(int key, char c) {
if (super.keyReleased(key, c)) {
return true;
}
if (focusedComponent != null) { if (focusedComponent != null) {
if (key == Input.KEY_ESCAPE) { if (key == Input.KEY_ESCAPE) {
focusedComponent.setFocused(false); focusedComponent.setFocused(false);