remove delegating stuff from Input

This commit is contained in:
yugecin
2017-05-27 02:10:32 +02:00
parent 08f5bfc27f
commit 9b5dc4c121
18 changed files with 129 additions and 266 deletions

View File

@@ -27,39 +27,40 @@ import java.util.Collections;
import org.newdawn.slick.Color;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import static org.lwjgl.input.Keyboard.*;
/**
* Game mods.
*/
public enum GameMod {
EASY (Category.EASY, 0, GameImage.MOD_EASY, "EZ", 2, Input.KEY_Q, 0.5f,
EASY (Category.EASY, 0, GameImage.MOD_EASY, "EZ", 2, KEY_Q, 0.5f,
"Easy", "Reduces overall difficulty - larger circles, more forgiving HP drain, less accuracy required."),
NO_FAIL (Category.EASY, 1, GameImage.MOD_NO_FAIL, "NF", 1, Input.KEY_W, 0.5f,
NO_FAIL (Category.EASY, 1, GameImage.MOD_NO_FAIL, "NF", 1, KEY_W, 0.5f,
"NoFail", "You can't fail. No matter what."),
HALF_TIME (Category.EASY, 2, GameImage.MOD_HALF_TIME, "HT", 256, Input.KEY_E, 0.3f,
HALF_TIME (Category.EASY, 2, GameImage.MOD_HALF_TIME, "HT", 256, KEY_E, 0.3f,
"HalfTime", "Less zoom."),
HARD_ROCK (Category.HARD, 0, GameImage.MOD_HARD_ROCK, "HR", 16, Input.KEY_A, 1.06f,
HARD_ROCK (Category.HARD, 0, GameImage.MOD_HARD_ROCK, "HR", 16, KEY_A, 1.06f,
"HardRock", "Everything just got a bit harder..."),
SUDDEN_DEATH (Category.HARD, 1, GameImage.MOD_SUDDEN_DEATH, "SD", 32, Input.KEY_S, 1f,
SUDDEN_DEATH (Category.HARD, 1, GameImage.MOD_SUDDEN_DEATH, "SD", 32, KEY_S, 1f,
"SuddenDeath", "Miss a note and fail."),
// PERFECT (Category.HARD, 1, GameImage.MOD_PERFECT, "PF", 64, Input.KEY_S, 1f,
// "Perfect", "SS or quit."),
DOUBLE_TIME (Category.HARD, 2, GameImage.MOD_DOUBLE_TIME, "DT", 64, Input.KEY_D, 1.12f,
DOUBLE_TIME (Category.HARD, 2, GameImage.MOD_DOUBLE_TIME, "DT", 64, KEY_D, 1.12f,
"DoubleTime", "Zoooooooooom."),
// NIGHTCORE (Category.HARD, 2, GameImage.MOD_NIGHTCORE, "NT", 64, Input.KEY_D, 1.12f,
// "Nightcore", "uguuuuuuuu"),
HIDDEN (Category.HARD, 3, GameImage.MOD_HIDDEN, "HD", 8, Input.KEY_F, 1.06f,
HIDDEN (Category.HARD, 3, GameImage.MOD_HIDDEN, "HD", 8, KEY_F, 1.06f,
"Hidden", "Play with no approach circles and fading notes for a slight score advantage."),
FLASHLIGHT (Category.HARD, 4, GameImage.MOD_FLASHLIGHT, "FL", 1024, Input.KEY_G, 1.12f,
FLASHLIGHT (Category.HARD, 4, GameImage.MOD_FLASHLIGHT, "FL", 1024, KEY_G, 1.12f,
"Flashlight", "Restricted view area."),
RELAX (Category.SPECIAL, 0, GameImage.MOD_RELAX, "RL", 128, Input.KEY_Z, 0f,
RELAX (Category.SPECIAL, 0, GameImage.MOD_RELAX, "RL", 128, KEY_Z, 0f,
"Relax", "You don't need to click.\nGive your clicking/tapping finger a break from the heat of things.\n**UNRANKED**"),
AUTOPILOT (Category.SPECIAL, 1, GameImage.MOD_AUTOPILOT, "AP", 8192, Input.KEY_X, 0f,
AUTOPILOT (Category.SPECIAL, 1, GameImage.MOD_AUTOPILOT, "AP", 8192, KEY_X, 0f,
"Relax2", "Automatic cursor movement - just follow the rhythm.\n**UNRANKED**"),
SPUN_OUT (Category.SPECIAL, 2, GameImage.MOD_SPUN_OUT, "SO", 4096, Input.KEY_C, 0.9f,
SPUN_OUT (Category.SPECIAL, 2, GameImage.MOD_SPUN_OUT, "SO", 4096, KEY_C, 0.9f,
"SpunOut", "Spinners will be automatically completed."),
AUTO (Category.SPECIAL, 3, GameImage.MOD_AUTO, "", 2048, Input.KEY_V, 1f,
AUTO (Category.SPECIAL, 3, GameImage.MOD_AUTO, "", 2048, KEY_V, 1f,
"Autoplay", "Watch a perfect automated play through the song.");
/** Mod categories. */

View File

@@ -35,6 +35,7 @@ import itdelatrisu.opsu.ui.animations.AnimationEquation;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Keyboard;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
@@ -650,7 +651,7 @@ public class ButtonMenu extends BaseOpsuState {
return true;
}
if (key == Input.KEY_ESCAPE) {
if (key == Keyboard.KEY_ESCAPE) {
menuState.leave();
return true;
}

View File

@@ -55,6 +55,7 @@ import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.state.ComplexOpsuState;
import yugecin.opsudance.events.BarNotifListener;
import static org.lwjgl.input.Keyboard.*;
import static yugecin.opsudance.core.InstanceContainer.*;
/**
@@ -888,12 +889,12 @@ public class DownloadsMenu extends ComplexOpsuState {
}
// block input during beatmap importing
if (importThread != null && key != Input.KEY_ESCAPE) {
if (importThread != null && key != KEY_ESCAPE) {
return true;
}
switch (key) {
case Input.KEY_ESCAPE:
case KEY_ESCAPE:
if (importThread != null) {
// beatmap importing: stop parsing beatmaps by sending interrupt to BeatmapParser
importThread.interrupt();
@@ -908,13 +909,13 @@ public class DownloadsMenu extends ComplexOpsuState {
displayContainer.switchState(mainmenuState);
}
return true;
case Input.KEY_ENTER:
case KEY_RETURN:
if (!search.getText().isEmpty()) {
pageDir = Page.RESET;
resetSearchTimer();
}
return true;
case Input.KEY_F5:
case KEY_F5:
SoundController.playSound(SoundEffect.MENUCLICK);
lastQuery = null;
pageDir = Page.CURRENT;
@@ -924,7 +925,7 @@ public class DownloadsMenu extends ComplexOpsuState {
return true;
}
// wait for user to finish typing
if (Character.isLetterOrDigit(c) || key == Input.KEY_BACK) {
if (Character.isLetterOrDigit(c) || key == KEY_BACK) {
search.keyPressed(key, c);
searchTimer = 0;
pageDir = Page.RESET;

View File

@@ -67,6 +67,7 @@ import yugecin.opsudance.ui.OptionsOverlay;
import yugecin.opsudance.ui.StoryboardOverlay;
import yugecin.opsudance.utils.GLHelper;
import static org.lwjgl.input.Keyboard.*;
import static yugecin.opsudance.options.Options.*;
import static yugecin.opsudance.core.InstanceContainer.*;
@@ -1127,7 +1128,7 @@ public class Game extends ComplexOpsuState {
}
switch (key) {
case Input.KEY_ESCAPE:
case KEY_ESCAPE:
// "auto" mod or watching replay: go back to song menu
if (GameMod.AUTO.isActive() || isReplay) {
onCloseRequest();
@@ -1144,13 +1145,13 @@ public class Game extends ComplexOpsuState {
}
displayContainer.switchStateInstantly(pauseState);
break;
case Input.KEY_SPACE:
case KEY_SPACE:
// skip intro
skipIntro();
break;
case Input.KEY_R:
case KEY_R:
// restart
if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) {
if (input.isControlDown()) {
if (trackPosition < beatmap.objects[0].getTime()) {
retries--; // don't count this retry (cancel out later increment)
}
@@ -1159,9 +1160,9 @@ public class Game extends ComplexOpsuState {
skipIntro();
}
break;
case Input.KEY_S:
case KEY_S:
// save checkpoint
if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) {
if (input.isControlDown()) {
if (isLeadIn()) {
break;
}
@@ -1175,9 +1176,9 @@ public class Game extends ComplexOpsuState {
}
}
break;
case Input.KEY_L:
case KEY_L:
// load checkpoint
if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) {
if (input.isControlDown()) {
int checkpoint = OPTION_CHECKPOINT.val * 1000;
if (checkpoint == 0 || checkpoint > beatmap.endTime)
break; // invalid checkpoint
@@ -1186,25 +1187,25 @@ public class Game extends ComplexOpsuState {
BarNotifListener.EVENT.make().onBarNotif("Checkpoint loaded.");
}
break;
case Input.KEY_F:
case KEY_F:
// change playback speed
if (isReplay || GameMod.AUTO.isActive()) {
playbackSpeed = playbackSpeed.next();
MusicController.setPitch(GameMod.getSpeedMultiplier() * playbackSpeed.getModifier());
}
break;
case Input.KEY_UP:
case KEY_UP:
UI.changeVolume(1);
break;
case Input.KEY_DOWN:
case KEY_DOWN:
UI.changeVolume(-1);
break;
case Input.KEY_TAB:
case KEY_TAB:
if (!OPTION_DANCE_HIDE_UI.state) {
scoreboardVisible = !scoreboardVisible;
}
break;
case Input.KEY_M:
case KEY_M:
if (OPTION_DANCE_MIRROR.state) {
mirrorTo = objectIndex;
} else {
@@ -1214,7 +1215,7 @@ public class Game extends ComplexOpsuState {
}
OPTION_DANCE_MIRROR.toggle();
break;
case Input.KEY_P:
case KEY_P:
if (OPTION_DANCE_MIRROR.state) {
mirrorTo = objectIndex;
} else {
@@ -1224,12 +1225,12 @@ public class Game extends ComplexOpsuState {
}
OPTION_DANCE_MIRROR.toggle();
break;
case Input.KEY_MINUS:
case KEY_MINUS:
currentMapMusicOffset += 5;
BarNotifListener.EVENT.make().onBarNotif("Current map offset: " + currentMapMusicOffset);
break;
}
if (key == Input.KEY_ADD || c == '+') {
if (key == KEY_ADD || c == '+') {
currentMapMusicOffset -= 5;
BarNotifListener.EVENT.make().onBarNotif("Current map offset: " + currentMapMusicOffset);
}

View File

@@ -32,6 +32,7 @@ import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import yugecin.opsudance.core.state.BaseOpsuState;
import static org.lwjgl.input.Keyboard.*;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*;
@@ -94,7 +95,7 @@ public class GamePauseMenu extends BaseOpsuState {
}
}
if (key == Input.KEY_ESCAPE) {
if (key == KEY_ESCAPE) {
// 'esc' will normally unpause, but will return to song menu if health is zero
if (gameState.getRestart() == Game.Restart.LOSE) {
SoundController.playSound(SoundEffect.MENUBACK);
@@ -109,7 +110,7 @@ public class GamePauseMenu extends BaseOpsuState {
return true;
}
if (key == Input.KEY_R && (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL))) {
if (key == KEY_R && input.isControlDown()) {
gameState.setRestart(Game.Restart.MANUAL);
displayContainer.switchState(gameState);
return true;

View File

@@ -32,6 +32,7 @@ import itdelatrisu.opsu.ui.UI;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.lwjgl.input.Keyboard;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
@@ -121,7 +122,7 @@ public class GameRanking extends BaseOpsuState {
return true;
}
if (key == Input.KEY_ESCAPE) {
if (key == Keyboard.KEY_ESCAPE) {
returnToSongMenu();
}
return true;

View File

@@ -51,6 +51,7 @@ import yugecin.opsudance.core.state.OpsuState;
import yugecin.opsudance.events.BarNotifListener;
import yugecin.opsudance.events.BubNotifListener;
import static org.lwjgl.input.Keyboard.*;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*;
@@ -651,8 +652,8 @@ public class MainMenu extends BaseOpsuState {
}
switch (key) {
case Input.KEY_ESCAPE:
case Input.KEY_Q:
case KEY_ESCAPE:
case KEY_Q:
if (logoTimer > 0) {
logoState = LogoState.CLOSING;
logoClose.setTime(0);
@@ -662,7 +663,7 @@ public class MainMenu extends BaseOpsuState {
buttonState.setMenuState(MenuState.EXIT);
displayContainer.switchState(buttonState);
return true;
case Input.KEY_P:
case KEY_P:
SoundController.playSound(SoundEffect.MENUHIT);
if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) {
logoState = LogoState.OPENING;
@@ -673,17 +674,17 @@ public class MainMenu extends BaseOpsuState {
} else
enterSongMenu();
return true;
case Input.KEY_D:
case KEY_D:
SoundController.playSound(SoundEffect.MENUHIT);
displayContainer.switchState(downloadState);
return true;
case Input.KEY_R:
case KEY_R:
nextTrack(true);
return true;
case Input.KEY_UP:
case KEY_UP:
UI.changeVolume(1);
return true;
case Input.KEY_DOWN:
case KEY_DOWN:
UI.changeVolume(-1);
return true;
}

View File

@@ -55,6 +55,7 @@ import java.nio.file.WatchEvent.Kind;
import java.util.Map;
import java.util.Stack;
import org.lwjgl.input.Mouse;
import org.newdawn.slick.Animation;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
@@ -67,6 +68,7 @@ import yugecin.opsudance.events.BarNotifListener;
import yugecin.opsudance.options.OptionGroups;
import yugecin.opsudance.ui.OptionsOverlay;
import static org.lwjgl.input.Keyboard.*;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*;
@@ -914,13 +916,13 @@ public class SongMenu extends ComplexOpsuState {
// selection buttons
if (selectModsButton.contains(x, y)) {
this.keyPressed(Input.KEY_F1, '\0');
this.keyPressed(KEY_F1, '\0');
return true;
} else if (selectRandomButton.contains(x, y)) {
this.keyPressed(Input.KEY_F2, '\0');
this.keyPressed(KEY_F2, '\0');
return true;
} else if (selectMapOptionsButton.contains(x, y)) {
this.keyPressed(Input.KEY_F3, '\0');
this.keyPressed(KEY_F3, '\0');
return true;
} else if (selectOptionsButton.contains(x, y)) {
SoundController.playSound(SoundEffect.MENUHIT);
@@ -1038,12 +1040,12 @@ public class SongMenu extends ComplexOpsuState {
}
// block input
if ((reloadThread != null && key != Input.KEY_ESCAPE) || beatmapMenuTimer > -1 || isScrollingToFocusNode) {
if ((reloadThread != null && key != KEY_ESCAPE) || beatmapMenuTimer > -1 || isScrollingToFocusNode) {
return true;
}
switch (key) {
case Input.KEY_ESCAPE:
case KEY_ESCAPE:
if (reloadThread != null) {
// beatmap reloading: stop parsing beatmaps by sending interrupt to BeatmapParser
reloadThread.interrupt();
@@ -1059,16 +1061,16 @@ public class SongMenu extends ComplexOpsuState {
displayContainer.switchState(mainmenuState);
}
return true;
case Input.KEY_F1:
case KEY_F1:
SoundController.playSound(SoundEffect.MENUHIT);
buttonState.setMenuState(MenuState.MODS);
displayContainer.switchState(buttonState);
return true;
case Input.KEY_F2:
case KEY_F2:
if (focusNode == null)
break;
SoundController.playSound(SoundEffect.MENUHIT);
if (input.isKeyDown(Input.KEY_RSHIFT) || input.isKeyDown(Input.KEY_LSHIFT)) {
if (isKeyDown(KEY_RSHIFT) || isKeyDown(KEY_LSHIFT)) {
// shift key: previous random track
SongNode prev;
if (randomStack.isEmpty() || (prev = randomStack.pop()) == null)
@@ -1084,7 +1086,7 @@ public class SongMenu extends ComplexOpsuState {
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
}
return true;
case Input.KEY_F3:
case KEY_F3:
if (focusNode == null)
break;
SoundController.playSound(SoundEffect.MENUHIT);
@@ -1093,7 +1095,7 @@ public class SongMenu extends ComplexOpsuState {
buttonState.setMenuState(state, focusNode);
displayContainer.switchState(buttonState);
return true;
case Input.KEY_F5:
case KEY_F5:
SoundController.playSound(SoundEffect.MENUHIT);
if (songFolderChanged)
reloadBeatmaps(false);
@@ -1102,10 +1104,10 @@ public class SongMenu extends ComplexOpsuState {
displayContainer.switchState(buttonState);
}
return true;
case Input.KEY_DELETE:
case KEY_DELETE:
if (focusNode == null)
break;
if (input.isKeyDown(Input.KEY_RSHIFT) || input.isKeyDown(Input.KEY_LSHIFT)) {
if (isKeyDown(KEY_RSHIFT) || isKeyDown(KEY_LSHIFT)) {
SoundController.playSound(SoundEffect.MENUHIT);
MenuState ms = (focusNode.beatmapIndex == -1 || focusNode.getBeatmapSet().size() == 1) ?
MenuState.BEATMAP_DELETE_CONFIRM : MenuState.BEATMAP_DELETE_SELECT;
@@ -1113,18 +1115,18 @@ public class SongMenu extends ComplexOpsuState {
displayContainer.switchState(buttonState);
}
return true;
case Input.KEY_ENTER:
case KEY_RETURN:
if (focusNode == null)
break;
startGame();
return true;
case Input.KEY_DOWN:
case KEY_DOWN:
changeIndex(1);
return true;
case Input.KEY_UP:
case KEY_UP:
changeIndex(-1);
return true;
case Input.KEY_RIGHT:
case KEY_RIGHT:
if (focusNode == null)
break;
BeatmapSetNode next = focusNode.next;
@@ -1140,7 +1142,7 @@ public class SongMenu extends ComplexOpsuState {
}
}
return true;
case Input.KEY_LEFT:
case KEY_LEFT:
if (focusNode == null)
break;
BeatmapSetNode prev = focusNode.prev;
@@ -1156,25 +1158,25 @@ public class SongMenu extends ComplexOpsuState {
}
}
return true;
case Input.KEY_NEXT:
case KEY_NEXT:
changeIndex(MAX_SONG_BUTTONS);
return true;
case Input.KEY_PRIOR:
case KEY_PRIOR:
changeIndex(-MAX_SONG_BUTTONS);
return true;
}
if (key == Input.KEY_O && (input.isKeyDown(Input.KEY_LCONTROL) || input.isKeyDown(Input.KEY_RCONTROL))) {
if (key == KEY_O && input.isControlDown()) {
optionsOverlay.show();
return true;
}
// wait for user to finish typing
// TODO: accept all characters (current conditions are from TextField class)
if ((c > 31 && c < 127) || key == Input.KEY_BACK) {
if ((c > 31 && c < 127) || key == KEY_BACK) {
searchTimer = 0;
searchTextField.keyPressed(key, c);
int textLength = searchTextField.getText().length();
if (lastSearchTextLength != textLength) {
if (key == Input.KEY_BACK) {
if (key == KEY_BACK) {
if (textLength == 0)
searchTransitionTimer = 0;
} else if (textLength == 1)
@@ -1202,9 +1204,9 @@ public class SongMenu extends ComplexOpsuState {
// check mouse button (right click scrolls faster on songs)
int multiplier;
if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) {
if (Mouse.isButtonDown(Input.MOUSE_RIGHT_BUTTON)) {
multiplier = 10;
} else if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
} else if (Mouse.isButtonDown(Input.MOUSE_LEFT_BUTTON)) {
multiplier = 1;
} else {
return false;
@@ -1764,9 +1766,8 @@ public class SongMenu extends ComplexOpsuState {
}
// turn on "auto" mod if holding "ctrl" key
if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) {
if (!GameMod.AUTO.isActive())
GameMod.AUTO.toggle(true);
if (input.isControlDown() && !GameMod.AUTO.isActive()) {
GameMod.AUTO.toggle(true);
}
SoundController.playSound(SoundEffect.MENUHIT);

View File

@@ -24,6 +24,7 @@ import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.beatmap.BeatmapSetList;
import itdelatrisu.opsu.ui.UI;
import org.lwjgl.input.Keyboard;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
@@ -128,7 +129,7 @@ public class Splash extends BaseOpsuState {
@Override
public boolean keyPressed(int key, char c) {
if (key != Input.KEY_ESCAPE) {
if (key != Keyboard.KEY_ESCAPE) {
return false;
}
if (++escapeCount >= 3) {

View File

@@ -22,6 +22,7 @@ import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.ui.animations.AnimatedValue;
import itdelatrisu.opsu.ui.animations.AnimationEquation;
import org.lwjgl.input.Keyboard;
import org.newdawn.slick.Color;
import org.newdawn.slick.Font;
import org.newdawn.slick.Graphics;
@@ -82,7 +83,7 @@ public class DropdownMenu<E> extends Component {
@Override
public void keyPressed(int key, char c) {
if (key == Input.KEY_ESCAPE) {
if (key == Keyboard.KEY_ESCAPE) {
this.expanded = false;
}
}