Add con_scale, for high DPI displays

This commit is contained in:
Tim Angus 2025-10-27 15:15:28 +00:00
parent f2c1f990f8
commit 66330c72b0
6 changed files with 44 additions and 28 deletions

View File

@ -37,6 +37,7 @@ Some of the major features currently implemented are:
is stored in "%APPDATA%\Quake3")
* PNG support
* Web support via Emscripten
* console scaling with con_scale
* Many, many bug fixes
The map editor and associated compiling tools are not included. We suggest you
@ -259,6 +260,8 @@ the above locations, if desired.
at the beginning
con_autoclear - Set to 0 to disable clearing console
input text when console is closed
con_scale - Scales console text to make it legible at
high resolutions
in_joystickUseAnalog - Do not translate joystick axis events
to keyboard commands

View File

@ -24,8 +24,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "client.h"
int g_console_field_width = 78;
#define DEFAULT_CONSOLE_WIDTH 78
int g_console_field_width = DEFAULT_CONSOLE_WIDTH;
int g_smallchar_width = SMALLCHAR_WIDTH;
int g_smallchar_height = SMALLCHAR_HEIGHT;
#define NUM_CON_TIMES 4
@ -58,8 +60,8 @@ console_t con;
cvar_t *con_conspeed;
cvar_t *con_autoclear;
cvar_t *con_notifytime;
cvar_t *con_scale;
#define DEFAULT_CONSOLE_WIDTH 78
/*
@ -283,7 +285,13 @@ void Con_CheckResize (void)
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
short tbuf[CON_TEXTSIZE];
width = (cls.glconfig.vidWidth / SMALLCHAR_WIDTH) - 2;
if (con_scale != NULL)
{
g_smallchar_width = (int)((float)SMALLCHAR_WIDTH * con_scale->value);
g_smallchar_height = (int)((float)SMALLCHAR_HEIGHT * con_scale->value);
}
width = (cls.glconfig.vidWidth / g_smallchar_width) - 2;
if (width == con.linewidth)
return;
@ -359,6 +367,8 @@ void Con_Init (void) {
con_notifytime = Cvar_Get ("con_notifytime", "3", 0);
con_conspeed = Cvar_Get ("scr_conspeed", "3", 0);
con_autoclear = Cvar_Get("con_autoclear", "1", CVAR_ARCHIVE);
con_scale = Cvar_Get("con_scale", "1", CVAR_ARCHIVE);
Cvar_CheckRange(con_scale, 1.0f, 4.0f, qfalse);
Field_Clear( &g_consoleField );
g_consoleField.widthInChars = g_console_field_width;
@ -543,14 +553,14 @@ void Con_DrawInput (void) {
return;
}
y = con.vislines - ( SMALLCHAR_HEIGHT * 2 );
y = con.vislines - ( g_smallchar_height * 2 );
re.SetColor( con.color );
SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, ']' );
SCR_DrawSmallChar( con.xadjust + 1 * g_smallchar_width, y, ']' );
Field_Draw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH, y,
SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue, qtrue );
Field_Draw( &g_consoleField, con.xadjust + 2 * g_smallchar_width, y,
SCREEN_WIDTH - 3 * g_smallchar_width, qtrue, qtrue );
}
@ -598,10 +608,10 @@ void Con_DrawNotify (void)
currentColor = ColorIndexForNumber( text[x]>>8 );
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)*g_smallchar_width, v, text[x] & 0xff );
}
v += SMALLCHAR_HEIGHT;
v += g_smallchar_height;
}
re.SetColor( NULL );
@ -681,16 +691,16 @@ void Con_DrawSolidConsole( float frac ) {
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] );
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * g_smallchar_width,
lines - g_smallchar_height, Q3_VERSION[x] );
}
// draw the text
con.vislines = lines;
rows = (lines-SMALLCHAR_HEIGHT)/SMALLCHAR_HEIGHT; // rows of text to draw
rows = (lines-g_smallchar_height)/g_smallchar_height; // rows of text to draw
y = lines - (SMALLCHAR_HEIGHT*3);
y = lines - (g_smallchar_height*3);
// draw from the bottom up
if (con.display != con.current)
@ -698,8 +708,8 @@ void Con_DrawSolidConsole( float frac ) {
// draw arrows to show the buffer is backscrolled
re.SetColor( g_color_table[ColorIndex(COLOR_RED)] );
for (x=0 ; x<con.linewidth ; x+=4)
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, '^' );
y -= SMALLCHAR_HEIGHT;
SCR_DrawSmallChar( con.xadjust + (x+1)*g_smallchar_width, y, '^' );
y -= g_smallchar_height;
rows--;
}
@ -712,7 +722,7 @@ void Con_DrawSolidConsole( float frac ) {
currentColor = 7;
re.SetColor( g_color_table[currentColor] );
for (i=0 ; i<rows ; i++, y -= SMALLCHAR_HEIGHT, row--)
for (i=0 ; i<rows ; i++, y -= g_smallchar_height, row--)
{
if (row < 0)
break;
@ -732,7 +742,7 @@ void Con_DrawSolidConsole( float frac ) {
currentColor = ColorIndexForNumber( text[x]>>8 );
re.SetColor( g_color_table[currentColor] );
}
SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, text[x] & 0xff );
SCR_DrawSmallChar( con.xadjust + (x+1)*g_smallchar_width, y, text[x] & 0xff );
}
}

View File

@ -343,8 +343,8 @@ Handles horizontal scrolling and cursor blinking
x, y, and width are in pixels
===================
*/
void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, qboolean showCursor,
qboolean noColorEscape ) {
static void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size,
qboolean drawSmall, qboolean showCursor, qboolean noColorEscape ) {
int len;
int drawLen;
int prestep;
@ -381,7 +381,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
str[ drawLen ] = 0;
// draw it
if ( size == SMALLCHAR_WIDTH ) {
if ( drawSmall ) {
float color[4];
color[0] = color[1] = color[2] = color[3] = 1.0;
@ -405,7 +405,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
i = drawLen - strlen( str );
if ( size == SMALLCHAR_WIDTH ) {
if ( drawSmall ) {
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar );
} else {
str[0] = cursorChar;
@ -418,12 +418,12 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
void Field_Draw( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape )
{
Field_VariableSizeDraw( edit, x, y, width, SMALLCHAR_WIDTH, showCursor, noColorEscape );
Field_VariableSizeDraw( edit, x, y, width, g_smallchar_width, qtrue, showCursor, noColorEscape );
}
void Field_BigDraw( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape )
{
Field_VariableSizeDraw( edit, x, y, width, BIGCHAR_WIDTH, showCursor, noColorEscape );
Field_VariableSizeDraw( edit, x, y, width, BIGCHAR_WIDTH, qfalse, showCursor, noColorEscape );
}
/*

View File

@ -3175,7 +3175,7 @@ void CL_InitRenderer( void ) {
cls.charSetShader = re.RegisterShader( "gfx/2d/bigchars" );
cls.whiteShader = re.RegisterShader( "white" );
cls.consoleShader = re.RegisterShader( "console" );
g_console_field_width = cls.glconfig.vidWidth / SMALLCHAR_WIDTH - 2;
g_console_field_width = cls.glconfig.vidWidth / g_smallchar_width - 2;
g_consoleField.widthInChars = g_console_field_width;
}

View File

@ -168,7 +168,7 @@ void SCR_DrawSmallChar( int x, int y, int ch ) {
return;
}
if ( y < -SMALLCHAR_HEIGHT ) {
if ( y < -g_smallchar_height ) {
return;
}
@ -179,7 +179,7 @@ void SCR_DrawSmallChar( int x, int y, int ch ) {
fcol = col*0.0625;
size = 0.0625;
re.DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT,
re.DrawStretchPic( x, y, g_smallchar_width, g_smallchar_height,
fcol, frow,
fcol + size, frow + size,
cls.charSetShader );
@ -287,7 +287,7 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor,
}
}
SCR_DrawSmallChar( xx, y, *s );
xx += SMALLCHAR_WIDTH;
xx += g_smallchar_width;
s++;
}
re.SetColor( NULL );

View File

@ -536,6 +536,9 @@ qboolean CL_UpdateVisiblePings_f( int source );
//
// console
//
extern int g_smallchar_width;
extern int g_smallchar_height;
void Con_DrawCharacter (int cx, int line, int num);
void Con_CheckResize (void);