xoreos  0.0.5
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Engines::ConsoleWindow Class Reference

#include <console.h>

Inheritance diagram for Engines::ConsoleWindow:
Inheritance graph
[legend]
Collaboration diagram for Engines::ConsoleWindow:
Collaboration graph
[legend]

Public Member Functions

 ConsoleWindow (const Common::UString &font, size_t lines, size_t history, int fontHeight=0)
 
 ~ConsoleWindow ()
 
void show ()
 Show the object. More...
 
void hide ()
 Hide the object. More...
 
void showPrompt ()
 
void hidePrompt ()
 
bool isIn (float x, float y) const
 Is that point within the object? More...
 
bool isIn (float x, float y, float z) const
 Is that point within the object? More...
 
float getWidth () const
 
float getHeight () const
 
float getContentWidth () const
 
float getContentHeight () const
 
size_t getLines () const
 
size_t getColumns () const
 
void setPrompt (const Common::UString &prompt)
 
void setInput (const Common::UString &input, size_t cursorPos, bool overwrite)
 
void clear ()
 
void print (const Common::UString &line)
 
bool setRedirect (Common::UString redirect="")
 
void clearHighlight ()
 
void startHighlight (int x, int y)
 
void stopHighlight (int x, int y)
 
void highlightWord (int x, int y)
 
void highlightLine (int x, int y)
 
Common::UString getHighlight () const
 
void scrollUp (size_t n=1)
 
void scrollDown (size_t n=1)
 
void scrollTop ()
 
void scrollBottom ()
 
void calculateDistance ()
 Calculate the object's distance. More...
 
void render (Graphics::RenderPass pass)
 Render the object. More...
 
- Public Member Functions inherited from Graphics::GUIElement
 GUIElement (GUIElementType type)
 
 ~GUIElement ()
 
- Public Member Functions inherited from Graphics::Renderable
 Renderable (RenderableType type)
 
 ~Renderable ()
 
bool operator< (const Queueable &q) const
 
virtual void advanceTime (float dt)
 Advance time (used by renderables with animations). More...
 
virtual void renderImmediate (const glm::mat4 &parentTransform)
 For shader based systems, don't sort anything, render this right_now. More...
 
virtual void queueRender (const glm::mat4 &parentTransform)
 Queue the object for later rendering. More...
 
double getDistance () const
 Get the distance of the object from the viewer. More...
 
uint32 getID () const
 Get the object's unique ID. More...
 
bool isClickable () const
 Is the object clickable? More...
 
void setClickable (bool clickable)
 Set the object's clickable state. More...
 
const Common::UStringgetTag () const
 Get the object's tag. More...
 
void setTag (const Common::UString &tag)
 Set the object's tag. More...
 
bool isVisible () const
 Is the object visible? More...
 
virtual bool isIn (float x1, float y1, float z1, float x2, float y2, float z2) const
 Does the line from x1.y1.z1 to x2.y2.z2 intersect with the object? More...
 
- Public Member Functions inherited from Graphics::Queueable
 Queueable ()
 
virtual ~Queueable ()
 
- Public Member Functions inherited from Events::Notifyable
 Notifyable ()
 
virtual ~Notifyable ()
 

Private Member Functions

void recalcCursor ()
 
void redrawLines ()
 
void printLine (const Common::UString &line)
 
bool openLogFile ()
 
bool openLogFile (const Common::UString &file)
 
void closeLogFile ()
 
void updateHighlight ()
 
bool getPosition (int cursorX, int cursorY, float &x, float &y)
 
void highlightClip (size_t &x, size_t &y) const
 
void updateScrollbarLength ()
 
void updateScrollbarPosition ()
 
void notifyResized (int oldWidth, int oldHeight, int newWidth, int newHeight)
 

Static Private Member Functions

static size_t findWordStart (const Common::UString &line, size_t pos)
 
static size_t findWordEnd (const Common::UString &line, size_t pos)
 

Private Attributes

Graphics::Aurora::FontHandle _font
 
Common::ScopedPtr< Graphics::Aurora::Text_prompt
 
Common::ScopedPtr< Graphics::Aurora::GUIQuad_cursor
 
Common::ScopedPtr< Graphics::Aurora::GUIQuad_highlight
 
size_t _historySizeMax
 
size_t _historySizeCurrent
 
std::list< Common::UString_history
 
size_t _historyStart
 
std::vector< Graphics::Aurora::Text * > _lines
 
Common::ScopedPtr< Graphics::Aurora::Text_input
 
Common::UString _inputText
 
size_t _cursorPosition
 
bool _overwrite
 
float _lineHeight
 
float _x
 
float _y
 
float _width
 
float _height
 
bool _cursorBlinkState
 
uint32 _lastCursorBlink
 
float _scrollbarLength
 
float _scrollbarPosition
 
size_t _highlightX
 
size_t _highlightY
 
ptrdiff_t _highlightLength
 
Common::WriteFile _logFile
 
Common::WriteFile _redirect
 

Additional Inherited Members

- Public Types inherited from Graphics::GUIElement
enum  GUIElementType { kGUIElementFront = kRenderableTypeGUIFront, kGUIElementBack = kRenderableTypeGUIBack, kGUIElementConsole = kRenderableTypeConsole }
 
- Protected Member Functions inherited from Graphics::Renderable
void resort ()
 
void lockFrame ()
 
void unlockFrame ()
 
void lockFrameIfVisible ()
 
void unlockFrameIfVisible ()
 
- Protected Member Functions inherited from Graphics::Queueable
bool isInQueue (QueueType queue) const
 
void addToQueue (QueueType queue)
 
void removeFromQueue (QueueType queue)
 
void lockQueue (QueueType queue)
 
void unlockQueue (QueueType queue)
 
void sortQueue (QueueType queue)
 
- Protected Attributes inherited from Graphics::Renderable
QueueType _queueExists
 
QueueType _queueVisible
 
uint32 _id
 
bool _clickable
 
Common::UString _tag
 
double _distance
 The distance of the object from the viewer. More...
 

Detailed Description

Definition at line 58 of file console.h.

Constructor & Destructor Documentation

◆ ConsoleWindow()

Engines::ConsoleWindow::ConsoleWindow ( const Common::UString font,
size_t  lines,
size_t  history,
int  fontHeight = 0 
)

◆ ~ConsoleWindow()

Engines::ConsoleWindow::~ConsoleWindow ( )

Definition at line 119 of file console.cpp.

References _lines, _redirect, Common::WriteFile::close(), and Common::WriteFile::flush().

Here is the call graph for this function:

Member Function Documentation

◆ calculateDistance()

void Engines::ConsoleWindow::calculateDistance ( )
virtual

Calculate the object's distance.

Implements Graphics::Renderable.

Definition at line 557 of file console.cpp.

References Graphics::Renderable::_distance.

Referenced by ConsoleWindow().

Here is the caller graph for this function:

◆ clear()

void Engines::ConsoleWindow::clear ( )

Definition at line 254 of file console.cpp.

References _history, _historySizeCurrent, _historyStart, _lines, GfxMan, updateScrollbarLength(), and updateScrollbarPosition().

Here is the call graph for this function:

◆ clearHighlight()

void Engines::ConsoleWindow::clearHighlight ( )

Definition at line 481 of file console.cpp.

References _highlightLength, _highlightX, _highlightY, and updateHighlight().

Referenced by ConsoleWindow(), highlightLine(), highlightWord(), and startHighlight().

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

◆ closeLogFile()

void Engines::ConsoleWindow::closeLogFile ( )
private

Definition at line 354 of file console.cpp.

References _logFile, and Common::WriteFile::close().

Referenced by openLogFile().

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

◆ findWordEnd()

size_t Engines::ConsoleWindow::findWordEnd ( const Common::UString line,
size_t  pos 
)
staticprivate

Definition at line 647 of file console.cpp.

References Common::UString::end(), and Common::UString::getPosition().

Referenced by highlightWord().

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

◆ findWordStart()

size_t Engines::ConsoleWindow::findWordStart ( const Common::UString line,
size_t  pos 
)
staticprivate

Definition at line 633 of file console.cpp.

References Common::UString::begin(), Common::UString::end(), and Common::UString::getPosition().

Referenced by highlightWord().

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

◆ getColumns()

size_t Engines::ConsoleWindow::getColumns ( ) const

Definition at line 221 of file console.cpp.

References _font, getContentWidth(), Graphics::Aurora::FontHandle::getFont(), and Graphics::Font::getWidth().

Here is the call graph for this function:

◆ getContentHeight()

float Engines::ConsoleWindow::getContentHeight ( ) const

Definition at line 213 of file console.cpp.

References _height, and _lineHeight.

◆ getContentWidth()

float Engines::ConsoleWindow::getContentWidth ( ) const

Definition at line 209 of file console.cpp.

References _width.

Referenced by getColumns().

Here is the caller graph for this function:

◆ getHeight()

float Engines::ConsoleWindow::getHeight ( ) const

Definition at line 205 of file console.cpp.

References _height.

◆ getHighlight()

Common::UString Engines::ConsoleWindow::getHighlight ( ) const

◆ getLines()

size_t Engines::ConsoleWindow::getLines ( ) const

Definition at line 217 of file console.cpp.

References _lines.

◆ getPosition()

bool Engines::ConsoleWindow::getPosition ( int  cursorX,
int  cursorY,
float &  x,
float &  y 
)
private

Definition at line 377 of file console.cpp.

References _font, _height, _lineHeight, _width, _x, _y, CursorMan, Graphics::Aurora::FontHandle::getFont(), and Graphics::Font::getWidth().

Referenced by highlightLine(), highlightWord(), startHighlight(), and stopHighlight().

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

◆ getWidth()

float Engines::ConsoleWindow::getWidth ( ) const

Definition at line 201 of file console.cpp.

References _width.

◆ hide()

void Engines::ConsoleWindow::hide ( )
virtual

Hide the object.

Reimplemented from Graphics::Renderable.

Definition at line 145 of file console.cpp.

References _cursor, _highlight, _input, _lines, _prompt, GfxMan, and Graphics::Renderable::hide().

Here is the call graph for this function:

◆ hidePrompt()

void Engines::ConsoleWindow::hidePrompt ( )

Definition at line 175 of file console.cpp.

References _cursor, _input, _prompt, GfxMan, and Graphics::Renderable::isVisible().

Here is the call graph for this function:

◆ highlightClip()

void Engines::ConsoleWindow::highlightClip ( size_t &  x,
size_t &  y 
) const
private

Definition at line 392 of file console.cpp.

References _input, _lines, _prompt, CLIP(), and Common::ScopedPtrBase< T, Deallocator >::get().

Referenced by highlightLine(), highlightWord(), startHighlight(), and stopHighlight().

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

◆ highlightLine()

void Engines::ConsoleWindow::highlightLine ( int  x,
int  y 
)

◆ highlightWord()

void Engines::ConsoleWindow::highlightWord ( int  x,
int  y 
)

◆ isIn() [1/2]

bool Engines::ConsoleWindow::isIn ( float  x,
float  y 
) const
virtual

Is that point within the object?

Reimplemented from Graphics::Renderable.

Definition at line 188 of file console.cpp.

References _height, _width, _x, and _y.

Referenced by isIn().

Here is the caller graph for this function:

◆ isIn() [2/2]

bool Engines::ConsoleWindow::isIn ( float  x,
float  y,
float  z 
) const
virtual

Is that point within the object?

Reimplemented from Graphics::Renderable.

Definition at line 197 of file console.cpp.

References isIn().

Here is the call graph for this function:

◆ notifyResized()

void Engines::ConsoleWindow::notifyResized ( int  oldWidth,
int  oldHeight,
int  newWidth,
int  newHeight 
)
privatevirtual

Reimplemented from Events::Notifyable.

Definition at line 615 of file console.cpp.

References _height, _input, _lineHeight, _lines, _prompt, _width, _x, _y, and recalcCursor().

Referenced by ConsoleWindow().

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

◆ openLogFile() [1/2]

bool Engines::ConsoleWindow::openLogFile ( )
private

Definition at line 321 of file console.cpp.

References Common::UString::clear(), ConfigMan, Common::UString::empty(), and Common::FilePath::getUserDataDirectory().

Referenced by ConsoleWindow().

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

◆ openLogFile() [2/2]

bool Engines::ConsoleWindow::openLogFile ( const Common::UString file)
private

◆ print()

void Engines::ConsoleWindow::print ( const Common::UString line)

Definition at line 271 of file console.cpp.

References _font, _width, Graphics::Aurora::FontHandle::getFont(), printLine(), and Graphics::Font::split().

Referenced by setRedirect().

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

◆ printLine()

void Engines::ConsoleWindow::printLine ( const Common::UString line)
private

Definition at line 279 of file console.cpp.

References _history, _historySizeCurrent, _historySizeMax, _logFile, _redirect, Common::WriteFile::flush(), Common::WriteFile::isOpen(), redrawLines(), updateScrollbarLength(), Common::WriteStream::writeByte(), and Common::WriteStream::writeString().

Referenced by print().

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

◆ recalcCursor()

void Engines::ConsoleWindow::recalcCursor ( )
private

Definition at line 658 of file console.cpp.

References _cursor, _cursorPosition, _font, _inputText, _overwrite, _prompt, _x, _y, Graphics::Aurora::FontHandle::getFont(), Graphics::Font::getWidth(), and Common::UString::truncate().

Referenced by notifyResized(), setInput(), and setPrompt().

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

◆ redrawLines()

void Engines::ConsoleWindow::redrawLines ( )
private

Definition at line 669 of file console.cpp.

References _history, _historyStart, _lines, and GfxMan.

Referenced by printLine(), scrollBottom(), scrollDown(), scrollTop(), and scrollUp().

Here is the caller graph for this function:

◆ render()

void Engines::ConsoleWindow::render ( Graphics::RenderPass  pass)
virtual

◆ scrollBottom()

void Engines::ConsoleWindow::scrollBottom ( )

Definition at line 547 of file console.cpp.

References _historyStart, redrawLines(), and updateScrollbarPosition().

Here is the call graph for this function:

◆ scrollDown()

void Engines::ConsoleWindow::scrollDown ( size_t  n = 1)

Definition at line 523 of file console.cpp.

References _historyStart, MIN(), redrawLines(), and updateScrollbarPosition().

Here is the call graph for this function:

◆ scrollTop()

void Engines::ConsoleWindow::scrollTop ( )

Definition at line 533 of file console.cpp.

References _historySizeCurrent, _historyStart, _lines, redrawLines(), and updateScrollbarPosition().

Here is the call graph for this function:

◆ scrollUp()

void Engines::ConsoleWindow::scrollUp ( size_t  n = 1)

Definition at line 513 of file console.cpp.

References _historySizeCurrent, _historyStart, _lines, redrawLines(), and updateScrollbarPosition().

Here is the call graph for this function:

◆ setInput()

void Engines::ConsoleWindow::setInput ( const Common::UString input,
size_t  cursorPos,
bool  overwrite 
)

Definition at line 236 of file console.cpp.

References _cursorBlinkState, _cursorPosition, _input, _inputText, _lastCursorBlink, _overwrite, GfxMan, and recalcCursor().

Here is the call graph for this function:

◆ setPrompt()

void Engines::ConsoleWindow::setPrompt ( const Common::UString prompt)

Definition at line 225 of file console.cpp.

References _input, _prompt, _x, _y, GfxMan, and recalcCursor().

Here is the call graph for this function:

◆ setRedirect()

bool Engines::ConsoleWindow::setRedirect ( Common::UString  redirect = "")

◆ show()

void Engines::ConsoleWindow::show ( )
virtual

Show the object.

Reimplemented from Graphics::Renderable.

Definition at line 128 of file console.cpp.

References _cursor, _highlight, _input, _lines, _prompt, GfxMan, and Graphics::Renderable::show().

Here is the call graph for this function:

◆ showPrompt()

void Engines::ConsoleWindow::showPrompt ( )

Definition at line 162 of file console.cpp.

References _cursor, _input, _prompt, GfxMan, and Graphics::Renderable::isVisible().

Here is the call graph for this function:

◆ startHighlight()

void Engines::ConsoleWindow::startHighlight ( int  x,
int  y 
)

Definition at line 407 of file console.cpp.

References _highlightX, _highlightY, clearHighlight(), getPosition(), highlightClip(), and updateHighlight().

Here is the call graph for this function:

◆ stopHighlight()

void Engines::ConsoleWindow::stopHighlight ( int  x,
int  y 
)

Definition at line 422 of file console.cpp.

References _highlightLength, _highlightX, _highlightY, getPosition(), highlightClip(), and updateHighlight().

Here is the call graph for this function:

◆ updateHighlight()

void Engines::ConsoleWindow::updateHighlight ( )
private

Definition at line 358 of file console.cpp.

References _font, _highlight, _highlightLength, _highlightX, _highlightY, _lineHeight, _x, _y, ABS(), Graphics::Aurora::FontHandle::getFont(), Graphics::Font::getWidth(), kConsoleLines, and MIN().

Referenced by clearHighlight(), highlightLine(), highlightWord(), startHighlight(), and stopHighlight().

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

◆ updateScrollbarLength()

void Engines::ConsoleWindow::updateScrollbarLength ( )
private

Definition at line 681 of file console.cpp.

References _height, _historySizeCurrent, _lines, _scrollbarLength, and CLIP().

Referenced by clear(), ConsoleWindow(), and printLine().

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

◆ updateScrollbarPosition()

void Engines::ConsoleWindow::updateScrollbarPosition ( )
private

Definition at line 691 of file console.cpp.

References _height, _historySizeCurrent, _historyStart, _lines, _scrollbarLength, _scrollbarPosition, and CLIP().

Referenced by clear(), ConsoleWindow(), scrollBottom(), scrollDown(), scrollTop(), and scrollUp().

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

Member Data Documentation

◆ _cursor

Common::ScopedPtr<Graphics::Aurora::GUIQuad> Engines::ConsoleWindow::_cursor
private

Definition at line 129 of file console.h.

Referenced by ConsoleWindow(), hide(), hidePrompt(), recalcCursor(), render(), show(), and showPrompt().

◆ _cursorBlinkState

bool Engines::ConsoleWindow::_cursorBlinkState
private

Definition at line 154 of file console.h.

Referenced by render(), and setInput().

◆ _cursorPosition

size_t Engines::ConsoleWindow::_cursorPosition
private

Definition at line 143 of file console.h.

Referenced by recalcCursor(), and setInput().

◆ _font

Graphics::Aurora::FontHandle Engines::ConsoleWindow::_font
private

Definition at line 126 of file console.h.

Referenced by ConsoleWindow(), getColumns(), getPosition(), print(), recalcCursor(), and updateHighlight().

◆ _height

float Engines::ConsoleWindow::_height
private

◆ _highlight

Common::ScopedPtr<Graphics::Aurora::GUIQuad> Engines::ConsoleWindow::_highlight
private

Definition at line 130 of file console.h.

Referenced by ConsoleWindow(), hide(), show(), and updateHighlight().

◆ _highlightLength

ptrdiff_t Engines::ConsoleWindow::_highlightLength
private

◆ _highlightX

size_t Engines::ConsoleWindow::_highlightX
private

◆ _highlightY

size_t Engines::ConsoleWindow::_highlightY
private

◆ _history

std::list<Common::UString> Engines::ConsoleWindow::_history
private

Definition at line 134 of file console.h.

Referenced by clear(), printLine(), and redrawLines().

◆ _historySizeCurrent

size_t Engines::ConsoleWindow::_historySizeCurrent
private

◆ _historySizeMax

size_t Engines::ConsoleWindow::_historySizeMax
private

Definition at line 132 of file console.h.

Referenced by printLine().

◆ _historyStart

size_t Engines::ConsoleWindow::_historyStart
private

◆ _input

Common::ScopedPtr<Graphics::Aurora::Text> Engines::ConsoleWindow::_input
private

◆ _inputText

Common::UString Engines::ConsoleWindow::_inputText
private

Definition at line 142 of file console.h.

Referenced by recalcCursor(), and setInput().

◆ _lastCursorBlink

uint32 Engines::ConsoleWindow::_lastCursorBlink
private

Definition at line 155 of file console.h.

Referenced by render(), and setInput().

◆ _lineHeight

float Engines::ConsoleWindow::_lineHeight
private

◆ _lines

std::vector<Graphics::Aurora::Text *> Engines::ConsoleWindow::_lines
private

◆ _logFile

Common::WriteFile Engines::ConsoleWindow::_logFile
private

Definition at line 164 of file console.h.

Referenced by closeLogFile(), openLogFile(), and printLine().

◆ _overwrite

bool Engines::ConsoleWindow::_overwrite
private

Definition at line 144 of file console.h.

Referenced by recalcCursor(), and setInput().

◆ _prompt

Common::ScopedPtr<Graphics::Aurora::Text> Engines::ConsoleWindow::_prompt
private

◆ _redirect

Common::WriteFile Engines::ConsoleWindow::_redirect
private

Definition at line 165 of file console.h.

Referenced by printLine(), setRedirect(), and ~ConsoleWindow().

◆ _scrollbarLength

float Engines::ConsoleWindow::_scrollbarLength
private

Definition at line 157 of file console.h.

Referenced by render(), updateScrollbarLength(), and updateScrollbarPosition().

◆ _scrollbarPosition

float Engines::ConsoleWindow::_scrollbarPosition
private

Definition at line 158 of file console.h.

Referenced by render(), and updateScrollbarPosition().

◆ _width

float Engines::ConsoleWindow::_width
private

Definition at line 151 of file console.h.

Referenced by getContentWidth(), getPosition(), getWidth(), isIn(), notifyResized(), print(), and render().

◆ _x

float Engines::ConsoleWindow::_x
private

◆ _y

float Engines::ConsoleWindow::_y
private

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