/* ================= UI_Credits_DrawFunc ================= */ static void UI_Credits_DrawFunc( void ) { int i, y; float speed = 40.0f; int w = UI_MED_CHAR_WIDTH; int h = UI_MED_CHAR_HEIGHT; int color = 0; // draw the background first if( !uiCredits.finalCredits && !CVAR_GET_FLOAT( "sv_background" )) UI_DrawPic( 0, 0, 1024 * uiStatic.scaleX, 768 * uiStatic.scaleY, uiColorWhite, ART_BACKGROUND ); else speed = 45.0f; // syncronize with final background track :-) // otherwise running on cutscene speed = 32.0f * (768.0f / ScreenHeight); // now draw the credits UI_ScaleCoords( NULL, NULL, &w, &h ); y = ScreenHeight - (((gpGlobals->time * 1000) - uiCredits.startTime ) / speed ); // draw the credits for ( i = 0; i < uiCredits.numLines && uiCredits.credits[i]; i++, y += h ) { // skip not visible lines, but always draw end line if( y <= -h && i != uiCredits.numLines - 1 ) continue; if(( y < ( ScreenHeight - h ) / 2 ) && i == uiCredits.numLines - 1 ) { if( !uiCredits.fadeTime ) uiCredits.fadeTime = (gpGlobals->time * 1000); color = UI_FadeAlpha( uiCredits.fadeTime, uiCredits.showTime ); if( UnpackAlpha( color )) UI_DrawString( 0, ( ScreenHeight - h ) / 2, 1024 * uiStatic.scaleX, h, uiCredits.credits[i], color, true, w, h, 1, true ); } else UI_DrawString( 0, y, 1024 * uiStatic.scaleX, h, uiCredits.credits[i], uiColorWhite, false, w, h, 1, true ); } if( y < 0 && UnpackAlpha( color ) == 0 ) { uiCredits.active = false; // end of credits if( uiCredits.finalCredits ) HOST_ENDGAME( gMenu.m_gameinfo.title ); } if( !uiCredits.active ) UI_PopMenu(); }
/* ================= UI_Credits_DrawFunc ================= */ static void UI_Credits_DrawFunc( void ) { int i, y; float speed = 32.0f * (768.0f / ScreenHeight); int w = UI_SMALL_CHAR_WIDTH; int h = UI_SMALL_CHAR_HEIGHT; int color = 0x00FFA000; // draw the background first UI_FillRect( 0, 0, ScreenWidth, ScreenHeight, uiColorBlack ); // now draw the credits UI_ScaleCoords( NULL, NULL, &w, &h ); y = ScreenHeight - (((gpGlobals->time * 1000) - uiCredits.startTime ) / speed ); // draw the credits for ( i = 0; i < uiCredits.numLines && uiCredits.credits[i]; i++, y += h ) { // skip not visible lines, but always draw end line if( y <= -h && i != uiCredits.numLines - 1 ) continue; if(( y < ( ScreenHeight - h ) / 2 ) && i == uiCredits.numLines - 1 ) { if( !uiCredits.fadeTime ) uiCredits.fadeTime = (gpGlobals->time * 1000); color = UI_FadeAlpha( uiCredits.fadeTime, uiCredits.showTime ); if( UnpackAlpha( color )) UI_DrawString( 0, ( ScreenHeight - h ) / 2, ScreenWidth, h, uiCredits.credits[i], color, true, w, h, 1, true ); } else UI_DrawString( 0, y, ScreenWidth, h, uiCredits.credits[i], uiColorWhite, false, w, h, 1, true ); } if( y < 0 && UnpackAlpha( color ) == 0 ) { uiCredits.active = false; // end of credits } if( !uiCredits.active ) UI_PopMenu(); }
/* ================= UI_DrawString ================= */ void UI_DrawString( int x, int y, int w, int h, const char *string, const int color, int forceColor, int charW, int charH, int justify, int shadow ) { int modulate, shadowModulate; char line[1024], *l; int xx, yy, ofsX, ofsY, len, ch; if( !string || !string[0] ) return; #if 0 // g-cont. disabled 29/06/2011 // this code do a bad things with prompt dialogues // vertically centered if( !strchr( string, '\n' )) y = y + (( h - charH ) / 2 ); #endif if( shadow ) { shadowModulate = PackAlpha( uiColorBlack, UnpackAlpha( color )); ofsX = charW / 8; ofsY = charH / 8; } modulate = color; yy = y; while( *string ) { // get a line of text len = 0; while( *string ) { if( *string == '\n' ) { string++; break; } line[len++] = *string++; if( len == sizeof( line ) - 1 ) break; } line[len] = 0; // align the text as appropriate if( justify == 0 ) xx = x; if( justify == 1 ) xx = x + ((w - (ColorStrlen( line ) * charW )) / 2); if( justify == 2 ) xx = x + (w - (ColorStrlen( line ) * charW )); // draw it l = line; while( *l ) { if( IsColorString( l )) { if( !forceColor ) { int colorNum = ColorIndex( *(l+1) ); modulate = PackAlpha( g_iColorTable[colorNum], UnpackAlpha( color )); } l += 2; continue; } ch = *l++; ch &= 255; // fix for letter ¸ if( ch == 0xB8 ) ch = (byte)'å'; if( ch == 0xA8 ) ch = (byte)'Å'; if( ch != ' ' ) { if( shadow ) TextMessageDrawChar( xx + ofsX, yy + ofsY, charW, charH, ch, shadowModulate, uiStatic.hFont ); TextMessageDrawChar( xx, yy, charW, charH, ch, modulate, uiStatic.hFont ); } xx += charW; } yy += charH; } }