void CL_ConsolePrint( char *txt ) { int y; int c, i, l; int color; qboolean skipnotify = qfalse; // NERVE - SMF int prev; // NERVE - SMF // NERVE - SMF - work around for text that shows up in console but not in notify if ( !Q_strncmp( txt, "[skipnotify]", 12 ) ) { skipnotify = qtrue; txt += 12; } // for some demos we don't want to ever show anything on the console if ( cl_noprint && cl_noprint->integer ) { return; } if ( !con.initialized ) { con.color[ 0 ] = con.color[ 1 ] = con.color[ 2 ] = con.color[ 3 ] = 1.0f; con.linewidth = -1; Con_CheckResize(); con.initialized = qtrue; } if ( !skipnotify && !( cls.keyCatchers & KEYCATCH_CONSOLE ) && strncmp( txt, "EXCL: ", 6 ) ) { // feed the text to cgame Cmd_SaveCmdContext(); Cmd_TokenizeString( txt ); CL_GameConsoleText(); Cmd_RestoreCmdContext(); } color = ColorIndex( CONSOLE_COLOR ); while ( ( c = *txt & 0xFF ) != 0 ) { if ( Q_IsColorString( txt ) ) { color = ( txt[ 1 ] == COLOR_NULL ) ? ColorIndex( CONSOLE_COLOR ) : ColorIndex( txt[ 1 ] ); txt += 2; continue; } // count word length for ( i = l = 0; l < con.linewidth; ++l ) { if ( txt[ i ] <= ' ' && txt[ i ] >= 0 ) { break; } if ( txt[ i ] == Q_COLOR_ESCAPE && txt[ i + 1 ] == Q_COLOR_ESCAPE ) { ++i; } i += Q_UTF8Width( txt + i ); } // word wrap if ( l != con.linewidth && ( con.x + l >= con.linewidth ) ) { Con_Linefeed( skipnotify ); } switch ( c ) { case '\n': Con_Linefeed( skipnotify ); break; case '\r': con.x = 0; break; case Q_COLOR_ESCAPE: if ( txt[ 1 ] == Q_COLOR_ESCAPE ) { ++txt; } default: // display character and advance y = con.current % con.totallines; // rain - sign extension caused the character to carry over // into the color info for high ascii chars; casting c to unsigned con.text[ y * con.linewidth + con.x ].ch = Q_UTF8CodePoint( txt ); con.text[ y * con.linewidth + con.x ].ink = color; ++con.x; if ( con.x >= con.linewidth ) { Con_Linefeed( skipnotify ); con.x = 0; } break; } txt += Q_UTF8Width( txt ); } // mark time for transparent overlay if ( con.current >= 0 ) { // NERVE - SMF if ( skipnotify ) { prev = con.current % NUM_CON_TIMES - 1; if ( prev < 0 ) { prev = NUM_CON_TIMES - 1; } con.times[ prev ] = 0; } else { // -NERVE - SMF con.times[ con.current % NUM_CON_TIMES ] = cls.realtime; } } }
qboolean CL_InternalConsolePrint( const char *text ) { int y; int c, i, l; int color; // for some demos we don't want to ever show anything on the console if ( cl_noprint && cl_noprint->integer ) { return qtrue; } if ( !consoleState.initialized ) { consoleState.textWidthInChars = -1; consoleState.initialized = Con_CheckResize(); } //Video hasn't been initialized if ( ! cls.glconfig.vidWidth ) { return qfalse; } // NERVE - SMF - work around for text that shows up in console but not in notify if ( !Q_strncmp( text, S_SKIPNOTIFY, 12 ) ) { text += 12; } else if ( !consoleState.isOpened && strncmp( text, "EXCL: ", 6 ) ) { // feed the text to cgame Cmd_SaveCmdContext(); Cmd_TokenizeString( Cmd::Escape(text).c_str() ); CL_GameConsoleText(); Cmd_RestoreCmdContext(); } color = ColorIndex( CONSOLE_COLOR ); while ( ( c = *text & 0xFF ) != 0 ) { if ( Q_IsColorString( text ) ) { color = ( text[ 1 ] == COLOR_NULL ) ? ColorIndex( CONSOLE_COLOR ) : ColorIndex( text[ 1 ] ); text += 2; continue; } // count word length for ( i = l = 0; l < consoleState.textWidthInChars; ++l ) { if ( text[ i ] <= ' ' && text[ i ] >= 0 ) { break; } if ( text[ i ] == Q_COLOR_ESCAPE && text[ i + 1 ] == Q_COLOR_ESCAPE ) { ++i; } i += Q_UTF8_Width( text + i ); } // word wrap if ( l != consoleState.textWidthInChars && ( consoleState.horizontalCharOffset + l >= consoleState.textWidthInChars ) ) { Con_Linefeed( ); } switch ( c ) { case '\n': Con_Linefeed( ); break; case '\r': consoleState.horizontalCharOffset = 0; break; case Q_COLOR_ESCAPE: if ( text[ 1 ] == Q_COLOR_ESCAPE ) { ++text; } /* no break */ default: // display character and advance y = consoleState.currentLine % consoleState.maxScrollbackLengthInLines; // rain - sign extension caused the character to carry over // into the color info for high ascii chars; casting c to unsigned consoleState.text[ y * consoleState.textWidthInChars + consoleState.horizontalCharOffset ].ch = Q_UTF8_CodePoint( text ); consoleState.text[ y * consoleState.textWidthInChars + consoleState.horizontalCharOffset ].ink = color; ++consoleState.horizontalCharOffset; if ( consoleState.horizontalCharOffset >= consoleState.textWidthInChars ) { Con_Linefeed( ); consoleState.horizontalCharOffset = 0; } break; } text += Q_UTF8_Width( text ); } return qtrue; }
void SV_PrintTranslatedText( const char *text, qboolean broadcast ) { char str[ MAX_STRING_CHARS ]; char buf[ MAX_STRING_CHARS ]; const char *in; int i = 0; Cmd_SaveCmdContext(); Cmd_TokenizeString( text ); Q_strncpyz( buf, Trans_GettextGame( Cmd_Argv( 1 ) ), sizeof( buf ) ); in = buf; memset( &str, 0, sizeof( str ) ); while( *in ) { const char *inOld = in; if( *in == '$' ) { const char *number = ++in; while( *in ) { if( *in == '$' ) { str[ i++ ] = *in; in++; break; } if( isdigit( *in ) ) { in++; if( *in == 't' && *(in+1) == '$' ) { int num = atoi( number ); if( num <= 0 || num > 99 ) { in++; break; } i += strlen( Trans_GettextGame( Cmd_Argv( num + 1 ) ) ); if( i >= MAX_STRING_CHARS ) { Com_Printf( "%s", str ); memset( &str, 0, sizeof( str ) ); i = strlen( Trans_GettextGame( Cmd_Argv( num + 1 ) ) ); } Q_strcat( str, sizeof( str ), Trans_GettextGame( Cmd_Argv( num + 1 ) ) ); in += 2; break; } else if( *in == '$' ) { int num = atoi( number ); if( num <= 0 || num > 99 ) { in++; break; } i += strlen( Cmd_Argv( num + 1 ) ); if( i >= MAX_STRING_CHARS ) { Com_Printf( "%s", str ); memset( &str, 0, sizeof( str ) ); i = strlen( Trans_GettextGame( Cmd_Argv( num + 1 ) ) ); } Q_strcat( str, sizeof( str ), Cmd_Argv( num + 1 ) ); in++; break; } } else { in = inOld; goto broken; } } } else { broken: if( i < MAX_STRING_CHARS ) { str[ i++ ] = *in; in++; } else { Com_Printf( "%s", str ); memset( &str, 0, sizeof( str ) ); i = 0; } } } Com_Printf( "%s%s", broadcast ? "Broadcast: " : "", str ); Cmd_RestoreCmdContext(); }