| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#include "client.h" |
| 25 |
|
| 26 |
|
| 27 |
#define DEFAULT_CONSOLE_WIDTH 78 |
| 28 |
int g_console_field_width = DEFAULT_CONSOLE_WIDTH; |
| 29 |
int g_smallchar_width = SMALLCHAR_WIDTH; |
| 30 |
int g_smallchar_height = SMALLCHAR_HEIGHT; |
| 31 |
|
| 32 |
#define NUM_CON_TIMES 17 |
| 33 |
|
| 34 |
#define CON_TEXTSIZE 32768 |
| 35 |
typedef struct { |
| 36 |
qboolean initialized; |
| 37 |
|
| 38 |
short text[CON_TEXTSIZE]; |
| 39 |
int current; |
| 40 |
int x; |
| 41 |
int display; |
| 42 |
|
| 43 |
int linewidth; |
| 44 |
int totallines; |
| 45 |
|
| 46 |
float xadjust; |
| 47 |
|
| 48 |
float displayFrac; |
| 49 |
float finalFrac; |
| 50 |
|
| 51 |
int vislines; |
| 52 |
|
| 53 |
int times[NUM_CON_TIMES]; |
| 54 |
|
| 55 |
vec4_t color; |
| 56 |
} console_t; |
| 57 |
|
| 58 |
console_t con; |
| 59 |
|
| 60 |
cvar_t *con_conspeed; |
| 61 |
cvar_t *con_autoclear; |
| 62 |
cvar_t *con_notifytime; |
| 63 |
cvar_t *con_notifylines; |
| 64 |
cvar_t *con_scale; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
void Con_ToggleConsole_f (void) { |
| 74 |
|
| 75 |
if ( clc.state == CA_DISCONNECTED && Key_GetCatcher( ) == KEYCATCH_CONSOLE ) { |
| 76 |
return; |
| 77 |
} |
| 78 |
|
| 79 |
if ( con_autoclear->integer ) { |
| 80 |
Field_Clear( &g_consoleField ); |
| 81 |
} |
| 82 |
|
| 83 |
g_consoleField.widthInChars = g_console_field_width; |
| 84 |
|
| 85 |
Con_ClearNotify (); |
| 86 |
Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_CONSOLE ); |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
void Con_ToggleMenu_f( void ) { |
| 95 |
CL_KeyEvent( K_ESCAPE, qtrue, Sys_Milliseconds() ); |
| 96 |
CL_KeyEvent( K_ESCAPE, qfalse, Sys_Milliseconds() ); |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
void Con_MessageMode_f (void) { |
| 105 |
chat_playerNum = -1; |
| 106 |
chat_team = qfalse; |
| 107 |
Field_Clear( &chatField ); |
| 108 |
chatField.widthInChars = 30; |
| 109 |
|
| 110 |
Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
void Con_MessageMode2_f (void) { |
| 119 |
chat_playerNum = -1; |
| 120 |
chat_team = qtrue; |
| 121 |
Field_Clear( &chatField ); |
| 122 |
chatField.widthInChars = 25; |
| 123 |
Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
void Con_MessageMode3_f (void) { |
| 132 |
chat_playerNum = VM_Call( cgvm, CG_CROSSHAIR_PLAYER ); |
| 133 |
if ( chat_playerNum < 0 || chat_playerNum >= MAX_CLIENTS ) { |
| 134 |
chat_playerNum = -1; |
| 135 |
return; |
| 136 |
} |
| 137 |
chat_team = qfalse; |
| 138 |
Field_Clear( &chatField ); |
| 139 |
chatField.widthInChars = 30; |
| 140 |
Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
void Con_MessageMode4_f (void) { |
| 149 |
chat_playerNum = VM_Call( cgvm, CG_LAST_ATTACKER ); |
| 150 |
if ( chat_playerNum < 0 || chat_playerNum >= MAX_CLIENTS ) { |
| 151 |
chat_playerNum = -1; |
| 152 |
return; |
| 153 |
} |
| 154 |
chat_team = qfalse; |
| 155 |
Field_Clear( &chatField ); |
| 156 |
chatField.widthInChars = 30; |
| 157 |
Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
void Con_Clear_f (void) { |
| 166 |
int i; |
| 167 |
|
| 168 |
for ( i = 0 ; i < CON_TEXTSIZE ; i++ ) { |
| 169 |
con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' '; |
| 170 |
} |
| 171 |
|
| 172 |
Con_Bottom(); |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
void Con_Dump_f (void) |
| 184 |
{ |
| 185 |
int l, x, i; |
| 186 |
short *line; |
| 187 |
fileHandle_t f; |
| 188 |
int bufferlen; |
| 189 |
char *buffer; |
| 190 |
char filename[MAX_QPATH]; |
| 191 |
|
| 192 |
if (Cmd_Argc() != 2) |
| 193 |
{ |
| 194 |
Com_Printf ("usage: condump <filename>\n"); |
| 195 |
return; |
| 196 |
} |
| 197 |
|
| 198 |
Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) ); |
| 199 |
COM_DefaultExtension( filename, sizeof( filename ), ".txt" ); |
| 200 |
|
| 201 |
if (!COM_CompareExtension(filename, ".txt")) |
| 202 |
{ |
| 203 |
Com_Printf("Con_Dump_f: Only the \".txt\" extension is supported by this command!\n"); |
| 204 |
return; |
| 205 |
} |
| 206 |
|
| 207 |
f = FS_FOpenFileWrite_HomeData( filename ); |
| 208 |
if (!f) |
| 209 |
{ |
| 210 |
Com_Printf ("ERROR: couldn't open %s.\n", filename); |
| 211 |
return; |
| 212 |
} |
| 213 |
|
| 214 |
Com_Printf ("Dumped console text to %s.\n", filename ); |
| 215 |
|
| 216 |
|
| 217 |
for (l = con.current - con.totallines + 1 ; l <= con.current ; l++) |
| 218 |
{ |
| 219 |
line = con.text + (l%con.totallines)*con.linewidth; |
| 220 |
for (x=0 ; x<con.linewidth ; x++) |
| 221 |
if ((line[x] & 0xff) != ' ') |
| 222 |
break; |
| 223 |
if (x != con.linewidth) |
| 224 |
break; |
| 225 |
} |
| 226 |
|
| 227 |
#ifdef _WIN32 |
| 228 |
bufferlen = con.linewidth + 3 * sizeof ( char ); |
| 229 |
#else |
| 230 |
bufferlen = con.linewidth + 2 * sizeof ( char ); |
| 231 |
#endif |
| 232 |
|
| 233 |
buffer = Hunk_AllocateTempMemory( bufferlen ); |
| 234 |
|
| 235 |
|
| 236 |
buffer[bufferlen-1] = 0; |
| 237 |
for ( ; l <= con.current ; l++) |
| 238 |
{ |
| 239 |
line = con.text + (l%con.totallines)*con.linewidth; |
| 240 |
for(i=0; i<con.linewidth; i++) |
| 241 |
buffer[i] = line[i] & 0xff; |
| 242 |
for (x=con.linewidth-1 ; x>=0 ; x--) |
| 243 |
{ |
| 244 |
if (buffer[x] == ' ') |
| 245 |
buffer[x] = 0; |
| 246 |
else |
| 247 |
break; |
| 248 |
} |
| 249 |
#ifdef _WIN32 |
| 250 |
Q_strcat(buffer, bufferlen, "\r\n"); |
| 251 |
#else |
| 252 |
Q_strcat(buffer, bufferlen, "\n"); |
| 253 |
#endif |
| 254 |
FS_Write(buffer, strlen(buffer), f); |
| 255 |
} |
| 256 |
|
| 257 |
Hunk_FreeTempMemory( buffer ); |
| 258 |
FS_FCloseFile( f ); |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
void Con_ClearNotify( void ) { |
| 268 |
int i; |
| 269 |
|
| 270 |
for ( i = 0 ; i < NUM_CON_TIMES ; i++ ) { |
| 271 |
con.times[i] = 0; |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
void Con_CheckResize (void) |
| 285 |
{ |
| 286 |
int i, j, width, oldwidth, oldtotallines, numlines, numchars; |
| 287 |
short tbuf[CON_TEXTSIZE]; |
| 288 |
|
| 289 |
if (con_scale != NULL) |
| 290 |
{ |
| 291 |
g_smallchar_width = (int)((float)SMALLCHAR_WIDTH * con_scale->value); |
| 292 |
g_smallchar_height = (int)((float)SMALLCHAR_HEIGHT * con_scale->value); |
| 293 |
} |
| 294 |
|
| 295 |
width = (cls.glconfig.vidWidth / g_smallchar_width) - 2; |
| 296 |
|
| 297 |
if (width == con.linewidth) |
| 298 |
return; |
| 299 |
|
| 300 |
if (width < 1) |
| 301 |
{ |
| 302 |
width = DEFAULT_CONSOLE_WIDTH; |
| 303 |
con.linewidth = width; |
| 304 |
con.totallines = CON_TEXTSIZE / con.linewidth; |
| 305 |
for(i=0; i<CON_TEXTSIZE; i++) |
| 306 |
|
| 307 |
con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' '; |
| 308 |
} |
| 309 |
else |
| 310 |
{ |
| 311 |
oldwidth = con.linewidth; |
| 312 |
con.linewidth = width; |
| 313 |
oldtotallines = con.totallines; |
| 314 |
con.totallines = CON_TEXTSIZE / con.linewidth; |
| 315 |
numlines = oldtotallines; |
| 316 |
|
| 317 |
if (con.totallines < numlines) |
| 318 |
numlines = con.totallines; |
| 319 |
|
| 320 |
numchars = oldwidth; |
| 321 |
|
| 322 |
if (con.linewidth < numchars) |
| 323 |
numchars = con.linewidth; |
| 324 |
|
| 325 |
Com_Memcpy (tbuf, con.text, CON_TEXTSIZE * sizeof(short)); |
| 326 |
for(i=0; i<CON_TEXTSIZE; i++) |
| 327 |
|
| 328 |
con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' '; |
| 329 |
|
| 330 |
|
| 331 |
for (i=0 ; i<numlines ; i++) |
| 332 |
{ |
| 333 |
for (j=0 ; j<numchars ; j++) |
| 334 |
{ |
| 335 |
con.text[(con.totallines - 1 - i) * con.linewidth + j] = |
| 336 |
tbuf[((con.current - i + oldtotallines) % |
| 337 |
oldtotallines) * oldwidth + j]; |
| 338 |
} |
| 339 |
} |
| 340 |
|
| 341 |
Con_ClearNotify (); |
| 342 |
} |
| 343 |
|
| 344 |
con.current = con.totallines - 1; |
| 345 |
con.display = con.current; |
| 346 |
} |
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
void Cmd_CompleteTxtName( char *args, int argNum ) { |
| 354 |
if( argNum == 2 ) { |
| 355 |
Field_CompleteFilename( "", "txt", NULL, qfalse, qtrue ); |
| 356 |
} |
| 357 |
} |
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
void Con_Init (void) { |
| 366 |
int i; |
| 367 |
|
| 368 |
con_notifytime = Cvar_Get ("con_notifytime", "3", CVAR_ARCHIVE); |
| 369 |
con_notifylines = Cvar_Get ("con_notifylines", "3", CVAR_ARCHIVE); |
| 370 |
Cvar_CheckRange(con_notifylines, 1, NUM_CON_TIMES - 1, qtrue); |
| 371 |
con_conspeed = Cvar_Get ("scr_conspeed", "3", CVAR_ARCHIVE); |
| 372 |
con_autoclear = Cvar_Get("con_autoclear", "1", CVAR_ARCHIVE); |
| 373 |
con_scale = Cvar_Get("con_scale", "1", CVAR_ARCHIVE); |
| 374 |
Cvar_CheckRange(con_scale, 1.0f, 4.0f, qfalse); |
| 375 |
|
| 376 |
Field_Clear( &g_consoleField ); |
| 377 |
g_consoleField.widthInChars = g_console_field_width; |
| 378 |
for ( i = 0 ; i < COMMAND_HISTORY ; i++ ) { |
| 379 |
Field_Clear( &historyEditLines[i] ); |
| 380 |
historyEditLines[i].widthInChars = g_console_field_width; |
| 381 |
} |
| 382 |
CL_LoadConsoleHistory( ); |
| 383 |
|
| 384 |
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f); |
| 385 |
Cmd_AddCommand ("togglemenu", Con_ToggleMenu_f); |
| 386 |
Cmd_AddCommand ("messagemode", Con_MessageMode_f); |
| 387 |
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f); |
| 388 |
Cmd_AddCommand ("messagemode3", Con_MessageMode3_f); |
| 389 |
Cmd_AddCommand ("messagemode4", Con_MessageMode4_f); |
| 390 |
Cmd_AddCommand ("clear", Con_Clear_f); |
| 391 |
Cmd_AddCommand ("condump", Con_Dump_f); |
| 392 |
Cmd_SetCommandCompletionFunc( "condump", Cmd_CompleteTxtName ); |
| 393 |
} |
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
void Con_Shutdown(void) |
| 401 |
{ |
| 402 |
Cmd_RemoveCommand("toggleconsole"); |
| 403 |
Cmd_RemoveCommand("togglemenu"); |
| 404 |
Cmd_RemoveCommand("messagemode"); |
| 405 |
Cmd_RemoveCommand("messagemode2"); |
| 406 |
Cmd_RemoveCommand("messagemode3"); |
| 407 |
Cmd_RemoveCommand("messagemode4"); |
| 408 |
Cmd_RemoveCommand("clear"); |
| 409 |
Cmd_RemoveCommand("condump"); |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
void Con_Linefeed (qboolean skipnotify) |
| 418 |
{ |
| 419 |
int i; |
| 420 |
|
| 421 |
|
| 422 |
if (con.current >= 0) |
| 423 |
{ |
| 424 |
if (skipnotify) |
| 425 |
con.times[con.current % NUM_CON_TIMES] = 0; |
| 426 |
else |
| 427 |
con.times[con.current % NUM_CON_TIMES] = cls.realtime; |
| 428 |
} |
| 429 |
|
| 430 |
con.x = 0; |
| 431 |
if (con.display == con.current) |
| 432 |
con.display++; |
| 433 |
con.current++; |
| 434 |
for(i=0; i<con.linewidth; i++) |
| 435 |
con.text[(con.current%con.totallines)*con.linewidth+i] = (ColorIndex(COLOR_WHITE)<<8) | ' '; |
| 436 |
} |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
void CL_ConsolePrint( char *txt ) { |
| 448 |
int y, l; |
| 449 |
unsigned char c; |
| 450 |
unsigned short color; |
| 451 |
qboolean skipnotify = qfalse; |
| 452 |
int prev; |
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
if ( !Q_strncmp( txt, "[skipnotify]", 12 ) ) { |
| 457 |
skipnotify = qtrue; |
| 458 |
txt += 12; |
| 459 |
} |
| 460 |
|
| 461 |
|
| 462 |
if ( cl_noprint && cl_noprint->integer ) { |
| 463 |
return; |
| 464 |
} |
| 465 |
|
| 466 |
if (!con.initialized) { |
| 467 |
con.color[0] = |
| 468 |
con.color[1] = |
| 469 |
con.color[2] = |
| 470 |
con.color[3] = 1.0f; |
| 471 |
con.linewidth = -1; |
| 472 |
Con_CheckResize (); |
| 473 |
con.initialized = qtrue; |
| 474 |
} |
| 475 |
|
| 476 |
color = ColorIndex(COLOR_WHITE); |
| 477 |
|
| 478 |
while ( (c = *((unsigned char *) txt)) != 0 ) { |
| 479 |
if ( Q_IsColorString( txt ) ) { |
| 480 |
color = ColorIndex( *(txt+1) ); |
| 481 |
txt += 2; |
| 482 |
continue; |
| 483 |
} |
| 484 |
|
| 485 |
|
| 486 |
for (l=0 ; l< con.linewidth ; l++) { |
| 487 |
if ( txt[l] <= ' ') { |
| 488 |
break; |
| 489 |
} |
| 490 |
|
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
if (l != con.linewidth && (con.x + l >= con.linewidth) ) { |
| 495 |
Con_Linefeed(skipnotify); |
| 496 |
|
| 497 |
} |
| 498 |
|
| 499 |
txt++; |
| 500 |
|
| 501 |
switch (c) |
| 502 |
{ |
| 503 |
case '\n': |
| 504 |
Con_Linefeed (skipnotify); |
| 505 |
break; |
| 506 |
case '\r': |
| 507 |
con.x = 0; |
| 508 |
break; |
| 509 |
default: |
| 510 |
y = con.current % con.totallines; |
| 511 |
con.text[y*con.linewidth+con.x] = (color << 8) | c; |
| 512 |
con.x++; |
| 513 |
if(con.x >= con.linewidth) |
| 514 |
Con_Linefeed(skipnotify); |
| 515 |
break; |
| 516 |
} |
| 517 |
} |
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
if (con.current >= 0) { |
| 522 |
|
| 523 |
if ( skipnotify ) { |
| 524 |
prev = con.current % NUM_CON_TIMES - 1; |
| 525 |
if ( prev < 0 ) |
| 526 |
prev = NUM_CON_TIMES - 1; |
| 527 |
con.times[prev] = 0; |
| 528 |
} |
| 529 |
else |
| 530 |
|
| 531 |
con.times[con.current % NUM_CON_TIMES] = cls.realtime; |
| 532 |
} |
| 533 |
} |
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
void Con_DrawInput (void) { |
| 553 |
int y; |
| 554 |
|
| 555 |
if ( clc.state != CA_DISCONNECTED && !(Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ) { |
| 556 |
return; |
| 557 |
} |
| 558 |
|
| 559 |
y = con.vislines - ( g_smallchar_height * 2 ); |
| 560 |
|
| 561 |
re.SetColor( con.color ); |
| 562 |
|
| 563 |
SCR_DrawSmallChar( con.xadjust + 1 * g_smallchar_width, y, ']' ); |
| 564 |
|
| 565 |
Field_Draw( &g_consoleField, con.xadjust + 2 * g_smallchar_width, y, |
| 566 |
SCREEN_WIDTH - 3 * g_smallchar_width, qtrue, qtrue ); |
| 567 |
} |
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
void Con_DrawNotify (void) |
| 578 |
{ |
| 579 |
int x, v; |
| 580 |
short *text; |
| 581 |
int i; |
| 582 |
int time; |
| 583 |
int skip; |
| 584 |
int currentColor; |
| 585 |
|
| 586 |
currentColor = 7; |
| 587 |
re.SetColor( g_color_table[currentColor] ); |
| 588 |
|
| 589 |
v = 0; |
| 590 |
for (i= con.current-con_notifylines->integer ; i<=con.current ; i++) |
| 591 |
{ |
| 592 |
int linelength = 0; |
| 593 |
|
| 594 |
if (i < 0) |
| 595 |
continue; |
| 596 |
time = con.times[i % NUM_CON_TIMES]; |
| 597 |
if (time == 0) |
| 598 |
continue; |
| 599 |
time = cls.realtime - time; |
| 600 |
if (time > con_notifytime->value*1000) |
| 601 |
continue; |
| 602 |
text = con.text + (i % con.totallines)*con.linewidth; |
| 603 |
|
| 604 |
if (cl.snap.ps.pm_type != PM_INTERMISSION && Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME) ) { |
| 605 |
continue; |
| 606 |
} |
| 607 |
|
| 608 |
for (x = 0 ; x < con.linewidth ; x++) { |
| 609 |
if ( ( text[x] & 0xff ) == ' ' ) { |
| 610 |
continue; |
| 611 |
} |
| 612 |
if ( ColorIndexForNumber( text[x]>>8 ) != currentColor ) { |
| 613 |
currentColor = ColorIndexForNumber( text[x]>>8 ); |
| 614 |
re.SetColor( g_color_table[currentColor] ); |
| 615 |
} |
| 616 |
SCR_DrawSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*g_smallchar_width, v, text[x] & 0xff ); |
| 617 |
linelength++; |
| 618 |
} |
| 619 |
|
| 620 |
if (linelength > 0) { |
| 621 |
v += g_smallchar_height; |
| 622 |
} |
| 623 |
} |
| 624 |
|
| 625 |
|
| 626 |
v *= 480.0f / cls.glconfig.vidHeight; |
| 627 |
v += 8; |
| 628 |
|
| 629 |
re.SetColor( NULL ); |
| 630 |
|
| 631 |
if (Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME) ) { |
| 632 |
return; |
| 633 |
} |
| 634 |
|
| 635 |
|
| 636 |
if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE ) |
| 637 |
{ |
| 638 |
if (chat_team) |
| 639 |
{ |
| 640 |
SCR_DrawBigString (8, v, "say_team:", 1.0f, qfalse ); |
| 641 |
skip = 10; |
| 642 |
} |
| 643 |
else |
| 644 |
{ |
| 645 |
SCR_DrawBigString (8, v, "say:", 1.0f, qfalse ); |
| 646 |
skip = 5; |
| 647 |
} |
| 648 |
|
| 649 |
Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, v, |
| 650 |
SCREEN_WIDTH - ( skip + 1 ) * BIGCHAR_WIDTH, qtrue, qtrue ); |
| 651 |
} |
| 652 |
|
| 653 |
} |
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
void Con_DrawSolidConsole( float frac ) { |
| 663 |
int i, x, y; |
| 664 |
int rows; |
| 665 |
short *text; |
| 666 |
int row; |
| 667 |
int lines; |
| 668 |
|
| 669 |
int currentColor; |
| 670 |
vec4_t color; |
| 671 |
|
| 672 |
lines = cls.glconfig.vidHeight * frac; |
| 673 |
if (lines <= 0) |
| 674 |
return; |
| 675 |
|
| 676 |
if (lines > cls.glconfig.vidHeight ) |
| 677 |
lines = cls.glconfig.vidHeight; |
| 678 |
|
| 679 |
|
| 680 |
con.xadjust = 0; |
| 681 |
SCR_AdjustFrom640( &con.xadjust, NULL, NULL, NULL ); |
| 682 |
|
| 683 |
|
| 684 |
y = frac * SCREEN_HEIGHT; |
| 685 |
if ( y < 1 ) { |
| 686 |
y = 0; |
| 687 |
} |
| 688 |
else { |
| 689 |
SCR_DrawPic( 0, 0, SCREEN_WIDTH, y, cls.consoleShader ); |
| 690 |
} |
| 691 |
|
| 692 |
color[0] = 1; |
| 693 |
color[1] = 0; |
| 694 |
color[2] = 0; |
| 695 |
color[3] = 1; |
| 696 |
SCR_FillRect( 0, y, SCREEN_WIDTH, 2, color ); |
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
re.SetColor( g_color_table[ColorIndex(COLOR_RED)] ); |
| 702 |
|
| 703 |
i = strlen( Q3_VERSION ); |
| 704 |
|
| 705 |
for (x=0 ; x<i ; x++) { |
| 706 |
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * g_smallchar_width, |
| 707 |
lines - g_smallchar_height, Q3_VERSION[x] ); |
| 708 |
} |
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
con.vislines = lines; |
| 713 |
rows = (lines-g_smallchar_height)/g_smallchar_height; |
| 714 |
|
| 715 |
y = lines - (g_smallchar_height*3); |
| 716 |
|
| 717 |
|
| 718 |
if (con.display != con.current) |
| 719 |
{ |
| 720 |
|
| 721 |
re.SetColor( g_color_table[ColorIndex(COLOR_RED)] ); |
| 722 |
for (x=0 ; x<con.linewidth ; x+=4) |
| 723 |
SCR_DrawSmallChar( con.xadjust + (x+1)*g_smallchar_width, y, '^' ); |
| 724 |
y -= g_smallchar_height; |
| 725 |
rows--; |
| 726 |
} |
| 727 |
|
| 728 |
row = con.display; |
| 729 |
|
| 730 |
if ( con.x == 0 ) { |
| 731 |
row--; |
| 732 |
} |
| 733 |
|
| 734 |
currentColor = 7; |
| 735 |
re.SetColor( g_color_table[currentColor] ); |
| 736 |
|
| 737 |
for (i=0 ; i<rows ; i++, y -= g_smallchar_height, row--) |
| 738 |
{ |
| 739 |
if (row < 0) |
| 740 |
break; |
| 741 |
if (con.current - row >= con.totallines) { |
| 742 |
|
| 743 |
continue; |
| 744 |
} |
| 745 |
|
| 746 |
text = con.text + (row % con.totallines)*con.linewidth; |
| 747 |
|
| 748 |
for (x=0 ; x<con.linewidth ; x++) { |
| 749 |
if ( ( text[x] & 0xff ) == ' ' ) { |
| 750 |
continue; |
| 751 |
} |
| 752 |
|
| 753 |
if ( ColorIndexForNumber( text[x]>>8 ) != currentColor ) { |
| 754 |
currentColor = ColorIndexForNumber( text[x]>>8 ); |
| 755 |
re.SetColor( g_color_table[currentColor] ); |
| 756 |
} |
| 757 |
SCR_DrawSmallChar( con.xadjust + (x+1)*g_smallchar_width, y, text[x] & 0xff ); |
| 758 |
} |
| 759 |
} |
| 760 |
|
| 761 |
|
| 762 |
Con_DrawInput (); |
| 763 |
|
| 764 |
re.SetColor( NULL ); |
| 765 |
} |
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
void Con_DrawConsole( void ) { |
| 775 |
|
| 776 |
Con_CheckResize (); |
| 777 |
|
| 778 |
|
| 779 |
if ( clc.state == CA_DISCONNECTED ) { |
| 780 |
if ( !( Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME)) ) { |
| 781 |
Con_DrawSolidConsole( 1.0 ); |
| 782 |
return; |
| 783 |
} |
| 784 |
} |
| 785 |
|
| 786 |
if ( con.displayFrac ) { |
| 787 |
Con_DrawSolidConsole( con.displayFrac ); |
| 788 |
} else { |
| 789 |
|
| 790 |
if ( clc.state == CA_ACTIVE ) { |
| 791 |
Con_DrawNotify (); |
| 792 |
} |
| 793 |
} |
| 794 |
} |
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
void Con_RunConsole (void) { |
| 806 |
|
| 807 |
if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) |
| 808 |
con.finalFrac = 0.5; |
| 809 |
else |
| 810 |
con.finalFrac = 0; |
| 811 |
|
| 812 |
|
| 813 |
if (con.finalFrac < con.displayFrac) |
| 814 |
{ |
| 815 |
con.displayFrac -= con_conspeed->value*cls.realFrametime*0.001; |
| 816 |
if (con.finalFrac > con.displayFrac) |
| 817 |
con.displayFrac = con.finalFrac; |
| 818 |
|
| 819 |
} |
| 820 |
else if (con.finalFrac > con.displayFrac) |
| 821 |
{ |
| 822 |
con.displayFrac += con_conspeed->value*cls.realFrametime*0.001; |
| 823 |
if (con.finalFrac < con.displayFrac) |
| 824 |
con.displayFrac = con.finalFrac; |
| 825 |
} |
| 826 |
|
| 827 |
} |
| 828 |
|
| 829 |
|
| 830 |
void Con_PageUp( void ) { |
| 831 |
con.display -= 2; |
| 832 |
if ( con.current - con.display >= con.totallines ) { |
| 833 |
con.display = con.current - con.totallines + 1; |
| 834 |
} |
| 835 |
} |
| 836 |
|
| 837 |
void Con_PageDown( void ) { |
| 838 |
con.display += 2; |
| 839 |
if (con.display > con.current) { |
| 840 |
con.display = con.current; |
| 841 |
} |
| 842 |
} |
| 843 |
|
| 844 |
void Con_Top( void ) { |
| 845 |
con.display = con.totallines; |
| 846 |
if ( con.current - con.display >= con.totallines ) { |
| 847 |
con.display = con.current - con.totallines + 1; |
| 848 |
} |
| 849 |
} |
| 850 |
|
| 851 |
void Con_Bottom( void ) { |
| 852 |
con.display = con.current; |
| 853 |
} |
| 854 |
|
| 855 |
|
| 856 |
void Con_Close( void ) { |
| 857 |
if ( !com_cl_running->integer ) { |
| 858 |
return; |
| 859 |
} |
| 860 |
Field_Clear( &g_consoleField ); |
| 861 |
Con_ClearNotify (); |
| 862 |
Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_CONSOLE ); |
| 863 |
con.finalFrac = 0; |
| 864 |
con.displayFrac = 0; |
| 865 |
} |