strip Input handling
This commit is contained in:
File diff suppressed because it is too large
Load Diff
10
src/org/newdawn/slick/InputListener.java
Normal file
10
src/org/newdawn/slick/InputListener.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package org.newdawn.slick;
|
||||
|
||||
/**
|
||||
* A listener that will be notified of keyboard and mouse events
|
||||
* Edited for opsu!
|
||||
*
|
||||
* @author kevin
|
||||
*/
|
||||
public interface InputListener extends MouseListener, KeyListener {
|
||||
}
|
||||
27
src/org/newdawn/slick/KeyListener.java
Normal file
27
src/org/newdawn/slick/KeyListener.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package org.newdawn.slick;
|
||||
|
||||
/**
|
||||
* Describes classes capable of responding to key presses
|
||||
* Edited for opsu!
|
||||
*
|
||||
* @author kevin
|
||||
*/
|
||||
public interface KeyListener {
|
||||
|
||||
/**
|
||||
* Notification that a key was pressed
|
||||
*
|
||||
* @param key The key code that was pressed (@see org.newdawn.slick.Input)
|
||||
* @param c The character of the key that was pressed
|
||||
*/
|
||||
boolean keyPressed(int key, char c);
|
||||
|
||||
/**
|
||||
* Notification that a key was released
|
||||
*
|
||||
* @param key The key code that was released (@see org.newdawn.slick.Input)
|
||||
* @param c The character of the key that was released
|
||||
*/
|
||||
boolean keyReleased(int key, char c);
|
||||
|
||||
}
|
||||
46
src/org/newdawn/slick/MouseListener.java
Normal file
46
src/org/newdawn/slick/MouseListener.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package org.newdawn.slick;
|
||||
|
||||
/**
|
||||
* Description of classes that respond to mouse related input events
|
||||
* Edited for opsu!
|
||||
*
|
||||
* @author kevin
|
||||
*/
|
||||
public interface MouseListener {
|
||||
|
||||
/**
|
||||
* Notification that the mouse wheel position was updated
|
||||
*
|
||||
* @param delta The amount of the wheel has moved
|
||||
*/
|
||||
boolean mouseWheelMoved(int delta);
|
||||
|
||||
/**
|
||||
* Notification that a mouse button was pressed
|
||||
*
|
||||
* @param button The index of the button (starting at 0)
|
||||
* @param x The x position of the mouse when the button was pressed
|
||||
* @param y The y position of the mouse when the button was pressed
|
||||
*/
|
||||
boolean mousePressed(int button, int x, int y);
|
||||
|
||||
/**
|
||||
* Notification that a mouse button was released
|
||||
*
|
||||
* @param button The index of the button (starting at 0)
|
||||
* @param x The x position of the mouse when the button was released
|
||||
* @param y The y position of the mouse when the button was released
|
||||
*/
|
||||
boolean mouseReleased(int button, int x, int y);
|
||||
|
||||
/**
|
||||
* Notification that mouse cursor was dragged
|
||||
*
|
||||
* @param oldx The old x position of the mouse
|
||||
* @param oldy The old y position of the mouse
|
||||
* @param newx The new x position of the mouse
|
||||
* @param newy The new y position of the mouse
|
||||
*/
|
||||
boolean mouseDragged(int oldx, int oldy, int newx, int newy);
|
||||
|
||||
}
|
||||
@@ -34,10 +34,11 @@ import org.newdawn.slick.Font;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.geom.Rectangle;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
import yugecin.opsudance.core.components.ActionListener;
|
||||
import yugecin.opsudance.core.components.Component;
|
||||
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
/**
|
||||
* A single text field supporting text entry
|
||||
*
|
||||
@@ -48,8 +49,6 @@ public class TextField extends Component {
|
||||
private static final int INITIAL_KEY_REPEAT_INTERVAL = 400;
|
||||
private static final int KEY_REPEAT_INTERVAL = 50;
|
||||
|
||||
private final DisplayContainer displayContainer;
|
||||
|
||||
private String value = "";
|
||||
private Font font;
|
||||
private int maxCharacter = 10000;
|
||||
@@ -65,8 +64,7 @@ public class TextField extends Component {
|
||||
|
||||
private ActionListener listener;
|
||||
|
||||
public TextField(DisplayContainer displayContainer, Font font, int x, int y, int width, int height) {
|
||||
this.displayContainer = displayContainer;
|
||||
public TextField(Font font, int x, int y, int width, int height) {
|
||||
this.font = font;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -97,7 +95,7 @@ public class TextField extends Component {
|
||||
|
||||
public void render(Graphics g) {
|
||||
if (lastKey != -1) {
|
||||
if (displayContainer.input.isKeyDown(lastKey)) {
|
||||
if (input.isKeyDown(lastKey)) {
|
||||
if (repeatTimer < System.currentTimeMillis()) {
|
||||
repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL;
|
||||
keyPressed(lastKey, lastChar);
|
||||
@@ -173,7 +171,7 @@ public class TextField extends Component {
|
||||
if (key != -1)
|
||||
{
|
||||
if ((key == Input.KEY_V) &&
|
||||
((displayContainer.input.isKeyDown(Input.KEY_LCONTROL)) || (displayContainer.input.isKeyDown(Input.KEY_RCONTROL)))) {
|
||||
((input.isKeyDown(Input.KEY_LCONTROL)) || (input.isKeyDown(Input.KEY_RCONTROL)))) {
|
||||
String text = Sys.getClipboard();
|
||||
if (text != null) {
|
||||
doPaste(text);
|
||||
@@ -208,7 +206,7 @@ public class TextField extends Component {
|
||||
}
|
||||
*/ } else if (key == Input.KEY_BACK) {
|
||||
if ((cursorPos > 0) && (value.length() > 0)) {
|
||||
if (displayContainer.input.isKeyDown(Input.KEY_LCONTROL) || displayContainer.input.isKeyDown(Input.KEY_RCONTROL)) {
|
||||
if (input.isKeyDown(Input.KEY_LCONTROL) || input.isKeyDown(Input.KEY_RCONTROL)) {
|
||||
int sp = 0;
|
||||
boolean startSpace = Character.isWhitespace(value.charAt(cursorPos - 1));
|
||||
boolean charSeen = false;
|
||||
|
||||
Reference in New Issue
Block a user