0
0
Fork 0
mirror of https://github.com/DrBeef/ioq3quest.git synced 2025-02-27 22:30:52 +00:00

* Don't apply colour escape chars on input fields

This commit is contained in:
Tim Angus 2007-09-21 10:35:24 +00:00
parent d86f72f75e
commit da29118ae0
5 changed files with 46 additions and 48 deletions

View file

@ -488,7 +488,7 @@ void Con_DrawInput (void) {
SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, ']' ); SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, ']' );
Field_Draw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH, y, Field_Draw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH, y,
SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue ); SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue, qtrue );
} }
@ -553,17 +553,17 @@ void Con_DrawNotify (void)
{ {
if (chat_team) if (chat_team)
{ {
SCR_DrawBigString (8, v, "say_team:", 1.0f ); SCR_DrawBigString (8, v, "say_team:", 1.0f, qfalse );
skip = 10; skip = 10;
} }
else else
{ {
SCR_DrawBigString (8, v, "say:", 1.0f ); SCR_DrawBigString (8, v, "say:", 1.0f, qfalse );
skip = 5; skip = 5;
} }
Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, v, Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, v,
SCREEN_WIDTH - ( skip + 1 ) * BIGCHAR_WIDTH, qtrue ); SCREEN_WIDTH - ( skip + 1 ) * BIGCHAR_WIDTH, qtrue, qtrue );
v += BIGCHAR_HEIGHT; v += BIGCHAR_HEIGHT;
} }
@ -623,7 +623,6 @@ void Con_DrawSolidConsole( float frac ) {
for (x=0 ; x<i ; x++) { for (x=0 ; x<i ; x++) {
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x ) * SMALLCHAR_WIDTH, SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x ) * SMALLCHAR_WIDTH,
(lines-(SMALLCHAR_HEIGHT+SMALLCHAR_HEIGHT/2)), Q3_VERSION[x] ); (lines-(SMALLCHAR_HEIGHT+SMALLCHAR_HEIGHT/2)), Q3_VERSION[x] );
} }

View file

@ -309,7 +309,8 @@ Handles horizontal scrolling and cursor blinking
x, y, and width are in pixels x, y, and width are in pixels
=================== ===================
*/ */
void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, qboolean showCursor ) { void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, qboolean showCursor,
qboolean noColorEscape ) {
int len; int len;
int drawLen; int drawLen;
int prestep; int prestep;
@ -350,47 +351,45 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
float color[4]; float color[4];
color[0] = color[1] = color[2] = color[3] = 1.0; color[0] = color[1] = color[2] = color[3] = 1.0;
SCR_DrawSmallStringExt( x, y, str, color, qfalse ); SCR_DrawSmallStringExt( x, y, str, color, qfalse, noColorEscape );
} else { } else {
// draw big string with drop shadow // draw big string with drop shadow
SCR_DrawBigString( x, y, str, 1.0 ); SCR_DrawBigString( x, y, str, 1.0, noColorEscape );
} }
// draw the cursor // draw the cursor
if ( !showCursor ) { if ( showCursor ) {
return; if ( (int)( cls.realtime >> 8 ) & 1 ) {
} return; // off blink
}
if ( (int)( cls.realtime >> 8 ) & 1 ) { if ( key_overstrikeMode ) {
return; // off blink cursorChar = 11;
} } else {
cursorChar = 10;
}
if ( key_overstrikeMode ) { i = drawLen - strlen( str );
cursorChar = 11;
} else {
cursorChar = 10;
}
i = drawLen - Q_PrintStrlen( str ); if ( size == SMALLCHAR_WIDTH ) {
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar );
if ( size == SMALLCHAR_WIDTH ) { } else {
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar ); str[0] = cursorChar;
} else { str[1] = 0;
str[0] = cursorChar; SCR_DrawBigString( x + ( edit->cursor - prestep - i ) * size, y, str, 1.0, qfalse );
str[1] = 0;
SCR_DrawBigString( x + ( edit->cursor - prestep - i ) * size, y, str, 1.0 );
}
} }
} }
void Field_Draw( field_t *edit, int x, int y, int width, qboolean showCursor ) 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 ); Field_VariableSizeDraw( edit, x, y, width, SMALLCHAR_WIDTH, showCursor, noColorEscape );
} }
void Field_BigDraw( field_t *edit, int x, int y, int width, qboolean showCursor ) 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 ); Field_VariableSizeDraw( edit, x, y, width, BIGCHAR_WIDTH, showCursor, noColorEscape );
} }
/* /*

View file

@ -196,7 +196,8 @@ to a fixed color.
Coordinates are at 640 by 480 virtual resolution Coordinates are at 640 by 480 virtual resolution
================== ==================
*/ */
void SCR_DrawStringExt( int x, int y, float size, const char *string, float *setColor, qboolean forceColor ) { void SCR_DrawStringExt( int x, int y, float size, const char *string, float *setColor, qboolean forceColor,
qboolean noColorEscape ) {
vec4_t color; vec4_t color;
const char *s; const char *s;
int xx; int xx;
@ -208,7 +209,7 @@ void SCR_DrawStringExt( int x, int y, float size, const char *string, float *set
s = string; s = string;
xx = x; xx = x;
while ( *s ) { while ( *s ) {
if ( Q_IsColorString( s ) ) { if ( !noColorEscape && Q_IsColorString( s ) ) {
s += 2; s += 2;
continue; continue;
} }
@ -223,7 +224,7 @@ void SCR_DrawStringExt( int x, int y, float size, const char *string, float *set
xx = x; xx = x;
re.SetColor( setColor ); re.SetColor( setColor );
while ( *s ) { while ( *s ) {
if ( Q_IsColorString( s ) ) { if ( !noColorEscape && Q_IsColorString( s ) ) {
if ( !forceColor ) { if ( !forceColor ) {
Com_Memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) ); Com_Memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );
color[3] = setColor[3]; color[3] = setColor[3];
@ -240,16 +241,16 @@ void SCR_DrawStringExt( int x, int y, float size, const char *string, float *set
} }
void SCR_DrawBigString( int x, int y, const char *s, float alpha ) { void SCR_DrawBigString( int x, int y, const char *s, float alpha, qboolean noColorEscape ) {
float color[4]; float color[4];
color[0] = color[1] = color[2] = 1.0; color[0] = color[1] = color[2] = 1.0;
color[3] = alpha; color[3] = alpha;
SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, qfalse ); SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, qfalse, noColorEscape );
} }
void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color ) { void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color, qboolean noColorEscape ) {
SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, qtrue ); SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, qtrue, noColorEscape );
} }
@ -259,11 +260,10 @@ SCR_DrawSmallString[Color]
Draws a multi-colored string with a drop shadow, optionally forcing Draws a multi-colored string with a drop shadow, optionally forcing
to a fixed color. to a fixed color.
Coordinates are at 640 by 480 virtual resolution
================== ==================
*/ */
void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor ) { void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor,
qboolean noColorEscape ) {
vec4_t color; vec4_t color;
const char *s; const char *s;
int xx; int xx;
@ -273,7 +273,7 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor,
xx = x; xx = x;
re.SetColor( setColor ); re.SetColor( setColor );
while ( *s ) { while ( *s ) {
if ( Q_IsColorString( s ) ) { if ( !noColorEscape && Q_IsColorString( s ) ) {
if ( !forceColor ) { if ( !forceColor ) {
Com_Memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) ); Com_Memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );
color[3] = setColor[3]; color[3] = setColor[3];
@ -339,7 +339,7 @@ void SCR_DrawDemoRecording( void ) {
pos = FS_FTell( clc.demofile ); pos = FS_FTell( clc.demofile );
sprintf( string, "RECORDING %s: %ik", clc.demoName, pos / 1024 ); sprintf( string, "RECORDING %s: %ik", clc.demoName, pos / 1024 );
SCR_DrawStringExt( 320 - strlen( string ) * 4, 20, 8, string, g_color_table[7], qtrue ); SCR_DrawStringExt( 320 - strlen( string ) * 4, 20, 8, string, g_color_table[7], qtrue, qfalse );
} }

View file

@ -500,9 +500,9 @@ void SCR_FillRect( float x, float y, float width, float height,
void SCR_DrawPic( float x, float y, float width, float height, qhandle_t hShader ); void SCR_DrawPic( float x, float y, float width, float height, qhandle_t hShader );
void SCR_DrawNamedPic( float x, float y, float width, float height, const char *picname ); void SCR_DrawNamedPic( float x, float y, float width, float height, const char *picname );
void SCR_DrawBigString( int x, int y, const char *s, float alpha ); // draws a string with embedded color control characters with fade 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 ); // ignores embedded color control characters 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 ); 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 );

View file

@ -33,8 +33,8 @@ extern qkey_t keys[MAX_KEYS];
// NOTE TTimo the declaration of field_t and Field_Clear is now in qcommon/qcommon.h // NOTE TTimo the declaration of field_t and Field_Clear is now in qcommon/qcommon.h
void Field_KeyDownEvent( field_t *edit, int key ); void Field_KeyDownEvent( field_t *edit, int key );
void Field_CharEvent( field_t *edit, int ch ); void Field_CharEvent( field_t *edit, int ch );
void Field_Draw( field_t *edit, int x, int y, int width, qboolean showCursor ); 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 ); void Field_BigDraw( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape );
#define COMMAND_HISTORY 32 #define COMMAND_HISTORY 32
extern field_t historyEditLines[COMMAND_HISTORY]; extern field_t historyEditLines[COMMAND_HISTORY];