Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

Console Class Reference

#include <console.h>

Inheritance diagram for Console:

Inheritance graph
[legend]
Collaboration diagram for Console:

Collaboration graph
[legend]
List of all members.

Detailed Description

Dropdown console for easy debugging A console is a semi-transparent quad rendered in orthographic mode displaying the debug output sent to it. A console also has a prompt that supports registering commands (and default fallback).

A console is also a log sink that you can attach to a log source to get log messages printed in the console. Example:

neolog.AttachSink( Core::Get()->GetConsole() );
This will attach the core console object as a log sink to the global neolog log source.

For an example on how to use the command callbacks, look at the documentation for the ConsoleCmdCallback class.

Author:
Mattias Jansson (mattias@realityrift.com)


Public Types

enum  CONSOLEDEFS { DEFAULTHISTORY = 200 }

Public Member Functions

 Console (unsigned int uiHistory=DEFAULTHISTORY)
virtual ~Console ()
virtual bool Render (Frustum *pkFrustum=0, bool bForce=false)
void SetFont (FontPtr pkFont)
const FontPtr & GetFont () const
virtual void Input (const InputEvent *pkEvent)
virtual void Write (const std::string &rstrMsg)
bool RegisterCommand (const HashString &rstrCmd, ConsoleCmdCallback *pkCallback)
void RegisterDefaultCallback (ConsoleCmdCallback *pkCallback)
void SetDimensions (int iX=0, int iY=0, int iWidth=-1, int iHeight=-1)
void DeleteBuffers ()
void Clear ()
bool IsActive () const
virtual void Activate ()
virtual void Deactivate ()
bool Toggle ()
void AttachToGroup (InputGroup *pkGroup)
void SetLogThreshold (unsigned int uiLevel)

Static Public Member Functions

void LoadDefaultFont ()
FontPtr GetDefaultFont ()
void UnloadDefaultFont ()

Public Attributes

unsigned int m_uiLastFrame

Static Public Attributes

unsigned int s_uiFrameCount

Protected Member Functions

virtual bool ProcessCmd (const std::string &rstrCmd)

Protected Attributes

std::vector< std::string > m_vstrHistory
FontPtr m_pkFont
std::string m_strCmd
std::vector< ConsoleCmd * > m_vpkCommands
int m_iX
int m_iY
int m_iWidth
int m_iHeight
ConsoleCmdCallbackm_pkDefaultCallback
VertexBufferPtr m_pkVertexBuffer
PolygonBufferPtr m_pkPolygonBuffer
MaterialPtr m_pkMaterial
unsigned int m_uiHistory
bool m_bActive
InputGroupm_pkGroup
unsigned int m_uiThreshold

Static Protected Attributes

FontPtr s_pkDefaultFont


Member Enumeration Documentation

enum CONSOLEDEFS
 

Console defines and default values

Enumeration values:
DEFAULTHISTORY  Default history length


Constructor & Destructor Documentation

Console unsigned int  uiHistory = DEFAULTHISTORY  ) 
 

Parameters:
uiHistory Number of lines in history

virtual ~Console  )  [virtual]
 

Deallocate memory


Member Function Documentation

virtual bool ProcessCmd const std::string &  rstrCmd  )  [protected, virtual]
 

Process command entered in console

Parameters:
rstrCmd Command string
Returns:
true if command was processed, false if not

virtual bool Render Frustum pkFrustum = 0,
bool  bForce = false
[virtual]
 

Render object

Parameters:
pkFrustum Current view frustum (if any), ignored
bForce Render even if rendered previously this frame (default false)
Returns:
true if we were rendered, false if not (already rendered, not forced)

Reimplemented from RenderEntity.

void SetFont FontPtr  pkFont  ) 
 

Set font

Parameters:
pkFont Font

const FontPtr& GetFont  )  const [inline]
 

Returns:
Current font

virtual void Input const InputEvent pkEvent  )  [virtual]
 

Process input

Parameters:
pkEvent Event

Implements InputEntity.

virtual void Write const std::string &  rstrMsg  )  [virtual]
 

Write log sink data to console

Parameters:
rstrMsg Log message

Implements LogSink.

bool RegisterCommand const HashString rstrCmd,
ConsoleCmdCallback pkCallback
 

Register new command

Parameters:
rstrCmd Command
pkCallback Callback object
Returns:
true if registered successfully, false if error (already registered)

void RegisterDefaultCallback ConsoleCmdCallback pkCallback  ) 
 

Register default callback (not deleted)

Parameters:
pkCallback Default callback object

void SetDimensions int  iX = 0,
int  iY = 0,
int  iWidth = -1,
int  iHeight = -1
 

Set position and dimensions of console "window". All arguments are in pixels

Parameters:
iX x coordinate
iY y coordinate
iWidth width (a value of -1 means to cover whole screen from x coordinate to right edge)
iHeight height (like width, a -1 value indicates whole screen from y coordinate)

void DeleteBuffers  ) 
 

Delete buffers. Only for internal use

void Clear  ) 
 

Clear the console history

void LoadDefaultFont  )  [static]
 

Load default font

FontPtr GetDefaultFont  )  [static]
 

Get default console font. Will load font if not previously loaded

Returns:
Default console font object

void UnloadDefaultFont  )  [static]
 

Unload default font

bool IsActive  )  const [inline, inherited]
 

Query state of object

Returns:
true if active, false if not

void Activate  )  [inline, virtual, inherited]
 

Activate object

void Deactivate  )  [inline, virtual, inherited]
 

Deactivate object

bool Toggle  )  [inline, inherited]
 

Toggle active state. This method does not need to be overloaded, it is only a wrapper to Activate and Deactivate

Returns:
true if activated, false if deactivated

void AttachToGroup InputGroup pkGroup  )  [inherited]
 

Attach to an input group (will detach from any current group)

Parameters:
pkGroup 

void SetLogThreshold unsigned int  uiLevel  )  [inherited]
 

Set the threshold of loglevel

Parameters:
uiLevel The new loglevel threshold


Member Data Documentation

std::vector< std::string > m_vstrHistory [protected]
 

Messages

FontPtr m_pkFont [protected]
 

Font

std::string m_strCmd [protected]
 

Current command

std::vector< ConsoleCmd* > m_vpkCommands [protected]
 

Registered commands

int m_iX [protected]
 

x coordinate

int m_iY [protected]
 

y coordinate

int m_iWidth [protected]
 

Width

int m_iHeight [protected]
 

Height

ConsoleCmdCallback* m_pkDefaultCallback [protected]
 

Default callback object

VertexBufferPtr m_pkVertexBuffer [protected]
 

Vertex buffer

PolygonBufferPtr m_pkPolygonBuffer [protected]
 

Polygon buffer

MaterialPtr m_pkMaterial [protected]
 

Material

unsigned int m_uiHistory [protected]
 

History length

FontPtr s_pkDefaultFont [static, protected]
 

Default console font

unsigned int s_uiFrameCount [static, inherited]
 

Frame counter (at 500 frames per second, can be active ~100 days continously before loop, and then it will just skip one frame -> safe enough)

unsigned int m_uiLastFrame [inherited]
 

Last frame count we were rendered

bool m_bActive [protected, inherited]
 

Active flag

InputGroup* m_pkGroup [protected, inherited]
 

Input group we belong to

unsigned int m_uiThreshold [protected, inherited]
 

Loglevel threshold


The documentation for this class was generated from the following file:
Generated on Wed Jan 21 14:21:11 2004 for NeoEngine by doxygen 1.3.5