Class Terminal

java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.ui.terminal.Terminal

public class Terminal
extends Component
State tracker for a debug terminal. Any commands to be actioned through the terminal input should be added to the map of commands.
  • Constructor Details

  • Method Details

    • getEnteredMessage

      public java.lang.String 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

      public void addCommand​(java.lang.String name, Command command)
      Adds a command to the list of valid terminal commands.
      Parameters:
      name - command name
      command - 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

      public void setEnteredMessage​(java.lang.String text)
      Sets the text shown on the terminal
      Parameters:
      text - Text to show