Debian Codegraph @

code/cgame/cg_newdraw.c

raw symbols SCIP
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22
23 #ifndef MISSIONPACK
24 #error This file not be used for classic Q3A.
25 #endif
26
27 #include "cg_local.h"
28 #include "../ui/ui_shared.h"
29
30 extern displayContextDef_t cgDC;
31
32
33 // set in CG_ParseTeamInfo
34
35 //static int sortedTeamPlayers[TEAM_MAXOVERLAY];
36 //static int numSortedTeamPlayers;
37 int drawTeamOverlayModificationCount = -1;
38
39 //static char systemChat[256];
40 //static char teamChat1[256];
41 //static char teamChat2[256];
42
43 void CG_InitTeamChat(void) {
44 memset(teamChat1, 0, sizeof(teamChat1));
45 memset(teamChat2, 0, sizeof(teamChat2));
46 memset(systemChat, 0, sizeof(systemChat));
47 }
48
49 void CG_SetPrintString(int type, const char *p) {
50 if (type == SYSTEM_PRINT) {
51 strcpy(systemChat, p);
52 } else {
53 strcpy(teamChat2, teamChat1);
54 strcpy(teamChat1, p);
55 }
56 }
57
58 void CG_CheckOrderPending(void) {
59 if (cgs.gametype < GT_CTF) {
60 return;
61 }
62 if (cgs.orderPending) {
63 //clientInfo_t *ci = cgs.clientinfo + sortedTeamPlayers[cg_currentSelectedPlayer.integer];
64 const char *p1, *p2, *b;
65 p1 = p2 = b = NULL;
66 switch (cgs.currentOrder) {
67 case TEAMTASK_OFFENSE:
68 p1 = VOICECHAT_ONOFFENSE;
69 p2 = VOICECHAT_OFFENSE;
70 b = "+button7; wait; -button7";
71 break;
72 case TEAMTASK_DEFENSE:
73 p1 = VOICECHAT_ONDEFENSE;
74 p2 = VOICECHAT_DEFEND;
75 b = "+button8; wait; -button8";
76 break;
77 case TEAMTASK_PATROL:
78 p1 = VOICECHAT_ONPATROL;
79 p2 = VOICECHAT_PATROL;
80 b = "+button9; wait; -button9";
81 break;
82 case TEAMTASK_FOLLOW:
83 p1 = VOICECHAT_ONFOLLOW;
84 p2 = VOICECHAT_FOLLOWME;
85 b = "+button10; wait; -button10";
86 break;
87 case TEAMTASK_CAMP:
88 p1 = VOICECHAT_ONCAMPING;
89 p2 = VOICECHAT_CAMP;
90 break;
91 case TEAMTASK_RETRIEVE:
92 p1 = VOICECHAT_ONGETFLAG;
93 p2 = VOICECHAT_RETURNFLAG;
94 break;
95 case TEAMTASK_ESCORT:
96 p1 = VOICECHAT_ONFOLLOWCARRIER;
97 p2 = VOICECHAT_FOLLOWFLAGCARRIER;
98 break;
99 }
100
101 if (cg_currentSelectedPlayer.integer == numSortedTeamPlayers) {
102 if (p2) {
103 // to everyone
104 trap_SendConsoleCommand(va("cmd vsay_team %s\n", p2));
105 }
106 } else {
107 // for the player self
108 if (sortedTeamPlayers[cg_currentSelectedPlayer.integer] == cg.snap->ps.clientNum && p1) {
109 trap_SendConsoleCommand(va("teamtask %i\n", cgs.currentOrder));
110 //trap_SendConsoleCommand(va("cmd say_team %s\n", p2));
111 trap_SendConsoleCommand(va("cmd vsay_team %s\n", p1));
112 } else if (p2) {
113 //trap_SendConsoleCommand(va("cmd say_team %s, %s\n", ci->name,p));
114 trap_SendConsoleCommand(va("cmd vtell %d %s\n", sortedTeamPlayers[cg_currentSelectedPlayer.integer], p2));
115 }
116 }
117 if (b) {
118 trap_SendConsoleCommand(b);
119 }
120 cgs.orderPending = qfalse;
121 }
122 }
123
124 static void CG_SetSelectedPlayerName( void ) {
125 if (cg_currentSelectedPlayer.integer >= 0 && cg_currentSelectedPlayer.integer < numSortedTeamPlayers) {
126 clientInfo_t *ci = cgs.clientinfo + sortedTeamPlayers[cg_currentSelectedPlayer.integer];
127 if (ci) {
128 trap_Cvar_Set("cg_selectedPlayerName", ci->name);
129 trap_Cvar_Set("cg_selectedPlayer", va("%d", sortedTeamPlayers[cg_currentSelectedPlayer.integer]));
130 cgs.currentOrder = ci->teamTask;
131 }
132 } else {
133 trap_Cvar_Set("cg_selectedPlayerName", "Everyone");
134 }
135 }
136 int CG_GetSelectedPlayer( void ) {
137 if (cg_currentSelectedPlayer.integer < 0 || cg_currentSelectedPlayer.integer >= numSortedTeamPlayers) {
138 cg_currentSelectedPlayer.integer = 0;
139 }
140 return cg_currentSelectedPlayer.integer;
141 }
142
143 void CG_SelectNextPlayer( void ) {
144 CG_CheckOrderPending();
145 if (cg_currentSelectedPlayer.integer >= 0 && cg_currentSelectedPlayer.integer < numSortedTeamPlayers) {
146 cg_currentSelectedPlayer.integer++;
147 } else {
148 cg_currentSelectedPlayer.integer = 0;
149 }
150 CG_SetSelectedPlayerName();
151 }
152
153 void CG_SelectPrevPlayer( void ) {
154 CG_CheckOrderPending();
155 if (cg_currentSelectedPlayer.integer > 0 && cg_currentSelectedPlayer.integer <= numSortedTeamPlayers) {
156 cg_currentSelectedPlayer.integer--;
157 } else {
158 cg_currentSelectedPlayer.integer = numSortedTeamPlayers;
159 }
160 CG_SetSelectedPlayerName();
161 }
162
163
164 static void CG_DrawPlayerArmorIcon( rectDef_t *rect, qboolean draw2D ) {
165 vec3_t angles;
166 vec3_t origin;
167
168 if ( cg_drawStatus.integer == 0 ) {
169 return;
170 }
171
172 if ( draw2D || ( !cg_draw3dIcons.integer && cg_drawIcons.integer) ) {
173 CG_DrawPic( rect->x, rect->y + rect->h/2 + 1, rect->w, rect->h, cgs.media.armorIcon );
174 } else if (cg_draw3dIcons.integer) {
175 VectorClear( angles );
176 origin[0] = 90;
177 origin[1] = 0;
178 origin[2] = -10;
179 angles[YAW] = ( cg.time & 2047 ) * 360 / 2048.0f;
180 CG_Draw3DModel( rect->x, rect->y, rect->w, rect->h, cgs.media.armorModel, 0, origin, angles );
181 }
182 }
183
184 static void CG_DrawPlayerArmorValue(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle) {
185 char num[16];
186 int value;
187 playerState_t *ps;
188
189 ps = &cg.snap->ps;
190
191 value = ps->stats[STAT_ARMOR];
192
193 if (shader) {
194 trap_R_SetColor( color );
195 CG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);
196 trap_R_SetColor( NULL );
197 } else {
198 Com_sprintf (num, sizeof(num), "%i", value);
199 value = CG_Text_Width(num, scale, 0);
200 CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);
201 }
202 }
203
204 static void CG_DrawPlayerAmmoIcon( rectDef_t *rect, qboolean draw2D ) {
205 centity_t *cent;
206 vec3_t angles;
207 vec3_t origin;
208
209 cent = &cg_entities[cg.snap->ps.clientNum];
210
211 if ( draw2D || (!cg_draw3dIcons.integer && cg_drawIcons.integer) ) {
212 qhandle_t icon;
213 icon = cg_weapons[ cg.predictedPlayerState.weapon ].ammoIcon;
214 if ( icon ) {
215 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, icon );
216 }
217 } else if (cg_draw3dIcons.integer) {
218 if ( cent->currentState.weapon && cg_weapons[ cent->currentState.weapon ].ammoModel ) {
219 VectorClear( angles );
220 origin[0] = 70;
221 origin[1] = 0;
222 origin[2] = 0;
223 angles[YAW] = 90 + 20 * sin( cg.time / 1000.0 );
224 CG_Draw3DModel( rect->x, rect->y, rect->w, rect->h, cg_weapons[ cent->currentState.weapon ].ammoModel, 0, origin, angles );
225 }
226 }
227 }
228
229 static void CG_DrawPlayerAmmoValue(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle) {
230 char num[16];
231 int value;
232 centity_t *cent;
233 playerState_t *ps;
234
235 cent = &cg_entities[cg.snap->ps.clientNum];
236 ps = &cg.snap->ps;
237
238 if ( cent->currentState.weapon ) {
239 value = ps->ammo[cent->currentState.weapon];
240 if ( value > -1 ) {
241 if (shader) {
242 trap_R_SetColor( color );
243 CG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);
244 trap_R_SetColor( NULL );
245 } else {
246 Com_sprintf (num, sizeof(num), "%i", value);
247 value = CG_Text_Width(num, scale, 0);
248 CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);
249 }
250 }
251 }
252
253 }
254
255
256
257 static void CG_DrawPlayerHead(rectDef_t *rect, qboolean draw2D) {
258 vec3_t angles;
259 float size, stretch;
260 float frac;
261 float x = rect->x;
262
263 VectorClear( angles );
264
265 if ( cg.damageTime && cg.time - cg.damageTime < DAMAGE_TIME ) {
266 frac = (float)(cg.time - cg.damageTime ) / DAMAGE_TIME;
267 size = rect->w * 1.25 * ( 1.5 - frac * 0.5 );
268
269 stretch = size - rect->w * 1.25;
270 // kick in the direction of damage
271 x -= stretch * 0.5 + cg.damageX * stretch * 0.5;
272
273 cg.headStartYaw = 180 + cg.damageX * 45;
274
275 cg.headEndYaw = 180 + 20 * cos( crandom()*M_PI );
276 cg.headEndPitch = 5 * cos( crandom()*M_PI );
277
278 cg.headStartTime = cg.time;
279 cg.headEndTime = cg.time + 100 + random() * 2000;
280 } else {
281 if ( cg.time >= cg.headEndTime ) {
282 // select a new head angle
283 cg.headStartYaw = cg.headEndYaw;
284 cg.headStartPitch = cg.headEndPitch;
285 cg.headStartTime = cg.headEndTime;
286 cg.headEndTime = cg.time + 100 + random() * 2000;
287
288 cg.headEndYaw = 180 + 20 * cos( crandom()*M_PI );
289 cg.headEndPitch = 5 * cos( crandom()*M_PI );
290 }
291 }
292
293 // if the server was frozen for a while we may have a bad head start time
294 if ( cg.headStartTime > cg.time ) {
295 cg.headStartTime = cg.time;
296 }
297
298 frac = ( cg.time - cg.headStartTime ) / (float)( cg.headEndTime - cg.headStartTime );
299 frac = frac * frac * ( 3 - 2 * frac );
300 angles[YAW] = cg.headStartYaw + ( cg.headEndYaw - cg.headStartYaw ) * frac;
301 angles[PITCH] = cg.headStartPitch + ( cg.headEndPitch - cg.headStartPitch ) * frac;
302
303 CG_DrawHead( x, rect->y, rect->w, rect->h, cg.snap->ps.clientNum, angles );
304 }
305
306 static void CG_DrawSelectedPlayerHealth( rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {
307 clientInfo_t *ci;
308 int value;
309 char num[16];
310
311 ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];
312 if (ci) {
313 if (shader) {
314 trap_R_SetColor( color );
315 CG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);
316 trap_R_SetColor( NULL );
317 } else {
318 Com_sprintf (num, sizeof(num), "%i", ci->health);
319 value = CG_Text_Width(num, scale, 0);
320 CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);
321 }
322 }
323 }
324
325 static void CG_DrawSelectedPlayerArmor( rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {
326 clientInfo_t *ci;
327 int value;
328 char num[16];
329 ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];
330 if (ci) {
331 if (ci->armor > 0) {
332 if (shader) {
333 trap_R_SetColor( color );
334 CG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);
335 trap_R_SetColor( NULL );
336 } else {
337 Com_sprintf (num, sizeof(num), "%i", ci->armor);
338 value = CG_Text_Width(num, scale, 0);
339 CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);
340 }
341 }
342 }
343 }
344
345 qhandle_t CG_StatusHandle(int task) {
346 qhandle_t h;
347 switch (task) {
348 case TEAMTASK_OFFENSE :
349 h = cgs.media.assaultShader;
350 break;
351 case TEAMTASK_DEFENSE :
352 h = cgs.media.defendShader;
353 break;
354 case TEAMTASK_PATROL :
355 h = cgs.media.patrolShader;
356 break;
357 case TEAMTASK_FOLLOW :
358 h = cgs.media.followShader;
359 break;
360 case TEAMTASK_CAMP :
361 h = cgs.media.campShader;
362 break;
363 case TEAMTASK_RETRIEVE :
364 h = cgs.media.retrieveShader;
365 break;
366 case TEAMTASK_ESCORT :
367 h = cgs.media.escortShader;
368 break;
369 default :
370 h = cgs.media.assaultShader;
371 break;
372 }
373 return h;
374 }
375
376 static void CG_DrawSelectedPlayerStatus( rectDef_t *rect ) {
377 clientInfo_t *ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];
378 if (ci) {
379 qhandle_t h;
380 if (cgs.orderPending) {
381 // blink the icon
382 if ( cg.time > cgs.orderTime - 2500 && (cg.time >> 9 ) & 1 ) {
383 return;
384 }
385 h = CG_StatusHandle(cgs.currentOrder);
386 } else {
387 h = CG_StatusHandle(ci->teamTask);
388 }
389 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, h );
390 }
391 }
392
393
394 static void CG_DrawPlayerStatus( rectDef_t *rect ) {
395 clientInfo_t *ci = &cgs.clientinfo[cg.snap->ps.clientNum];
396 if (ci) {
397 qhandle_t h = CG_StatusHandle(ci->teamTask);
398 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, h);
399 }
400 }
401
402
403 static void CG_DrawSelectedPlayerName( rectDef_t *rect, float scale, vec4_t color, qboolean voice, int textStyle) {
404 clientInfo_t *ci;
405 ci = cgs.clientinfo + ((voice) ? cgs.currentVoiceClient : sortedTeamPlayers[CG_GetSelectedPlayer()]);
406 if (ci) {
407 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, ci->name, 0, 0, textStyle);
408 }
409 }
410
411 static void CG_DrawSelectedPlayerLocation( rectDef_t *rect, float scale, vec4_t color, int textStyle ) {
412 clientInfo_t *ci;
413 ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];
414 if (ci) {
415 const char *p = CG_ConfigString(CS_LOCATIONS + ci->location);
416 if (!p || !*p) {
417 p = "unknown";
418 }
419 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, p, 0, 0, textStyle);
420 }
421 }
422
423 static void CG_DrawPlayerLocation( rectDef_t *rect, float scale, vec4_t color, int textStyle ) {
424 clientInfo_t *ci = &cgs.clientinfo[cg.snap->ps.clientNum];
425 if (ci) {
426 const char *p = CG_ConfigString(CS_LOCATIONS + ci->location);
427 if (!p || !*p) {
428 p = "unknown";
429 }
430 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, p, 0, 0, textStyle);
431 }
432 }
433
434
435
436 static void CG_DrawSelectedPlayerWeapon( rectDef_t *rect ) {
437 clientInfo_t *ci;
438
439 ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];
440 if (ci) {
441 if ( cg_weapons[ci->curWeapon].weaponIcon ) {
442 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cg_weapons[ci->curWeapon].weaponIcon );
443 } else {
444 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.deferShader);
445 }
446 }
447 }
448
449 static void CG_DrawPlayerScore( rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {
450 char num[16];
451 int value = cg.snap->ps.persistant[PERS_SCORE];
452
453 if (shader) {
454 trap_R_SetColor( color );
455 CG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);
456 trap_R_SetColor( NULL );
457 } else {
458 Com_sprintf (num, sizeof(num), "%i", value);
459 value = CG_Text_Width(num, scale, 0);
460 CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);
461 }
462 }
463
464 static void CG_DrawPlayerItem( rectDef_t *rect, float scale, qboolean draw2D) {
465 int value;
466 vec3_t origin, angles;
467
468 value = cg.snap->ps.stats[STAT_HOLDABLE_ITEM];
469 if ( value ) {
470 CG_RegisterItemVisuals( value );
471
472 if (qtrue) {
473 CG_RegisterItemVisuals( value );
474 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cg_items[ value ].icon );
475 } else {
476 VectorClear( angles );
477 origin[0] = 90;
478 origin[1] = 0;
479 origin[2] = -10;
480 angles[YAW] = ( cg.time & 2047 ) * 360 / 2048.0;
481 CG_Draw3DModel(rect->x, rect->y, rect->w, rect->h, cg_items[ value ].models[0], 0, origin, angles );
482 }
483 }
484
485 }
486
487
488 static void CG_DrawSelectedPlayerPowerup( rectDef_t *rect, qboolean draw2D ) {
489 clientInfo_t *ci;
490 int j;
491 float x, y;
492
493 ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];
494 if (ci) {
495 x = rect->x;
496 y = rect->y;
497
498 for (j = 0; j < PW_NUM_POWERUPS; j++) {
499 if (ci->powerups & (1 << j)) {
500 gitem_t *item;
501 item = BG_FindItemForPowerup( j );
502 if (item) {
503 CG_DrawPic( x, y, rect->w, rect->h, trap_R_RegisterShader( item->icon ) );
504 return;
505 }
506 }
507 }
508
509 }
510 }
511
512
513 static void CG_DrawSelectedPlayerHead( rectDef_t *rect, qboolean draw2D, qboolean voice ) {
514 clipHandle_t cm;
515 clientInfo_t *ci;
516 float len;
517 vec3_t origin;
518 vec3_t mins, maxs, angles;
519
520
521 ci = cgs.clientinfo + ((voice) ? cgs.currentVoiceClient : sortedTeamPlayers[CG_GetSelectedPlayer()]);
522
523 if (ci) {
524 if ( cg_draw3dIcons.integer ) {
525 cm = ci->headModel;
526 if ( !cm ) {
527 return;
528 }
529
530 // offset the origin y and z to center the head
531 trap_R_ModelBounds( cm, mins, maxs );
532
533 origin[2] = -0.5 * ( mins[2] + maxs[2] );
534 origin[1] = 0.5 * ( mins[1] + maxs[1] );
535
536 // calculate distance so the head nearly fills the box
537 // assume heads are taller than wide
538 len = 0.7 * ( maxs[2] - mins[2] );
539 origin[0] = len / 0.268; // len / tan( fov/2 )
540
541 // allow per-model tweaking
542 VectorAdd( origin, ci->headOffset, origin );
543
544 angles[PITCH] = 0;
545 angles[YAW] = 180;
546 angles[ROLL] = 0;
547
548 CG_Draw3DModel( rect->x, rect->y, rect->w, rect->h, ci->headModel, ci->headSkin, origin, angles );
549 } else if ( cg_drawIcons.integer ) {
550 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, ci->modelIcon );
551 }
552
553 // if they are deferred, draw a cross out
554 if ( ci->deferred ) {
555 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.deferShader );
556 }
557 }
558
559 }
560
561
562 static void CG_DrawPlayerHealth(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {
563 playerState_t *ps;
564 int value;
565 char num[16];
566
567 ps = &cg.snap->ps;
568
569 value = ps->stats[STAT_HEALTH];
570
571 if (shader) {
572 trap_R_SetColor( color );
573 CG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);
574 trap_R_SetColor( NULL );
575 } else {
576 Com_sprintf (num, sizeof(num), "%i", value);
577 value = CG_Text_Width(num, scale, 0);
578 CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);
579 }
580 }
581
582
583 static void CG_DrawRedScore(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {
584 int value;
585 char num[16];
586 if ( cgs.scores1 == SCORE_NOT_PRESENT ) {
587 Com_sprintf (num, sizeof(num), "-");
588 }
589 else {
590 Com_sprintf (num, sizeof(num), "%i", cgs.scores1);
591 }
592 value = CG_Text_Width(num, scale, 0);
593 CG_Text_Paint(rect->x + rect->w - value, rect->y + rect->h, scale, color, num, 0, 0, textStyle);
594 }
595
596 static void CG_DrawBlueScore(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {
597 int value;
598 char num[16];
599
600 if ( cgs.scores2 == SCORE_NOT_PRESENT ) {
601 Com_sprintf (num, sizeof(num), "-");
602 }
603 else {
604 Com_sprintf (num, sizeof(num), "%i", cgs.scores2);
605 }
606 value = CG_Text_Width(num, scale, 0);
607 CG_Text_Paint(rect->x + rect->w - value, rect->y + rect->h, scale, color, num, 0, 0, textStyle);
608 }
609
610 // FIXME: team name support
611 static void CG_DrawRedName(rectDef_t *rect, float scale, vec4_t color, int textStyle ) {
612 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, cg_redTeamName.string , 0, 0, textStyle);
613 }
614
615 static void CG_DrawBlueName(rectDef_t *rect, float scale, vec4_t color, int textStyle ) {
616 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, cg_blueTeamName.string, 0, 0, textStyle);
617 }
618
619 static void CG_DrawBlueFlagName(rectDef_t *rect, float scale, vec4_t color, int textStyle ) {
620 int i;
621 for ( i = 0 ; i < cgs.maxclients ; i++ ) {
622 if ( cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_RED && cgs.clientinfo[i].powerups & ( 1<< PW_BLUEFLAG )) {
623 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, cgs.clientinfo[i].name, 0, 0, textStyle);
624 return;
625 }
626 }
627 }
628
629 static void CG_DrawBlueFlagStatus(rectDef_t *rect, qhandle_t shader) {
630 if (cgs.gametype != GT_CTF && cgs.gametype != GT_1FCTF) {
631 if (cgs.gametype == GT_HARVESTER) {
632 vec4_t color = {0, 0, 1, 1};
633 trap_R_SetColor(color);
634 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.blueCubeIcon );
635 trap_R_SetColor(NULL);
636 }
637 return;
638 }
639 if (shader) {
640 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );
641 } else {
642 gitem_t *item = BG_FindItemForPowerup( PW_BLUEFLAG );
643 if (item) {
644 vec4_t color = {0, 0, 1, 1};
645 trap_R_SetColor(color);
646 if( cgs.blueflag >= 0 && cgs.blueflag <= 2 ) {
647 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.flagShaders[cgs.blueflag] );
648 } else {
649 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.flagShaders[0] );
650 }
651 trap_R_SetColor(NULL);
652 }
653 }
654 }
655
656 static void CG_DrawBlueFlagHead(rectDef_t *rect) {
657 int i;
658 for ( i = 0 ; i < cgs.maxclients ; i++ ) {
659 if ( cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_RED && cgs.clientinfo[i].powerups & ( 1<< PW_BLUEFLAG )) {
660 vec3_t angles;
661 VectorClear( angles );
662 angles[YAW] = 180 + 20 * sin( cg.time / 650.0 );;
663 CG_DrawHead( rect->x, rect->y, rect->w, rect->h, 0,angles );
664 return;
665 }
666 }
667 }
668
669 static void CG_DrawRedFlagName(rectDef_t *rect, float scale, vec4_t color, int textStyle ) {
670 int i;
671 for ( i = 0 ; i < cgs.maxclients ; i++ ) {
672 if ( cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_BLUE && cgs.clientinfo[i].powerups & ( 1<< PW_REDFLAG )) {
673 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, cgs.clientinfo[i].name, 0, 0, textStyle);
674 return;
675 }
676 }
677 }
678
679 static void CG_DrawRedFlagStatus(rectDef_t *rect, qhandle_t shader) {
680 if (cgs.gametype != GT_CTF && cgs.gametype != GT_1FCTF) {
681 if (cgs.gametype == GT_HARVESTER) {
682 vec4_t color = {1, 0, 0, 1};
683 trap_R_SetColor(color);
684 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.redCubeIcon );
685 trap_R_SetColor(NULL);
686 }
687 return;
688 }
689 if (shader) {
690 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );
691 } else {
692 gitem_t *item = BG_FindItemForPowerup( PW_REDFLAG );
693 if (item) {
694 vec4_t color = {1, 0, 0, 1};
695 trap_R_SetColor(color);
696 if( cgs.redflag >= 0 && cgs.redflag <= 2) {
697 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.flagShaders[cgs.redflag] );
698 } else {
699 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.flagShaders[0] );
700 }
701 trap_R_SetColor(NULL);
702 }
703 }
704 }
705
706 static void CG_DrawRedFlagHead(rectDef_t *rect) {
707 int i;
708 for ( i = 0 ; i < cgs.maxclients ; i++ ) {
709 if ( cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_BLUE && cgs.clientinfo[i].powerups & ( 1<< PW_REDFLAG )) {
710 vec3_t angles;
711 VectorClear( angles );
712 angles[YAW] = 180 + 20 * sin( cg.time / 650.0 );;
713 CG_DrawHead( rect->x, rect->y, rect->w, rect->h, 0,angles );
714 return;
715 }
716 }
717 }
718
719 static void CG_HarvesterSkulls(rectDef_t *rect, float scale, vec4_t color, qboolean force2D, int textStyle ) {
720 char num[16];
721 vec3_t origin, angles;
722 qhandle_t handle;
723 int value = cg.snap->ps.generic1;
724
725 if (cgs.gametype != GT_HARVESTER) {
726 return;
727 }
728
729 if( value > 99 ) {
730 value = 99;
731 }
732
733 Com_sprintf (num, sizeof(num), "%i", value);
734 value = CG_Text_Width(num, scale, 0);
735 CG_Text_Paint(rect->x + (rect->w - value), rect->y + rect->h, scale, color, num, 0, 0, textStyle);
736
737 if (cg_drawIcons.integer) {
738 if (!force2D && cg_draw3dIcons.integer) {
739 VectorClear(angles);
740 origin[0] = 90;
741 origin[1] = 0;
742 origin[2] = -10;
743 angles[YAW] = ( cg.time & 2047 ) * 360 / 2048.0;
744 if( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {
745 handle = cgs.media.redCubeModel;
746 } else {
747 handle = cgs.media.blueCubeModel;
748 }
749 CG_Draw3DModel( rect->x, rect->y, 35, 35, handle, 0, origin, angles );
750 } else {
751 if( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {
752 handle = cgs.media.redCubeIcon;
753 } else {
754 handle = cgs.media.blueCubeIcon;
755 }
756 CG_DrawPic( rect->x + 3, rect->y + 16, 20, 20, handle );
757 }
758 }
759 }
760
761 static void CG_OneFlagStatus(rectDef_t *rect) {
762 if (cgs.gametype != GT_1FCTF) {
763 return;
764 } else {
765 gitem_t *item = BG_FindItemForPowerup( PW_NEUTRALFLAG );
766 if (item) {
767 if( cgs.flagStatus >= 0 && cgs.flagStatus <= 4 ) {
768 vec4_t color = {1, 1, 1, 1};
769 int index = 0;
770 if (cgs.flagStatus == FLAG_TAKEN_RED) {
771 color[1] = color[2] = 0;
772 index = 1;
773 } else if (cgs.flagStatus == FLAG_TAKEN_BLUE) {
774 color[0] = color[1] = 0;
775 index = 1;
776 } else if (cgs.flagStatus == FLAG_DROPPED) {
777 index = 2;
778 }
779 trap_R_SetColor(color);
780 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.flagShaders[index] );
781 }
782 }
783 }
784 }
785
786
787 static void CG_DrawCTFPowerUp(rectDef_t *rect) {
788 int value;
789
790 if (cgs.gametype < GT_CTF) {
791 return;
792 }
793 value = cg.snap->ps.stats[STAT_PERSISTANT_POWERUP];
794 if ( value ) {
795 CG_RegisterItemVisuals( value );
796 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cg_items[ value ].icon );
797 }
798 }
799
800
801
802 static void CG_DrawTeamColor(rectDef_t *rect, vec4_t color) {
803 CG_DrawTeamBackground(rect->x, rect->y, rect->w, rect->h, color[3], cg.snap->ps.persistant[PERS_TEAM]);
804 }
805
806 static void CG_DrawAreaPowerUp(rectDef_t *rect, int align, float special, float scale, vec4_t color) {
807 char num[16];
808 int sorted[MAX_POWERUPS];
809 int sortedTime[MAX_POWERUPS];
810 int i, j, k;
811 int active;
812 playerState_t *ps;
813 int t;
814 gitem_t *item;
815 float f;
816 rectDef_t r2;
817 float *inc;
818 r2.x = rect->x;
819 r2.y = rect->y;
820 r2.w = rect->w;
821 r2.h = rect->h;
822
823 inc = (align == HUD_VERTICAL) ? &r2.y : &r2.x;
824
825 ps = &cg.snap->ps;
826
827 if ( ps->stats[STAT_HEALTH] <= 0 ) {
828 return;
829 }
830
831 // sort the list by time remaining
832 active = 0;
833 for ( i = 0 ; i < MAX_POWERUPS ; i++ ) {
834 if ( !ps->powerups[ i ] ) {
835 continue;
836 }
837
838 // ZOID--don't draw if the power up has unlimited time
839 // This is true of the CTF flags
840 if ( ps->powerups[ i ] == INT_MAX ) {
841 continue;
842 }
843
844 t = ps->powerups[ i ] - cg.time;
845 if ( t <= 0 ) {
846 continue;
847 }
848
849 // insert into the list
850 for ( j = 0 ; j < active ; j++ ) {
851 if ( sortedTime[j] >= t ) {
852 for ( k = active - 1 ; k >= j ; k-- ) {
853 sorted[k+1] = sorted[k];
854 sortedTime[k+1] = sortedTime[k];
855 }
856 break;
857 }
858 }
859 sorted[j] = i;
860 sortedTime[j] = t;
861 active++;
862 }
863
864 // draw the icons and timers
865 for ( i = 0 ; i < active ; i++ ) {
866 item = BG_FindItemForPowerup( sorted[i] );
867
868 if (item) {
869 t = ps->powerups[ sorted[i] ];
870 if ( t - cg.time >= POWERUP_BLINKS * POWERUP_BLINK_TIME ) {
871 trap_R_SetColor( NULL );
872 } else {
873 vec4_t modulate;
874
875 f = (float)( t - cg.time ) / POWERUP_BLINK_TIME;
876 f -= (int)f;
877 modulate[0] = modulate[1] = modulate[2] = modulate[3] = f;
878 trap_R_SetColor( modulate );
879 }
880
881 CG_DrawPic( r2.x, r2.y, r2.w * .75, r2.h, trap_R_RegisterShader( item->icon ) );
882
883 Com_sprintf (num, sizeof(num), "%i", sortedTime[i] / 1000);
884 CG_Text_Paint(r2.x + (r2.w * .75) + 3 , r2.y + r2.h, scale, color, num, 0, 0, 0);
885 *inc += r2.w + special;
886 }
887
888 }
889 trap_R_SetColor( NULL );
890
891 }
892
893 float CG_GetValue(int ownerDraw) {
894 centity_t *cent;
895 clientInfo_t *ci;
896 playerState_t *ps;
897
898 cent = &cg_entities[cg.snap->ps.clientNum];
899 ps = &cg.snap->ps;
900
901 switch (ownerDraw) {
902 case CG_SELECTEDPLAYER_ARMOR:
903 ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];
904 return ci->armor;
905 break;
906 case CG_SELECTEDPLAYER_HEALTH:
907 ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];
908 return ci->health;
909 break;
910 case CG_PLAYER_ARMOR_VALUE:
911 return ps->stats[STAT_ARMOR];
912 break;
913 case CG_PLAYER_AMMO_VALUE:
914 if ( cent->currentState.weapon ) {
915 return ps->ammo[cent->currentState.weapon];
916 }
917 break;
918 case CG_PLAYER_SCORE:
919 return cg.snap->ps.persistant[PERS_SCORE];
920 break;
921 case CG_PLAYER_HEALTH:
922 return ps->stats[STAT_HEALTH];
923 break;
924 case CG_RED_SCORE:
925 return cgs.scores1;
926 break;
927 case CG_BLUE_SCORE:
928 return cgs.scores2;
929 break;
930 default:
931 break;
932 }
933 return -1;
934 }
935
936 qboolean CG_OtherTeamHasFlag(void) {
937 if (cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF) {
938 int team = cg.snap->ps.persistant[PERS_TEAM];
939 if (cgs.gametype == GT_1FCTF) {
940 if (team == TEAM_RED && cgs.flagStatus == FLAG_TAKEN_BLUE) {
941 return qtrue;
942 } else if (team == TEAM_BLUE && cgs.flagStatus == FLAG_TAKEN_RED) {
943 return qtrue;
944 } else {
945 return qfalse;
946 }
947 } else {
948 if (team == TEAM_RED && cgs.redflag == FLAG_TAKEN) {
949 return qtrue;
950 } else if (team == TEAM_BLUE && cgs.blueflag == FLAG_TAKEN) {
951 return qtrue;
952 } else {
953 return qfalse;
954 }
955 }
956 }
957 return qfalse;
958 }
959
960 qboolean CG_YourTeamHasFlag(void) {
961 if (cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF) {
962 int team = cg.snap->ps.persistant[PERS_TEAM];
963 if (cgs.gametype == GT_1FCTF) {
964 if (team == TEAM_RED && cgs.flagStatus == FLAG_TAKEN_RED) {
965 return qtrue;
966 } else if (team == TEAM_BLUE && cgs.flagStatus == FLAG_TAKEN_BLUE) {
967 return qtrue;
968 } else {
969 return qfalse;
970 }
971 } else {
972 if (team == TEAM_RED && cgs.blueflag == FLAG_TAKEN) {
973 return qtrue;
974 } else if (team == TEAM_BLUE && cgs.redflag == FLAG_TAKEN) {
975 return qtrue;
976 } else {
977 return qfalse;
978 }
979 }
980 }
981 return qfalse;
982 }
983
984 // THINKABOUTME: should these be exclusive or inclusive..
985 //
986 qboolean CG_OwnerDrawVisible(int flags) {
987
988 if (flags & CG_SHOW_TEAMINFO) {
989 return (cg_currentSelectedPlayer.integer == numSortedTeamPlayers);
990 }
991
992 if (flags & CG_SHOW_NOTEAMINFO) {
993 return !(cg_currentSelectedPlayer.integer == numSortedTeamPlayers);
994 }
995
996 if (flags & CG_SHOW_OTHERTEAMHASFLAG) {
997 return CG_OtherTeamHasFlag();
998 }
999
1000 if (flags & CG_SHOW_YOURTEAMHASENEMYFLAG) {
1001 return CG_YourTeamHasFlag();
1002 }
1003
1004 if (flags & (CG_SHOW_BLUE_TEAM_HAS_REDFLAG | CG_SHOW_RED_TEAM_HAS_BLUEFLAG)) {
1005 if (flags & CG_SHOW_BLUE_TEAM_HAS_REDFLAG && (cgs.redflag == FLAG_TAKEN || cgs.flagStatus == FLAG_TAKEN_RED)) {
1006 return qtrue;
1007 } else if (flags & CG_SHOW_RED_TEAM_HAS_BLUEFLAG && (cgs.blueflag == FLAG_TAKEN || cgs.flagStatus == FLAG_TAKEN_BLUE)) {
1008 return qtrue;
1009 }
1010 return qfalse;
1011 }
1012
1013 if (flags & CG_SHOW_ANYTEAMGAME) {
1014 if( cgs.gametype >= GT_TEAM) {
1015 return qtrue;
1016 }
1017 }
1018
1019 if (flags & CG_SHOW_ANYNONTEAMGAME) {
1020 if( cgs.gametype < GT_TEAM) {
1021 return qtrue;
1022 }
1023 }
1024
1025 if (flags & CG_SHOW_HARVESTER) {
1026 if( cgs.gametype == GT_HARVESTER ) {
1027 return qtrue;
1028 } else {
1029 return qfalse;
1030 }
1031 }
1032
1033 if (flags & CG_SHOW_ONEFLAG) {
1034 if( cgs.gametype == GT_1FCTF ) {
1035 return qtrue;
1036 } else {
1037 return qfalse;
1038 }
1039 }
1040
1041 if (flags & CG_SHOW_CTF) {
1042 if( cgs.gametype == GT_CTF ) {
1043 return qtrue;
1044 }
1045 }
1046
1047 if (flags & CG_SHOW_OBELISK) {
1048 if( cgs.gametype == GT_OBELISK ) {
1049 return qtrue;
1050 } else {
1051 return qfalse;
1052 }
1053 }
1054
1055 if (flags & CG_SHOW_HEALTHCRITICAL) {
1056 if (cg.snap->ps.stats[STAT_HEALTH] < 25) {
1057 return qtrue;
1058 }
1059 }
1060
1061 if (flags & CG_SHOW_HEALTHOK) {
1062 if (cg.snap->ps.stats[STAT_HEALTH] >= 25) {
1063 return qtrue;
1064 }
1065 }
1066
1067 if (flags & CG_SHOW_SINGLEPLAYER) {
1068 if( cgs.gametype == GT_SINGLE_PLAYER ) {
1069 return qtrue;
1070 }
1071 }
1072
1073 if (flags & CG_SHOW_TOURNAMENT) {
1074 if( cgs.gametype == GT_TOURNAMENT ) {
1075 return qtrue;
1076 }
1077 }
1078
1079 if (flags & CG_SHOW_DURINGINCOMINGVOICE) {
1080 }
1081
1082 if (flags & CG_SHOW_IF_PLAYER_HAS_FLAG) {
1083 if (cg.snap->ps.powerups[PW_REDFLAG] || cg.snap->ps.powerups[PW_BLUEFLAG] || cg.snap->ps.powerups[PW_NEUTRALFLAG]) {
1084 return qtrue;
1085 }
1086 }
1087 return qfalse;
1088 }
1089
1090
1091
1092 static void CG_DrawPlayerHasFlag(rectDef_t *rect, qboolean force2D) {
1093 int adj = (force2D) ? 0 : 2;
1094 if( cg.predictedPlayerState.powerups[PW_REDFLAG] ) {
1095 CG_DrawFlagModel( rect->x + adj, rect->y + adj, rect->w - adj, rect->h - adj, TEAM_RED, force2D);
1096 } else if( cg.predictedPlayerState.powerups[PW_BLUEFLAG] ) {
1097 CG_DrawFlagModel( rect->x + adj, rect->y + adj, rect->w - adj, rect->h - adj, TEAM_BLUE, force2D);
1098 } else if( cg.predictedPlayerState.powerups[PW_NEUTRALFLAG] ) {
1099 CG_DrawFlagModel( rect->x + adj, rect->y + adj, rect->w - adj, rect->h - adj, TEAM_FREE, force2D);
1100 }
1101 }
1102
1103 static void CG_DrawAreaSystemChat(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {
1104 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, systemChat, 0, 0, 0);
1105 }
1106
1107 static void CG_DrawAreaTeamChat(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {
1108 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color,teamChat1, 0, 0, 0);
1109 }
1110
1111 static void CG_DrawAreaChat(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {
1112 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, teamChat2, 0, 0, 0);
1113 }
1114
1115 const char *CG_GetKillerText(void) {
1116 const char *s = "";
1117 if ( cg.killerName[0] ) {
1118 s = va("Fragged by %s", cg.killerName );
1119 }
1120 return s;
1121 }
1122
1123
1124 static void CG_DrawKiller(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {
1125 // fragged by ... line
1126 if ( cg.killerName[0] ) {
1127 int x = rect->x + rect->w / 2;
1128 CG_Text_Paint(x - CG_Text_Width(CG_GetKillerText(), scale, 0) / 2, rect->y + rect->h, scale, color, CG_GetKillerText(), 0, 0, textStyle);
1129 }
1130
1131 }
1132
1133
1134 static void CG_DrawCapFragLimit(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle) {
1135 int limit = (cgs.gametype >= GT_CTF) ? cgs.capturelimit : cgs.fraglimit;
1136 CG_Text_Paint(rect->x, rect->y, scale, color, va("%2i", limit),0, 0, textStyle);
1137 }
1138
1139 static void CG_Draw1stPlace(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle) {
1140 if (cgs.scores1 != SCORE_NOT_PRESENT) {
1141 CG_Text_Paint(rect->x, rect->y, scale, color, va("%2i", cgs.scores1),0, 0, textStyle);
1142 }
1143 }
1144
1145 static void CG_Draw2ndPlace(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle) {
1146 if (cgs.scores2 != SCORE_NOT_PRESENT) {
1147 CG_Text_Paint(rect->x, rect->y, scale, color, va("%2i", cgs.scores2),0, 0, textStyle);
1148 }
1149 }
1150
1151 const char *CG_GetGameStatusText(void) {
1152 const char *s = "";
1153 if ( cgs.gametype < GT_TEAM) {
1154 if (cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR ) {
1155 s = va("%s place with %i",CG_PlaceString( cg.snap->ps.persistant[PERS_RANK] + 1 ),cg.snap->ps.persistant[PERS_SCORE] );
1156 }
1157 } else {
1158 if ( cg.teamScores[0] == cg.teamScores[1] ) {
1159 s = va("Teams are tied at %i", cg.teamScores[0] );
1160 } else if ( cg.teamScores[0] >= cg.teamScores[1] ) {
1161 s = va("Red leads Blue, %i to %i", cg.teamScores[0], cg.teamScores[1] );
1162 } else {
1163 s = va("Blue leads Red, %i to %i", cg.teamScores[1], cg.teamScores[0] );
1164 }
1165 }
1166 return s;
1167 }
1168
1169 static void CG_DrawGameStatus(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {
1170 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, CG_GetGameStatusText(), 0, 0, textStyle);
1171 }
1172
1173 const char *CG_GameTypeString(void) {
1174 if ( cgs.gametype == GT_FFA ) {
1175 return "Free For All";
1176 } else if ( cgs.gametype == GT_TEAM ) {
1177 return "Team Deathmatch";
1178 } else if ( cgs.gametype == GT_CTF ) {
1179 return "Capture the Flag";
1180 } else if ( cgs.gametype == GT_1FCTF ) {
1181 return "One Flag CTF";
1182 } else if ( cgs.gametype == GT_OBELISK ) {
1183 return "Overload";
1184 } else if ( cgs.gametype == GT_HARVESTER ) {
1185 return "Harvester";
1186 }
1187 return "";
1188 }
1189 static void CG_DrawGameType(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {
1190 CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, CG_GameTypeString(), 0, 0, textStyle);
1191 }
1192
1193 static void CG_Text_Paint_Limit(float *maxX, float x, float y, float scale, vec4_t color, const char* text, float adjust, int limit) {
1194 int len, count;
1195 vec4_t newColor;
1196 glyphInfo_t *glyph;
1197 if (text) {
1198 const char *s = text;
1199 float max = *maxX;
1200 float useScale;
1201 fontInfo_t *font = &cgDC.Assets.textFont;
1202 if (scale <= cg_smallFont.value) {
1203 font = &cgDC.Assets.smallFont;
1204 } else if (scale > cg_bigFont.value) {
1205 font = &cgDC.Assets.bigFont;
1206 }
1207 useScale = scale * font->glyphScale;
1208 trap_R_SetColor( color );
1209 len = strlen(text);
1210 if (limit > 0 && len > limit) {
1211 len = limit;
1212 }
1213 count = 0;
1214 while (s && *s && count < len) {
1215 glyph = &font->glyphs[*s & 255];
1216 if ( Q_IsColorString( s ) ) {
1217 memcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) );
1218 newColor[3] = color[3];
1219 trap_R_SetColor( newColor );
1220 s += 2;
1221 continue;
1222 } else {
1223 float yadj = useScale * glyph->top;
1224 if (CG_Text_Width(s, scale, 1) + x > max) {
1225 *maxX = 0;
1226 break;
1227 }
1228 CG_Text_PaintChar(x, y - yadj,
1229 glyph->imageWidth,
1230 glyph->imageHeight,
1231 useScale,
1232 glyph->s,
1233 glyph->t,
1234 glyph->s2,
1235 glyph->t2,
1236 glyph->glyph);
1237 x += (glyph->xSkip * useScale) + adjust;
1238 *maxX = x;
1239 count++;
1240 s++;
1241 }
1242 }
1243 trap_R_SetColor( NULL );
1244 }
1245
1246 }
1247
1248
1249
1250 #define PIC_WIDTH 12
1251
1252 void CG_DrawNewTeamInfo(rectDef_t *rect, float text_x, float text_y, float scale, vec4_t color, qhandle_t shader) {
1253 int xx;
1254 float y;
1255 int i, j, len, count;
1256 const char *p;
1257 vec4_t hcolor;
1258 float pwidth, lwidth, maxx, leftOver;
1259 clientInfo_t *ci;
1260 gitem_t *item;
1261 qhandle_t h;
1262
1263 // max player name width
1264 pwidth = 0;
1265 count = (numSortedTeamPlayers > 8) ? 8 : numSortedTeamPlayers;
1266 for (i = 0; i < count; i++) {
1267 ci = cgs.clientinfo + sortedTeamPlayers[i];
1268 if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) {
1269 len = CG_Text_Width( ci->name, scale, 0);
1270 if (len > pwidth)
1271 pwidth = len;
1272 }
1273 }
1274
1275 // max location name width
1276 lwidth = 0;
1277 for (i = 1; i < MAX_LOCATIONS; i++) {
1278 p = CG_ConfigString(CS_LOCATIONS + i);
1279 if (p && *p) {
1280 len = CG_Text_Width(p, scale, 0);
1281 if (len > lwidth)
1282 lwidth = len;
1283 }
1284 }
1285
1286 y = rect->y;
1287
1288 for (i = 0; i < count; i++) {
1289 ci = cgs.clientinfo + sortedTeamPlayers[i];
1290 if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) {
1291
1292 xx = rect->x + 1;
1293 for (j = 0; j <= PW_NUM_POWERUPS; j++) {
1294 if (ci->powerups & (1 << j)) {
1295
1296 item = BG_FindItemForPowerup( j );
1297
1298 if (item) {
1299 CG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, trap_R_RegisterShader( item->icon ) );
1300 xx += PIC_WIDTH;
1301 }
1302 }
1303 }
1304
1305 // FIXME: max of 3 powerups shown properly
1306 xx = rect->x + (PIC_WIDTH * 3) + 2;
1307
1308 CG_GetColorForHealth( ci->health, ci->armor, hcolor );
1309 trap_R_SetColor(hcolor);
1310 CG_DrawPic( xx, y + 1, PIC_WIDTH - 2, PIC_WIDTH - 2, cgs.media.heartShader );
1311
1312 //Com_sprintf (st, sizeof(st), "%3i %3i", ci->health, ci->armor);
1313 //CG_Text_Paint(xx, y + text_y, scale, hcolor, st, 0, 0);
1314
1315 // draw weapon icon
1316 xx += PIC_WIDTH + 1;
1317
1318 // weapon used is not that useful, use the space for task
1319 #if 0
1320 if ( cg_weapons[ci->curWeapon].weaponIcon ) {
1321 CG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, cg_weapons[ci->curWeapon].weaponIcon );
1322 } else {
1323 CG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, cgs.media.deferShader );
1324 }
1325 #endif
1326
1327 trap_R_SetColor(NULL);
1328 if (cgs.orderPending) {
1329 // blink the icon
1330 if ( cg.time > cgs.orderTime - 2500 && (cg.time >> 9 ) & 1 ) {
1331 h = 0;
1332 } else {
1333 h = CG_StatusHandle(cgs.currentOrder);
1334 }
1335 } else {
1336 h = CG_StatusHandle(ci->teamTask);
1337 }
1338
1339 if (h) {
1340 CG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, h);
1341 }
1342
1343 xx += PIC_WIDTH + 1;
1344
1345 leftOver = rect->w - xx;
1346 maxx = xx + leftOver / 3;
1347
1348
1349
1350 CG_Text_Paint_Limit(&maxx, xx, y + text_y, scale, color, ci->name, 0, 0);
1351
1352 p = CG_ConfigString(CS_LOCATIONS + ci->location);
1353 if (!p || !*p) {
1354 p = "unknown";
1355 }
1356
1357 xx += leftOver / 3 + 2;
1358 maxx = rect->w - 4;
1359
1360 CG_Text_Paint_Limit(&maxx, xx, y + text_y, scale, color, p, 0, 0);
1361 y += text_y + 2;
1362 if ( y + text_y + 2 > rect->y + rect->h ) {
1363 break;
1364 }
1365
1366 }
1367 }
1368 }
1369
1370
1371 void CG_DrawTeamSpectators(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {
1372 if (cg.spectatorLen) {
1373 float maxX;
1374
1375 if (cg.spectatorWidth == -1) {
1376 cg.spectatorWidth = 0;
1377 cg.spectatorPaintX = rect->x + 1;
1378 cg.spectatorPaintX2 = -1;
1379 }
1380
1381 if (cg.spectatorOffset > cg.spectatorLen) {
1382 cg.spectatorOffset = 0;
1383 cg.spectatorPaintX = rect->x + 1;
1384 cg.spectatorPaintX2 = -1;
1385 }
1386
1387 if (cg.time > cg.spectatorTime) {
1388 cg.spectatorTime = cg.time + 10;
1389 if (cg.spectatorPaintX <= rect->x + 2) {
1390 if (cg.spectatorOffset < cg.spectatorLen) {
1391 cg.spectatorPaintX += CG_Text_Width(&cg.spectatorList[cg.spectatorOffset], scale, 1) - 1;
1392 cg.spectatorOffset++;
1393 } else {
1394 cg.spectatorOffset = 0;
1395 if (cg.spectatorPaintX2 >= 0) {
1396 cg.spectatorPaintX = cg.spectatorPaintX2;
1397 } else {
1398 cg.spectatorPaintX = rect->x + rect->w - 2;
1399 }
1400 cg.spectatorPaintX2 = -1;
1401 }
1402 } else {
1403 cg.spectatorPaintX--;
1404 if (cg.spectatorPaintX2 >= 0) {
1405 cg.spectatorPaintX2--;
1406 }
1407 }
1408 }
1409
1410 maxX = rect->x + rect->w - 2;
1411 CG_Text_Paint_Limit(&maxX, cg.spectatorPaintX, rect->y + rect->h - 3, scale, color, &cg.spectatorList[cg.spectatorOffset], 0, 0);
1412 if (cg.spectatorPaintX2 >= 0) {
1413 float maxX2 = rect->x + rect->w - 2;
1414 CG_Text_Paint_Limit(&maxX2, cg.spectatorPaintX2, rect->y + rect->h - 3, scale, color, cg.spectatorList, 0, cg.spectatorOffset);
1415 }
1416 if (cg.spectatorOffset && maxX > 0) {
1417 // if we have an offset ( we are skipping the first part of the string ) and we fit the string
1418 if (cg.spectatorPaintX2 == -1) {
1419 cg.spectatorPaintX2 = rect->x + rect->w - 2;
1420 }
1421 } else {
1422 cg.spectatorPaintX2 = -1;
1423 }
1424
1425 }
1426 }
1427
1428
1429
1430 void CG_DrawMedal(int ownerDraw, rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {
1431 score_t *score = &cg.scores[cg.selectedScore];
1432 float value = 0;
1433 char *text = NULL;
1434 color[3] = 0.25;
1435
1436 switch (ownerDraw) {
1437 case CG_ACCURACY:
1438 value = score->accuracy;
1439 break;
1440 case CG_ASSISTS:
1441 value = score->assistCount;
1442 break;
1443 case CG_DEFEND:
1444 value = score->defendCount;
1445 break;
1446 case CG_EXCELLENT:
1447 value = score->excellentCount;
1448 break;
1449 case CG_IMPRESSIVE:
1450 value = score->impressiveCount;
1451 break;
1452 case CG_PERFECT:
1453 value = score->perfect;
1454 break;
1455 case CG_GAUNTLET:
1456 value = score->guantletCount;
1457 break;
1458 case CG_CAPTURES:
1459 value = score->captures;
1460 break;
1461 }
1462
1463 if (value > 0) {
1464 if (ownerDraw != CG_PERFECT) {
1465 if (ownerDraw == CG_ACCURACY) {
1466 text = va("%i%%", (int)value);
1467 if (value > 50) {
1468 color[3] = 1.0;
1469 }
1470 } else {
1471 text = va("%i", (int)value);
1472 color[3] = 1.0;
1473 }
1474 } else {
1475 if (value) {
1476 color[3] = 1.0;
1477 }
1478 text = "Wow";
1479 }
1480 }
1481
1482 trap_R_SetColor(color);
1483 CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );
1484
1485 if (text) {
1486 color[3] = 1.0;
1487 value = CG_Text_Width(text, scale, 0);
1488 CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h + 10 , scale, color, text, 0, 0, 0);
1489 }
1490 trap_R_SetColor(NULL);
1491
1492 }
1493
1494
1495 //
1496 void CG_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle) {
1497 rectDef_t rect;
1498
1499 if ( cg_drawStatus.integer == 0 ) {
1500 return;
1501 }
1502
1503 //if (ownerDrawFlags != 0 && !CG_OwnerDrawVisible(ownerDrawFlags)) {
1504 // return;
1505 //}
1506
1507 rect.x = x;
1508 rect.y = y;
1509 rect.w = w;
1510 rect.h = h;
1511
1512 switch (ownerDraw) {
1513 case CG_PLAYER_ARMOR_ICON:
1514 CG_DrawPlayerArmorIcon(&rect, ownerDrawFlags & CG_SHOW_2DONLY);
1515 break;
1516 case CG_PLAYER_ARMOR_ICON2D:
1517 CG_DrawPlayerArmorIcon(&rect, qtrue);
1518 break;
1519 case CG_PLAYER_ARMOR_VALUE:
1520 CG_DrawPlayerArmorValue(&rect, scale, color, shader, textStyle);
1521 break;
1522 case CG_PLAYER_AMMO_ICON:
1523 CG_DrawPlayerAmmoIcon(&rect, ownerDrawFlags & CG_SHOW_2DONLY);
1524 break;
1525 case CG_PLAYER_AMMO_ICON2D:
1526 CG_DrawPlayerAmmoIcon(&rect, qtrue);
1527 break;
1528 case CG_PLAYER_AMMO_VALUE:
1529 CG_DrawPlayerAmmoValue(&rect, scale, color, shader, textStyle);
1530 break;
1531 case CG_SELECTEDPLAYER_HEAD:
1532 CG_DrawSelectedPlayerHead(&rect, ownerDrawFlags & CG_SHOW_2DONLY, qfalse);
1533 break;
1534 case CG_VOICE_HEAD:
1535 CG_DrawSelectedPlayerHead(&rect, ownerDrawFlags & CG_SHOW_2DONLY, qtrue);
1536 break;
1537 case CG_VOICE_NAME:
1538 CG_DrawSelectedPlayerName(&rect, scale, color, qtrue, textStyle);
1539 break;
1540 case CG_SELECTEDPLAYER_STATUS:
1541 CG_DrawSelectedPlayerStatus(&rect);
1542 break;
1543 case CG_SELECTEDPLAYER_ARMOR:
1544 CG_DrawSelectedPlayerArmor(&rect, scale, color, shader, textStyle);
1545 break;
1546 case CG_SELECTEDPLAYER_HEALTH:
1547 CG_DrawSelectedPlayerHealth(&rect, scale, color, shader, textStyle);
1548 break;
1549 case CG_SELECTEDPLAYER_NAME:
1550 CG_DrawSelectedPlayerName(&rect, scale, color, qfalse, textStyle);
1551 break;
1552 case CG_SELECTEDPLAYER_LOCATION:
1553 CG_DrawSelectedPlayerLocation(&rect, scale, color, textStyle);
1554 break;
1555 case CG_SELECTEDPLAYER_WEAPON:
1556 CG_DrawSelectedPlayerWeapon(&rect);
1557 break;
1558 case CG_SELECTEDPLAYER_POWERUP:
1559 CG_DrawSelectedPlayerPowerup(&rect, ownerDrawFlags & CG_SHOW_2DONLY);
1560 break;
1561 case CG_PLAYER_HEAD:
1562 CG_DrawPlayerHead(&rect, ownerDrawFlags & CG_SHOW_2DONLY);
1563 break;
1564 case CG_PLAYER_ITEM:
1565 CG_DrawPlayerItem(&rect, scale, ownerDrawFlags & CG_SHOW_2DONLY);
1566 break;
1567 case CG_PLAYER_SCORE:
1568 CG_DrawPlayerScore(&rect, scale, color, shader, textStyle);
1569 break;
1570 case CG_PLAYER_HEALTH:
1571 CG_DrawPlayerHealth(&rect, scale, color, shader, textStyle);
1572 break;
1573 case CG_RED_SCORE:
1574 CG_DrawRedScore(&rect, scale, color, shader, textStyle);
1575 break;
1576 case CG_BLUE_SCORE:
1577 CG_DrawBlueScore(&rect, scale, color, shader, textStyle);
1578 break;
1579 case CG_RED_NAME:
1580 CG_DrawRedName(&rect, scale, color, textStyle);
1581 break;
1582 case CG_BLUE_NAME:
1583 CG_DrawBlueName(&rect, scale, color, textStyle);
1584 break;
1585 case CG_BLUE_FLAGHEAD:
1586 CG_DrawBlueFlagHead(&rect);
1587 break;
1588 case CG_BLUE_FLAGSTATUS:
1589 CG_DrawBlueFlagStatus(&rect, shader);
1590 break;
1591 case CG_BLUE_FLAGNAME:
1592 CG_DrawBlueFlagName(&rect, scale, color, textStyle);
1593 break;
1594 case CG_RED_FLAGHEAD:
1595 CG_DrawRedFlagHead(&rect);
1596 break;
1597 case CG_RED_FLAGSTATUS:
1598 CG_DrawRedFlagStatus(&rect, shader);
1599 break;
1600 case CG_RED_FLAGNAME:
1601 CG_DrawRedFlagName(&rect, scale, color, textStyle);
1602 break;
1603 case CG_HARVESTER_SKULLS:
1604 CG_HarvesterSkulls(&rect, scale, color, qfalse, textStyle);
1605 break;
1606 case CG_HARVESTER_SKULLS2D:
1607 CG_HarvesterSkulls(&rect, scale, color, qtrue, textStyle);
1608 break;
1609 case CG_ONEFLAG_STATUS:
1610 CG_OneFlagStatus(&rect);
1611 break;
1612 case CG_PLAYER_LOCATION:
1613 CG_DrawPlayerLocation(&rect, scale, color, textStyle);
1614 break;
1615 case CG_TEAM_COLOR:
1616 CG_DrawTeamColor(&rect, color);
1617 break;
1618 case CG_CTF_POWERUP:
1619 CG_DrawCTFPowerUp(&rect);
1620 break;
1621 case CG_AREA_POWERUP:
1622 CG_DrawAreaPowerUp(&rect, align, special, scale, color);
1623 break;
1624 case CG_PLAYER_STATUS:
1625 CG_DrawPlayerStatus(&rect);
1626 break;
1627 case CG_PLAYER_HASFLAG:
1628 CG_DrawPlayerHasFlag(&rect, qfalse);
1629 break;
1630 case CG_PLAYER_HASFLAG2D:
1631 CG_DrawPlayerHasFlag(&rect, qtrue);
1632 break;
1633 case CG_AREA_SYSTEMCHAT:
1634 CG_DrawAreaSystemChat(&rect, scale, color, shader);
1635 break;
1636 case CG_AREA_TEAMCHAT:
1637 CG_DrawAreaTeamChat(&rect, scale, color, shader);
1638 break;
1639 case CG_AREA_CHAT:
1640 CG_DrawAreaChat(&rect, scale, color, shader);
1641 break;
1642 case CG_GAME_TYPE:
1643 CG_DrawGameType(&rect, scale, color, shader, textStyle);
1644 break;
1645 case CG_GAME_STATUS:
1646 CG_DrawGameStatus(&rect, scale, color, shader, textStyle);
1647 break;
1648 case CG_KILLER:
1649 CG_DrawKiller(&rect, scale, color, shader, textStyle);
1650 break;
1651 case CG_ACCURACY:
1652 case CG_ASSISTS:
1653 case CG_DEFEND:
1654 case CG_EXCELLENT:
1655 case CG_IMPRESSIVE:
1656 case CG_PERFECT:
1657 case CG_GAUNTLET:
1658 case CG_CAPTURES:
1659 CG_DrawMedal(ownerDraw, &rect, scale, color, shader);
1660 break;
1661 case CG_SPECTATORS:
1662 CG_DrawTeamSpectators(&rect, scale, color, shader);
1663 break;
1664 case CG_TEAMINFO:
1665 if (cg_currentSelectedPlayer.integer == numSortedTeamPlayers) {
1666 CG_DrawNewTeamInfo(&rect, text_x, text_y, scale, color, shader);
1667 }
1668 break;
1669 case CG_CAPFRAGLIMIT:
1670 CG_DrawCapFragLimit(&rect, scale, color, shader, textStyle);
1671 break;
1672 case CG_1STPLACE:
1673 CG_Draw1stPlace(&rect, scale, color, shader, textStyle);
1674 break;
1675 case CG_2NDPLACE:
1676 CG_Draw2ndPlace(&rect, scale, color, shader, textStyle);
1677 break;
1678 default:
1679 break;
1680 }
1681 }
1682
1683 void CG_MouseEvent(int x, int y) {
1684 int n;
1685
1686 if ( (cg.predictedPlayerState.pm_type == PM_NORMAL || cg.predictedPlayerState.pm_type == PM_SPECTATOR) && cg.showScores == qfalse) {
1687 trap_Key_SetCatcher(0);
1688 return;
1689 }
1690
1691 cgs.cursorX+= x;
1692 if (cgs.cursorX < 0)
1693 cgs.cursorX = 0;
1694 else if (cgs.cursorX > 640)
1695 cgs.cursorX = 640;
1696
1697 cgs.cursorY += y;
1698 if (cgs.cursorY < 0)
1699 cgs.cursorY = 0;
1700 else if (cgs.cursorY > 480)
1701 cgs.cursorY = 480;
1702
1703 n = Display_CursorType(cgs.cursorX, cgs.cursorY);
1704 cgs.activeCursor = 0;
1705 if (n == CURSOR_ARROW) {
1706 cgs.activeCursor = cgs.media.selectCursor;
1707 } else if (n == CURSOR_SIZER) {
1708 cgs.activeCursor = cgs.media.sizeCursor;
1709 }
1710
1711 if (cgs.capturedItem) {
1712 Display_MouseMove(cgs.capturedItem, x, y);
1713 } else {
1714 Display_MouseMove(NULL, cgs.cursorX, cgs.cursorY);
1715 }
1716
1717 }
1718
1719 /*
1720 ==================
1721 CG_HideTeamMenus
1722 ==================
1723
1724 */
1725 void CG_HideTeamMenu( void ) {
1726 Menus_CloseByName("teamMenu");
1727 Menus_CloseByName("getMenu");
1728 }
1729
1730 /*
1731 ==================
1732 CG_ShowTeamMenus
1733 ==================
1734
1735 */
1736 void CG_ShowTeamMenu( void ) {
1737 Menus_OpenByName("teamMenu");
1738 }
1739
1740
1741
1742
1743 /*
1744 ==================
1745 CG_EventHandling
1746 ==================
1747 type 0 - no event handling
1748 1 - team menu
1749 2 - hud editor
1750
1751 */
1752 void CG_EventHandling(int type) {
1753 cgs.eventHandling = type;
1754 if (type == CGAME_EVENT_NONE) {
1755 CG_HideTeamMenu();
1756 } else if (type == CGAME_EVENT_TEAMMENU) {
1757 //CG_ShowTeamMenu();
1758 } else if (type == CGAME_EVENT_SCOREBOARD) {
1759 }
1760
1761 }
1762
1763
1764
1765 void CG_KeyEvent(int key, qboolean down) {
1766
1767 if (!down) {
1768 return;
1769 }
1770
1771 if ( cg.predictedPlayerState.pm_type == PM_NORMAL || (cg.predictedPlayerState.pm_type == PM_SPECTATOR && cg.showScores == qfalse)) {
1772 CG_EventHandling(CGAME_EVENT_NONE);
1773 trap_Key_SetCatcher(0);
1774 return;
1775 }
1776
1777 //if (key == trap_Key_GetKey("teamMenu") || !Display_CaptureItem(cgs.cursorX, cgs.cursorY)) {
1778 // if we see this then we should always be visible
1779 // CG_EventHandling(CGAME_EVENT_NONE);
1780 // trap_Key_SetCatcher(0);
1781 //}
1782
1783
1784
1785 Display_HandleKey(key, down, cgs.cursorX, cgs.cursorY);
1786
1787 if (cgs.capturedItem) {
1788 cgs.capturedItem = NULL;
1789 } else {
1790 if (key == K_MOUSE2 && down) {
1791 cgs.capturedItem = Display_CaptureItem(cgs.cursorX, cgs.cursorY);
1792 }
1793 }
1794 }
1795
1796 int CG_ClientNumFromName(const char *p) {
1797 int i;
1798 for (i = 0; i < cgs.maxclients; i++) {
1799 if (cgs.clientinfo[i].infoValid && Q_stricmp(cgs.clientinfo[i].name, p) == 0) {
1800 return i;
1801 }
1802 }
1803 return -1;
1804 }
1805
1806 void CG_ShowResponseHead(void) {
1807 float x, y, w, h;
1808
1809 x = 72;
1810 y = w = h = 0;
1811 CG_AdjustFrom640( &x, &y, &w, &h );
1812
1813 Menus_OpenByName("voiceMenu");
1814 trap_Cvar_Set("cl_conXOffset", va("%d", (int)x));
1815 cg.voiceTime = cg.time;
1816 }
1817
1818 void CG_RunMenuScript(char **args) {
1819 }
1820
1821
1822 void CG_GetTeamColor(vec4_t *color) {
1823 if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED) {
1824 (*color)[0] = 1.0f;
1825 (*color)[3] = 0.25f;
1826 (*color)[1] = (*color)[2] = 0.0f;
1827 } else if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE) {
1828 (*color)[0] = (*color)[1] = 0.0f;
1829 (*color)[2] = 1.0f;
1830 (*color)[3] = 0.25f;
1831 } else {
1832 (*color)[0] = (*color)[2] = 0.0f;
1833 (*color)[1] = 0.17f;
1834 (*color)[3] = 0.25f;
1835 }
1836 }
1837