Annwvyn::AnnConsole Class Reference

In engine - On screen floating console. More...

#include <AnnConsole.hpp>

Inheritance diagram for Annwvyn::AnnConsole:
Collaboration diagram for Annwvyn::AnnConsole:

Public Member Functions

 AnnConsole ()
 Construct the console. This should only be called by AnnEngine itself when the camera and ogre are operational. More...
 
 ~AnnConsole ()
 Destructor. More...
 
void append (const std::string &string)
 
void setVisible (bool visibility=true)
 Set arbitrary the visibility state of the console. Visible if no arg given, hide it if visibility = false. More...
 
void toggle ()
 Toggle the console. More...
 
bool needUpdate () override
 True if text has been updated on the console and the console is visible. More...
 
void update () override
 
void syncConsolePosition () const
 Move the console where it should. More...
 
void bufferClear ()
 Clear the text draw buffer of the console. More...
 
bool setFromPointedHistory ()
 return true if pointed to an empty slot More...
 
void notifyNavigationKey (KeyCode::code code)
 Method to be called for navigation keys. More...
 
- Public Member Functions inherited from Annwvyn::AnnSubSystem
 AnnSubSystem (const std::string &systemName)
 Construct a SubSystem. More...
 
virtual ~AnnSubSystem ()
 Destruct a SubSystem. More...
 

Static Public Member Functions

static void WriteToTexture (const Ogre::String &str, Ogre::TexturePtr destTexture, Ogre::Image::Box destRectangle, Ogre::Font *font, const Ogre::ColourValue &color, char justify='l', bool wordwrap=false)
 This piece of code if from the Ogre Wiki. Write text to a texture using Ogre::FontManager to create glyphs. More...
 

Public Attributes

std::array< const char *, 2 > forbidden = { { "var", "auto" } }
 Array of forbidden keyword to check. More...
 

Static Public Attributes

static constexpr auto CONSOLE_BUFFER = 17
 
static constexpr auto MAX_CONSOLE_LOG_WIDTH = 72
 
static constexpr auto BASE = 256
 
static constexpr auto MARGIN = 4
 
static constexpr auto CONSOLE_HISTORY = 64
 

Private Member Functions

void runInput (std::string &input)
 Cleanup and run the user input. More...
 
void addToHistory (const std::string &input)
 Push the inputed text into the command history. More...
 
bool runSpecialInput (const std::string &input)
 Run input that are not regular script commands. More...
 
bool isForbdiden (const std::string &keyword)
 Return true if the given string match with any of the forbidden keyword int the array. More...
 

Private Attributes

bool modified
 True if content of the buffer has been modified. More...
 
std::array< AnnVect3, 4 > points
 Array of 3D points to construct the render plane. More...
 
std::array< AnnVect2, 4 > textCoord
 Array of UV coordinates to constructed the render plane. More...
 
std::string buffer [CONSOLE_BUFFER]
 Buffer of string objects. More...
 
Ogre::ManualObject * displaySurface
 The surface used to display (aka the render plane) More...
 
Ogre::SceneNode * consoleNode
 Node where the console is attached. More...
 
Ogre::TexturePtr texture
 The actual texture of the display. More...
 
AnnVect3 offset
 Position of the plane using the camera as reference. More...
 
Ogre::TexturePtr background
 Background texture, should be a random PNG file from the CORE resources. More...
 
GLuint backgroundID
 OpenGL Texture IDs, to use glCopyImageSubData to clone texture quickly. More...
 
GLuint textureID
 
Ogre::FontPtr font
 The font object used, should be Vera Mono in true type format from the Gnome project, included in CORE resources. More...
 
bool visibility
 If false, the console is not visible. More...
 
double lastUpdate
 Timestamp in seconds since the start of the game the last console refresh was performed. More...
 
const double refreshRate
 Delay in seconds to re-refresh the console. More...
 
std::array< std::string, CONSOLE_HISTORYcommandHistory
 Buffer of strings containing past run commands. More...
 
int historyStatus
 Status of the history. More...
 
int cursorPos
 Position of the text cursor, indexed from the end of the string. More...
 

Additional Inherited Members

- Protected Attributes inherited from Annwvyn::AnnSubSystem
std::string name
 Name of the subsystem. More...
 

Detailed Description

In engine - On screen floating console.

Definition at line 28 of file AnnConsole.hpp.

Constructor & Destructor Documentation

◆ AnnConsole()

AnnConsole::AnnConsole ( )

Construct the console. This should only be called by AnnEngine itself when the camera and ogre are operational.

Definition at line 18 of file AnnConsole.cpp.

◆ ~AnnConsole()

AnnConsole::~AnnConsole ( )

Destructor.

Definition at line 604 of file AnnConsole.cpp.

Member Function Documentation

◆ addToHistory()

void AnnConsole::addToHistory ( const std::string input)
private

Push the inputed text into the command history.

Definition at line 545 of file AnnConsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append()

void AnnConsole::append ( const std::string string)

Add text to the console buffer. The console buffer will keep CONSOLE_BUFFER lines of messages in memory only

Parameters
stringtext to append to the console

Definition at line 136 of file AnnConsole.cpp.

Here is the caller graph for this function:

◆ bufferClear()

void AnnConsole::bufferClear ( )

Clear the text draw buffer of the console.

Definition at line 598 of file AnnConsole.cpp.

Here is the caller graph for this function:

◆ isForbdiden()

bool AnnConsole::isForbdiden ( const std::string keyword)
private

Return true if the given string match with any of the forbidden keyword int the array.

Definition at line 245 of file AnnConsole.cpp.

Here is the caller graph for this function:

◆ needUpdate()

bool AnnConsole::needUpdate ( )
overridevirtual

True if text has been updated on the console and the console is visible.

Reimplemented from Annwvyn::AnnSubSystem.

Definition at line 498 of file AnnConsole.cpp.

Here is the call graph for this function:

◆ notifyNavigationKey()

void AnnConsole::notifyNavigationKey ( KeyCode::code  code)

Method to be called for navigation keys.

Definition at line 454 of file AnnConsole.cpp.

Here is the call graph for this function:

◆ runInput()

void AnnConsole::runInput ( std::string input)
private

Cleanup and run the user input.

Definition at line 508 of file AnnConsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runSpecialInput()

bool AnnConsole::runSpecialInput ( const std::string input)
private

Run input that are not regular script commands.

Definition at line 552 of file AnnConsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFromPointedHistory()

bool AnnConsole::setFromPointedHistory ( )

return true if pointed to an empty slot

Definition at line 443 of file AnnConsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVisible()

void AnnConsole::setVisible ( bool  visibility = true)

Set arbitrary the visibility state of the console. Visible if no arg given, hide it if visibility = false.

Definition at line 145 of file AnnConsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ syncConsolePosition()

void AnnConsole::syncConsolePosition ( ) const

Move the console where it should.

Definition at line 489 of file AnnConsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toggle()

void AnnConsole::toggle ( )

Toggle the console.

Definition at line 157 of file AnnConsole.cpp.

Here is the call graph for this function:

◆ update()

void AnnConsole::update ( )
overridevirtual

Update the console by filling it with background texture then blitting text on it. Can take some computing time depending on the size/resolution of the textures and buffer

Reimplemented from Annwvyn::AnnSubSystem.

Definition at line 162 of file AnnConsole.cpp.

Here is the call graph for this function:

◆ WriteToTexture()

void AnnConsole::WriteToTexture ( const Ogre::String &  str,
Ogre::TexturePtr  destTexture,
Ogre::Image::Box  destRectangle,
Ogre::Font *  font,
const Ogre::ColourValue &  color,
char  justify = 'l',
bool  wordwrap = false 
)
static

This piece of code if from the Ogre Wiki. Write text to a texture using Ogre::FontManager to create glyphs.

Definition at line 253 of file AnnConsole.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ background

Ogre::TexturePtr Annwvyn::AnnConsole::background
private

Background texture, should be a random PNG file from the CORE resources.

Definition at line 116 of file AnnConsole.hpp.

◆ backgroundID

GLuint Annwvyn::AnnConsole::backgroundID
private

OpenGL Texture IDs, to use glCopyImageSubData to clone texture quickly.

Definition at line 119 of file AnnConsole.hpp.

◆ BASE

constexpr auto Annwvyn::AnnConsole::BASE = 256
static

Definition at line 33 of file AnnConsole.hpp.

◆ buffer

std::string Annwvyn::AnnConsole::buffer[CONSOLE_BUFFER]
private

Buffer of string objects.

Definition at line 101 of file AnnConsole.hpp.

◆ commandHistory

std::array<std::string, CONSOLE_HISTORY> Annwvyn::AnnConsole::commandHistory
private

Buffer of strings containing past run commands.

Definition at line 134 of file AnnConsole.hpp.

◆ CONSOLE_BUFFER

constexpr auto Annwvyn::AnnConsole::CONSOLE_BUFFER = 17
static

Definition at line 31 of file AnnConsole.hpp.

◆ CONSOLE_HISTORY

constexpr auto Annwvyn::AnnConsole::CONSOLE_HISTORY = 64
static

Definition at line 35 of file AnnConsole.hpp.

◆ consoleNode

Ogre::SceneNode* Annwvyn::AnnConsole::consoleNode
private

Node where the console is attached.

Definition at line 107 of file AnnConsole.hpp.

◆ cursorPos

int Annwvyn::AnnConsole::cursorPos
private

Position of the text cursor, indexed from the end of the string.

Definition at line 140 of file AnnConsole.hpp.

◆ displaySurface

Ogre::ManualObject* Annwvyn::AnnConsole::displaySurface
private

The surface used to display (aka the render plane)

Definition at line 104 of file AnnConsole.hpp.

◆ font

Ogre::FontPtr Annwvyn::AnnConsole::font
private

The font object used, should be Vera Mono in true type format from the Gnome project, included in CORE resources.

Definition at line 122 of file AnnConsole.hpp.

◆ forbidden

std::array<const char*, 2> Annwvyn::AnnConsole::forbidden = { { "var", "auto" } }

Array of forbidden keyword to check.

Definition at line 67 of file AnnConsole.hpp.

◆ historyStatus

int Annwvyn::AnnConsole::historyStatus
private

Status of the history.

Definition at line 137 of file AnnConsole.hpp.

◆ lastUpdate

double Annwvyn::AnnConsole::lastUpdate
private

Timestamp in seconds since the start of the game the last console refresh was performed.

Definition at line 128 of file AnnConsole.hpp.

◆ MARGIN

constexpr auto Annwvyn::AnnConsole::MARGIN = 4
static

Definition at line 34 of file AnnConsole.hpp.

◆ MAX_CONSOLE_LOG_WIDTH

constexpr auto Annwvyn::AnnConsole::MAX_CONSOLE_LOG_WIDTH = 72
static

Definition at line 32 of file AnnConsole.hpp.

◆ modified

bool Annwvyn::AnnConsole::modified
private

True if content of the buffer has been modified.

Definition at line 92 of file AnnConsole.hpp.

◆ offset

AnnVect3 Annwvyn::AnnConsole::offset
private

Position of the plane using the camera as reference.

Definition at line 113 of file AnnConsole.hpp.

◆ points

std::array<AnnVect3, 4> Annwvyn::AnnConsole::points
private

Array of 3D points to construct the render plane.

Definition at line 95 of file AnnConsole.hpp.

◆ refreshRate

const double Annwvyn::AnnConsole::refreshRate
private

Delay in seconds to re-refresh the console.

Definition at line 131 of file AnnConsole.hpp.

◆ textCoord

std::array<AnnVect2, 4> Annwvyn::AnnConsole::textCoord
private

Array of UV coordinates to constructed the render plane.

Definition at line 98 of file AnnConsole.hpp.

◆ texture

Ogre::TexturePtr Annwvyn::AnnConsole::texture
private

The actual texture of the display.

Definition at line 110 of file AnnConsole.hpp.

◆ textureID

GLuint Annwvyn::AnnConsole::textureID
private

Definition at line 119 of file AnnConsole.hpp.

◆ visibility

bool Annwvyn::AnnConsole::visibility
private

If false, the console is not visible.

Definition at line 125 of file AnnConsole.hpp.


The documentation for this class was generated from the following files: