Class Console



  • public class Console
    extends java.lang.Object
    The message system can manage & show messages (Line).
    • Constructor Summary

      Constructors 
      Constructor Description
      Console​(com.badlogic.gdx.scenes.scene2d.ui.Skin skin, int xPos, int yPos)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String message)
      Adds a message with the sender "System"
      void add​(java.lang.String message, java.lang.String sender)
      Adds a message to the console.
      void add​(java.lang.String message, java.lang.String sender, int importance)
      Adds a message to the console.
      void addCommand​(ConsoleCommand command)
      Add new commands
      java.util.ArrayList<java.lang.String> autoComplete​()
      suggests a cvar or a dir if cd entered
      boolean checkPath​(java.lang.String newPath)
      check if the path is valid relative to the current one
      void clearCommandLine​()  
      void enter​()
      when a message is entered
      boolean executeCommand​(java.lang.String command)
      Tries executing a command.
      java.lang.String getCurrentCommand​()
      returns the currently typed command
      java.lang.String getLastMessage​()
      Returns the last Message
      java.lang.String getLastMessage​(java.lang.String sender, int skip)
      Returns the last Message
      java.lang.String getPath​()  
      protected java.util.ArrayList<ConsoleCommand> getRegisteredCommands​()  
      boolean isActive​()
      Is the window open?
      java.util.ArrayList<java.lang.String> ls​()
      displays the content of a folder.
      void setGameplayRef​(GameplayScreen gameplayRef)
      Set the reference field for the console so that it can access the game.
      void setPath​(java.lang.String path)
      Set a path as the current path for the console access.
      void setText​(java.lang.String text)
      Set the text in the box and the cursor at the end.
      void update​(float dt)
      Updates the console.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Console

        public Console​(com.badlogic.gdx.scenes.scene2d.ui.Skin skin,
                       int xPos,
                       int yPos)
        Parameters:
        skin -
        xPos -
        yPos -
    • Method Detail

      • getPath

        public java.lang.String getPath​()
        Returns:
      • setGameplayRef

        public void setGameplayRef​(GameplayScreen gameplayRef)
        Set the reference field for the console so that it can access the game.
        Parameters:
        gameplayRef -
      • add

        public void add​(java.lang.String message)
        Adds a message with the sender "System"
        Parameters:
        message -
      • add

        public void add​(java.lang.String message,
                        java.lang.String sender)
        Adds a message to the console.
        Parameters:
        message -
        sender -
      • add

        public void add​(java.lang.String message,
                        java.lang.String sender,
                        int importance)
        Adds a message to the console.
        Parameters:
        message -
        sender -
        importance -
      • update

        public void update​(float dt)
        Updates the console.
        Parameters:
        dt - time in ms
      • enter

        public void enter​()
        when a message is entered
      • clearCommandLine

        public void clearCommandLine​()
      • isActive

        public boolean isActive​()
        Is the window open?
        Returns:
      • getLastMessage

        public java.lang.String getLastMessage​()
        Returns the last Message
        Returns:
        if there spawn no last message it returns an empty string
      • getLastMessage

        public java.lang.String getLastMessage​(java.lang.String sender,
                                               int skip)
        Returns the last Message
        Parameters:
        sender - filter by the sender, e.g. if you want the last message of a specific player
        skip - how many items you want to skip
        Returns:
        if there spawn no last message it returns an empty string
      • setText

        public void setText​(java.lang.String text)
        Set the text in the box and the cursor at the end.
        Parameters:
        text -
      • autoComplete

        public java.util.ArrayList<java.lang.String> autoComplete​()
        suggests a cvar or a dir if cd entered
        Returns:
        the possible completions
      • addCommand

        public void addCommand​(ConsoleCommand command)
        Add new commands
        Parameters:
        command -
      • getRegisteredCommands

        protected java.util.ArrayList<ConsoleCommand> getRegisteredCommands​()
        Returns:
      • checkPath

        public boolean checkPath​(java.lang.String newPath)
        check if the path is valid relative to the current one
        Parameters:
        newPath -
        Returns:
      • getCurrentCommand

        public java.lang.String getCurrentCommand​()
        returns the currently typed command
        Returns:
      • ls

        public java.util.ArrayList<java.lang.String> ls​()
        displays the content of a folder.
        Returns:
      • executeCommand

        public boolean executeCommand​(java.lang.String command)
        Tries executing a command. If that fails trys to set cvar. if that fails trys to execute external commands.
        Parameters:
        command -
        Returns:
        false if command or cvar not found
      • setPath

        public void setPath​(java.lang.String path)
        Set a path as the current path for the console access.
        Parameters:
        path -