33 fxAnimatedText::fxAnimatedText(
void)
35 _ttLineAnim.parameters(1.5);
41 _bFX_Slide = _bFX_Ramble = _bFX_Chaos = M_FALSE;
44 fxAnimatedText::~fxAnimatedText(
void)
49 void fxAnimatedText::animate(laTimer &t)
51 _ttLineAnim.animate(t);
53 if( _ttLineAnim.isElapsed() && (_nVisible<_vLines.size()) )
59 for(
unsigned i=0; i<_nVisible; i++)
63 if( _vLines[i].dBias > 0 ) _vLines[i].dBias -= t.delta()*0.8;
64 else _vLines[i].dBias = 0;
76 void fxAnimatedText::draw(
laRenderer *r, laPoint3 pos)
78 PROFILE_REN(fxAnimatedText_draw);
81 double alpha, ofx, ofy;
83 _pFont->ctlAlignH(_align);
84 _pFont->ctlAlignV(
M_AT);
86 for(
unsigned i=0; i<_nVisible; i++)
91 alpha = _color[3]- _ttLineAnim.reminder()*_color.a();
92 sz = _dFontSz - (_dFontSz*0.1)*_ttLineAnim.reminder();
94 else { alpha = _color.a(); sz = _dFontSz; }
100 ofx += sin( _ang*_dFX_Slide_speedx ) * (_vLines[i].dBias) * _dFX_Slide_rangex;
101 ofy += sin( _ang*_dFX_Slide_speedy ) * (_vLines[i].dBias) * _dFX_Slide_rangey;
106 ofx += sin( _ang*_dFX_Ramble_speedx + (_vLines[i].dRandBias-0.5)*90 ) * _dFX_Ramble_rangex;
107 ofy += sin( _ang*_dFX_Ramble_speedy + (_vLines[i].dRandBias-0.5)*90 ) * _dFX_Ramble_rangey;
113 r->transTranslate( pos + laPoint3(ofx, ofy + i*( _dFontSz * _dLineSpacing )) );
114 if(_bFX_Chaos) r->transRotate( _vLines[i].dRandBias*_dFX_Chaos_arange - (_dFX_Chaos_arange/2.0), laPoint3(0,0,1) );
117 r->styleSet( laColor(_color.r()*0.4, _color.g()*0.4, _color.b()*0.4, alpha) );
118 _pFont->draw( laPoint3(2,2,0), _vLines[i].strText );
121 r->styleSet( laColor(_color.r(), _color.g(), _color.b(), alpha) );
122 _pFont->draw( laPoint3(), _vLines[i].strText );
137 fp->readSectionSeparator(strSection);
139 if(!strcmp(strSection,
"End"))
break;
141 _vLines.push_back( _laIntroTextLine(fp) );
152 void fxAnimatedText::replace(
char* strFind,
char* strFormat, ...)
155 char strTarget[M_ANIMETED_TEXT_MAX_LINE];
157 if (!strFormat)
return;
159 va_start(ap, strFormat);
160 vsnprintf(strTarget, M_ANIMETED_TEXT_MAX_LINE-1, strFormat, ap);
163 for(
unsigned i=0; i<_vLines.size(); i++)
167 while( ps = strstr(_vLines[i].strText, strFind) )
170 char temp[M_ANIMETED_TEXT_MAX_LINE];
171 unsigned n = (unsigned)(ps - _vLines[i].strText);
173 strncpy(temp, _vLines[i].strText, n);
176 strncat(temp, strTarget, M_ANIMETED_TEXT_MAX_LINE-1);
177 strncat(temp, _vLines[i].strText + n + strlen(strFind), M_ANIMETED_TEXT_MAX_LINE-1);
179 strncpy(_vLines[i].strText, temp, M_ANIMETED_TEXT_MAX_LINE-1);
#define M_AT
Text align top.
Virtual interface for the Engine graphics renderer.