1 ///////////////////////////////////////// 2 // 3 // OpenLieroX 4 // 5 // code under LGPL, based on JasonBs work, 6 // enhanced by Dark Charlie and Albert Zeyer 7 // 8 // 9 ///////////////////////////////////////// 10 11 12 // Chat Box class 13 // Created 10/5/01 14 // Jason Boettcher 15 16 17 #ifndef __CCHATBOX_H__ 18 #define __CCHATBOX_H__ 19 20 #include <SDL.h> 21 #include <list> 22 #include "Protocol.h" 23 #include "types.h" 24 #include "Color.h" 25 26 #define MAX_LLENGTH 128 27 28 29 // Line structure 30 struct line_t { 31 std::string strLine; 32 Color iColour; 33 TXT_TYPE iTextType; 34 AbsTime fTime; 35 size_t iID; 36 }; 37 38 typedef std::list<line_t> ct_lines_t; 39 typedef ct_lines_t::iterator lines_iterator; 40 typedef ct_lines_t::reverse_iterator lines_riterator; 41 42 class CChatBox { 43 public: 44 // Constructor CChatBox()45 CChatBox() { 46 Clear(); 47 } 48 ~CChatBox()49 ~CChatBox() { 50 Clear(); 51 } 52 53 private: 54 // Attributes 55 ct_lines_t Lines; 56 ct_lines_t NewLines; 57 58 public: 59 // Methods 60 void Clear(); 61 void AddText(const std::string& txt, Color colour, TXT_TYPE TextType, const AbsTime& time); 62 63 // Variables Begin()64 lines_iterator Begin() { return Lines.begin(); } End()65 lines_iterator End() { return Lines.end(); } 66 lines_iterator At(int i); RBegin()67 lines_riterator RBegin() { return Lines.rbegin(); } REnd()68 lines_riterator REnd() { return Lines.rend(); } 69 bool GetNewLine(line_t& ln); getNumLines()70 size_t getNumLines() { return Lines.size(); } 71 }; 72 73 74 75 76 #endif // __CCHATBOX_H__ 77