Skip to content

Commit d06babd

Browse files
committed
Cool console things
- cl_consoleScale : makes the console more 640x480 sized on any higher res. Also affects notify messages, so you can read chat easier - cl_consoleColor also affects the line at the bottom. Also new default colors - If consoleShader can't load (which will happen with some mods), it will fallback to a flat-colored console. - Generic'd the red/blue team names. We will not be having missionpack clans.
1 parent 9dcac5d commit d06babd

File tree

5 files changed

+179
-39
lines changed

5 files changed

+179
-39
lines changed

code/client/cl_console.c

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,8 @@ DRAWING
517517
==============================================================================
518518
*/
519519

520+
extern cvar_t *cl_consoleScale; // leilei - scale the console
521+
520522

521523
/*
522524
================
@@ -536,7 +538,7 @@ void Con_DrawInput (void) {
536538

537539
re.SetColor( con.color );
538540

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

541543
Field_Draw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH, y,
542544
SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue, qtrue );
@@ -587,7 +589,7 @@ void Con_DrawNotify (void)
587589
currentColor = (text[x]>>8) % NUMBER_OF_COLORS;
588590
re.SetColor( g_color_table[currentColor] );
589591
}
590-
SCR_DrawSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*SMALLCHAR_WIDTH, v, text[x] & 0xff );
592+
SCR_DrawSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*SMALLCHAR_WIDTH, v, text[x] & 0xff ,2);
591593
}
592594

593595
v += SMALLCHAR_HEIGHT;
@@ -636,6 +638,17 @@ void Con_DrawSolidConsole( float frac ) {
636638
int currentColor;
637639
vec4_t color;
638640

641+
if (cl_consoleScale->integer && (cls.glconfig.vidWidth > SCREEN_WIDTH))
642+
{
643+
lines = SCREEN_HEIGHT * frac;
644+
if (lines <= 0)
645+
return;
646+
647+
if (lines > SCREEN_HEIGHT )
648+
lines = SCREEN_HEIGHT;
649+
}
650+
else
651+
{
639652
lines = cls.glconfig.vidHeight * frac;
640653
if (lines <= 0)
641654
return;
@@ -646,6 +659,7 @@ void Con_DrawSolidConsole( float frac ) {
646659
// on wide screens, we will center the text
647660
con.xadjust = 0;
648661
SCR_AdjustFrom640( &con.xadjust, NULL, NULL, NULL );
662+
}
649663

650664
// draw the background
651665
y = frac * SCREEN_HEIGHT;
@@ -667,26 +681,58 @@ void Con_DrawSolidConsole( float frac ) {
667681
}
668682
}
669683

670-
color[0] = 1;
671-
color[1] = 0;
672-
color[2] = 0;
684+
// leilei - normalize our custom color for the line
685+
//color[0] = 1;
686+
//color[1] = 0; // was 1 pre-1.25
687+
//color[2] = 0;
688+
689+
// leilei - normalize from our custom console color and apply it to the line
690+
{
691+
float max;
692+
float rgb[3];
693+
694+
rgb[0] = cl_consoleColor[0]->value;
695+
rgb[1] = cl_consoleColor[1]->value;
696+
rgb[2] = cl_consoleColor[2]->value;
697+
698+
max = rgb[0] + rgb[1] + rgb[2] / 3;
699+
700+
if (max > 0)
701+
{
702+
color[0] = rgb[0] / max;
703+
color[1] = rgb[1] / max;
704+
color[2] = rgb[2] / max;
705+
}
706+
}
707+
708+
673709
if( !cl_consoleType->integer )
674710
color[3] = 1;
675711
SCR_FillRect( 0, y, SCREEN_WIDTH, 2, color );
676712

677713

678714
// draw the version number
679715

680-
re.SetColor( g_color_table[ColorIndex(COLOR_RED)] );
716+
re.SetColor( g_color_table[ColorIndex(cl_consoleAccent->integer)] );
681717

682718
i = strlen( Q3_VERSION );
683719

684-
for (x=0 ; x<i ; x++) {
685-
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * SMALLCHAR_WIDTH,
686-
lines - SMALLCHAR_HEIGHT, Q3_VERSION[x] );
720+
if (cl_consoleScale->integer && (cls.glconfig.vidWidth > SCREEN_WIDTH)){
721+
for (x=0 ; x<i ; x++) {
722+
SCR_DrawSmallChar( SCREEN_WIDTH - ( i - x + 1 ) * SMALLCHAR_WIDTH,
723+
lines - SMALLCHAR_HEIGHT, Q3_VERSION[x], 1 );
724+
}
725+
}
726+
else
727+
{
728+
for (x=0 ; x<i ; x++) {
729+
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * SMALLCHAR_WIDTH,
730+
lines - SMALLCHAR_HEIGHT, Q3_VERSION[x], 0 );
731+
}
687732
}
688733

689734

735+
690736
// draw the text
691737
con.vislines = lines;
692738
rows = (lines-SMALLCHAR_WIDTH)/SMALLCHAR_WIDTH; // rows of text to draw
@@ -697,9 +743,9 @@ void Con_DrawSolidConsole( float frac ) {
697743
if (con.display != con.current)
698744
{
699745
// draw arrows to show the buffer is backscrolled
700-
re.SetColor( g_color_table[ColorIndex(COLOR_RED)] );
746+
re.SetColor( g_color_table[ColorIndex(cl_consoleAccent->integer)] );
701747
for (x=0 ; x<con.linewidth ; x+=4)
702-
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, '^' );
748+
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, '^' ,2);
703749
y -= SMALLCHAR_HEIGHT;
704750
rows--;
705751
}
@@ -733,7 +779,7 @@ void Con_DrawSolidConsole( float frac ) {
733779
currentColor = (text[x]>>8) % NUMBER_OF_COLORS;
734780
re.SetColor( g_color_table[currentColor] );
735781
}
736-
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, text[x] & 0xff );
782+
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, text[x] & 0xff, 2 );
737783
}
738784
}
739785

code/client/cl_keys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
378378
i = drawLen - strlen( str );
379379

380380
if ( size == SMALLCHAR_WIDTH ) {
381-
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar );
381+
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar, 2 );
382382
} else {
383383
str[0] = cursorChar;
384384
str[1] = 0;

code/client/cl_main.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ cvar_t *cl_consoleType;
124124
cvar_t *cl_consoleColor[4];
125125

126126
cvar_t *cl_consoleHeight;
127+
cvar_t *cl_consoleAccent; // leilei - change version and line color
128+
cvar_t *cl_consoleScale; // leilei - scale the console
127129

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

35543561
cl_consoleType = Cvar_Get( "cl_consoleType", "0", CVAR_ARCHIVE );
3555-
cl_consoleColor[0] = Cvar_Get( "cl_consoleColorRed", "1", CVAR_ARCHIVE );
3556-
cl_consoleColor[1] = Cvar_Get( "cl_consoleColorGreen", "0", CVAR_ARCHIVE );
3557-
cl_consoleColor[2] = Cvar_Get( "cl_consoleColorBlue", "0", CVAR_ARCHIVE );
3562+
cl_consoleColor[0] = Cvar_Get( "cl_consoleColorRed", "0.104", CVAR_ARCHIVE );
3563+
cl_consoleColor[1] = Cvar_Get( "cl_consoleColorGreen", "0.187", CVAR_ARCHIVE );
3564+
cl_consoleColor[2] = Cvar_Get( "cl_consoleColorBlue", "0.312", CVAR_ARCHIVE );
35583565
cl_consoleColor[3] = Cvar_Get( "cl_consoleColorAlpha", "0.8", CVAR_ARCHIVE );
35593566

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

35623571
// userinfo
35633572
Cvar_Get ("name", "UnnamedPlayer", CVAR_USERINFO | CVAR_ARCHIVE );
@@ -3567,8 +3576,8 @@ void CL_Init( void ) {
35673576
Cvar_Get ("headmodel", "sarge", CVAR_USERINFO | CVAR_ARCHIVE );
35683577
Cvar_Get ("team_model", "james", CVAR_USERINFO | CVAR_ARCHIVE );
35693578
Cvar_Get ("team_headmodel", "*james", CVAR_USERINFO | CVAR_ARCHIVE );
3570-
Cvar_Get ("g_redTeam", "Stroggs", CVAR_SERVERINFO | CVAR_ARCHIVE);
3571-
Cvar_Get ("g_blueTeam", "Pagans", CVAR_SERVERINFO | CVAR_ARCHIVE);
3579+
Cvar_Get ("g_redTeam", "Red", CVAR_SERVERINFO | CVAR_ARCHIVE);
3580+
Cvar_Get ("g_blueTeam", "Blue", CVAR_SERVERINFO | CVAR_ARCHIVE);
35723581
Cvar_Get ("color1", "4", CVAR_USERINFO | CVAR_ARCHIVE );
35733582
Cvar_Get ("color2", "5", CVAR_USERINFO | CVAR_ARCHIVE );
35743583
Cvar_Get ("handicap", "100", CVAR_USERINFO | CVAR_ARCHIVE );

code/client/cl_scrn.c

Lines changed: 102 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,36 @@ void SCR_AdjustFrom640( float *x, float *y, float *w, float *h ) {
8484
}
8585
}
8686

87+
88+
/*
89+
================
90+
SCR_AdjustFrom480
91+
92+
leilei - Adjusted for resolution and screen aspect ratio.... but from vertical only so the aspect is ok
93+
================
94+
*/
95+
void SCR_AdjustFrom480( float *x, float *y, float *w, float *h ) {
96+
float xscale;
97+
float yscale;
98+
99+
// scale for screen sizes
100+
yscale = cls.glconfig.vidHeight / 480.0;
101+
102+
if ( x ) {
103+
*x *= yscale;
104+
}
105+
if ( y ) {
106+
*y *= yscale;
107+
}
108+
if ( w ) {
109+
*w *= yscale;
110+
}
111+
if ( h ) {
112+
*h *= yscale;
113+
}
114+
}
115+
116+
87117
/*
88118
================
89119
SCR_FillRect
@@ -157,32 +187,84 @@ static void SCR_DrawChar( int x, int y, float size, int ch ) {
157187
** SCR_DrawSmallChar
158188
** small chars are drawn at native screen resolution
159189
*/
160-
void SCR_DrawSmallChar( int x, int y, int ch ) {
190+
void SCR_DrawSmallChar( int x, int y, int ch, int scalemode ) {
161191
int row, col;
162192
float frow, fcol;
163193
float size;
164194

165-
ch &= 255;
195+
if ((scalemode) && (cl_consoleScale->integer) && (cls.glconfig.vidWidth > SCREEN_WIDTH))
196+
{
197+
// leilei - ideally, I want to have the same amount of lines as 640x480 on any higher resolution to keep it readable,
198+
// while horizontally it's also like 640x480 but keeping up a gap to the right so the characters are still 1:2 aspect.
199+
// like idTech 4.
200+
// 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
201+
int row, col;
202+
float frow, fcol;
203+
float ax, ay, aw, ah;
204+
float size;
205+
float sizeup = 1.0f;
206+
float sizedown = 1.0f;
207+
ch &= 255;
208+
209+
if (cls.glconfig.vidHeight >= 480)
210+
sizeup = cls.glconfig.vidHeight / 480;
211+
sizedown = (cls.glconfig.vidHeight - 480);
166212

167-
if ( ch == ' ' ) {
168-
return;
213+
if ( ch == ' ' ) {
214+
return;
215+
}
216+
217+
if ( y < -SMALLCHAR_HEIGHT ) {
218+
return;
219+
}
220+
221+
ax = x;
222+
ay = y;
223+
aw = SMALLCHAR_WIDTH ;
224+
ah = SMALLCHAR_HEIGHT;
225+
if (scalemode == 2)
226+
SCR_AdjustFrom480( &ax, &ay, &aw, &ah );
227+
else
228+
SCR_AdjustFrom640( &ax, &ay, &aw, &ah );
229+
230+
row = ch>>4;
231+
col = ch&15;
232+
233+
frow = row*0.0625;
234+
fcol = col*0.0625;
235+
size = 0.0625;
236+
237+
re.DrawStretchPic( ax, ay, aw, ah,
238+
fcol, frow,
239+
fcol + size, frow + size,
240+
cls.charSetShader );
241+
242+
169243
}
170-
171-
if ( y < -SMALLCHAR_HEIGHT ) {
172-
return;
244+
else
245+
{
246+
ch &= 255;
247+
248+
if ( ch == ' ' ) {
249+
return;
250+
}
251+
252+
if ( y < -SMALLCHAR_HEIGHT ) {
253+
return;
254+
}
255+
256+
row = ch>>4;
257+
col = ch&15;
258+
259+
frow = row*0.0625;
260+
fcol = col*0.0625;
261+
size = 0.0625;
262+
263+
re.DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT,
264+
fcol, frow,
265+
fcol + size, frow + size,
266+
cls.charSetShader );
173267
}
174-
175-
row = ch>>4;
176-
col = ch&15;
177-
178-
frow = row*0.0625;
179-
fcol = col*0.0625;
180-
size = 0.0625;
181-
182-
re.DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT,
183-
fcol, frow,
184-
fcol + size, frow + size,
185-
cls.charSetShader );
186268
}
187269

188270

@@ -286,7 +368,7 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor,
286368
continue;
287369
}
288370
}
289-
SCR_DrawSmallChar( xx, y, *s );
371+
SCR_DrawSmallChar( xx, y, *s, 2 );
290372
xx += SMALLCHAR_WIDTH;
291373
s++;
292374
}

code/client/client.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ extern cvar_t *cl_consoleKeys;
433433
extern cvar_t *cl_consoleType;
434434
extern cvar_t *cl_consoleColor[4];
435435

436+
extern cvar_t *cl_consoleScale;
437+
extern cvar_t *cl_consoleAccent;
438+
436439
extern cvar_t *cl_consoleHeight;
437440

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

587590

588591
//

0 commit comments

Comments
 (0)