Package com.csse3200.game.ui.terminal
Class TouchTerminalInputComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.input.InputComponent
com.csse3200.game.ui.terminal.TouchTerminalInputComponent
- All Implemented Interfaces:
com.badlogic.gdx.input.GestureDetector.GestureListener
,com.badlogic.gdx.InputProcessor
Input handler for the debug terminal for keyboard and touch (mouse) input.
This input handler uses keyboard and touch input.
The debug terminal can be opened and closed by scrolling vertically and a message can be entered via the keyboard.
-
Field Summary
Fields inherited from class com.csse3200.game.input.InputComponent
priority
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Called when the entity is created and registered.boolean
keyDown
(int keycode) Handles input if the terminal is open.boolean
keyTyped
(char character) Handles input if the terminal is open.boolean
keyUp
(int keycode) Handles input if the terminal is open.boolean
scrolled
(float amountX, float amountY) Scrolling up will open the terminal and scrolling down will close the terminal.Methods inherited from class com.csse3200.game.input.InputComponent
dispose, fling, getPriority, longPress, mouseMoved, pan, panStop, pinch, pinchStop, pinchStopHandled, setPriority, tap, touchDown, touchDown, touchDragged, touchUp, zoom
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
TouchTerminalInputComponent
public TouchTerminalInputComponent() -
TouchTerminalInputComponent
-
-
Method Details
-
create
public void create()Description copied from class:Component
Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.- Overrides:
create
in classInputComponent
-
keyDown
public boolean keyDown(int keycode) Handles input if the terminal is open. This is because keyDown events are triggered alongside keyTyped events. If the user is typing in the terminal, the input shouldn't trigger any other input handlers.- Specified by:
keyDown
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
keyDown
in classInputComponent
- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.keyDown(int)
-
keyTyped
public boolean keyTyped(char character) Handles input if the terminal is open. If 'enter' is typed, the entered message will be processed, otherwise the message will be updated with the new character.- Specified by:
keyTyped
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
keyTyped
in classInputComponent
- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.keyTyped(char)
-
keyUp
public boolean keyUp(int keycode) Handles input if the terminal is open. This is because keyUp events are triggered alongside keyTyped events. If the user is typing in the terminal, the input shouldn't trigger any other input handlers.- Specified by:
keyUp
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
keyUp
in classInputComponent
- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.keyUp(int)
-
scrolled
public boolean scrolled(float amountX, float amountY) Scrolling up will open the terminal and scrolling down will close the terminal.- Specified by:
scrolled
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
scrolled
in classInputComponent
- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.scrolled(float, float)
-