void Con_DrawRightFloatingTextLine( const int linePosition, const float *color, const char* text ) { int i, x; float currentWidthLocation = 0; const int charHeight = SCR_ConsoleFontCharHeight(); const int positionFromTop = consoleState.margin.top + consoleState.border.top + consoleState.padding.top + charHeight; i = strlen( text ); currentWidthLocation = cls.glconfig.vidWidth - SCR_ConsoleFontStringWidth( text, i ) - consoleState.margin.sides - consoleState.padding.sides; re.SetColor( color ); for ( x = 0; x < i; x++ ) { int ch = Q_UTF8_CodePoint( &text[ x ] ); SCR_DrawConsoleFontUnichar( currentWidthLocation, positionFromTop + ( linePosition * charHeight ), ch ); currentWidthLocation += SCR_ConsoleFontUnicharWidth( ch ); } }
/* ================ Con_DrawInput Draw the editline after a ] prompt ================ */ void Con_DrawInput( void ) { int y; char prompt[ MAX_STRING_CHARS ]; vec4_t color; qtime_t realtime; if ( cls.state != CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_CONSOLE ) ) { return; } Com_RealTime( &realtime ); y = con.vislines - ( SCR_ConsoleFontCharHeight() * 2 ) + 2; Com_sprintf( prompt, sizeof( prompt ), "^0[^3%02d%c%02d^0]^7 %s", realtime.tm_hour, ( realtime.tm_sec & 1 ) ? ':' : ' ', realtime.tm_min, cl_consolePrompt->string ); color[ 0 ] = 1.0f; color[ 1 ] = 1.0f; color[ 2 ] = 1.0f; color[ 3 ] = ( scr_conUseOld->integer ? 1.0f : con.displayFrac * 2.0f ); SCR_DrawSmallStringExt( con.xadjust + cl_conXOffset->integer, y + 10, prompt, color, qfalse, qfalse ); Q_CleanStr( prompt ); Field_Draw( &g_consoleField, con.xadjust + cl_conXOffset->integer + SCR_ConsoleFontStringWidth( prompt, strlen( prompt ) ), y + 10, qtrue, qtrue, color[ 3 ] ); }
/* ================ Con_DrawInput Draw the editline after a ] prompt ================ */ void Con_DrawInput( int linePosition, float overrideAlpha ) { char prompt[ MAX_STRING_CHARS ]; vec4_t color; qtime_t realtime; Com_RealTime( &realtime ); Com_sprintf( prompt, sizeof( prompt ), "^0[^3%02d%c%02d^0]^7 %s", realtime.tm_hour, ( realtime.tm_sec & 1 ) ? ':' : ' ', realtime.tm_min, con_prompt->string ); color[ 0 ] = 1.0f; color[ 1 ] = 1.0f; color[ 2 ] = 1.0f; color[ 3 ] = consoleState.currentAlphaFactor * overrideAlpha; SCR_DrawSmallStringExt( consoleState.margin.sides + consoleState.padding.sides, linePosition, prompt, color, qfalse, qfalse ); Q_CleanStr( prompt ); Field_Draw( g_consoleField, consoleState.margin.sides + consoleState.padding.sides + SCR_ConsoleFontStringWidth( prompt, strlen( prompt ) ), linePosition, qtrue, qtrue, color[ 3 ] ); }
/* ================ Con_DrawSolidConsole Draws the console with the solid background ================ */ void Con_DrawSolidConsole( float frac ) { int i, x, y; int rows; int row; int lines; // qhandle_t conShader; int currentColor; vec4_t color; float yVer; float totalwidth; float currentWidthLocation = 0; const int charHeight = SCR_ConsoleFontCharHeight(); if ( scr_conUseOld->integer ) { lines = cls.glconfig.vidHeight * frac; if ( lines <= 0 ) { return; } if ( lines > cls.glconfig.vidHeight ) { lines = cls.glconfig.vidHeight; } } else { lines = cls.glconfig.vidHeight * frac; } lines += charHeight / ( CONSOLE_FONT_VPADDING + 1 ); // on wide screens, we will center the text if (!scr_conUseOld->integer) { con.xadjust = 15; } SCR_AdjustFrom640 (&con.xadjust, NULL, NULL, NULL); // draw the background if ( scr_conUseOld->integer ) { yVer = 5 + charHeight; y = frac * SCREEN_HEIGHT; if ( y < 1 ) { y = 0; } else { if ( scr_conUseShader->integer ) { SCR_DrawPic( 0, 0, SCREEN_WIDTH, y, cls.consoleShader ); } else { // This will be overwritten, so i'll just abuse it here, no need to define another array color[ 0 ] = scr_conColorRed->value; color[ 1 ] = scr_conColorGreen->value; color[ 2 ] = scr_conColorBlue->value; color[ 3 ] = scr_conColorAlpha->value; SCR_FillRect( 0, 0, SCREEN_WIDTH, y, color ); } } color[ 0 ] = scr_conBarColorRed->value; color[ 1 ] = scr_conBarColorGreen->value; color[ 2 ] = scr_conBarColorBlue->value; color[ 3 ] = scr_conBarColorAlpha->value; SCR_FillRect( 0, y, SCREEN_WIDTH, scr_conBarSize->value, color ); } else { yVer = 10; SCR_AdjustFrom640( NULL, &yVer, NULL, NULL ); yVer = floor( yVer + 5 + charHeight ); color[ 0 ] = scr_conColorRed->value; color[ 1 ] = scr_conColorGreen->value; color[ 2 ] = scr_conColorBlue->value; color[ 3 ] = frac * 2 * scr_conColorAlpha->value; SCR_FillRect( 10, 10, 620, 460 * scr_conHeight->integer * 0.01, color ); color[ 0 ] = scr_conBarColorRed->value; color[ 1 ] = scr_conBarColorGreen->value; color[ 2 ] = scr_conBarColorBlue->value; color[ 3 ] = frac * 2 * scr_conBarColorAlpha->value; SCR_FillRect( 10, 10, 620, 1, color ); //top SCR_FillRect( 10, 460 * scr_conHeight->integer * 0.01 + 10, 621, 1, color ); //bottom SCR_FillRect( 10, 10, 1, 460 * scr_conHeight->integer * 0.01, color ); //left SCR_FillRect( 630, 10, 1, 460 * scr_conHeight->integer * 0.01, color ); //right } // draw the version number color[ 0 ] = 1.0f; color[ 1 ] = 1.0f; color[ 2 ] = 1.0f; color[ 3 ] = ( scr_conUseOld->integer ? 0.75f : frac * 0.75f ); re.SetColor( color ); i = strlen( Q3_VERSION ); totalwidth = SCR_ConsoleFontStringWidth( Q3_VERSION, i ) + cl_conXOffset->integer; if ( !scr_conUseOld->integer ) { totalwidth += 30; } currentWidthLocation = cls.glconfig.vidWidth - totalwidth; for ( x = 0; x < i; x++ ) { int ch = Q_UTF8CodePoint( &Q3_VERSION[ x ] ); SCR_DrawConsoleFontUnichar( currentWidthLocation, yVer, ch ); currentWidthLocation += SCR_ConsoleFontUnicharWidth( ch ); } // engine string i = strlen( Q3_ENGINE ); totalwidth = SCR_ConsoleFontStringWidth( Q3_ENGINE, i ) + cl_conXOffset->integer; if ( !scr_conUseOld->integer ) { totalwidth += 30; } currentWidthLocation = cls.glconfig.vidWidth - totalwidth; for ( x = 0; x < i; x++ ) { int ch = Q_UTF8CodePoint( &Q3_ENGINE[ x ] ); SCR_DrawConsoleFontUnichar( currentWidthLocation, yVer + charHeight, ch ); currentWidthLocation += SCR_ConsoleFontUnicharWidth( ch ); } // draw the input prompt, user text, and cursor if desired // moved back here (have observed render issues to do with time taken) Con_DrawInput(); // draw the text con.vislines = lines; rows = ( lines ) / SCR_ConsoleFontCharHeight() - 3; // rows of text to draw if ( scr_conUseOld->integer ) { rows++; } y = lines - ( SCR_ConsoleFontCharHeight() * 3 ) + 10; // draw from the bottom up if ( con.display != con.current ) { // draw arrows to show the buffer is backscrolled const int hatWidth = SCR_ConsoleFontUnicharWidth( '^' ); color[ 0 ] = 1.0f; color[ 1 ] = 0.0f; color[ 2 ] = 0.0f; color[ 3 ] = ( scr_conUseOld->integer ? 1.0f : frac * 2.0f ); re.SetColor( color ); for ( x = 0; x < con.linewidth - ( scr_conUseOld->integer ? 0 : 4 ); x += 4 ) { SCR_DrawConsoleFontUnichar( con.xadjust + ( x + 1 ) * hatWidth, y, '^' ); } y -= charHeight; rows--; } row = con.display; if ( con.x == 0 ) { row--; } currentColor = 7; color[ 0 ] = g_color_table[ currentColor ][ 0 ]; color[ 1 ] = g_color_table[ currentColor ][ 1 ]; color[ 2 ] = g_color_table[ currentColor ][ 2 ]; color[ 3 ] = ( scr_conUseOld->integer ? 1.0f : frac * 2.0f ); re.SetColor( color ); for ( i = 0; i < rows; i++, y -= charHeight, row-- ) { conChar_t *text; if ( row < 0 ) { break; } if ( con.current - row >= con.totallines ) { // past scrollback wrap point continue; } text = con.text + CON_LINE( row ); currentWidthLocation = cl_conXOffset->integer; for ( x = 0; x < con.linewidth && text[x].ch; ++x ) { if ( text[ x ].ink != currentColor ) { currentColor = text[ x ].ink; color[ 0 ] = g_color_table[ currentColor ][ 0 ]; color[ 1 ] = g_color_table[ currentColor ][ 1 ]; color[ 2 ] = g_color_table[ currentColor ][ 2 ]; color[ 3 ] = ( scr_conUseOld->integer ? 1.0f : frac * 2.0f ); re.SetColor( color ); } SCR_DrawConsoleFontUnichar( con.xadjust + currentWidthLocation, y, text[ x ].ch ); currentWidthLocation += SCR_ConsoleFontUnicharWidth( text[ x ].ch ); } } re.SetColor( NULL ); }