Package com.csse3200.game.ui.terminal
Class Terminal
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.ui.terminal.Terminal
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCommand
(String name, Command command) Adds a command to the list of valid terminal commands.void
appendToMessage
(char character) Appends the character to the end of the entered message.void
Removes the last character of the entered message.boolean
isOpen()
boolean
Processes the completed message entered by the user.void
Closes the terminal and clears the stored message.void
setEnteredMessage
(String text) Sets the text shown on the terminalvoid
setOpen()
Opens the terminal.void
Toggles between the terminal being open and closed.Methods inherited from class com.csse3200.game.components.Component
create, dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
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
-