Dragonfly 4.20
A text-based game engine
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
df::DisplayManager Class Reference
Inheritance diagram for df::DisplayManager:
Inheritance graph

Public Member Functions

int startUp () override
 
void shutDown () override
 
int drawCh (Vector world_pos, char ch, Color color, float rotation=0.0f) const
 
int drawCh (Vector world_pos, char ch, unsigned char r, unsigned char g, unsigned char b, float rotation=0.0f) const
 
int drawString (Vector world_pos, std::string str, Justification just, Color color) const
 
void setHorizontal (int new_horizontal)
 
int getHorizontal () const
 
void setVertical (int new_vertical)
 
int getVertical () const
 
int getHorizontalPixels () const
 
int getVerticalPixels () const
 
bool setBackgroundColor (Color new_color)
 
void shake (int scale_x, int scale_y, int duration, bool delta=false)
 
int swapBuffers ()
 
sf::RenderWindow * getWindow () const
 
- Public Member Functions inherited from df::Manager
std::string getType () const
 
virtual int startUp ()
 
virtual void shutDown ()
 
bool isStarted () const
 
int onEvent (const Event *p_event) const
 
int registerInterest (Object *p_o, std::string event_type)
 
int unregisterInterest (Object *p_o, std::string event_type)
 

Static Public Member Functions

static DisplayManagergetInstance ()
 

Private Member Functions

 DisplayManager ()
 
 DisplayManager (DisplayManager const &)
 
void operator= (DisplayManager const &)
 

Private Attributes

sf::Font m_font
 
sf::RenderWindow * m_p_window
 
int m_window_horizontal_pixels
 
int m_window_vertical_pixels
 
int m_window_horizontal_chars
 
int m_window_vertical_chars
 
sf::RectangleShape * m_p_rectangle
 
sf::Color m_window_background_color
 
sf::Text * m_p_text
 
int m_shake_duration
 
int m_shake_scale_x
 
int m_shake_scale_y
 
int m_shake_x
 
int m_shake_y
 

Additional Inherited Members

- Protected Member Functions inherited from df::Manager
void setType (std::string new_type)
 

Constructor & Destructor Documentation

◆ DisplayManager() [1/2]

df::DisplayManager::DisplayManager ( )
private

Private since a singleton.

◆ DisplayManager() [2/2]

df::DisplayManager::DisplayManager ( DisplayManager const &  )
private

Don't allow copy.

Member Function Documentation

◆ drawCh() [1/2]

int df::DisplayManager::drawCh ( Vector  world_pos,
char  ch,
Color  color,
float  rotation = 0.0f 
) const

Draw character at window location (x,y) with color and rotation (degrees).

Return 0 if ok, else -1.

◆ drawCh() [2/2]

int df::DisplayManager::drawCh ( Vector  world_pos,
char  ch,
unsigned char  r,
unsigned char  g,
unsigned char  b,
float  rotation = 0.0f 
) const

Draw character at window location (x,y) with custom color, and rotation (degrees).

Return 0 if ok, else -1.

◆ drawString()

int df::DisplayManager::drawString ( Vector  world_pos,
std::string  str,
Justification  just,
Color  color 
) const

Draw string at window location (x,y) with color.

Justified left, center or right. Return 0 if ok, else -1.

◆ getHorizontal()

int df::DisplayManager::getHorizontal ( ) const

Return window's horizontal maximum (in characters).

◆ getHorizontalPixels()

int df::DisplayManager::getHorizontalPixels ( ) const

Return window's horizontal maximum (in pixels).

◆ getInstance()

static DisplayManager & df::DisplayManager::getInstance ( )
static

Get the one and only instance of the DisplayManager.

◆ getVertical()

int df::DisplayManager::getVertical ( ) const

Return window's vertical maximum (in characters).

◆ getVerticalPixels()

int df::DisplayManager::getVerticalPixels ( ) const

Return window's vertical maximum (in pixels).

◆ getWindow()

sf::RenderWindow * df::DisplayManager::getWindow ( ) const

Return pointer to SFML graphics window.

◆ operator=()

void df::DisplayManager::operator= ( DisplayManager const &  )
private

Don't allow assignment.

◆ setBackgroundColor()

bool df::DisplayManager::setBackgroundColor ( Color  new_color)

Set window's background color.

Return true if ok, else false.

◆ setHorizontal()

void df::DisplayManager::setHorizontal ( int  new_horizontal)

Set window's horizontal maximum (in characters).

◆ setVertical()

void df::DisplayManager::setVertical ( int  new_vertical)

Set window's vertical maximum (in characters).

◆ shake()

void df::DisplayManager::shake ( int  scale_x,
int  scale_y,
int  duration,
bool  delta = false 
)

"Shake" window with severity scale (pixels) and duration (frames).

Delta true then add else replace.

◆ shutDown()

void df::DisplayManager::shutDown ( )
overridevirtual

Close graphics window.

Reimplemented from df::Manager.

◆ startUp()

int df::DisplayManager::startUp ( )
overridevirtual

Open graphics window, ready for text-based display.

Return 0 if ok, else -1.

Reimplemented from df::Manager.

◆ swapBuffers()

int df::DisplayManager::swapBuffers ( )

Render current window buffer.

Return 0 if ok, else -1.

Member Data Documentation

◆ m_font

sf::Font df::DisplayManager::m_font
private

Font used for ASCII graphics.

◆ m_p_rectangle

sf::RectangleShape* df::DisplayManager::m_p_rectangle
private

Backing rectangle for under text.

◆ m_p_text

sf::Text* df::DisplayManager::m_p_text
private

ASCII character to draw.

◆ m_p_window

sf::RenderWindow* df::DisplayManager::m_p_window
private

Pointer to SFML window.

◆ m_shake_duration

int df::DisplayManager::m_shake_duration
private

Time left to shake (frames).

◆ m_shake_scale_y

int df::DisplayManager::m_shake_scale_y
private

Severity of shake (pixels).

◆ m_shake_y

int df::DisplayManager::m_shake_y
private

Shake (this frame).

◆ m_window_background_color

sf::Color df::DisplayManager::m_window_background_color
private

Background color of window.

◆ m_window_horizontal_chars

int df::DisplayManager::m_window_horizontal_chars
private

Horizontal ASCII spaces in window.

◆ m_window_horizontal_pixels

int df::DisplayManager::m_window_horizontal_pixels
private

Horizontal pixels in window.

◆ m_window_vertical_chars

int df::DisplayManager::m_window_vertical_chars
private

Vertical ASCII spaces in window.

◆ m_window_vertical_pixels

int df::DisplayManager::m_window_vertical_pixels
private

Vertical pixels in window.