fixed console/messagemode input buffers ignoring off-screen color modifiers when scrolled

This commit is contained in:
myT 2017-12-25 09:54:45 +01:00
parent bb4804ba49
commit f60ce0d1e8
5 changed files with 18 additions and 7 deletions

View file

@ -1,6 +1,8 @@
DD Mmm 17 - 1.49
fix: console/messagemode input buffers would ignore the last off-screen color modifier when scrolled
fix: console/messagemode input buffers would sometimes display the cursor at the wrong position
chg: console/messagemode input buffers now display the "^" character of color codes

View file

@ -507,12 +507,12 @@ static void Con_DrawNotify()
if (chat_team)
{
SCR_DrawStringEx( 8, y, cw, ch, "say_team:", qtrue, qtrue );
SCR_DrawStringEx( 8, y, cw, ch, "say_team:", qtrue, qtrue, NULL );
skip = 10;
}
else
{
SCR_DrawStringEx( 8, y, cw, ch, "say:", qtrue, qtrue );
SCR_DrawStringEx( 8, y, cw, ch, "say:", qtrue, qtrue, NULL );
skip = 5;
}

View file

@ -221,6 +221,7 @@ void Field_Draw( field_t* edit, int x, int y, int cw, int ch )
int cursorChar;
char str[MAX_STRING_CHARS];
int i;
int colorCode;
drawLen = edit->widthInChars + 1;
len = strlen( edit->buffer );
@ -247,10 +248,18 @@ void Field_Draw( field_t* edit, int x, int y, int cw, int ch )
Com_Error( ERR_DROP, "drawLen >= MAX_STRING_CHARS" );
}
colorCode = COLOR_WHITE;
for ( i = prestep - 1; i >= 0; --i ) {
if ( Q_IsColorString( &edit->buffer[i] ) ) {
colorCode = edit->buffer[i + 1];
break;
}
}
Com_Memcpy( str, edit->buffer + prestep, drawLen );
str[ drawLen ] = 0;
SCR_DrawStringEx( x, y, cw, ch, str, qtrue, qtrue );
SCR_DrawStringEx( x, y, cw, ch, str, qtrue, qtrue, ColorFromChar( colorCode ) );
if ( (int)( cls.realtime >> 8 ) & 1 ) {
return; // off blink

View file

@ -87,7 +87,7 @@ void SCR_DrawChar( float x, float y, float cw, float ch, int c )
// draws a string with a drop shadow, optionally with colorcodes
void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* string, qbool allowColor, qbool showColorCodes )
void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* string, qbool allowColor, qbool showColorCodes, const float* firstColor )
{
float xx;
const char* s;
@ -114,7 +114,7 @@ void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* string,
// draw the text, possibly with colors
s = string;
xx = x;
re.SetColor( colorWhite );
re.SetColor( firstColor ? firstColor : colorWhite );
while ( *s ) {
if ( allowColor && Q_IsColorString( s ) ) {
re.SetColor( ColorFromChar( s[1] ) );
@ -136,7 +136,7 @@ void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* string,
void SCR_DrawString( float x, float y, float cw, float ch, const char* string, qbool allowColor )
{
SCR_DrawStringEx( x, y, cw, ch, string, allowColor, qfalse );
SCR_DrawStringEx( x, y, cw, ch, string, allowColor, qfalse, NULL );
}

View file

@ -446,7 +446,7 @@ void SCR_AdjustFrom640( float *x, float *y, float *w, float *h );
void SCR_DrawChar( float x, float y, float cw, float ch, int c );
void SCR_DrawString( float x, float y, float cw, float ch, const char* s, qbool allowColor );
void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* s, qbool allowColor, qbool showColorCodes );
void SCR_DrawStringEx( float x, float y, float cw, float ch, const char* s, qbool allowColor, qbool showColorCodes, const float* firstColor );
void SCR_DebugGraph( float value, int color );