Main Page   Class Hierarchy   Compound List   File List   Compound Members  

StatusPanel Class Reference

Status Panel. More...

#include <statuspanel.h>

Inheritance diagram for StatusPanel:

Inheritance graph
[legend]
Collaboration diagram for StatusPanel:

Collaboration graph
[legend]
List of all members.

Public Methods

 StatusPanel ()
 Basic constructor. More...

 StatusPanel (const unsigned int x, const unsigned int y, const unsigned int w, const unsigned int h)
 Constructor. More...

virtual ~StatusPanel ()
 Destructor.

StatusPanel & operator= (StatusPanel const &other)
 Assignment operator.

bool draw (SDL_Surface *screen, Player *player)
 Draws the status panel. More...

void addMessage (string const &message, const Uint32 color)
 Add a message to the list of messages to draw. More...

void updateCurrentText (string const &text)
 Update the current text. More...

virtual void setFont (TTF_Font *font)
void setNeedToDraw (bool value)

Static Public Attributes

const string STATUS_BITMAP_FILE = string("statuspanel.bmp")
 Name of the file with the background bitmap.

const unsigned int INFO_BOX_WIDTH = 454
const unsigned int INFO_BOX_HEIGHT = 112

Private Methods

void drawInfoBox (SDL_Surface *screen)
 Aux function to draw the info/chat box. More...


Private Attributes

deque< pair< string, Uint32 > > messages
 List of messages. More...

string currentText
 Current text. More...

bool needToDraw
 Do we need to draw?. More...

unsigned int lines
int resources [NUMRESOURCES]

Detailed Description

Status Panel.

This class is used to draws the bottom part of the screen

where several status information is displayed. On the left

there is a list of resources and their amounts and on the

right there is a chat and info area.


Constructor & Destructor Documentation

StatusPanel::StatusPanel  
 

Basic constructor.

This constructor does not do anything useful. Probably

you shouldn't never use this one

StatusPanel::StatusPanel const unsigned int    x,
const unsigned int    y,
const unsigned int    w,
const unsigned int    h
 

Constructor.

This constructor creates a surface for this panel

with the given dimensions and the format of the

screen surface. Important: you can not call this constructor

before initializing the video because it need to access

to the screen surface with SDL_GetVideoSurface().

Parameters:
x  x coordinate of the upper left corner of the surface
y  y coordinate of the upper left corner of the surface
w  width of the surface
h  height of the surface
font  pointer to the font used in the game


Member Function Documentation

void StatusPanel::addMessage string const &    message,
const Uint32    color
 

Add a message to the list of messages to draw.

Add a pair of message and color to the list of messages to draw.

Parameters:
message  the text of the message
color  the color of the message

bool StatusPanel::draw SDL_Surface *    screen,
Player *    player
 

Draws the status panel.

Draws the status panel displaying the resources on the left

and a box with the messages on the right

Parameters:
screen  the screen surface where we are goint to draw
Returns:
true if the screen was updated

void StatusPanel::drawInfoBox SDL_Surface *    screen [private]
 

Aux function to draw the info/chat box.

Draw the background and then as many messages as they fit in

the box. First drawing the new ones and then the old ones.

Parameters:
screen  the screen surface where we are goint to draw

void StatusPanel::updateCurrentText string const &    text
 

Update the current text.

Update the text in the editing line that the user uses to enter

text for the chat.

Parameters:
text  the text that will replace the edit line


Member Data Documentation

string StatusPanel::currentText [private]
 

Current text.

The text in the edit line

deque<pair<string, Uint32> > StatusPanel::messages [private]
 

List of messages.

each element is a pair of text and color. This is a double

ended queue but it is used as a regular queue with iterator

capabilities.

bool StatusPanel::needToDraw [private]
 

Do we need to draw?.

With this simple variable we get some more fps by redrawing

this part of the screen only if we have to do it.


The documentation for this class was generated from the following files:
Generated on Thu Jun 6 17:22:24 2002 for Perihelion by doxygen1.2.15