OpenMortal Apocalypse mirror
Sourceforge mirror
SourceForge.net Logo
      News | Info | Characters | Arenas | Screenshots | Forums | Download  
Developer: Making of | Character-HOWTO | AI Design | Submit a Character
Documentation: Main Page | Modules | Class Hierarchy | Class List | File List

FlyingChars.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           FlyingChars.h  -  description
00003                              -------------------
00004     begin                : Mon Aug 12 2003
00005     copyright            : (C) 2003 by upi
00006     email                : upi@apocalypse.rulez.org
00007  ***************************************************************************/
00008 
00009 
00010 
00011 #ifndef FLYINGCHARS_H
00012 #define FLYINGCHARS_H
00013 
00014 
00015 #include "sge_bm_text.h"
00016 #include <vector>
00017 #include <list>
00018 
00019 
00027 class CFlyingChars
00028 {
00029 
00030     struct SFlyingLetter
00031     {
00032         int m_iX, m_iY;
00033         int m_iSX, m_iSY;
00034         int m_iDX, m_iDY;
00035         int m_iDelay;
00036         int m_iTime;
00037         unsigned char m_cLetter;
00038     };
00039 
00040 public:
00041 
00042     enum TextAlignmentEnum {
00043         FC_AlignLeft,
00044         FC_AlignRight,
00045         FC_AlignCenter,
00046         FC_AlignJustify,
00047     };
00048 
00049 public:
00050     CFlyingChars( sge_bmpFont* a_poFont, const SDL_Rect& a_roRect, int a_iFontDisplacement = 0 );
00051     ~CFlyingChars();
00052     
00053     void AddText( const char* a_pcText, TextAlignmentEnum a_enAlignment, bool bOneByOne );
00054     
00055     void Advance( int a_iNumFrames );
00056     void Draw();
00057     bool IsDone();
00058     int GetCount();
00059     
00060 protected:
00061     void AddNextLine();
00062     int GetCharWidth( unsigned char a_cChar );
00063     void DequeueText();
00064 
00065 protected:
00066 
00067     struct SEnqueuedText
00068     {
00069         const char*             m_pcText;
00070         TextAlignmentEnum       m_enAlignment;
00071     };
00072     std::list<SEnqueuedText>    m_oEnqueuedTexts;
00073     bool                        m_bDone;
00074 
00075     bool                        m_bScrolling;
00076     double                      m_dScrollupRate;
00077     double                      m_dScrollup;
00078 
00079     typedef std::vector<SFlyingLetter>  CFlyingLetterList;
00080     typedef CFlyingLetterList::iterator CFlyingLetterIterator;
00081 
00082     sge_bmpFont*                m_poFont;
00083     int                         m_iFontDisplacement;
00084     CFlyingLetterList           m_oLetters;
00085     int                         m_iTimeToNextLine;
00086 
00087     SDL_Rect                    m_oRect;    
00088     const unsigned char*        m_pcText;
00089     TextAlignmentEnum           m_enAlignment;
00090     int                         m_iTextOffset;
00091     int                         m_iLastLineY;
00092     int                         m_iDelay;
00093 };
00094 
00095 #endif //  FLYINGCHARS_H