00001 #ifndef HEADER_SUBTITLEAGENT_H 00002 #define HEADER_SUBTITLEAGENT_H 00003 00004 class ResColorPack; 00005 class Title; 00006 class Font; 00007 class Color; 00008 00009 #include "BaseAgent.h" 00010 #include "Drawable.h" 00011 #include "Name.h" 00012 00013 #include <string> 00014 #include <deque> 00015 00016 /** 00017 * Subtitles manager. 00018 */ 00019 class SubTitleAgent : public BaseAgent, public Drawable { 00020 AGENT(SubTitleAgent, Name::SUBTITLE_NAME); 00021 public: 00022 static const int TITLE_ROW = 26; 00023 static const int TITLE_BASE = 20; 00024 static const int TITLE_SPEED = 2; 00025 static const int TITLE_BORDER = 20; 00026 static const int TITLE_LIMIT_Y = TITLE_BASE + 5 * TITLE_ROW; 00027 typedef std::deque<Title*> t_titles; 00028 t_titles m_titles; 00029 00030 Font *m_font; 00031 ResColorPack *m_colors; 00032 int m_limitY; 00033 private: 00034 std::string splitAndCreate(const std::string &subtitle, const Color *color); 00035 void trimRest(std::string &buffer); 00036 void newShortSubtitle(const std::string &subtitle, const Color *color); 00037 00038 void shiftTitlesUp(int rate); 00039 void shiftFinalsUp(int rate); 00040 int lowestY(); 00041 protected: 00042 virtual void own_init(); 00043 virtual void own_update(); 00044 virtual void own_shutdown(); 00045 public: 00046 int getLimitY() const { return m_limitY; } 00047 void setLimitY(int limitY) { m_limitY = limitY; } 00048 void addFont(const std::string &fontname, Color *new_color); 00049 void newSubtitle(const std::string &subtitle, const std::string &fontname); 00050 00051 void killTalks(); 00052 void removeAll(); 00053 00054 virtual void drawOn(SDL_Surface *screen); 00055 }; 00056 00057 #endif 00058