GameMessages Class Reference

#include <game_msg.h>

Collaboration diagram for GameMessages:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void Reset ()
void Draw ()
void Refresh ()
void Add (const std::string &message)

Static Public Member Functions

static GameMessagesGetInstance ()

Private Types

typedef std::list< Message
* >::iterator 
iterator

Private Member Functions

 GameMessages ()

Private Attributes

std::list< Message * > liste

Static Private Attributes

static GameMessagessingleton = NULL

Detailed Description

Definition at line 57 of file game_msg.h.


Member Typedef Documentation

typedef std::list<Message *>::iterator GameMessages::iterator [private]

Definition at line 76 of file game_msg.h.


Constructor & Destructor Documentation

GameMessages::GameMessages (  )  [private]

Definition at line 50 of file game_msg.cpp.

00050                            {
00051 }

Here is the caller graph for this function:


Member Function Documentation

void GameMessages::Add ( const std::string &  message  ) 

Definition at line 91 of file game_msg.cpp.

00091                                               {
00092   // Debug message
00093   std::cout << "o MSG: " << message << std::endl;
00094   // Add message at the end of the list
00095   Message * newMessage = new Message(message, white_color, Font::GetInstance(Font::FONT_SMALL), Time::GetInstance()->Read());
00096   liste.push_back (newMessage);
00097 
00098   /* if there are too many messages, remove some of them */
00099   while( NBR_MSG_MAX < liste.size()) {
00100     Message * msg = liste.front();
00101     assert(msg); /* the message must be valid if nothing went wrong */
00102     liste.pop_front();
00103     delete msg;
00104   }
00105 }

Here is the call graph for this function:

Here is the caller graph for this function:

void GameMessages::Draw (  ) 

Definition at line 65 of file game_msg.cpp.

00065                        {
00066   // Display messages
00067   uint msgy = 50;
00068 
00069   for( iterator i=liste.begin(); i != liste.end(); ++i ){
00070     (*i)->DrawCenterTop(AppWormux::GetInstance()->video.window.GetWidth()/2, msgy);
00071     msgy += HAUT_POLICE_MINI + INTERLIGNE_MINI;
00072   }
00073 }

Here is the call graph for this function:

Here is the caller graph for this function:

GameMessages * GameMessages::GetInstance (  )  [static]

Definition at line 43 of file game_msg.cpp.

00043                                          {
00044   if (singleton == NULL) {
00045     singleton = new GameMessages();
00046   }
00047   return singleton;
00048 }

Here is the call graph for this function:

Here is the caller graph for this function:

void GameMessages::Refresh (  ) 

Definition at line 76 of file game_msg.cpp.

00076                           {
00077   iterator i;
00078   for( i=liste.begin(); i != liste.end(); ){
00079     Message * msg = *i;
00080     if( MSG_LIFESPAN < Time::GetInstance()->Read() - msg->get_time() ){
00081       delete (msg);
00082       /* erase method return the next element */
00083       i = liste.erase (i);
00084     }
00085     else /* nothing was removed, take next */
00086       i++;
00087   }
00088 }

Here is the call graph for this function:

Here is the caller graph for this function:

void GameMessages::Reset (  ) 

Definition at line 54 of file game_msg.cpp.

00054                         {
00055   iterator i;
00056   for( i=liste.begin(); i != liste.end(); i++){
00057     Message * msg = *i;
00058     assert(msg); /* the message must be valid if nothing went wrong */
00059     delete (msg);
00060     msg = NULL;
00061   }
00062   liste.clear();
00063 }

Here is the caller graph for this function:


Member Data Documentation

std::list<Message *> GameMessages::liste [private]

Definition at line 75 of file game_msg.h.

GameMessages * GameMessages::singleton = NULL [static, private]

Definition at line 77 of file game_msg.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 13:50:19 2007 for Wormux by  doxygen 1.4.7