Package com.csse3200.game.ui.terminal
Class Terminal
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.ui.terminal.Terminal
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
State tracker for a debug terminal. Any commands to be actioned through the terminal input should
be added to the map of commands.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommand(String name, Command command) Adds a command to the list of valid terminal commands.voidappendToMessage(char character) Appends the character to the end of the entered message.voidRemoves the last character of the entered message.booleanisOpen()booleanProcesses the completed message entered by the user.voidCloses the terminal and clears the stored message.voidsetEnteredMessage(String text) Sets the text shown on the terminalvoidsetOpen()Opens the terminal.voidToggles between the terminal being open and closed.Methods inherited from class com.csse3200.game.components.Component
create, dispose, earlyUpdate, getEntity, read, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update, write
-
Constructor Details
-
Terminal
public Terminal() -
Terminal
-
-
Method Details
-
getEnteredMessage
- Returns:
- message entered by user
-
isOpen
public boolean isOpen()- Returns:
- console is open
-
toggleIsOpen
public void toggleIsOpen()Toggles between the terminal being open and closed. -
setOpen
public void setOpen()Opens the terminal. -
setClosed
public void setClosed()Closes the terminal and clears the stored message. -
addCommand
Adds a command to the list of valid terminal commands.- Parameters:
name- command namecommand- command
-
processMessage
public boolean processMessage()Processes the completed message entered by the user. If the message corresponds to a valid command, the command will be actioned.- Returns:
- true if command handled, false otherwise
-
appendToMessage
public void appendToMessage(char character) Appends the character to the end of the entered message.- Parameters:
character- character to append
-
handleBackspace
public void handleBackspace()Removes the last character of the entered message. -
setEnteredMessage
Sets the text shown on the terminal- Parameters:
text- Text to show
-