Package com.deco2800.game.ui.terminal
Class KeyboardTerminalInputComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.input.InputComponent
com.deco2800.game.ui.terminal.KeyboardTerminalInputComponent
- 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 only uses keyboard input.
The debug terminal can be opened and closed by pressing 'F1' and a message can be entered via the keyboard.
-
Field Summary
Fields inherited from class com.deco2800.game.input.InputComponent
priority -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Called when the entity is created and registered.booleankeyDown(int keycode) If the toggle key is pressed, the terminal will open / close.booleankeyTyped(char character) Handles input if the terminal is open.booleankeyUp(int keycode) Handles input if the terminal is open.Methods inherited from class com.deco2800.game.input.InputComponent
dispose, fling, getPriority, longPress, mouseMoved, pan, panStop, pinch, pinchStop, pinchStopHandled, scrolled, setPriority, tap, touchDown, touchDown, touchDragged, touchUp, zoomMethods inherited from class com.deco2800.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
KeyboardTerminalInputComponent
public KeyboardTerminalInputComponent() -
KeyboardTerminalInputComponent
-
-
Method Details
-
create
public void create()Description copied from class:ComponentCalled 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:
createin classInputComponent
-
keyDown
public boolean keyDown(int keycode) If the toggle key is pressed, the terminal will open / close.Otherwise, 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:
keyDownin interfacecom.badlogic.gdx.InputProcessor- Overrides:
keyDownin 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:
keyTypedin interfacecom.badlogic.gdx.InputProcessor- Overrides:
keyTypedin 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:
keyUpin interfacecom.badlogic.gdx.InputProcessor- Overrides:
keyUpin classInputComponent- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.keyUp(int)
-