Console Class Reference

Simple dropdown console. More...

#include <console.h>

Inherits InputAcceptor, and LogAcceptor.

Inheritance diagram for Console:

Inheritance graph
[legend]
Collaboration diagram for Console:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Console ()
 ~Console ()
virtual bool wantKey (const SDL_keysym &keysym)
virtual bool keyDown (const SDL_keysym &keysym)
virtual void logLine (const std::string &line)
 Processing one line from log.
void render ()
 Render the console.
void init ()
 Inicialize the console and plug it into the system.
void clean ()
 Clean resources allocated by console.
void addConsoleMessage (const std::string &msg)
 Add new message to console.

Private Member Functions

void processCommand (const std::string &cmd)
 Handles the command.
void registerLog ()
 Update console state as log listener.

Private Attributes

int mInHistory
 Number of lines in console history.
std::list< std::string > mMessageHistory
 Lines of history in console.
Mutex mHistoryMutex
 Lock for history.
bool mHistoryIgnore
bool mLineWrap
bool mActive
 true if console is active
InputString mInputLine
 currently edited command
FontRef mFont
 font for console
bool mLogForwarding
 log messages are printed to console if true
int mTitle
 translation index for title of console

Detailed Description

Simple dropdown console.

Process input from keyboard and send commands to Commander. Doesn't process any command itself. TODO: commands history better visualisation? (slide down?)

Definition at line 25 of file console.h.


Constructor & Destructor Documentation

Console::Console  ) 
 

Definition at line 31 of file console.cpp.

References g_settings, Settings::getInt(), IA_PRIORITY_CONSOLE, mActive, mFont, mHistoryIgnore, mInHistory, mLineWrap, mLogForwarding, InputAcceptor::mPriority, and mTitle.

Here is the call graph for this function:

Console::~Console  ) 
 

Definition at line 49 of file console.cpp.

References TIN.


Member Function Documentation

void Console::addConsoleMessage const std::string &  msg  ) 
 

Add new message to console.

Is thread safe.

Parameters:
msg newly added message

Definition at line 231 of file console.cpp.

References CONSOLE_LEFT, getAppClient(), ApplicationClient::getGFX(), GFX::getWidth(), Mutex::lock(), mFont, mHistoryIgnore, mHistoryMutex, mLineWrap, mMessageHistory, utf8tows(), and wstoutf8().

Referenced by CommanderClient::command_getvar(), CommanderClient::command_help(), CommanderClient::command_players(), CommanderClient::command_setvar(), logLine(), and processCommand().

Here is the call graph for this function:

void Console::clean  ) 
 

Clean resources allocated by console.

Definition at line 79 of file console.cpp.

References CONSOLE_ONOFF, g_log, getAppClient(), ApplicationClient::getInputManager(), LNG_UNCACHE, mFont, mTitle, InputManager::removeInputAcceptor(), Log::setAcceptor(), InputManager::setKeyReceiver(), and TIN.

Referenced by ApplicationClient::clean().

Here is the call graph for this function:

void Console::init  ) 
 

Inicialize the console and plug it into the system.

Menas loading font, textures and adding to InputManager.

Definition at line 55 of file console.cpp.

References InputManager::addInputAcceptor(), CONSOLE_ONOFF, DIE(), getAppClient(), ApplicationClient::getInputManager(), Singleton< T >::getRef(), LNG_CACHE_, LOGE, mFont, mTitle, registerLog(), InputManager::setKeyReceiver(), and TIN.

Referenced by ApplicationClient::init().

Here is the call graph for this function:

bool Console::keyDown const SDL_keysym &  keysym  )  [virtual]
 

Inform acceptor that key was down.

Returns:
true if the key was accepted

Reimplemented from InputAcceptor.

Definition at line 106 of file console.cpp.

References InputString::clear(), CONSOLE_ONOFF, getAppClient(), ApplicationClient::getInputManager(), InputString::getLineU(), LOGD, LOGI, LOGT, mActive, mInputLine, processCommand(), InputString::processKey(), TIN, and InputManager::WantAllInput().

Here is the call graph for this function:

void Console::logLine const std::string &  line  )  [virtual]
 

Processing one line from log.

The line is simply added as a message line.

Parameters:
line one line

Implements LogAcceptor.

Definition at line 155 of file console.cpp.

References addConsoleMessage(), and mLogForwarding.

Here is the call graph for this function:

void Console::processCommand const std::string &  cmd  )  [private]
 

Handles the command.

Processing is simple forward to Commander.

Parameters:
cmd string with command

Definition at line 295 of file console.cpp.

References Commander::addCommand(), addConsoleMessage(), getAppClient(), ApplicationClient::getCommander(), LOGD, and TIN.

Referenced by keyDown().

Here is the call graph for this function:

void Console::registerLog  )  [private]
 

Update console state as log listener.

Register/unregister to log as acceptor. Depending on mLogForwarding

Definition at line 162 of file console.cpp.

References g_log, mLogForwarding, and Log::setAcceptor().

Referenced by init().

Here is the call graph for this function:

void Console::render  ) 
 

Render the console.

Renders nothig if console is not active. Also render FPS - but it should be removed.

Definition at line 175 of file console.cpp.

References assertL, CONSOLE_LEFT, CONSOLE_TOP, getAppClient(), ApplicationClient::getGFX(), LNG_GET, Mutex::lock(), mActive, mFont, mHistoryIgnore, mHistoryMutex, mInHistory, mMessageHistory, mTitle, GFX::set2DOpenGL(), TIN, and xtos().

Referenced by LayerGUI::render().

Here is the call graph for this function:

bool Console::wantKey const SDL_keysym &  keysym  )  [virtual]
 

Console takes every key when active

Reimplemented from InputAcceptor.

Definition at line 98 of file console.cpp.

References CONSOLE_ONOFF, and mActive.


Member Data Documentation

bool Console::mActive [private]
 

true if console is active

Definition at line 113 of file console.h.

Referenced by Console(), keyDown(), render(), and wantKey().

FontRef Console::mFont [private]
 

font for console

Definition at line 117 of file console.h.

Referenced by addConsoleMessage(), clean(), Console(), init(), and render().

bool Console::mHistoryIgnore [private]
 

New messages are ignored if this is true.

This exists becasue when you are rendering a history it may happen that new messages will appear and it would corrupt iterators.

Definition at line 109 of file console.h.

Referenced by addConsoleMessage(), Console(), and render().

Mutex Console::mHistoryMutex [private]
 

Lock for history.

Definition at line 100 of file console.h.

Referenced by addConsoleMessage(), and render().

int Console::mInHistory [private]
 

Number of lines in console history.

Definition at line 97 of file console.h.

Referenced by Console(), and render().

InputString Console::mInputLine [private]
 

currently edited command

Definition at line 115 of file console.h.

Referenced by keyDown().

bool Console::mLineWrap [private]
 

Definition at line 111 of file console.h.

Referenced by addConsoleMessage(), and Console().

bool Console::mLogForwarding [private]
 

log messages are printed to console if true

Definition at line 119 of file console.h.

Referenced by Console(), logLine(), and registerLog().

std::list<std::string> Console::mMessageHistory [private]
 

Lines of history in console.

Definition at line 99 of file console.h.

Referenced by addConsoleMessage(), and render().

int Console::mTitle [private]
 

translation index for title of console

Definition at line 121 of file console.h.

Referenced by clean(), Console(), init(), and render().


The documentation for this class was generated from the following files:
Generated on Wed Apr 12 14:13:56 2006 for bjs by  doxygen 1.4.5