Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 58 additions & 12 deletions code/client/cl_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,8 @@ DRAWING
==============================================================================
*/

extern cvar_t *cl_consoleScale; // leilei - scale the console


/*
================
Expand All @@ -536,7 +538,7 @@ void Con_DrawInput (void) {

re.SetColor( con.color );

SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, ']' );
SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, ']' ,2);

Field_Draw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH, y,
SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue, qtrue );
Expand Down Expand Up @@ -587,7 +589,7 @@ void Con_DrawNotify (void)
currentColor = (text[x]>>8) % NUMBER_OF_COLORS;
re.SetColor( g_color_table[currentColor] );
}
SCR_DrawSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*SMALLCHAR_WIDTH, v, text[x] & 0xff );
SCR_DrawSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*SMALLCHAR_WIDTH, v, text[x] & 0xff ,2);
}

v += SMALLCHAR_HEIGHT;
Expand Down Expand Up @@ -636,6 +638,17 @@ void Con_DrawSolidConsole( float frac ) {
int currentColor;
vec4_t color;

if (cl_consoleScale->integer && (cls.glconfig.vidWidth > SCREEN_WIDTH))
{
lines = SCREEN_HEIGHT * frac;
if (lines <= 0)
return;

if (lines > SCREEN_HEIGHT )
lines = SCREEN_HEIGHT;
}
else
{
lines = cls.glconfig.vidHeight * frac;
if (lines <= 0)
return;
Expand All @@ -646,6 +659,7 @@ void Con_DrawSolidConsole( float frac ) {
// on wide screens, we will center the text
con.xadjust = 0;
SCR_AdjustFrom640( &con.xadjust, NULL, NULL, NULL );
}

// draw the background
y = frac * SCREEN_HEIGHT;
Expand All @@ -667,26 +681,58 @@ void Con_DrawSolidConsole( float frac ) {
}
}

color[0] = 1;
color[1] = 0;
color[2] = 0;
// leilei - normalize our custom color for the line
//color[0] = 1;
//color[1] = 0; // was 1 pre-1.25
//color[2] = 0;

// leilei - normalize from our custom console color and apply it to the line
{
float max;
float rgb[3];

rgb[0] = cl_consoleColor[0]->value;
rgb[1] = cl_consoleColor[1]->value;
rgb[2] = cl_consoleColor[2]->value;

max = rgb[0] + rgb[1] + rgb[2] / 3;

if (max > 0)
{
color[0] = rgb[0] / max;
color[1] = rgb[1] / max;
color[2] = rgb[2] / max;
}
}


if( !cl_consoleType->integer )
color[3] = 1;
SCR_FillRect( 0, y, SCREEN_WIDTH, 2, color );


// draw the version number

re.SetColor( g_color_table[ColorIndex(COLOR_RED)] );
re.SetColor( g_color_table[ColorIndex(cl_consoleAccent->integer)] );

i = strlen( Q3_VERSION );

for (x=0 ; x<i ; x++) {
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * SMALLCHAR_WIDTH,
lines - SMALLCHAR_HEIGHT, Q3_VERSION[x] );
if (cl_consoleScale->integer && (cls.glconfig.vidWidth > SCREEN_WIDTH)){
for (x=0 ; x<i ; x++) {
SCR_DrawSmallChar( SCREEN_WIDTH - ( i - x + 1 ) * SMALLCHAR_WIDTH,
lines - SMALLCHAR_HEIGHT, Q3_VERSION[x], 1 );
}
}
else
{
for (x=0 ; x<i ; x++) {
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * SMALLCHAR_WIDTH,
lines - SMALLCHAR_HEIGHT, Q3_VERSION[x], 0 );
}
}



// draw the text
con.vislines = lines;
rows = (lines-SMALLCHAR_WIDTH)/SMALLCHAR_WIDTH; // rows of text to draw
Expand All @@ -697,9 +743,9 @@ void Con_DrawSolidConsole( float frac ) {
if (con.display != con.current)
{
// draw arrows to show the buffer is backscrolled
re.SetColor( g_color_table[ColorIndex(COLOR_RED)] );
re.SetColor( g_color_table[ColorIndex(cl_consoleAccent->integer)] );
for (x=0 ; x<con.linewidth ; x+=4)
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, '^' );
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, '^' ,2);
y -= SMALLCHAR_HEIGHT;
rows--;
}
Expand Down Expand Up @@ -733,7 +779,7 @@ void Con_DrawSolidConsole( float frac ) {
currentColor = (text[x]>>8) % NUMBER_OF_COLORS;
re.SetColor( g_color_table[currentColor] );
}
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, text[x] & 0xff );
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, text[x] & 0xff, 2 );
}
}

Expand Down
2 changes: 1 addition & 1 deletion code/client/cl_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
i = drawLen - strlen( str );

if ( size == SMALLCHAR_WIDTH ) {
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar );
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar, 2 );
} else {
str[0] = cursorChar;
str[1] = 0;
Expand Down
19 changes: 14 additions & 5 deletions code/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ cvar_t *cl_consoleType;
cvar_t *cl_consoleColor[4];

cvar_t *cl_consoleHeight;
cvar_t *cl_consoleAccent; // leilei - change version and line color
cvar_t *cl_consoleScale; // leilei - scale the console

clientActive_t cl;
clientConnection_t clc;
Expand Down Expand Up @@ -3115,6 +3117,11 @@ void CL_InitRenderer( void ) {
cls.charSetShader = re.RegisterShader( "gfx/2d/bigchars" );
cls.whiteShader = re.RegisterShader( "white" );
cls.consoleShader = re.RegisterShader( "console" );
if (!cls.consoleShader) // leilei - fallback console type if it fails
{
Cvar_Set("cl_consoleType", "2");
Com_Printf( "Console shader failed to load, falling back to simple console\n");
}
g_console_field_width = cls.glconfig.vidWidth / SMALLCHAR_WIDTH - 2;
g_consoleField.widthInChars = g_console_field_width;
}
Expand Down Expand Up @@ -3552,12 +3559,14 @@ void CL_Init( void ) {
cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE);

cl_consoleType = Cvar_Get( "cl_consoleType", "0", CVAR_ARCHIVE );
cl_consoleColor[0] = Cvar_Get( "cl_consoleColorRed", "1", CVAR_ARCHIVE );
cl_consoleColor[1] = Cvar_Get( "cl_consoleColorGreen", "0", CVAR_ARCHIVE );
cl_consoleColor[2] = Cvar_Get( "cl_consoleColorBlue", "0", CVAR_ARCHIVE );
cl_consoleColor[0] = Cvar_Get( "cl_consoleColorRed", "0.104", CVAR_ARCHIVE );
cl_consoleColor[1] = Cvar_Get( "cl_consoleColorGreen", "0.187", CVAR_ARCHIVE );
cl_consoleColor[2] = Cvar_Get( "cl_consoleColorBlue", "0.312", CVAR_ARCHIVE );
cl_consoleColor[3] = Cvar_Get( "cl_consoleColorAlpha", "0.8", CVAR_ARCHIVE );

cl_consoleHeight = Cvar_Get("cl_consoleHeight", "0.5", CVAR_ARCHIVE);
cl_consoleAccent = Cvar_Get("cl_consoleAccent", "61" , CVAR_ARCHIVE); // leilei - change version and scroll color
cl_consoleScale = Cvar_Get ("cl_consoleScale" , "1" , CVAR_ARCHIVE); // leilei - console/notify text scale

// userinfo
Cvar_Get ("name", "UnnamedPlayer", CVAR_USERINFO | CVAR_ARCHIVE );
Expand All @@ -3567,8 +3576,8 @@ void CL_Init( void ) {
Cvar_Get ("headmodel", "sarge", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("team_model", "james", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("team_headmodel", "*james", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("g_redTeam", "Stroggs", CVAR_SERVERINFO | CVAR_ARCHIVE);
Cvar_Get ("g_blueTeam", "Pagans", CVAR_SERVERINFO | CVAR_ARCHIVE);
Cvar_Get ("g_redTeam", "Red", CVAR_SERVERINFO | CVAR_ARCHIVE);
Cvar_Get ("g_blueTeam", "Blue", CVAR_SERVERINFO | CVAR_ARCHIVE);
Cvar_Get ("color1", "4", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("color2", "5", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("handicap", "100", CVAR_USERINFO | CVAR_ARCHIVE );
Expand Down
117 changes: 96 additions & 21 deletions code/client/cl_scrn.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,35 @@ void SCR_AdjustFrom640( float *x, float *y, float *w, float *h ) {
}
}


/*
================
SCR_AdjustFrom480

leilei - Adjusted for resolution and screen aspect ratio.... but from vertical only so the aspect is ok
================
*/
void SCR_AdjustFrom480( float *x, float *y, float *w, float *h ) {
float yscale;

// scale for screen sizes
yscale = cls.glconfig.vidHeight / 480.0;

if ( x ) {
*x *= yscale;
}
if ( y ) {
*y *= yscale;
}
if ( w ) {
*w *= yscale;
}
if ( h ) {
*h *= yscale;
}
}


/*
================
SCR_FillRect
Expand Down Expand Up @@ -157,32 +186,78 @@ static void SCR_DrawChar( int x, int y, float size, int ch ) {
** SCR_DrawSmallChar
** small chars are drawn at native screen resolution
*/
void SCR_DrawSmallChar( int x, int y, int ch ) {
void SCR_DrawSmallChar( int x, int y, int ch, int scalemode ) {
int row, col;
float frow, fcol;
float size;

ch &= 255;

if ( ch == ' ' ) {
return;
if ((scalemode) && (cl_consoleScale->integer) && (cls.glconfig.vidWidth > SCREEN_WIDTH))
{
// leilei - ideally, I want to have the same amount of lines as 640x480 on any higher resolution to keep it readable,
// while horizontally it's also like 640x480 but keeping up a gap to the right so the characters are still 1:2 aspect.
// like idTech 4.
// in 640x480 on a normal pulled down console, there are 12 lines, 6.5 lines on a half pull, and 29 for a full console
int row, col;
float frow, fcol;
float ax, ay, aw, ah;
float size;
ch &= 255;

if ( ch == ' ' ) {
return;
}

if ( y < -SMALLCHAR_HEIGHT ) {
return;
}

ax = x;
ay = y;
aw = SMALLCHAR_WIDTH ;
ah = SMALLCHAR_HEIGHT;
if (scalemode == 2)
SCR_AdjustFrom480( &ax, &ay, &aw, &ah );
else
SCR_AdjustFrom640( &ax, &ay, &aw, &ah );

row = ch>>4;
col = ch&15;

frow = row*0.0625;
fcol = col*0.0625;
size = 0.0625;

re.DrawStretchPic( ax, ay, aw, ah,
fcol, frow,
fcol + size, frow + size,
cls.charSetShader );


}

if ( y < -SMALLCHAR_HEIGHT ) {
return;
else
{
ch &= 255;

if ( ch == ' ' ) {
return;
}

if ( y < -SMALLCHAR_HEIGHT ) {
return;
}

row = ch>>4;
col = ch&15;

frow = row*0.0625;
fcol = col*0.0625;
size = 0.0625;

re.DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT,
fcol, frow,
fcol + size, frow + size,
cls.charSetShader );
}

row = ch>>4;
col = ch&15;

frow = row*0.0625;
fcol = col*0.0625;
size = 0.0625;

re.DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT,
fcol, frow,
fcol + size, frow + size,
cls.charSetShader );
}


Expand Down Expand Up @@ -286,7 +361,7 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor,
continue;
}
}
SCR_DrawSmallChar( xx, y, *s );
SCR_DrawSmallChar( xx, y, *s, 2 );
xx += SMALLCHAR_WIDTH;
s++;
}
Expand Down
5 changes: 4 additions & 1 deletion code/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ extern cvar_t *cl_consoleKeys;
extern cvar_t *cl_consoleType;
extern cvar_t *cl_consoleColor[4];

extern cvar_t *cl_consoleScale;
extern cvar_t *cl_consoleAccent;

extern cvar_t *cl_consoleHeight;

#ifdef USE_MUMBLE
Expand Down Expand Up @@ -582,7 +585,7 @@ void SCR_DrawNamedPic( float x, float y, float width, float height, const char *
void SCR_DrawBigString( int x, int y, const char *s, float alpha, qboolean noColorEscape ); // draws a string with embedded color control characters with fade
void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color, qboolean noColorEscape ); // ignores embedded color control characters
void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor, qboolean noColorEscape );
void SCR_DrawSmallChar( int x, int y, int ch );
void SCR_DrawSmallChar( int x, int y, int ch, int scalemode );


//
Expand Down
Loading