#include <spUtilityCommandLine.hpp>
Classes | |
struct | SCommand |
struct | SCursor |
struct | SHelpLine |
struct | SMemento |
struct | STextLine |
Public Member Functions | |
CommandLineUI () throw (io::RenderSystemException, io::stringc) | |
virtual | ~CommandLineUI () |
virtual void | render (s32 Flags=CMDFLAG_COMMON) |
virtual void | draw (s32 Flags=CMDFLAG_COMMON) |
virtual void | updateInput (s32 Flags=CMDFLAG_COMMON) |
virtual void | updateScrollInput (s32 DefaultScrollSpeed=3) |
This will be called in "updateInput" if the CMDFLAG_SCROLL flag is set. | |
virtual void | message (const io::stringc &Message, const video::color &Color=255, u32 NewLineTab=0) |
Prints the given message in the specified color. | |
virtual void | warning (const io::stringc &Message) |
Prints a yellow message in the form: "Warning: " + Message + "!". | |
virtual void | error (const io::stringc &Message) |
Prints a red message in the form: "Error: " + Message + "!". | |
virtual void | unknown (const io::stringc &Command) |
Prints an error message that the given command is unknown. | |
virtual void | confirm (const io::stringc &Output) |
Prints a message to confirm the current command with the given output. | |
virtual void | image (video::Texture *Image) |
Prints the given image (or rather texture) as 'text'-line entry. | |
virtual bool | executeCommand (const io::stringc &Command) |
Executes the given command. | |
void | setupCursorTimer (u64 IntervalDuration) |
bool | execute (const io::stringc &Command) |
virtual void | clear (bool isHelpInfo=true) |
Clears the console content. | |
bool | isScrollingEnabled () const |
Returns true if vertical scrolling is enabled. | |
virtual bool | scroll (s32 Direction) |
virtual bool | scrollPage (s32 Direction) |
virtual void | scrollStart () |
Scrolls to the start. | |
virtual void | scrollEnd () |
Scrolls to the end. | |
void | setScrollPosition (s32 Pos) |
Sets the new scroll position. Start position is 0. | |
s32 | getMaxScrollPosition () const |
Returns the maximal scroll position. | |
s32 | getScrollPage () const |
Returns the scrolling size for one page. | |
void | setFont (video::Font *FontObj) |
bool | getCmdParam (const io::stringc &Command, io::stringc &Param) |
video::Font * | getFont () const |
Returns a pointer to the active font object. | |
video::Font * | getOrigFont () const |
Returns a pointer to the original font object. | |
s32 | getScrollPosition () const |
Returns the current scroll position. Start position is 0. | |
void | setBackgroundColor (const video::color &Color) |
Sets the user interface background color. By default black or rather video::color(0, 0, 0, 255). | |
video::color | getBackgroundColor () const |
Returns the background color. | |
void | setForegroundColor (const video::color &Color) |
Sets the user interface background color. By default white or rather video::color(255). | |
video::color | getForegroundColor () const |
Returns the foreground color (for the cursor, separation line and scroll bar). | |
void | setRect (const dim::rect2di &Rect) |
Sets the view rectangle. By default dim::rect2di(0, 0, ScreenWidth, ScreenHeight/2). | |
dim::rect2di | getRect () const |
Returbs the view rectangle. | |
void | setLineLimit (u32 Limit) |
Sets the maximal lines in the user interface. To make it unlimited set it to 0. By default 0. | |
u32 | getLineLimit () const |
Returns the count of maximal lines. 0 means unlimited. By default 0. | |
void | setMementoLimit (u32 Limit) |
Sets the maximal count of memento entries. To make it unlimited set it to 0. By default 0. | |
u32 | getMementoLimit () const |
Returns the count of maximal memento entries. 0 means unlimited. By default 0. | |
void | blank () |
Prints a new blank line. This is equivalent to: message("");. | |
Protected Member Functions | |
virtual void | drawBackground () |
virtual void | drawTextLines () |
virtual void | drawCursor () |
virtual void | drawScrollbar () |
virtual void | drawTextLine (s32 &PosVert, const STextLine &Line) |
virtual void | addHelpLine (const io::stringc &Command, const io::stringc &Description) |
virtual void | printHelpLines (c8 SeparationChar= '.', u32 MinSeparationChars=3) |
virtual bool | findAutoCompletion (io::stringc &Command) |
void | registerCommand (const io::stringc &Name, const io::stringc &Docu) |
void | addNewLine (const STextLine &Line) |
void | addNewLine (const io::stringc &Message, const video::color &Color) |
Protected Attributes | |
video::color | BgColor_ |
video::color | FgColor_ |
dim::rect2di | Rect_ |
SCursor | Cursor_ |
SMemento | Memento_ |
u32 | MaxLines_ |
s32 | Scroll_ |
std::vector< STextLine > | TextLines_ |
std::vector< SCommand > | RegisteredCommands_ |
io::stringc | CommandLine_ |
Static Protected Attributes | |
static const s32 | TEXT_DISTANCE |
static const s32 | SCROLLBAR_WIDTH |
static const s32 | SCROLLBAR_DISTANCE |
The command line is used to have an extended debug control during you are develping your games. Here is a code example on how to use this class:
class MyOwnCMD : public tool::CommandLineUI { public: MyOwnCMD() : tool::CommandLineUI() { } ~MyOwnCMD() { } // Overwrite the execution function bool execute(io::stringc Command) { // Check for your custom commands if (Command == "StartMyGame") return MyGame::Start(); if (Command == "QuitMyGame") exit(0); // Use the default commands return tool::CommandLineUI::execute(Command); } }; // ... // Just add this after all your drawing operations: (must not be in a begin/endDrawing2D block) MyCmdObj->render();
sp::tool::CommandLineUI::CommandLineUI | ( | ) | throw (io::RenderSystemException, io::stringc) |
virtual sp::tool::CommandLineUI::~CommandLineUI | ( | ) | [virtual] |
virtual void sp::tool::CommandLineUI::addHelpLine | ( | const io::stringc & | Command, | |
const io::stringc & | Description | |||
) | [protected, virtual] |
void sp::tool::CommandLineUI::addNewLine | ( | const STextLine & | Line | ) | [protected] |
void sp::tool::CommandLineUI::addNewLine | ( | const io::stringc & | Message, | |
const video::color & | Color | |||
) | [protected] |
void sp::tool::CommandLineUI::blank | ( | ) | [inline] |
Prints a new blank line. This is equivalent to: message("");.
virtual void sp::tool::CommandLineUI::clear | ( | bool | isHelpInfo = true |
) | [virtual] |
Clears the console content.
virtual void sp::tool::CommandLineUI::confirm | ( | const io::stringc & | Output | ) | [virtual] |
Prints a message to confirm the current command with the given output.
virtual void sp::tool::CommandLineUI::draw | ( | s32 | Flags = CMDFLAG_COMMON |
) | [virtual] |
Draws the command line interface.
[in] | Flags | Specifies the flags for drawing. |
virtual void sp::tool::CommandLineUI::drawBackground | ( | ) | [protected, virtual] |
virtual void sp::tool::CommandLineUI::drawCursor | ( | ) | [protected, virtual] |
virtual void sp::tool::CommandLineUI::drawScrollbar | ( | ) | [protected, virtual] |
virtual void sp::tool::CommandLineUI::drawTextLine | ( | s32 & | PosVert, | |
const STextLine & | Line | |||
) | [protected, virtual] |
virtual void sp::tool::CommandLineUI::drawTextLines | ( | ) | [protected, virtual] |
virtual void sp::tool::CommandLineUI::error | ( | const io::stringc & | Message | ) | [virtual] |
Prints a red message in the form: "Error: " + Message + "!".
bool sp::tool::CommandLineUI::execute | ( | const io::stringc & | Command | ) |
Excecutes the given command.
[in] | Command | Specifies the command which is to be executed. The default commands are case sensitive and are all in lower case. Enter "help" for a detailed list of all default commands. |
virtual bool sp::tool::CommandLineUI::executeCommand | ( | const io::stringc & | Command | ) | [virtual] |
Executes the given command.
virtual bool sp::tool::CommandLineUI::findAutoCompletion | ( | io::stringc & | Command | ) | [protected, virtual] |
Tries to find an automatic completion for the given command string.
[in,out] | Command | Specifies the command for the auto-completion to search for. |
video::color sp::tool::CommandLineUI::getBackgroundColor | ( | ) | const [inline] |
Returns the background color.
bool sp::tool::CommandLineUI::getCmdParam | ( | const io::stringc & | Command, | |
io::stringc & | Param | |||
) |
Returns the parameter part of the given command.
[in] | Command | Specifies the whole command string (e.g. 'MyCommand "MyParameter"'). |
[out] | Param | Specifies the output parameter string. |
video::Font* sp::tool::CommandLineUI::getFont | ( | ) | const [inline] |
Returns a pointer to the active font object.
video::color sp::tool::CommandLineUI::getForegroundColor | ( | ) | const [inline] |
Returns the foreground color (for the cursor, separation line and scroll bar).
u32 sp::tool::CommandLineUI::getLineLimit | ( | ) | const [inline] |
Returns the count of maximal lines. 0 means unlimited. By default 0.
s32 sp::tool::CommandLineUI::getMaxScrollPosition | ( | ) | const |
Returns the maximal scroll position.
u32 sp::tool::CommandLineUI::getMementoLimit | ( | ) | const [inline] |
Returns the count of maximal memento entries. 0 means unlimited. By default 0.
video::Font* sp::tool::CommandLineUI::getOrigFont | ( | ) | const [inline] |
Returns a pointer to the original font object.
dim::rect2di sp::tool::CommandLineUI::getRect | ( | ) | const [inline] |
Returbs the view rectangle.
s32 sp::tool::CommandLineUI::getScrollPage | ( | ) | const |
Returns the scrolling size for one page.
s32 sp::tool::CommandLineUI::getScrollPosition | ( | ) | const [inline] |
Returns the current scroll position. Start position is 0.
virtual void sp::tool::CommandLineUI::image | ( | video::Texture * | Image | ) | [virtual] |
Prints the given image (or rather texture) as 'text'-line entry.
bool sp::tool::CommandLineUI::isScrollingEnabled | ( | ) | const |
Returns true if vertical scrolling is enabled.
virtual void sp::tool::CommandLineUI::message | ( | const io::stringc & | Message, | |
const video::color & | Color = 255 , |
|||
u32 | NewLineTab = 0 | |||
) | [virtual] |
Prints the given message in the specified color.
virtual void sp::tool::CommandLineUI::printHelpLines | ( | c8 | SeparationChar = '.' , |
|
u32 | MinSeparationChars = 3 | |||
) | [protected, virtual] |
void sp::tool::CommandLineUI::registerCommand | ( | const io::stringc & | Name, | |
const io::stringc & | Docu | |||
) | [protected] |
virtual void sp::tool::CommandLineUI::render | ( | s32 | Flags = CMDFLAG_COMMON |
) | [virtual] |
Renders the user interfaces, i.e. draws and updates it. This is equivalent to the following code:
Cmd->draw(Flags); Cmd->updateInput(Flags);
virtual bool sp::tool::CommandLineUI::scroll | ( | s32 | Direction | ) | [virtual] |
Scrolls vertical in the given direction. Positive values mean up scrolling and negative values mean down scrolling.
virtual void sp::tool::CommandLineUI::scrollEnd | ( | ) | [virtual] |
Scrolls to the end.
virtual bool sp::tool::CommandLineUI::scrollPage | ( | s32 | Direction | ) | [virtual] |
Scrolls a whole page.
virtual void sp::tool::CommandLineUI::scrollStart | ( | ) | [virtual] |
Scrolls to the start.
void sp::tool::CommandLineUI::setBackgroundColor | ( | const video::color & | Color | ) | [inline] |
Sets the user interface background color. By default black or rather video::color(0, 0, 0, 255).
void sp::tool::CommandLineUI::setFont | ( | video::Font * | FontObj | ) |
Sets the new font for text drawing. By default "courier new".
[in] | FontObj | Pointer to the new font object. If this is a null pointer the original font will be used. |
void sp::tool::CommandLineUI::setForegroundColor | ( | const video::color & | Color | ) | [inline] |
Sets the user interface background color. By default white or rather video::color(255).
void sp::tool::CommandLineUI::setLineLimit | ( | u32 | Limit | ) | [inline] |
Sets the maximal lines in the user interface. To make it unlimited set it to 0. By default 0.
void sp::tool::CommandLineUI::setMementoLimit | ( | u32 | Limit | ) | [inline] |
Sets the maximal count of memento entries. To make it unlimited set it to 0. By default 0.
void sp::tool::CommandLineUI::setRect | ( | const dim::rect2di & | Rect | ) | [inline] |
Sets the view rectangle. By default dim::rect2di(0, 0, ScreenWidth, ScreenHeight/2).
void sp::tool::CommandLineUI::setScrollPosition | ( | s32 | Pos | ) |
Sets the new scroll position. Start position is 0.
void sp::tool::CommandLineUI::setupCursorTimer | ( | u64 | IntervalDuration | ) |
virtual void sp::tool::CommandLineUI::unknown | ( | const io::stringc & | Command | ) | [virtual] |
Prints an error message that the given command is unknown.
virtual void sp::tool::CommandLineUI::updateInput | ( | s32 | Flags = CMDFLAG_COMMON |
) | [virtual] |
Updates the command line input.
[in] | Flags | Specifies the flags for input. |
virtual void sp::tool::CommandLineUI::updateScrollInput | ( | s32 | DefaultScrollSpeed = 3 |
) | [virtual] |
This will be called in "updateInput" if the CMDFLAG_SCROLL flag is set.
virtual void sp::tool::CommandLineUI::warning | ( | const io::stringc & | Message | ) | [virtual] |
Prints a yellow message in the form: "Warning: " + Message + "!".
video::color sp::tool::CommandLineUI::BgColor_ [protected] |
io::stringc sp::tool::CommandLineUI::CommandLine_ [protected] |
SCursor sp::tool::CommandLineUI::Cursor_ [protected] |
video::color sp::tool::CommandLineUI::FgColor_ [protected] |
u32 sp::tool::CommandLineUI::MaxLines_ [protected] |
SMemento sp::tool::CommandLineUI::Memento_ [protected] |
dim::rect2di sp::tool::CommandLineUI::Rect_ [protected] |
std::vector<SCommand> sp::tool::CommandLineUI::RegisteredCommands_ [protected] |
s32 sp::tool::CommandLineUI::Scroll_ [protected] |
const s32 sp::tool::CommandLineUI::SCROLLBAR_DISTANCE [static, protected] |
const s32 sp::tool::CommandLineUI::SCROLLBAR_WIDTH [static, protected] |
const s32 sp::tool::CommandLineUI::TEXT_DISTANCE [static, protected] |
std::vector<STextLine> sp::tool::CommandLineUI::TextLines_ [protected] |