00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "Title.h"
00010
00011 #include "Font.h"
00012 #include "Color.h"
00013 #include "OptionAgent.h"
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 Title::Title(int baseY, int finalY, int bonusTime, int limitY,
00030 const std::string &content, Font *font, const Color *color)
00031 : m_content(content)
00032 {
00033 m_font = font;
00034 m_surface = m_font->renderTextOutlined(content, *color);
00035
00036 int text_width = m_font->calcTextWidth(content);
00037
00038 m_screenW = OptionAgent::agent()->getAsInt("screen_width");
00039 m_screenH = OptionAgent::agent()->getAsInt("screen_height");
00040 m_x = (m_screenW - text_width) / 2;
00041 m_y = m_screenH - baseY;
00042 m_finalY = m_screenH - finalY;
00043 m_limitY = m_screenH - limitY;
00044 m_mintime = m_content.size() * TIME_PER_CHAR;
00045 if (m_mintime < TIME_MIN) {
00046 m_mintime = TIME_MIN;
00047 }
00048 m_mintime += bonusTime;
00049 }
00050
00051 Title::~Title()
00052 {
00053 SDL_FreeSurface(m_surface);
00054 }
00055
00056
00057
00058
00059 void
00060 Title::drawOn(SDL_Surface *screen)
00061 {
00062
00063 SDL_Rect rect;
00064 rect.x = m_x;
00065 rect.y = m_y;
00066
00067 SDL_BlitSurface(m_surface, NULL, screen, &rect);
00068 }
00069
00070
00071
00072
00073
00074 void
00075 Title::shiftUp(int rate)
00076 {
00077 m_mintime--;
00078 m_y -= rate;
00079 if (m_y < m_finalY) {
00080 m_y = m_finalY;
00081 }
00082 }
00083
00084 void
00085 Title::shiftFinalUp(int rate)
00086 {
00087 m_finalY -= rate;
00088 }
00089
00090
00091
00092
00093 int
00094 Title::getY() const
00095 {
00096 return m_screenH - m_y;
00097 }
00098
00099
00100
00101
00102 bool
00103 Title::isGone()
00104 {
00105
00106 return (m_mintime < 0 || m_y < m_limitY);
00107
00108 }
00109