Package com.csse3200.game.ui.terminal
Class BaseTerminalInputComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.input.InputComponent
com.csse3200.game.ui.terminal.BaseTerminalInputComponent
- All Implemented Interfaces:
com.badlogic.gdx.input.GestureDetector.GestureListener
,com.badlogic.gdx.InputProcessor
- Direct Known Subclasses:
KeyboardTerminalInputComponent
,TouchTerminalInputComponent
-
Field Summary
FieldsFields 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.protected boolean
Returns false because this component is not one intended to be pausedabstract boolean
keyPressed
(int keycode) If the toggle key is pressed, the terminal will open / close.boolean
keyReleased
(int keycode) Handles input if the terminal is open.boolean
keyTyped
(char character) Handles input if the terminal is open.Methods inherited from class com.csse3200.game.input.InputComponent
dispose, fling, getPriority, keyDown, keyUp, longPress, mouseMoved, pan, panStop, pinch, pinchStop, pinchStopHandled, scrolled, setPriority, tap, touchDown, touchDown, touchDragged, touchUp, zoom
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Field Details
-
terminal
-
-
Constructor Details
-
BaseTerminalInputComponent
protected BaseTerminalInputComponent() -
BaseTerminalInputComponent
-
-
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
-
isPauseable
protected boolean isPauseable()Returns false because this component is not one intended to be paused- Overrides:
isPauseable
in classInputComponent
- Returns:
- False, as this is a component not affected by pause functionality
-
keyPressed
public abstract boolean keyPressed(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:
keyPressed
in classInputComponent
- Parameters:
keycode
- The key code of the key that was pressed.- Returns:
- whether the input was processed
- See Also:
-
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:
-
keyReleased
public boolean keyReleased(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:
keyReleased
in classInputComponent
- Parameters:
keycode
- The key code of the key that was pressed.- Returns:
- whether the input was processed
- See Also:
-