mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
Replaced con.textscale with con.charWidth and con.charHeight, ctrl+KP_INS for scale reset
This commit is contained in:
parent
71ba22c39f
commit
daa5248cc7
5 changed files with 82 additions and 61 deletions
|
@ -51,7 +51,7 @@ typedef struct {
|
|||
int times[NUM_CON_TIMES]; // cls.realtime time the line was generated
|
||||
// for transparent notify lines
|
||||
vec4_t color;
|
||||
float textscale;
|
||||
int charWidth, charHeight;
|
||||
} console_t;
|
||||
|
||||
console_t con;
|
||||
|
@ -277,7 +277,7 @@ void Con_CheckResize (void)
|
|||
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
|
||||
short tbuf[CON_TEXTSIZE];
|
||||
|
||||
width = (SCREEN_WIDTH / SMALLCHAR_WIDTH * con.textscale) - 2;
|
||||
width = (SCREEN_WIDTH / con.charWidth ) - 2;
|
||||
|
||||
if (width == con.linewidth)
|
||||
return;
|
||||
|
@ -451,6 +451,8 @@ void CL_ConsolePrint( char *txt ) {
|
|||
con.color[2] =
|
||||
con.color[3] = 1.0f;
|
||||
con.linewidth = -1;
|
||||
con.charWidth = SMALLCHAR_WIDTH;
|
||||
con.charHeight = SMALLCHAR_HEIGHT;
|
||||
Con_CheckResize ();
|
||||
con.initialized = qtrue;
|
||||
}
|
||||
|
@ -538,14 +540,14 @@ void Con_DrawInput (void) {
|
|||
return;
|
||||
}
|
||||
|
||||
y = con.vislines - ( SMALLCHAR_HEIGHT * 2 * con.textscale );
|
||||
y = con.vislines - ( con.charHeight * 2 );
|
||||
|
||||
re.SetColor( con.color );
|
||||
|
||||
SCR_DrawScaledSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH * con.textscale, y, con.textscale, ']' );
|
||||
SCR_DrawSmallChar( con.xadjust + 1 * con.charWidth, y, con.charWidth, con.charHeight, ']' );
|
||||
|
||||
Field_VariableSizeDraw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH * con.textscale, y,
|
||||
SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH * con.textscale, SMALLCHAR_WIDTH, con.textscale,
|
||||
Field_VariableSizeDraw( &g_consoleField, con.xadjust + 2 * con.charWidth, y,
|
||||
con.charWidth, con.charHeight, qfalse, SMALLCHAR_WIDTH,
|
||||
qtrue, qtrue );
|
||||
}
|
||||
|
||||
|
@ -565,14 +567,10 @@ void Con_DrawNotify (void)
|
|||
int time;
|
||||
int skip;
|
||||
int currentColor;
|
||||
int charHeight, charWidth;
|
||||
|
||||
currentColor = 7;
|
||||
re.SetColor( g_color_table[currentColor] );
|
||||
|
||||
charHeight = floor( SMALLCHAR_HEIGHT * con.textscale );
|
||||
charWidth = floor( SMALLCHAR_WIDTH * con.textscale );
|
||||
|
||||
v = 0;
|
||||
for (i= con.current-NUM_CON_TIMES+1 ; i<=con.current ; i++)
|
||||
{
|
||||
|
@ -598,10 +596,10 @@ void Con_DrawNotify (void)
|
|||
currentColor = ColorIndexForNumber( text[x]>>8 );
|
||||
re.SetColor( g_color_table[currentColor] );
|
||||
}
|
||||
SCR_DrawScaledSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*charWidth, v, con.textscale, text[x] & 0xff );
|
||||
SCR_DrawSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*con.charWidth, v, con.charWidth, con.charHeight, text[x] & 0xff );
|
||||
}
|
||||
|
||||
v += charHeight;
|
||||
v += con.charHeight;
|
||||
}
|
||||
|
||||
re.SetColor( NULL );
|
||||
|
@ -646,7 +644,6 @@ void Con_DrawSolidConsole( float frac ) {
|
|||
// qhandle_t conShader;
|
||||
int currentColor;
|
||||
vec4_t color;
|
||||
int charHeight, charWidth;
|
||||
|
||||
lines = cls.glconfig.vidHeight * frac;
|
||||
if (lines <= 0)
|
||||
|
@ -674,9 +671,6 @@ void Con_DrawSolidConsole( float frac ) {
|
|||
color[3] = 1;
|
||||
SCR_FillRect( 0, y, SCREEN_WIDTH, 2, color );
|
||||
|
||||
charHeight = floor( SMALLCHAR_HEIGHT * con.textscale );
|
||||
charWidth = floor( SMALLCHAR_WIDTH * con.textscale );
|
||||
|
||||
// draw the version number
|
||||
|
||||
re.SetColor( g_color_table[ColorIndex(COLOR_RED)] );
|
||||
|
@ -684,16 +678,16 @@ void Con_DrawSolidConsole( float frac ) {
|
|||
i = strlen( Q3_VERSION );
|
||||
|
||||
for (x=0 ; x<i ; x++) {
|
||||
SCR_DrawScaledSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * charWidth,
|
||||
lines - charHeight, con.textscale, Q3_VERSION[x] );
|
||||
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * con.charWidth,
|
||||
lines - con.charHeight, con.charWidth, con.charHeight, Q3_VERSION[x] );
|
||||
}
|
||||
|
||||
|
||||
// draw the text
|
||||
con.vislines = lines;
|
||||
rows = (lines-charHeight)/charHeight; // rows of text to draw
|
||||
rows = (lines-con.charHeight)/con.charHeight; // rows of text to draw
|
||||
|
||||
y = lines - (charHeight*3);
|
||||
y = lines - (con.charHeight*3);
|
||||
|
||||
// draw from the bottom up
|
||||
if (con.display != con.current)
|
||||
|
@ -701,8 +695,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_DrawScaledSmallChar( con.xadjust + (x+1)*charWidth, y, con.textscale, '^' );
|
||||
y -= charHeight;
|
||||
SCR_DrawSmallChar( con.xadjust + (x+1)*con.charWidth, y, con.charWidth, con.charHeight, '^' );
|
||||
y -= con.charHeight;
|
||||
rows--;
|
||||
}
|
||||
|
||||
|
@ -715,7 +709,7 @@ void Con_DrawSolidConsole( float frac ) {
|
|||
currentColor = 7;
|
||||
re.SetColor( g_color_table[currentColor] );
|
||||
|
||||
for (i=0 ; i<rows ; i++, y -= charHeight, row--)
|
||||
for (i=0 ; i<rows ; i++, y -= con.charHeight, row--)
|
||||
{
|
||||
if (row < 0)
|
||||
break;
|
||||
|
@ -735,7 +729,7 @@ void Con_DrawSolidConsole( float frac ) {
|
|||
currentColor = ColorIndexForNumber( text[x]>>8 );
|
||||
re.SetColor( g_color_table[currentColor] );
|
||||
}
|
||||
SCR_DrawScaledSmallChar( con.xadjust + (x+1)*charWidth, y, con.textscale, text[x] & 0xff );
|
||||
SCR_DrawSmallChar( con.xadjust + (x+1)*con.charWidth, y, con.charWidth, con.charHeight, text[x] & 0xff );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -755,13 +749,25 @@ Con_DrawConsole
|
|||
void Con_DrawConsole( void ) {
|
||||
|
||||
if ( con_textscale->value == -1.0f ) {
|
||||
con.textscale = cls.glconfig.vidHeight / ( CON_TEXT_LINE_COUNT * SMALLCHAR_HEIGHT + SMALLCHAR_HEIGHT );
|
||||
//aligning to 4 pixels to avoid any unsmooth text
|
||||
con.textscale = floor( con.textscale * 100 ) / 100.0f - ( (int)floor( con.textscale * 100 ) % 25 ) / 100.0f;
|
||||
if( con.textscale < 1.0f )
|
||||
con.textscale = 1.0f;
|
||||
float charWidth, charHeight;
|
||||
|
||||
charWidth = SMALLCHAR_WIDTH;
|
||||
charHeight = SMALLCHAR_HEIGHT;
|
||||
|
||||
SCR_AdjustFrom640( NULL, NULL, &charWidth, &charHeight );
|
||||
|
||||
con.charWidth = floor( charWidth );
|
||||
con.charHeight = floor( charHeight );
|
||||
|
||||
} else {
|
||||
con.textscale = con_textscale->value;
|
||||
con.charWidth = floor( SMALLCHAR_WIDTH * con_textscale->value );
|
||||
con.charHeight = floor( SMALLCHAR_HEIGHT * con_textscale->value );
|
||||
}
|
||||
if ( con.charWidth < 1 ) {
|
||||
con.charWidth = SMALLCHAR_WIDTH;
|
||||
}
|
||||
if ( con.charHeight < 1 ) {
|
||||
con.charHeight = SMALLCHAR_HEIGHT;
|
||||
}
|
||||
|
||||
// check for console width changes from a vid mode change
|
||||
|
|
|
@ -309,7 +309,7 @@ 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, float scale, qboolean showCursor,
|
||||
void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int height, qboolean nativeSize, int size, qboolean showCursor,
|
||||
qboolean noColorEscape ) {
|
||||
int len;
|
||||
int drawLen;
|
||||
|
@ -346,17 +346,27 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, f
|
|||
Com_Memcpy( str, edit->buffer + prestep, drawLen );
|
||||
str[ drawLen ] = 0;
|
||||
|
||||
if( nativeSize ) {
|
||||
// draw it
|
||||
if ( size == SMALLCHAR_WIDTH ) {
|
||||
float color[4];
|
||||
|
||||
color[0] = color[1] = color[2] = color[3] = 1.0;
|
||||
SCR_DrawScaledSmallStringExt( x, y, scale, str, color, qfalse, noColorEscape );
|
||||
if ( size == SMALLCHAR_WIDTH ) {
|
||||
float color[4];
|
||||
color[0] = color[1] = color[2] = color[3] = 1.0;
|
||||
SCR_DrawNativeSmallStringExt( x, y, str, color, qfalse, noColorEscape );
|
||||
} else {
|
||||
// draw big string with drop shadow
|
||||
SCR_DrawBigString( x, y, str, 1.0, noColorEscape );
|
||||
}
|
||||
} else {
|
||||
// draw big string with drop shadow
|
||||
SCR_DrawBigString( x, y, str, 1.0, noColorEscape );
|
||||
}
|
||||
if ( size == SMALLCHAR_WIDTH ) {
|
||||
float color[4];
|
||||
|
||||
color[0] = color[1] = color[2] = color[3] = 1.0;
|
||||
SCR_DrawSmallStringExt( x, y, width, height, str, color, qfalse, noColorEscape );
|
||||
} else {
|
||||
// draw big string with drop shadow
|
||||
SCR_DrawBigString( x, y, str, 1.0, noColorEscape );
|
||||
}
|
||||
}
|
||||
// draw the cursor
|
||||
if ( showCursor ) {
|
||||
if ( (int)( cls.realtime >> 8 ) & 1 ) {
|
||||
|
@ -372,7 +382,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, f
|
|||
i = drawLen - strlen( str );
|
||||
|
||||
if ( size == SMALLCHAR_WIDTH ) {
|
||||
SCR_DrawScaledSmallChar( x + ( edit->cursor - prestep - i ) * SMALLCHAR_WIDTH * scale, y, scale, cursorChar );
|
||||
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * width, y, width, height, cursorChar );
|
||||
} else {
|
||||
str[0] = cursorChar;
|
||||
str[1] = 0;
|
||||
|
@ -384,12 +394,12 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, f
|
|||
|
||||
void Field_Draw( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape )
|
||||
{
|
||||
Field_VariableSizeDraw( edit, x, y, width, SMALLCHAR_WIDTH, 1.0f, showCursor, noColorEscape );
|
||||
Field_VariableSizeDraw( edit, x, y, width, SMALLCHAR_HEIGHT, qtrue, SMALLCHAR_WIDTH, 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, 1.0f, showCursor, noColorEscape );
|
||||
Field_VariableSizeDraw( edit, x, y, width, BIGCHAR_HEIGHT, qtrue, BIGCHAR_WIDTH, showCursor, noColorEscape );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -704,19 +714,24 @@ void Console_Key (int key) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( key == K_KP_PLUS && keys[K_CTRL].down && con_textscale->value != -1.0f ) {
|
||||
if ( key == K_KP_PLUS && keys[K_CTRL].down && con_textscale->value > 0.0f ) {
|
||||
Cvar_SetValue( con_textscale->name, con_textscale->value + 0.25f );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( key == K_KP_MINUS && keys[K_CTRL].down && con_textscale->value != -1.0f ) {
|
||||
if( con_textscale->value - 0.25f >= 0 )
|
||||
if ( key == K_KP_MINUS && keys[K_CTRL].down && con_textscale->value > 0.0f ) {
|
||||
if( con_textscale->value - 0.25f > 0 )
|
||||
{
|
||||
Cvar_SetValue( con_textscale->name, con_textscale->value - 0.25f );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( key == K_KP_INS && keys[K_CTRL].down ) {
|
||||
Cvar_SetValue( con_textscale->name, 1.0f );
|
||||
return;
|
||||
}
|
||||
|
||||
// pass to the normal editline routine
|
||||
Field_KeyDownEvent( &g_consoleField, key );
|
||||
}
|
||||
|
|
|
@ -154,10 +154,10 @@ static void SCR_DrawChar( int x, int y, float size, int ch ) {
|
|||
}
|
||||
|
||||
/*
|
||||
** SCR_DrawSmallChar
|
||||
** SCR_DrawNativeSmallChar
|
||||
** small chars are drawn at native screen resolution
|
||||
*/
|
||||
void SCR_DrawSmallChar( int x, int y, int ch ) {
|
||||
void SCR_DrawNativeSmallChar( int x, int y, int ch ) {
|
||||
int row, col;
|
||||
float frow, fcol;
|
||||
float size;
|
||||
|
@ -185,7 +185,7 @@ void SCR_DrawSmallChar( int x, int y, int ch ) {
|
|||
cls.charSetShader );
|
||||
}
|
||||
|
||||
void SCR_DrawScaledSmallChar( int x, int y, float scale, int ch ) {
|
||||
void SCR_DrawSmallChar( int x, int y, int width, int height, int ch ) {
|
||||
int row, col;
|
||||
float frow, fcol;
|
||||
float size;
|
||||
|
@ -196,7 +196,7 @@ void SCR_DrawScaledSmallChar( int x, int y, float scale, int ch ) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( y < -SMALLCHAR_HEIGHT*scale ) {
|
||||
if ( y < -height ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ void SCR_DrawScaledSmallChar( int x, int y, float scale, int ch ) {
|
|||
fcol = col*0.0625;
|
||||
size = 0.0625;
|
||||
|
||||
re.DrawStretchPic( x, y, SMALLCHAR_WIDTH*scale, SMALLCHAR_HEIGHT*scale,
|
||||
re.DrawStretchPic( x, y, width, height,
|
||||
fcol, frow,
|
||||
fcol + size, frow + size,
|
||||
cls.charSetShader );
|
||||
|
@ -291,7 +291,7 @@ Draws a multi-colored string with a drop shadow, optionally forcing
|
|||
to a fixed color.
|
||||
==================
|
||||
*/
|
||||
void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor,
|
||||
void SCR_DrawSmallStringExt( int x, int y, int width, int height, const char *string, float *setColor, qboolean forceColor,
|
||||
qboolean noColorEscape ) {
|
||||
vec4_t color;
|
||||
const char *s;
|
||||
|
@ -313,15 +313,15 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor,
|
|||
continue;
|
||||
}
|
||||
}
|
||||
SCR_DrawSmallChar( xx, y, *s );
|
||||
xx += SMALLCHAR_WIDTH;
|
||||
SCR_DrawSmallChar( xx, y, width, height, *s );
|
||||
xx += width;
|
||||
s++;
|
||||
}
|
||||
re.SetColor( NULL );
|
||||
}
|
||||
|
||||
|
||||
void SCR_DrawScaledSmallStringExt( int x, int y, float scale, const char *string, float *setColor, qboolean forceColor,
|
||||
void SCR_DrawNativeSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor,
|
||||
qboolean noColorEscape ) {
|
||||
vec4_t color;
|
||||
const char *s;
|
||||
|
@ -343,8 +343,8 @@ void SCR_DrawScaledSmallStringExt( int x, int y, float scale, const char *string
|
|||
continue;
|
||||
}
|
||||
}
|
||||
SCR_DrawScaledSmallChar( xx, y, scale, *s );
|
||||
xx += SMALLCHAR_WIDTH * scale;
|
||||
SCR_DrawNativeSmallChar( xx, y, *s );
|
||||
xx += SMALLCHAR_WIDTH;
|
||||
s++;
|
||||
}
|
||||
re.SetColor( NULL );
|
||||
|
|
|
@ -576,10 +576,10 @@ 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_DrawScaledSmallStringExt( int x, int y, float scale, const char *string, float *setColor, qboolean forceColor, qboolean noColorEscape );
|
||||
void SCR_DrawSmallChar( int x, int y, int ch );
|
||||
void SCR_DrawScaledSmallChar( int x, int y, float scale, int ch );
|
||||
void SCR_DrawNativeSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor, qboolean noColorEscape );
|
||||
void SCR_DrawSmallStringExt( int x, int y, int width, int height, const char *string, float *setColor, qboolean forceColor, qboolean noColorEscape );
|
||||
void SCR_DrawNativeSmallChar( int x, int y, int ch );
|
||||
void SCR_DrawSmallChar( int x, int y, int width, int height, int ch );
|
||||
|
||||
|
||||
//
|
||||
|
|
|
@ -35,7 +35,7 @@ void Field_KeyDownEvent( field_t *edit, int key );
|
|||
void Field_CharEvent( field_t *edit, int ch );
|
||||
void Field_Draw( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape );
|
||||
void Field_BigDraw( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape );
|
||||
void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, float scale, qboolean showCursor, qboolean noColorEscape );
|
||||
void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int height, qboolean nativeSize, int size, qboolean showCursor, qboolean noColorEscape );
|
||||
|
||||
#define COMMAND_HISTORY 32
|
||||
extern field_t historyEditLines[COMMAND_HISTORY];
|
||||
|
|
Loading…
Reference in a new issue