/* =================== Field_Draw 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 ) { int len; int drawLen; int prestep; int cursorChar; char str[MAX_STRING_CHARS], *s; int i; int curColor; drawLen = edit->widthInChars - 1; // - 1 so there is always a space for the cursor len = strlen( edit->buffer ); // guarantee that cursor will be visible if ( len <= drawLen ) { prestep = 0; } else { if ( edit->scroll + drawLen > len ) { edit->scroll = len - drawLen; if ( edit->scroll < 0 ) { edit->scroll = 0; } } prestep = edit->scroll; } if ( prestep + drawLen > len ) { drawLen = len - prestep; } // extract <drawLen> characters from the field at <prestep> if ( drawLen >= MAX_STRING_CHARS ) { Com_Error( ERR_DROP, "drawLen >= MAX_STRING_CHARS" ); } Com_Memcpy( str, edit->buffer + prestep, drawLen ); str[ drawLen ] = '\0'; // color tracking curColor = COLOR_WHITE; if ( prestep > 0 ) { // we need to track last actual color because we cut some text before s = edit->buffer; for ( i = 0; i < prestep + 1; i++, s++ ) { if ( *s == Q_COLOR_ESCAPE && *(s+1) != '\0' && *(s+1) != Q_COLOR_ESCAPE ) { curColor = *(s+1); s++; } } // scroll marker // FIXME: force white color? if ( str[0] ) { str[0] = '<'; } } // draw it if ( size == SMALLCHAR_WIDTH ) { SCR_DrawSmallStringExt( x, y, str, g_color_table[ ColorIndex( curColor ) ], qfalse, noColorEscape ); if ( len > drawLen + prestep ) { SCR_DrawSmallChar( x + ( edit->widthInChars - 1 ) * size, y, '>' ); } } else { if ( len > drawLen + prestep ) { SCR_DrawStringExt( x + ( edit->widthInChars - 1 ) * size, y, size, ">", g_color_table[ ColorIndex( COLOR_WHITE ) ], qfalse, noColorEscape ); } // draw big string with drop shadow SCR_DrawStringExt( x, y, size, str, g_color_table[ ColorIndex( curColor ) ], qfalse, noColorEscape ); } // draw the cursor if ( showCursor ) { if ( cls.realtime & 256 ) { return; // off blink } if ( key_overstrikeMode ) { cursorChar = 11; } else { cursorChar = 10; } i = drawLen - strlen( str ); if ( size == SMALLCHAR_WIDTH ) { SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar ); } else { str[0] = cursorChar; str[1] = '\0'; SCR_DrawBigString( x + ( edit->cursor - prestep - i ) * size, y, str, 1.0, qfalse ); } } }
/* ================ Con_DrawNotify Draws the last few lines of output transparently over the game top ================ */ void Con_DrawNotify( void ) { int x, v; int i; int time; int skip = 0; int currentColor; conChar_t *text; currentColor = 7; re.SetColor( g_color_table[ currentColor ] ); v = 0; for ( i = con.current - NUM_CON_TIMES + 1; i <= con.current; i++ ) { if ( i < 0 ) { continue; } time = con.times[ i % NUM_CON_TIMES ]; if ( time == 0 ) { continue; } time = cls.realtime - time; if ( time > con_notifytime->value * 1000 ) { continue; } text = con.text + CON_LINE( i ); if ( cl.snap.ps.pm_type != PM_INTERMISSION && cls.keyCatchers & ( KEYCATCH_UI | KEYCATCH_CGAME ) ) { continue; } for ( x = 0; x < con.linewidth && text[ x ].ch; ++x ) { if ( text[ x ].ch == ' ' ) { continue; } if ( text[ x ].ink != currentColor ) { currentColor = text[ x ].ink; re.SetColor( g_color_table[ currentColor ] ); } SCR_DrawSmallUnichar( cl_conXOffset->integer + con.xadjust + ( x + 1 ) * SMALLCHAR_WIDTH, v, text[ x ].ch ); } v += SMALLCHAR_HEIGHT; } re.SetColor( NULL ); if ( cls.keyCatchers & ( KEYCATCH_UI | KEYCATCH_CGAME ) ) { return; } // draw the chat line if ( cls.keyCatchers & KEYCATCH_MESSAGE ) { if ( chat_irc ) { char buf[ 128 ]; SCR_DrawBigString( 8, v, "say_irc:", 1.0f, qfalse ); skip = strlen( buf ) + 2; } Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, 232, qtrue, qtrue ); v += BIGCHAR_HEIGHT; } }