Add con_scale, for high DPI displays
This commit is contained in:
1 parent
f2c1f990f8
commit
66330c72b0
6 files changed
+44
-28
No files matched your search
+28
-18
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user