| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#include "ui_local.h" |
| 29 |
|
| 30 |
uiStatic_t uis; |
| 31 |
qboolean m_entersound; |
| 32 |
|
| 33 |
void QDECL Com_Error( int level, const char *error, ... ) { |
| 34 |
va_list argptr; |
| 35 |
char text[1024]; |
| 36 |
|
| 37 |
va_start (argptr, error); |
| 38 |
Q_vsnprintf (text, sizeof(text), error, argptr); |
| 39 |
va_end (argptr); |
| 40 |
|
| 41 |
trap_Error( text ); |
| 42 |
} |
| 43 |
|
| 44 |
void QDECL Com_Printf( const char *msg, ... ) { |
| 45 |
va_list argptr; |
| 46 |
char text[1024]; |
| 47 |
|
| 48 |
va_start (argptr, msg); |
| 49 |
Q_vsnprintf (text, sizeof(text), msg, argptr); |
| 50 |
va_end (argptr); |
| 51 |
|
| 52 |
trap_Print( text ); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
float UI_ClampCvar( float min, float max, float value ) |
| 61 |
{ |
| 62 |
if ( value < min ) return min; |
| 63 |
if ( value > max ) return max; |
| 64 |
return value; |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
void UI_StartDemoLoop( void ) { |
| 73 |
trap_Cmd_ExecuteText( EXEC_APPEND, "d1\n" ); |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
void UI_PushMenu( menuframework_s *menu ) |
| 82 |
{ |
| 83 |
int i; |
| 84 |
menucommon_s* item; |
| 85 |
|
| 86 |
|
| 87 |
for (i=0 ; i<uis.menusp ; i++) |
| 88 |
{ |
| 89 |
if (uis.stack[i] == menu) |
| 90 |
{ |
| 91 |
uis.menusp = i; |
| 92 |
break; |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
if (i == uis.menusp) |
| 97 |
{ |
| 98 |
if (uis.menusp >= MAX_MENUDEPTH) |
| 99 |
trap_Error("UI_PushMenu: menu stack overflow"); |
| 100 |
|
| 101 |
uis.stack[uis.menusp++] = menu; |
| 102 |
} |
| 103 |
|
| 104 |
uis.activemenu = menu; |
| 105 |
|
| 106 |
|
| 107 |
menu->cursor = 0; |
| 108 |
menu->cursor_prev = 0; |
| 109 |
|
| 110 |
m_entersound = qtrue; |
| 111 |
|
| 112 |
trap_Key_SetCatcher( KEYCATCH_UI ); |
| 113 |
|
| 114 |
|
| 115 |
for (i=0; i<menu->nitems; i++) |
| 116 |
{ |
| 117 |
item = (menucommon_s *)menu->items[i]; |
| 118 |
if (!(item->flags & (QMF_GRAYED|QMF_MOUSEONLY|QMF_INACTIVE))) |
| 119 |
{ |
| 120 |
menu->cursor_prev = -1; |
| 121 |
Menu_SetCursor( menu, i ); |
| 122 |
break; |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
uis.firstdraw = qtrue; |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
void UI_PopMenu (void) |
| 135 |
{ |
| 136 |
trap_S_StartLocalSound( menu_out_sound, CHAN_LOCAL_SOUND ); |
| 137 |
|
| 138 |
uis.menusp--; |
| 139 |
|
| 140 |
if (uis.menusp < 0) |
| 141 |
trap_Error ("UI_PopMenu: menu stack underflow"); |
| 142 |
|
| 143 |
if (uis.menusp) { |
| 144 |
uis.activemenu = uis.stack[uis.menusp-1]; |
| 145 |
uis.firstdraw = qtrue; |
| 146 |
} |
| 147 |
else { |
| 148 |
UI_ForceMenuOff (); |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
void UI_ForceMenuOff (void) |
| 153 |
{ |
| 154 |
uis.menusp = 0; |
| 155 |
uis.activemenu = NULL; |
| 156 |
|
| 157 |
trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI ); |
| 158 |
trap_Key_ClearStates(); |
| 159 |
trap_Cvar_Set( "cl_paused", "0" ); |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
void UI_LerpColor(vec4_t a, vec4_t b, vec4_t c, float t) |
| 168 |
{ |
| 169 |
int i; |
| 170 |
|
| 171 |
|
| 172 |
for (i=0; i<4; i++) |
| 173 |
{ |
| 174 |
c[i] = a[i] + t*(b[i]-a[i]); |
| 175 |
if (c[i] < 0) |
| 176 |
c[i] = 0; |
| 177 |
else if (c[i] > 1.0) |
| 178 |
c[i] = 1.0; |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
static int propMap[128][3] = { |
| 188 |
{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, |
| 189 |
{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, |
| 190 |
|
| 191 |
{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, |
| 192 |
{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, |
| 193 |
|
| 194 |
{0, 0, PROP_SPACE_WIDTH}, |
| 195 |
{11, 122, 7}, |
| 196 |
{154, 181, 14}, |
| 197 |
{55, 122, 17}, |
| 198 |
{79, 122, 18}, |
| 199 |
{101, 122, 23}, |
| 200 |
{153, 122, 18}, |
| 201 |
{9, 93, 7}, |
| 202 |
{207, 122, 8}, |
| 203 |
{230, 122, 9}, |
| 204 |
{177, 122, 18}, |
| 205 |
{30, 152, 18}, |
| 206 |
{85, 181, 7}, |
| 207 |
{34, 93, 11}, |
| 208 |
{110, 181, 6}, |
| 209 |
{130, 152, 14}, |
| 210 |
|
| 211 |
{22, 64, 17}, |
| 212 |
{41, 64, 12}, |
| 213 |
{58, 64, 17}, |
| 214 |
{78, 64, 18}, |
| 215 |
{98, 64, 19}, |
| 216 |
{120, 64, 18}, |
| 217 |
{141, 64, 18}, |
| 218 |
{204, 64, 16}, |
| 219 |
{162, 64, 17}, |
| 220 |
{182, 64, 18}, |
| 221 |
{59, 181, 7}, |
| 222 |
{35,181, 7}, |
| 223 |
{203, 152, 14}, |
| 224 |
{56, 93, 14}, |
| 225 |
{228, 152, 14}, |
| 226 |
{177, 181, 18}, |
| 227 |
|
| 228 |
{28, 122, 22}, |
| 229 |
{5, 4, 18}, |
| 230 |
{27, 4, 18}, |
| 231 |
{48, 4, 18}, |
| 232 |
{69, 4, 17}, |
| 233 |
{90, 4, 13}, |
| 234 |
{106, 4, 13}, |
| 235 |
{121, 4, 18}, |
| 236 |
{143, 4, 17}, |
| 237 |
{164, 4, 8}, |
| 238 |
{175, 4, 16}, |
| 239 |
{195, 4, 18}, |
| 240 |
{216, 4, 12}, |
| 241 |
{230, 4, 23}, |
| 242 |
{6, 34, 18}, |
| 243 |
{27, 34, 18}, |
| 244 |
|
| 245 |
{48, 34, 18}, |
| 246 |
{68, 34, 18}, |
| 247 |
{90, 34, 17}, |
| 248 |
{110, 34, 18}, |
| 249 |
{130, 34, 14}, |
| 250 |
{146, 34, 18}, |
| 251 |
{166, 34, 19}, |
| 252 |
{185, 34, 29}, |
| 253 |
{215, 34, 18}, |
| 254 |
{234, 34, 18}, |
| 255 |
{5, 64, 14}, |
| 256 |
{60, 152, 7}, |
| 257 |
{106, 151, 13}, |
| 258 |
{83, 152, 7}, |
| 259 |
{128, 122, 17}, |
| 260 |
{4, 152, 21}, |
| 261 |
|
| 262 |
{134, 181, 5}, |
| 263 |
{5, 4, 18}, |
| 264 |
{27, 4, 18}, |
| 265 |
{48, 4, 18}, |
| 266 |
{69, 4, 17}, |
| 267 |
{90, 4, 13}, |
| 268 |
{106, 4, 13}, |
| 269 |
{121, 4, 18}, |
| 270 |
{143, 4, 17}, |
| 271 |
{164, 4, 8}, |
| 272 |
{175, 4, 16}, |
| 273 |
{195, 4, 18}, |
| 274 |
{216, 4, 12}, |
| 275 |
{230, 4, 23}, |
| 276 |
{6, 34, 18}, |
| 277 |
{27, 34, 18}, |
| 278 |
|
| 279 |
{48, 34, 18}, |
| 280 |
{68, 34, 18}, |
| 281 |
{90, 34, 17}, |
| 282 |
{110, 34, 18}, |
| 283 |
{130, 34, 14}, |
| 284 |
{146, 34, 18}, |
| 285 |
{166, 34, 19}, |
| 286 |
{185, 34, 29}, |
| 287 |
{215, 34, 18}, |
| 288 |
{234, 34, 18}, |
| 289 |
{5, 64, 14}, |
| 290 |
{153, 152, 13}, |
| 291 |
{11, 181, 5}, |
| 292 |
{180, 152, 13}, |
| 293 |
{79, 93, 17}, |
| 294 |
{0, 0, -1} |
| 295 |
}; |
| 296 |
|
| 297 |
static int propMapB[26][3] = { |
| 298 |
{11, 12, 33}, |
| 299 |
{49, 12, 31}, |
| 300 |
{85, 12, 31}, |
| 301 |
{120, 12, 30}, |
| 302 |
{156, 12, 21}, |
| 303 |
{183, 12, 21}, |
| 304 |
{207, 12, 32}, |
| 305 |
|
| 306 |
{13, 55, 30}, |
| 307 |
{49, 55, 13}, |
| 308 |
{66, 55, 29}, |
| 309 |
{101, 55, 31}, |
| 310 |
{135, 55, 21}, |
| 311 |
{158, 55, 40}, |
| 312 |
{204, 55, 32}, |
| 313 |
|
| 314 |
{12, 97, 31}, |
| 315 |
{48, 97, 31}, |
| 316 |
{82, 97, 30}, |
| 317 |
{118, 97, 30}, |
| 318 |
{153, 97, 30}, |
| 319 |
{185, 97, 25}, |
| 320 |
{213, 97, 30}, |
| 321 |
|
| 322 |
{11, 139, 32}, |
| 323 |
{42, 139, 51}, |
| 324 |
{93, 139, 32}, |
| 325 |
{126, 139, 31}, |
| 326 |
{158, 139, 25}, |
| 327 |
}; |
| 328 |
|
| 329 |
#define PROPB_GAP_WIDTH 4 |
| 330 |
#define PROPB_SPACE_WIDTH 12 |
| 331 |
#define PROPB_HEIGHT 36 |
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
static void UI_DrawBannerString2( int x, int y, const char* str, vec4_t color ) |
| 339 |
{ |
| 340 |
const char* s; |
| 341 |
unsigned char ch; |
| 342 |
float ax; |
| 343 |
float ay; |
| 344 |
float aw; |
| 345 |
float ah; |
| 346 |
float frow; |
| 347 |
float fcol; |
| 348 |
float fwidth; |
| 349 |
float fheight; |
| 350 |
|
| 351 |
|
| 352 |
trap_R_SetColor( color ); |
| 353 |
|
| 354 |
ax = x * uis.xscale + uis.bias; |
| 355 |
ay = y * uis.yscale; |
| 356 |
|
| 357 |
s = str; |
| 358 |
while ( *s ) |
| 359 |
{ |
| 360 |
ch = *s & 127; |
| 361 |
if ( ch == ' ' ) { |
| 362 |
ax += ((float)PROPB_SPACE_WIDTH + (float)PROPB_GAP_WIDTH)* uis.xscale; |
| 363 |
} |
| 364 |
else if ( ch >= 'A' && ch <= 'Z' ) { |
| 365 |
ch -= 'A'; |
| 366 |
fcol = (float)propMapB[ch][0] / 256.0f; |
| 367 |
frow = (float)propMapB[ch][1] / 256.0f; |
| 368 |
fwidth = (float)propMapB[ch][2] / 256.0f; |
| 369 |
fheight = (float)PROPB_HEIGHT / 256.0f; |
| 370 |
aw = (float)propMapB[ch][2] * uis.xscale; |
| 371 |
ah = (float)PROPB_HEIGHT * uis.yscale; |
| 372 |
trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, uis.charsetPropB ); |
| 373 |
ax += (aw + (float)PROPB_GAP_WIDTH * uis.xscale); |
| 374 |
} |
| 375 |
s++; |
| 376 |
} |
| 377 |
|
| 378 |
trap_R_SetColor( NULL ); |
| 379 |
} |
| 380 |
|
| 381 |
void UI_DrawBannerString( int x, int y, const char* str, int style, vec4_t color ) { |
| 382 |
const char * s; |
| 383 |
int ch; |
| 384 |
int width; |
| 385 |
vec4_t drawcolor; |
| 386 |
|
| 387 |
|
| 388 |
s = str; |
| 389 |
width = 0; |
| 390 |
while ( *s ) { |
| 391 |
ch = *s; |
| 392 |
if ( ch == ' ' ) { |
| 393 |
width += PROPB_SPACE_WIDTH; |
| 394 |
} |
| 395 |
else if ( ch >= 'A' && ch <= 'Z' ) { |
| 396 |
width += propMapB[ch - 'A'][2] + PROPB_GAP_WIDTH; |
| 397 |
} |
| 398 |
s++; |
| 399 |
} |
| 400 |
width -= PROPB_GAP_WIDTH; |
| 401 |
|
| 402 |
switch( style & UI_FORMATMASK ) { |
| 403 |
case UI_CENTER: |
| 404 |
x -= width / 2; |
| 405 |
break; |
| 406 |
|
| 407 |
case UI_RIGHT: |
| 408 |
x -= width; |
| 409 |
break; |
| 410 |
|
| 411 |
case UI_LEFT: |
| 412 |
default: |
| 413 |
break; |
| 414 |
} |
| 415 |
|
| 416 |
if ( style & UI_DROPSHADOW ) { |
| 417 |
drawcolor[0] = drawcolor[1] = drawcolor[2] = 0; |
| 418 |
drawcolor[3] = color[3]; |
| 419 |
UI_DrawBannerString2( x+2, y+2, str, drawcolor ); |
| 420 |
} |
| 421 |
|
| 422 |
UI_DrawBannerString2( x, y, str, color ); |
| 423 |
} |
| 424 |
|
| 425 |
|
| 426 |
int UI_ProportionalStringWidth( const char* str ) { |
| 427 |
const char * s; |
| 428 |
int ch; |
| 429 |
int charWidth; |
| 430 |
int width; |
| 431 |
|
| 432 |
s = str; |
| 433 |
width = 0; |
| 434 |
while ( *s ) { |
| 435 |
ch = *s & 127; |
| 436 |
charWidth = propMap[ch][2]; |
| 437 |
if ( charWidth != -1 ) { |
| 438 |
width += charWidth; |
| 439 |
width += PROP_GAP_WIDTH; |
| 440 |
} |
| 441 |
s++; |
| 442 |
} |
| 443 |
|
| 444 |
width -= PROP_GAP_WIDTH; |
| 445 |
return width; |
| 446 |
} |
| 447 |
|
| 448 |
static void UI_DrawProportionalString2( int x, int y, const char* str, vec4_t color, float sizeScale, qhandle_t charset ) |
| 449 |
{ |
| 450 |
const char* s; |
| 451 |
unsigned char ch; |
| 452 |
float ax; |
| 453 |
float ay; |
| 454 |
float aw = 0; |
| 455 |
float ah; |
| 456 |
float frow; |
| 457 |
float fcol; |
| 458 |
float fwidth; |
| 459 |
float fheight; |
| 460 |
|
| 461 |
|
| 462 |
trap_R_SetColor( color ); |
| 463 |
|
| 464 |
ax = x * uis.xscale + uis.bias; |
| 465 |
ay = y * uis.yscale; |
| 466 |
|
| 467 |
s = str; |
| 468 |
while ( *s ) |
| 469 |
{ |
| 470 |
ch = *s & 127; |
| 471 |
if ( ch == ' ' ) { |
| 472 |
aw = (float)PROP_SPACE_WIDTH * uis.xscale * sizeScale; |
| 473 |
} |
| 474 |
else if ( propMap[ch][2] != -1 ) { |
| 475 |
fcol = (float)propMap[ch][0] / 256.0f; |
| 476 |
frow = (float)propMap[ch][1] / 256.0f; |
| 477 |
fwidth = (float)propMap[ch][2] / 256.0f; |
| 478 |
fheight = (float)PROP_HEIGHT / 256.0f; |
| 479 |
aw = (float)propMap[ch][2] * uis.xscale * sizeScale; |
| 480 |
ah = (float)PROP_HEIGHT * uis.yscale * sizeScale; |
| 481 |
trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, charset ); |
| 482 |
} |
| 483 |
|
| 484 |
ax += (aw + (float)PROP_GAP_WIDTH * uis.xscale * sizeScale); |
| 485 |
s++; |
| 486 |
} |
| 487 |
|
| 488 |
trap_R_SetColor( NULL ); |
| 489 |
} |
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
float UI_ProportionalSizeScale( int style ) { |
| 497 |
if( style & UI_SMALLFONT ) { |
| 498 |
return PROP_SMALL_SIZE_SCALE; |
| 499 |
} |
| 500 |
|
| 501 |
return 1.00; |
| 502 |
} |
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
void UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ) { |
| 511 |
vec4_t drawcolor; |
| 512 |
int width; |
| 513 |
float sizeScale; |
| 514 |
|
| 515 |
if( !str ) { |
| 516 |
return; |
| 517 |
} |
| 518 |
|
| 519 |
sizeScale = UI_ProportionalSizeScale( style ); |
| 520 |
|
| 521 |
switch( style & UI_FORMATMASK ) { |
| 522 |
case UI_CENTER: |
| 523 |
width = UI_ProportionalStringWidth( str ) * sizeScale; |
| 524 |
x -= width / 2; |
| 525 |
break; |
| 526 |
|
| 527 |
case UI_RIGHT: |
| 528 |
width = UI_ProportionalStringWidth( str ) * sizeScale; |
| 529 |
x -= width; |
| 530 |
break; |
| 531 |
|
| 532 |
case UI_LEFT: |
| 533 |
default: |
| 534 |
break; |
| 535 |
} |
| 536 |
|
| 537 |
if ( style & UI_DROPSHADOW ) { |
| 538 |
drawcolor[0] = drawcolor[1] = drawcolor[2] = 0; |
| 539 |
drawcolor[3] = color[3]; |
| 540 |
UI_DrawProportionalString2( x+2, y+2, str, drawcolor, sizeScale, uis.charsetProp ); |
| 541 |
} |
| 542 |
|
| 543 |
if ( style & UI_INVERSE ) { |
| 544 |
drawcolor[0] = color[0] * 0.7; |
| 545 |
drawcolor[1] = color[1] * 0.7; |
| 546 |
drawcolor[2] = color[2] * 0.7; |
| 547 |
drawcolor[3] = color[3]; |
| 548 |
UI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, uis.charsetProp ); |
| 549 |
return; |
| 550 |
} |
| 551 |
|
| 552 |
if ( style & UI_PULSE ) { |
| 553 |
drawcolor[0] = color[0] * 0.7; |
| 554 |
drawcolor[1] = color[1] * 0.7; |
| 555 |
drawcolor[2] = color[2] * 0.7; |
| 556 |
drawcolor[3] = color[3]; |
| 557 |
UI_DrawProportionalString2( x, y, str, color, sizeScale, uis.charsetProp ); |
| 558 |
|
| 559 |
drawcolor[0] = color[0]; |
| 560 |
drawcolor[1] = color[1]; |
| 561 |
drawcolor[2] = color[2]; |
| 562 |
drawcolor[3] = 0.5 + 0.5 * sin( uis.realtime / PULSE_DIVISOR ); |
| 563 |
UI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, uis.charsetPropGlow ); |
| 564 |
return; |
| 565 |
} |
| 566 |
|
| 567 |
UI_DrawProportionalString2( x, y, str, color, sizeScale, uis.charsetProp ); |
| 568 |
} |
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
void UI_DrawProportionalString_AutoWrapped( int x, int y, int xmax, int ystep, const char* str, int style, vec4_t color ) { |
| 576 |
int width; |
| 577 |
char *s1,*s2,*s3; |
| 578 |
char c_bcp; |
| 579 |
char buf[1024]; |
| 580 |
float sizeScale; |
| 581 |
|
| 582 |
if (!str || str[0]=='\0') |
| 583 |
return; |
| 584 |
|
| 585 |
sizeScale = UI_ProportionalSizeScale( style ); |
| 586 |
|
| 587 |
Q_strncpyz(buf, str, sizeof(buf)); |
| 588 |
s1 = s2 = s3 = buf; |
| 589 |
|
| 590 |
while (1) { |
| 591 |
do { |
| 592 |
s3++; |
| 593 |
} while (*s3!=' ' && *s3!='\0'); |
| 594 |
c_bcp = *s3; |
| 595 |
*s3 = '\0'; |
| 596 |
width = UI_ProportionalStringWidth(s1) * sizeScale; |
| 597 |
*s3 = c_bcp; |
| 598 |
if (width > xmax) { |
| 599 |
if (s1==s2) |
| 600 |
{ |
| 601 |
|
| 602 |
s2 = s3; |
| 603 |
} |
| 604 |
*s2 = '\0'; |
| 605 |
UI_DrawProportionalString(x, y, s1, style, color); |
| 606 |
y += ystep; |
| 607 |
if (c_bcp == '\0') |
| 608 |
{ |
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
s2++; |
| 614 |
if (*s2 != '\0') |
| 615 |
UI_DrawProportionalString(x, y, s2, style, color); |
| 616 |
break; |
| 617 |
} |
| 618 |
s2++; |
| 619 |
s1 = s2; |
| 620 |
s3 = s2; |
| 621 |
} |
| 622 |
else |
| 623 |
{ |
| 624 |
s2 = s3; |
| 625 |
if (c_bcp == '\0') |
| 626 |
{ |
| 627 |
UI_DrawProportionalString(x, y, s1, style, color); |
| 628 |
break; |
| 629 |
} |
| 630 |
} |
| 631 |
} |
| 632 |
} |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
static void UI_DrawString2( int x, int y, const char* str, vec4_t color, int charw, int charh ) |
| 640 |
{ |
| 641 |
const char* s; |
| 642 |
char ch; |
| 643 |
int forceColor = qfalse; |
| 644 |
vec4_t tempcolor; |
| 645 |
float ax; |
| 646 |
float ay; |
| 647 |
float aw; |
| 648 |
float ah; |
| 649 |
float frow; |
| 650 |
float fcol; |
| 651 |
|
| 652 |
if (y < -charh) |
| 653 |
|
| 654 |
return; |
| 655 |
|
| 656 |
|
| 657 |
trap_R_SetColor( color ); |
| 658 |
|
| 659 |
ax = x * uis.xscale + uis.bias; |
| 660 |
ay = y * uis.yscale; |
| 661 |
aw = charw * uis.xscale; |
| 662 |
ah = charh * uis.yscale; |
| 663 |
|
| 664 |
s = str; |
| 665 |
while ( *s ) |
| 666 |
{ |
| 667 |
if ( Q_IsColorString( s ) ) |
| 668 |
{ |
| 669 |
if ( !forceColor ) |
| 670 |
{ |
| 671 |
memcpy( tempcolor, g_color_table[ColorIndex(s[1])], sizeof( tempcolor ) ); |
| 672 |
tempcolor[3] = color[3]; |
| 673 |
trap_R_SetColor( tempcolor ); |
| 674 |
} |
| 675 |
s += 2; |
| 676 |
continue; |
| 677 |
} |
| 678 |
|
| 679 |
ch = *s & 255; |
| 680 |
if (ch != ' ') |
| 681 |
{ |
| 682 |
frow = (ch>>4)*0.0625; |
| 683 |
fcol = (ch&15)*0.0625; |
| 684 |
trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + 0.0625, frow + 0.0625, uis.charset ); |
| 685 |
} |
| 686 |
|
| 687 |
ax += aw; |
| 688 |
s++; |
| 689 |
} |
| 690 |
|
| 691 |
trap_R_SetColor( NULL ); |
| 692 |
} |
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
void UI_DrawString( int x, int y, const char* str, int style, vec4_t color ) |
| 700 |
{ |
| 701 |
int len; |
| 702 |
int charw; |
| 703 |
int charh; |
| 704 |
vec4_t newcolor; |
| 705 |
vec4_t lowlight; |
| 706 |
float *drawcolor; |
| 707 |
vec4_t dropcolor; |
| 708 |
|
| 709 |
if( !str ) { |
| 710 |
return; |
| 711 |
} |
| 712 |
|
| 713 |
if ((style & UI_BLINK) && ((uis.realtime/BLINK_DIVISOR) & 1)) |
| 714 |
return; |
| 715 |
|
| 716 |
if (style & UI_SMALLFONT) |
| 717 |
{ |
| 718 |
charw = SMALLCHAR_WIDTH; |
| 719 |
charh = SMALLCHAR_HEIGHT; |
| 720 |
} |
| 721 |
else if (style & UI_GIANTFONT) |
| 722 |
{ |
| 723 |
charw = GIANTCHAR_WIDTH; |
| 724 |
charh = GIANTCHAR_HEIGHT; |
| 725 |
} |
| 726 |
else |
| 727 |
{ |
| 728 |
charw = BIGCHAR_WIDTH; |
| 729 |
charh = BIGCHAR_HEIGHT; |
| 730 |
} |
| 731 |
|
| 732 |
if (style & UI_PULSE) |
| 733 |
{ |
| 734 |
lowlight[0] = 0.8*color[0]; |
| 735 |
lowlight[1] = 0.8*color[1]; |
| 736 |
lowlight[2] = 0.8*color[2]; |
| 737 |
lowlight[3] = 0.8*color[3]; |
| 738 |
UI_LerpColor(color,lowlight,newcolor,0.5+0.5*sin(uis.realtime/PULSE_DIVISOR)); |
| 739 |
drawcolor = newcolor; |
| 740 |
} |
| 741 |
else |
| 742 |
drawcolor = color; |
| 743 |
|
| 744 |
switch (style & UI_FORMATMASK) |
| 745 |
{ |
| 746 |
case UI_CENTER: |
| 747 |
|
| 748 |
len = strlen(str); |
| 749 |
x = x - len*charw/2; |
| 750 |
break; |
| 751 |
|
| 752 |
case UI_RIGHT: |
| 753 |
|
| 754 |
len = strlen(str); |
| 755 |
x = x - len*charw; |
| 756 |
break; |
| 757 |
|
| 758 |
default: |
| 759 |
|
| 760 |
break; |
| 761 |
} |
| 762 |
|
| 763 |
if ( style & UI_DROPSHADOW ) |
| 764 |
{ |
| 765 |
dropcolor[0] = dropcolor[1] = dropcolor[2] = 0; |
| 766 |
dropcolor[3] = drawcolor[3]; |
| 767 |
UI_DrawString2(x+2,y+2,str,dropcolor,charw,charh); |
| 768 |
} |
| 769 |
|
| 770 |
UI_DrawString2(x,y,str,drawcolor,charw,charh); |
| 771 |
} |
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
void UI_DrawChar( int x, int y, int ch, int style, vec4_t color ) |
| 779 |
{ |
| 780 |
char buff[2]; |
| 781 |
|
| 782 |
buff[0] = ch; |
| 783 |
buff[1] = '\0'; |
| 784 |
|
| 785 |
UI_DrawString( x, y, buff, style, color ); |
| 786 |
} |
| 787 |
|
| 788 |
qboolean UI_IsFullscreen( void ) { |
| 789 |
if ( uis.activemenu && ( trap_Key_GetCatcher() & KEYCATCH_UI ) ) { |
| 790 |
return uis.activemenu->fullscreen; |
| 791 |
} |
| 792 |
|
| 793 |
return qfalse; |
| 794 |
} |
| 795 |
|
| 796 |
static void NeedCDAction( qboolean result ) { |
| 797 |
if ( !result ) { |
| 798 |
trap_Cmd_ExecuteText( EXEC_APPEND, "quit\n" ); |
| 799 |
} |
| 800 |
} |
| 801 |
|
| 802 |
static void NeedCDKeyAction( qboolean result ) { |
| 803 |
if ( !result ) { |
| 804 |
trap_Cmd_ExecuteText( EXEC_APPEND, "quit\n" ); |
| 805 |
} |
| 806 |
} |
| 807 |
|
| 808 |
void UI_SetActiveMenu( uiMenuCommand_t menu ) { |
| 809 |
|
| 810 |
|
| 811 |
Menu_Cache(); |
| 812 |
|
| 813 |
switch ( menu ) { |
| 814 |
case UIMENU_NONE: |
| 815 |
UI_ForceMenuOff(); |
| 816 |
return; |
| 817 |
case UIMENU_MAIN: |
| 818 |
UI_MainMenu(); |
| 819 |
return; |
| 820 |
case UIMENU_NEED_CD: |
| 821 |
UI_ConfirmMenu( "Insert the CD", 0, NeedCDAction ); |
| 822 |
return; |
| 823 |
case UIMENU_BAD_CD_KEY: |
| 824 |
UI_ConfirmMenu( "Bad CD Key", 0, NeedCDKeyAction ); |
| 825 |
return; |
| 826 |
case UIMENU_INGAME: |
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
trap_Cvar_Set( "cl_paused", "1" ); |
| 833 |
UI_InGameMenu(); |
| 834 |
return; |
| 835 |
|
| 836 |
case UIMENU_TEAM: |
| 837 |
case UIMENU_POSTGAME: |
| 838 |
default: |
| 839 |
#ifndef NDEBUG |
| 840 |
Com_Printf("UI_SetActiveMenu: bad enum %d\n", menu ); |
| 841 |
#endif |
| 842 |
break; |
| 843 |
} |
| 844 |
} |
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
void UI_KeyEvent( int key, int down ) { |
| 852 |
sfxHandle_t s; |
| 853 |
|
| 854 |
if (!uis.activemenu) { |
| 855 |
return; |
| 856 |
} |
| 857 |
|
| 858 |
if (!down) { |
| 859 |
return; |
| 860 |
} |
| 861 |
|
| 862 |
if (uis.activemenu->key) |
| 863 |
s = uis.activemenu->key( key ); |
| 864 |
else |
| 865 |
s = Menu_DefaultKey( uis.activemenu, key ); |
| 866 |
|
| 867 |
if ((s > 0) && (s != menu_null_sound)) |
| 868 |
trap_S_StartLocalSound( s, CHAN_LOCAL_SOUND ); |
| 869 |
} |
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
void UI_MouseEvent( int dx, int dy ) |
| 877 |
{ |
| 878 |
int i; |
| 879 |
int bias; |
| 880 |
menucommon_s* m; |
| 881 |
|
| 882 |
if (!uis.activemenu) |
| 883 |
return; |
| 884 |
|
| 885 |
|
| 886 |
bias = uis.bias / uis.xscale; |
| 887 |
|
| 888 |
|
| 889 |
uis.cursorx += dx; |
| 890 |
if (uis.cursorx < -bias) |
| 891 |
uis.cursorx = -bias; |
| 892 |
else if (uis.cursorx > SCREEN_WIDTH+bias) |
| 893 |
uis.cursorx = SCREEN_WIDTH+bias; |
| 894 |
|
| 895 |
uis.cursory += dy; |
| 896 |
if (uis.cursory < 0) |
| 897 |
uis.cursory = 0; |
| 898 |
else if (uis.cursory > SCREEN_HEIGHT) |
| 899 |
uis.cursory = SCREEN_HEIGHT; |
| 900 |
|
| 901 |
|
| 902 |
for (i=0; i<uis.activemenu->nitems; i++) |
| 903 |
{ |
| 904 |
m = (menucommon_s*)uis.activemenu->items[i]; |
| 905 |
|
| 906 |
if (m->flags & (QMF_GRAYED|QMF_INACTIVE)) |
| 907 |
continue; |
| 908 |
|
| 909 |
if ((uis.cursorx < m->left) || |
| 910 |
(uis.cursorx > m->right) || |
| 911 |
(uis.cursory < m->top) || |
| 912 |
(uis.cursory > m->bottom)) |
| 913 |
{ |
| 914 |
|
| 915 |
continue; |
| 916 |
} |
| 917 |
|
| 918 |
|
| 919 |
if (uis.activemenu->cursor != i) |
| 920 |
{ |
| 921 |
Menu_SetCursor( uis.activemenu, i ); |
| 922 |
((menucommon_s*)(uis.activemenu->items[uis.activemenu->cursor_prev]))->flags &= ~QMF_HASMOUSEFOCUS; |
| 923 |
|
| 924 |
if ( !(((menucommon_s*)(uis.activemenu->items[uis.activemenu->cursor]))->flags & QMF_SILENT ) ) { |
| 925 |
trap_S_StartLocalSound( menu_move_sound, CHAN_LOCAL_SOUND ); |
| 926 |
} |
| 927 |
} |
| 928 |
|
| 929 |
((menucommon_s*)(uis.activemenu->items[uis.activemenu->cursor]))->flags |= QMF_HASMOUSEFOCUS; |
| 930 |
return; |
| 931 |
} |
| 932 |
|
| 933 |
if (uis.activemenu->nitems > 0) { |
| 934 |
|
| 935 |
((menucommon_s*)(uis.activemenu->items[uis.activemenu->cursor]))->flags &= ~QMF_HASMOUSEFOCUS; |
| 936 |
} |
| 937 |
} |
| 938 |
|
| 939 |
char *UI_Argv( int arg ) { |
| 940 |
static char buffer[MAX_STRING_CHARS]; |
| 941 |
|
| 942 |
trap_Argv( arg, buffer, sizeof( buffer ) ); |
| 943 |
|
| 944 |
return buffer; |
| 945 |
} |
| 946 |
|
| 947 |
|
| 948 |
char *UI_Cvar_VariableString( const char *var_name ) { |
| 949 |
static char buffer[MAX_STRING_CHARS]; |
| 950 |
|
| 951 |
trap_Cvar_VariableStringBuffer( var_name, buffer, sizeof( buffer ) ); |
| 952 |
|
| 953 |
return buffer; |
| 954 |
} |
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
void UI_Cache_f( void ) { |
| 963 |
MainMenu_Cache(); |
| 964 |
InGame_Cache(); |
| 965 |
ConfirmMenu_Cache(); |
| 966 |
PlayerModel_Cache(); |
| 967 |
PlayerSettings_Cache(); |
| 968 |
Controls_Cache(); |
| 969 |
Demos_Cache(); |
| 970 |
UI_CinematicsMenu_Cache(); |
| 971 |
Preferences_Cache(); |
| 972 |
ServerInfo_Cache(); |
| 973 |
SpecifyServer_Cache(); |
| 974 |
ArenaServers_Cache(); |
| 975 |
StartServer_Cache(); |
| 976 |
ServerOptions_Cache(); |
| 977 |
DriverInfo_Cache(); |
| 978 |
GraphicsOptions_Cache(); |
| 979 |
UI_DisplayOptionsMenu_Cache(); |
| 980 |
UI_SoundOptionsMenu_Cache(); |
| 981 |
UI_NetworkOptionsMenu_Cache(); |
| 982 |
UI_SPLevelMenu_Cache(); |
| 983 |
UI_SPSkillMenu_Cache(); |
| 984 |
UI_SPPostgameMenu_Cache(); |
| 985 |
TeamMain_Cache(); |
| 986 |
UI_AddBots_Cache(); |
| 987 |
UI_RemoveBots_Cache(); |
| 988 |
UI_SetupMenu_Cache(); |
| 989 |
|
| 990 |
|
| 991 |
UI_BotSelectMenu_Cache(); |
| 992 |
UI_CDKeyMenu_Cache(); |
| 993 |
UI_ModsMenu_Cache(); |
| 994 |
|
| 995 |
} |
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
qboolean UI_ConsoleCommand( int realTime ) { |
| 1004 |
char *cmd; |
| 1005 |
|
| 1006 |
uis.frametime = realTime - uis.realtime; |
| 1007 |
uis.realtime = realTime; |
| 1008 |
|
| 1009 |
cmd = UI_Argv( 0 ); |
| 1010 |
|
| 1011 |
|
| 1012 |
Menu_Cache(); |
| 1013 |
|
| 1014 |
if ( Q_stricmp (cmd, "levelselect") == 0 ) { |
| 1015 |
UI_SPLevelMenu_f(); |
| 1016 |
return qtrue; |
| 1017 |
} |
| 1018 |
|
| 1019 |
if ( Q_stricmp (cmd, "postgame") == 0 ) { |
| 1020 |
UI_SPPostgameMenu_f(); |
| 1021 |
return qtrue; |
| 1022 |
} |
| 1023 |
|
| 1024 |
if ( Q_stricmp (cmd, "ui_cache") == 0 ) { |
| 1025 |
UI_Cache_f(); |
| 1026 |
return qtrue; |
| 1027 |
} |
| 1028 |
|
| 1029 |
if ( Q_stricmp (cmd, "ui_cinematics") == 0 ) { |
| 1030 |
UI_CinematicsMenu_f(); |
| 1031 |
return qtrue; |
| 1032 |
} |
| 1033 |
|
| 1034 |
if ( Q_stricmp (cmd, "ui_teamOrders") == 0 ) { |
| 1035 |
UI_TeamOrdersMenu_f(); |
| 1036 |
return qtrue; |
| 1037 |
} |
| 1038 |
|
| 1039 |
if ( Q_stricmp (cmd, "iamacheater") == 0 ) { |
| 1040 |
UI_SPUnlock_f(); |
| 1041 |
return qtrue; |
| 1042 |
} |
| 1043 |
|
| 1044 |
if ( Q_stricmp (cmd, "iamamonkey") == 0 ) { |
| 1045 |
UI_SPUnlockMedals_f(); |
| 1046 |
return qtrue; |
| 1047 |
} |
| 1048 |
|
| 1049 |
if ( Q_stricmp (cmd, "ui_cdkey") == 0 ) { |
| 1050 |
UI_CDKeyMenu_f(); |
| 1051 |
return qtrue; |
| 1052 |
} |
| 1053 |
|
| 1054 |
return qfalse; |
| 1055 |
} |
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
void UI_Shutdown( void ) { |
| 1063 |
} |
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
void UI_Init( void ) { |
| 1071 |
UI_RegisterCvars(); |
| 1072 |
|
| 1073 |
UI_InitGameinfo(); |
| 1074 |
|
| 1075 |
|
| 1076 |
trap_GetGlconfig( &uis.glconfig ); |
| 1077 |
|
| 1078 |
|
| 1079 |
uis.xscale = uis.glconfig.vidWidth * (1.0/640.0); |
| 1080 |
uis.yscale = uis.glconfig.vidHeight * (1.0/480.0); |
| 1081 |
if ( uis.glconfig.vidWidth * 480 > uis.glconfig.vidHeight * 640 ) { |
| 1082 |
|
| 1083 |
uis.bias = 0.5 * ( uis.glconfig.vidWidth - ( uis.glconfig.vidHeight * (640.0/480.0) ) ); |
| 1084 |
uis.xscale = uis.yscale; |
| 1085 |
} |
| 1086 |
else { |
| 1087 |
|
| 1088 |
uis.bias = 0; |
| 1089 |
} |
| 1090 |
|
| 1091 |
|
| 1092 |
Menu_Cache(); |
| 1093 |
|
| 1094 |
uis.activemenu = NULL; |
| 1095 |
uis.menusp = 0; |
| 1096 |
} |
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
void UI_AdjustFrom640( float *x, float *y, float *w, float *h ) { |
| 1106 |
|
| 1107 |
*x = *x * uis.xscale + uis.bias; |
| 1108 |
*y *= uis.yscale; |
| 1109 |
*w *= uis.xscale; |
| 1110 |
*h *= uis.yscale; |
| 1111 |
} |
| 1112 |
|
| 1113 |
void UI_DrawNamedPic( float x, float y, float width, float height, const char *picname ) { |
| 1114 |
qhandle_t hShader; |
| 1115 |
|
| 1116 |
hShader = trap_R_RegisterShaderNoMip( picname ); |
| 1117 |
UI_AdjustFrom640( &x, &y, &width, &height ); |
| 1118 |
trap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader ); |
| 1119 |
} |
| 1120 |
|
| 1121 |
void UI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader ) { |
| 1122 |
float s0; |
| 1123 |
float s1; |
| 1124 |
float t0; |
| 1125 |
float t1; |
| 1126 |
|
| 1127 |
if( w < 0 ) { |
| 1128 |
w = -w; |
| 1129 |
s0 = 1; |
| 1130 |
s1 = 0; |
| 1131 |
} |
| 1132 |
else { |
| 1133 |
s0 = 0; |
| 1134 |
s1 = 1; |
| 1135 |
} |
| 1136 |
|
| 1137 |
if( h < 0 ) { |
| 1138 |
h = -h; |
| 1139 |
t0 = 1; |
| 1140 |
t1 = 0; |
| 1141 |
} |
| 1142 |
else { |
| 1143 |
t0 = 0; |
| 1144 |
t1 = 1; |
| 1145 |
} |
| 1146 |
|
| 1147 |
UI_AdjustFrom640( &x, &y, &w, &h ); |
| 1148 |
trap_R_DrawStretchPic( x, y, w, h, s0, t0, s1, t1, hShader ); |
| 1149 |
} |
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
void UI_FillRect( float x, float y, float width, float height, const float *color ) { |
| 1159 |
trap_R_SetColor( color ); |
| 1160 |
|
| 1161 |
UI_AdjustFrom640( &x, &y, &width, &height ); |
| 1162 |
trap_R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, uis.whiteShader ); |
| 1163 |
|
| 1164 |
trap_R_SetColor( NULL ); |
| 1165 |
} |
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
void UI_DrawRect( float x, float y, float width, float height, const float *color ) { |
| 1175 |
trap_R_SetColor( color ); |
| 1176 |
|
| 1177 |
UI_AdjustFrom640( &x, &y, &width, &height ); |
| 1178 |
|
| 1179 |
trap_R_DrawStretchPic( x, y, width, 1, 0, 0, 0, 0, uis.whiteShader ); |
| 1180 |
trap_R_DrawStretchPic( x, y, 1, height, 0, 0, 0, 0, uis.whiteShader ); |
| 1181 |
trap_R_DrawStretchPic( x, y + height - 1, width, 1, 0, 0, 0, 0, uis.whiteShader ); |
| 1182 |
trap_R_DrawStretchPic( x + width - 1, y, 1, height, 0, 0, 0, 0, uis.whiteShader ); |
| 1183 |
|
| 1184 |
trap_R_SetColor( NULL ); |
| 1185 |
} |
| 1186 |
|
| 1187 |
void UI_SetColor( const float *rgba ) { |
| 1188 |
trap_R_SetColor( rgba ); |
| 1189 |
} |
| 1190 |
|
| 1191 |
void UI_UpdateScreen( void ) { |
| 1192 |
trap_UpdateScreen(); |
| 1193 |
} |
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
|
| 1200 |
void UI_Refresh( int realtime ) |
| 1201 |
{ |
| 1202 |
uis.frametime = realtime - uis.realtime; |
| 1203 |
uis.realtime = realtime; |
| 1204 |
|
| 1205 |
if ( !( trap_Key_GetCatcher() & KEYCATCH_UI ) ) { |
| 1206 |
return; |
| 1207 |
} |
| 1208 |
|
| 1209 |
UI_UpdateCvars(); |
| 1210 |
|
| 1211 |
if ( uis.activemenu ) |
| 1212 |
{ |
| 1213 |
if (uis.activemenu->fullscreen) |
| 1214 |
{ |
| 1215 |
|
| 1216 |
if( uis.activemenu->showlogo ) { |
| 1217 |
UI_DrawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, uis.menuBackShader ); |
| 1218 |
} |
| 1219 |
else { |
| 1220 |
UI_DrawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, uis.menuBackNoLogoShader ); |
| 1221 |
} |
| 1222 |
} |
| 1223 |
|
| 1224 |
if (uis.activemenu->draw) |
| 1225 |
uis.activemenu->draw(); |
| 1226 |
else |
| 1227 |
Menu_Draw( uis.activemenu ); |
| 1228 |
|
| 1229 |
if( uis.firstdraw ) { |
| 1230 |
UI_MouseEvent( 0, 0 ); |
| 1231 |
uis.firstdraw = qfalse; |
| 1232 |
} |
| 1233 |
} |
| 1234 |
|
| 1235 |
|
| 1236 |
UI_SetColor( NULL ); |
| 1237 |
UI_DrawHandlePic( uis.cursorx-16, uis.cursory-16, 32, 32, uis.cursor); |
| 1238 |
|
| 1239 |
#ifndef NDEBUG |
| 1240 |
if (uis.debug) |
| 1241 |
{ |
| 1242 |
|
| 1243 |
UI_DrawString( 0, 0, va("(%d,%d)",uis.cursorx,uis.cursory), UI_LEFT|UI_SMALLFONT, colorRed ); |
| 1244 |
} |
| 1245 |
#endif |
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
if (m_entersound) |
| 1251 |
{ |
| 1252 |
trap_S_StartLocalSound( menu_in_sound, CHAN_LOCAL_SOUND ); |
| 1253 |
m_entersound = qfalse; |
| 1254 |
} |
| 1255 |
} |
| 1256 |
|
| 1257 |
void UI_DrawTextBox (int x, int y, int width, int lines) |
| 1258 |
{ |
| 1259 |
UI_FillRect( x + BIGCHAR_WIDTH/2, y + BIGCHAR_HEIGHT/2, ( width + 1 ) * BIGCHAR_WIDTH, ( lines + 1 ) * BIGCHAR_HEIGHT, colorBlack ); |
| 1260 |
UI_DrawRect( x + BIGCHAR_WIDTH/2, y + BIGCHAR_HEIGHT/2, ( width + 1 ) * BIGCHAR_WIDTH, ( lines + 1 ) * BIGCHAR_HEIGHT, colorWhite ); |
| 1261 |
} |
| 1262 |
|
| 1263 |
qboolean UI_CursorInRect (int x, int y, int width, int height) |
| 1264 |
{ |
| 1265 |
if (uis.cursorx < x || |
| 1266 |
uis.cursory < y || |
| 1267 |
uis.cursorx > x+width || |
| 1268 |
uis.cursory > y+height) |
| 1269 |
return qfalse; |
| 1270 |
|
| 1271 |
return qtrue; |
| 1272 |
} |