Menu

Using LibJRogueConsole

Bryan Haley

Using this library is extremely simple.

First, create an instance of the RogueConsole class. This holds all the functions of the console as well as wrapping the rendering and input functions of the window.

Basic functionality is achieved through the print, getChar, update, and clearConsole methods. All of the available methods are listed below.

Note that a key listener that listens for the enter button pressed event should be implemented for retrieving the last command entered.

The default window is 640x380 with 80 characters per 24 lines. Note that one extra line is always added for text input.


addKeyListener
Adds a key listener to the window.

alwaysAllowTyping()
Check if typing is always allowed.

clearConsole()
Clear the console of all text.

clearInputField()
Clear the input field only.

char[][] getAll()
Gets the full console buffer.

char getChar(int x, int y)
Gets the char at the specified location (lineLength x numLines).

java.awt.Color getCharColor(int x, int y)
Gets the color of the character at the specified cell.

java.lang.String getInputText()
Gets the text in input field.

int getKeyToType()
Gets the key that toggles whether or not the user is allowed to type.

java.lang.String getLastCommand()
Retrieves the last command entered.

int getLineLength()
Retrieves the maximum number of characters per line.

int getMaxInputLength()
Retrieves the max input length.

int getNumLines()
Retrieves the number of lines in the console.

boolean getToggleTyping()
Retrieves status of the toggle typing boolean.

RenderInputHandler getWindow()
Retrieves the window in charge of rendering and input.

setWindow(RenderInputHandler newWindow)
Sets the window in charge of rendering and input.

print(char newChar, int x, int y, java.awt.Color color)
Prints a character at the specified location.

print(java.lang.String printSTR, int x, int y, java.awt.Color color)
Prints a String at the specified location.

print(char[] chars, int x, int y, java.awt.Color color)
Prints a characters at the specified location.

print(char[] chars, int x, int y, java.awt.Color colors[])
Prints a characters at the specified location with individual colors.

setAlwaysAllowTyping(boolean allow)
Sets if typing is always allowed or not.

setBackgroundColor(java.awt.Color newColor)
Sets the background color.

setFont(java.awt.Font newFont)
Sets the font. Use of this method is discouraged, as the console may not display correctly with fonts other than Monospace.

setInputStringText(java.lang.String newSTR)
Sets the input string text.

setKeyToType(int newKey)
Sets the key that toggles whether or not the user is allowed to type.

setLastCommand()
Sets the last command. Should only be used internally.

setLineLength(int newLeng)
Sets the maximum number of characters per line.

setMaxInputLength(int newMax)
Sets the maximum number of characters in the input field.

setNumLines(int newNum)
Sets the number of lines in the console window.

setRenderWindow(Window newWindow)
Sets the render/input window. Must be a subclass of Window.

setSpacing(float x, float y)
Sets the spacing between characters in the console.

setToggleTypingOnEnter(boolean toggle)
Sets the boolean for determining if pressing enter toggles the ability to type or not.

setWindowSize(int width, int height)
Sets the window size.

setWindowTitle(String title)
Sets the window title.

setWindow(RenderInputHandler newWindow)
Sets the object handling rendering and input to one that implements RenderInputHandler.

setRenderWindow(Window newWindow) [deprecated]
Sets the render/input handler object to a Window-class based one.

update()
Updates the console buffer & redraws.

updateBuffer()
Updates the buffer only.