00001 /****************************************************************************** 00002 * Wormux is a convivial mass murder game. 00003 * Copyright (C) 2001-2004 Lawrence Azzoug. 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00018 ****************************************************************************** 00019 * Messages s'affichant en haut de l'ecran (et écrit dans la console). 00020 *****************************************************************************/ 00021 00022 #ifndef GAME_MESSAGES_H 00023 #define GAME_MESSAGES_H 00024 //----------------------------------------------------------------------------- 00025 #include "../include/base.h" 00026 #include "../graphic/text.h" 00027 #include <string> 00028 #include <list> 00029 //----------------------------------------------------------------------------- 00030 00031 /* 00032 * Class Message 00033 * derivated from Text 00034 * Stores a Text and a date (typically the date of creation of the message) 00035 */ 00036 class Message : public Text 00037 { 00038 public: 00039 Message(const std::string &new_txt, 00040 const Color &new_color, Font* new_font, 00041 uint _time) : 00042 Text(new_txt, new_color, new_font), 00043 time(_time) {}; 00044 inline uint get_time() 00045 { return time; } 00046 private: 00047 uint time; 00048 }; 00049 /* 00050 * class GameMessages 00051 * stores and displays messages on the screen 00052 * 00053 * use 00054 * void Add(const std::string &message) 00055 * to add a message 00056 */ 00057 class GameMessages 00058 { 00059 public: 00060 static GameMessages * GetInstance(); 00061 00062 // remove all messages 00063 void Reset(); 00064 00065 // display all messages in list 00066 void Draw(); 00067 00068 // Remove too old messages 00069 void Refresh(); 00070 00071 // Add a message 00072 void Add(const std::string &message); 00073 00074 private: 00075 std::list<Message *> liste; 00076 typedef std::list<Message *>::iterator iterator; 00077 static GameMessages * singleton; 00078 GameMessages(); 00079 }; 00080 00081 //----------------------------------------------------------------------------- 00082 #endif