codemp/cgame/cg_newDraw.c

Go to the documentation of this file.
00001 #include "cg_local.h"
00002 #include "../ui/ui_shared.h"
00003 
00004 extern displayContextDef_t cgDC;
00005 
00006 
00007 int CG_GetSelectedPlayer() {
00008         if (cg_currentSelectedPlayer.integer < 0 || cg_currentSelectedPlayer.integer >= numSortedTeamPlayers) {
00009                 cg_currentSelectedPlayer.integer = 0;
00010         }
00011         return cg_currentSelectedPlayer.integer;
00012 }
00013 
00014 qhandle_t CG_StatusHandle(int task) {
00015         qhandle_t h = cgs.media.assaultShader;
00016         switch (task) {
00017                 case TEAMTASK_OFFENSE :
00018                         h = cgs.media.assaultShader;
00019                         break;
00020                 case TEAMTASK_DEFENSE :
00021                         h = cgs.media.defendShader;
00022                         break;
00023                 case TEAMTASK_PATROL :
00024                         h = cgs.media.patrolShader;
00025                         break;
00026                 case TEAMTASK_FOLLOW :
00027                         h = cgs.media.followShader;
00028                         break;
00029                 case TEAMTASK_CAMP :
00030                         h = cgs.media.campShader;
00031                         break;
00032                 case TEAMTASK_RETRIEVE :
00033                         h = cgs.media.retrieveShader; 
00034                         break;
00035                 case TEAMTASK_ESCORT :
00036                         h = cgs.media.escortShader; 
00037                         break;
00038                 default : 
00039                         h = cgs.media.assaultShader;
00040                         break;
00041         }
00042         return h;
00043 }
00044 
00045 
00046 float CG_GetValue(int ownerDraw) {
00047         centity_t       *cent;
00048         clientInfo_t *ci;
00049         playerState_t   *ps;
00050 
00051   cent = &cg_entities[cg.snap->ps.clientNum];
00052         ps = &cg.snap->ps;
00053 
00054   switch (ownerDraw) {
00055   case CG_SELECTEDPLAYER_ARMOR:
00056     ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];
00057     return ci->armor;
00058     break;
00059   case CG_SELECTEDPLAYER_HEALTH:
00060     ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];
00061     return ci->health;
00062     break;
00063   case CG_PLAYER_ARMOR_VALUE:
00064                 return ps->stats[STAT_ARMOR];
00065     break;
00066   case CG_PLAYER_AMMO_VALUE:
00067                 if ( cent->currentState.weapon ) 
00068                 {
00069                         return ps->ammo[weaponData[cent->currentState.weapon].ammoIndex];
00070                 }
00071     break;
00072   case CG_PLAYER_SCORE:
00073           return cg.snap->ps.persistant[PERS_SCORE];
00074     break;
00075   case CG_PLAYER_HEALTH:
00076                 return ps->stats[STAT_HEALTH];
00077     break;
00078   case CG_RED_SCORE:
00079                 return cgs.scores1;
00080     break;
00081   case CG_BLUE_SCORE:
00082                 return cgs.scores2;
00083     break;
00084   case CG_PLAYER_FORCE_VALUE:
00085                 return ps->fd.forcePower;
00086     break;
00087   default:
00088     break;
00089   }
00090         return -1;
00091 }
00092 
00093 qboolean CG_OtherTeamHasFlag(void) {
00094         if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTY) {
00095                 int team = cg.snap->ps.persistant[PERS_TEAM];
00096                 if (team == TEAM_RED && cgs.redflag == FLAG_TAKEN) {
00097                         return qtrue;
00098                 } else if (team == TEAM_BLUE && cgs.blueflag == FLAG_TAKEN) {
00099                         return qtrue;
00100                 } else {
00101                         return qfalse;
00102                 }
00103         }
00104         return qfalse;
00105 }
00106 
00107 qboolean CG_YourTeamHasFlag(void) {
00108         if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTY) {
00109                 int team = cg.snap->ps.persistant[PERS_TEAM];
00110                 if (team == TEAM_RED && cgs.blueflag == FLAG_TAKEN) {
00111                         return qtrue;
00112                 } else if (team == TEAM_BLUE && cgs.redflag == FLAG_TAKEN) {
00113                         return qtrue;
00114                 } else {
00115                         return qfalse;
00116                 }
00117         }
00118         return qfalse;
00119 }
00120 
00121 // THINKABOUTME: should these be exclusive or inclusive.. 
00122 // 
00123 qboolean CG_OwnerDrawVisible(int flags) {
00124 
00125         if (flags & CG_SHOW_TEAMINFO) {
00126                 return (cg_currentSelectedPlayer.integer == numSortedTeamPlayers);
00127         }
00128 
00129         if (flags & CG_SHOW_NOTEAMINFO) {
00130                 return !(cg_currentSelectedPlayer.integer == numSortedTeamPlayers);
00131         }
00132 
00133         if (flags & CG_SHOW_OTHERTEAMHASFLAG) {
00134                 return CG_OtherTeamHasFlag();
00135         }
00136 
00137         if (flags & CG_SHOW_YOURTEAMHASENEMYFLAG) {
00138                 return CG_YourTeamHasFlag();
00139         }
00140 
00141         if (flags & (CG_SHOW_BLUE_TEAM_HAS_REDFLAG | CG_SHOW_RED_TEAM_HAS_BLUEFLAG)) {
00142                 if (flags & CG_SHOW_BLUE_TEAM_HAS_REDFLAG && (cgs.redflag == FLAG_TAKEN || cgs.flagStatus == FLAG_TAKEN_RED)) {
00143                         return qtrue;
00144                 } else if (flags & CG_SHOW_RED_TEAM_HAS_BLUEFLAG && (cgs.blueflag == FLAG_TAKEN || cgs.flagStatus == FLAG_TAKEN_BLUE)) {
00145                         return qtrue;
00146                 }
00147                 return qfalse;
00148         }
00149 
00150         if (flags & CG_SHOW_ANYTEAMGAME) {
00151                 if( cgs.gametype >= GT_TEAM) {
00152                         return qtrue;
00153                 }
00154         }
00155 
00156         if (flags & CG_SHOW_ANYNONTEAMGAME) {
00157                 if( cgs.gametype < GT_TEAM) {
00158                         return qtrue;
00159                 }
00160         }
00161 
00162         if (flags & CG_SHOW_CTF) {
00163                 if( cgs.gametype == GT_CTF || cgs.gametype == GT_CTY ) {
00164                         return qtrue;
00165                 }
00166         }
00167 
00168         if (flags & CG_SHOW_HEALTHCRITICAL) {
00169                 if (cg.snap->ps.stats[STAT_HEALTH] < 25) {
00170                         return qtrue;
00171                 }
00172         }
00173 
00174         if (flags & CG_SHOW_HEALTHOK) {
00175                 if (cg.snap->ps.stats[STAT_HEALTH] >= 25) {
00176                         return qtrue;
00177                 }
00178         }
00179 
00180         if (flags & CG_SHOW_SINGLEPLAYER) {
00181                 if( cgs.gametype == GT_SINGLE_PLAYER ) {
00182                         return qtrue;
00183                 }
00184         }
00185 
00186         if (flags & CG_SHOW_TOURNAMENT) {
00187                 if( cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL ) {
00188                         return qtrue;
00189                 }
00190         }
00191 
00192         if (flags & CG_SHOW_DURINGINCOMINGVOICE) {
00193         }
00194 
00195         if (flags & CG_SHOW_IF_PLAYER_HAS_FLAG) {
00196                 if (cg.snap->ps.powerups[PW_REDFLAG] || cg.snap->ps.powerups[PW_BLUEFLAG] || cg.snap->ps.powerups[PW_NEUTRALFLAG]) {
00197                         return qtrue;
00198                 }
00199         }
00200         return qfalse;
00201 }
00202 
00203 
00204 const char *CG_GetKillerText(void) {
00205         static const char *s = "";
00206         if ( cg.killerName[0] ) {
00207                 s = va("%s %s", CG_GetStringEdString("MP_INGAME", "KILLEDBY"), cg.killerName );
00208         }
00209         return s;
00210 }
00211 
00212 
00213 const char *CG_GetGameStatusText(void) {
00214         static const char *s = "";
00215         if (cgs.gametype == GT_POWERDUEL)
00216         {
00217                 s = "";
00218         }       
00219         else if ( cgs.gametype < GT_TEAM)
00220         {
00221                 if (cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR ) 
00222                 {
00223                         char sPlaceWith[256];
00224                         trap_SP_GetStringTextString("MP_INGAME_PLACE_WITH", sPlaceWith, sizeof(sPlaceWith));
00225 
00226                         s = va("%s %s %i",CG_PlaceString( cg.snap->ps.persistant[PERS_RANK] + 1 ), sPlaceWith, cg.snap->ps.persistant[PERS_SCORE] );
00227                 }
00228         }
00229         else
00230         {
00231                 if ( cg.teamScores[0] == cg.teamScores[1] ) {
00232                         s = va("%s %i", CG_GetStringEdString("MP_INGAME", "TIEDAT"), cg.teamScores[0] );
00233                 } else if ( cg.teamScores[0] >= cg.teamScores[1] ) {
00234                         s = va("%s, %i / %i", CG_GetStringEdString("MP_INGAME", "RED_LEADS"), cg.teamScores[0], cg.teamScores[1] );
00235                 } else {
00236                         s = va("%s, %i / %i", CG_GetStringEdString("MP_INGAME", "BLUE_LEADS"), cg.teamScores[1], cg.teamScores[0] );
00237                 }
00238         }
00239         return s;
00240 }
00241         
00242 const char *CG_GameTypeString(void) {
00243         if ( cgs.gametype == GT_FFA ) {
00244                 return "Free For All";
00245         } else if ( cgs.gametype == GT_HOLOCRON ) {
00246                 return "Holocron FFA";
00247         } else if ( cgs.gametype == GT_JEDIMASTER ) {
00248                 return "Jedi Master";
00249         } else if ( cgs.gametype == GT_TEAM ) {
00250                 return "Team FFA";
00251         } else if ( cgs.gametype == GT_SIEGE ) {
00252                 return "Siege";
00253         } else if ( cgs.gametype == GT_CTF ) {
00254                 return "Capture the Flag";
00255         } else if ( cgs.gametype == GT_CTY ) {
00256                 return "Capture the Ysalamiri";
00257         }
00258         return "";
00259 }
00260                                                  
00261 #include "../namespace_begin.h"
00262 extern int MenuFontToHandle(int iMenuFont);
00263 #include "../namespace_end.h"
00264 
00265 // maxX param is initially an X limit, but is also used as feedback. 0 = text was clipped to fit within, else maxX = next pos
00266 //
00267 static void CG_Text_Paint_Limit(float *maxX, float x, float y, float scale, vec4_t color, const char* text, float adjust, int limit, int iMenuFont) 
00268 {
00269         qboolean bIsTrailingPunctuation;
00270 
00271         // this is kinda dirty, but...
00272         //
00273         int iFontIndex = MenuFontToHandle(iMenuFont);
00274         
00275         //float fMax = *maxX;
00276         int iPixelLen = trap_R_Font_StrLenPixels(text, iFontIndex, scale);
00277         if (x + iPixelLen > *maxX)
00278         {
00279                 // whole text won't fit, so we need to print just the amount that does...
00280                 //  Ok, this is slow and tacky, but only called occasionally, and it works...
00281                 //
00282                 char sTemp[4096]={0};   // lazy assumption
00283                 const char *psText = text;
00284                 char *psOut = &sTemp[0];
00285                 char *psOutLastGood = psOut;
00286                 unsigned int uiLetter;
00287 
00288                 while (*psText && (x + trap_R_Font_StrLenPixels(sTemp, iFontIndex, scale)<=*maxX) 
00289                            && psOut < &sTemp[sizeof(sTemp)-1]   // sanity
00290                                 )
00291                 {
00292                         int iAdvanceCount;
00293                         psOutLastGood = psOut;                  
00294 
00295                         uiLetter = trap_AnyLanguage_ReadCharFromString(psText, &iAdvanceCount, &bIsTrailingPunctuation);
00296                         psText += iAdvanceCount;
00297 
00298                         if (uiLetter > 255)
00299                         {
00300                                 *psOut++ = uiLetter>>8;
00301                                 *psOut++ = uiLetter&0xFF;
00302                         }
00303                         else
00304                         {
00305                                 *psOut++ = uiLetter&0xFF;
00306                         }
00307                 }
00308                 *psOutLastGood = '\0';
00309 
00310                 *maxX = 0;      // feedback
00311                 CG_Text_Paint(x, y, scale, color, sTemp, adjust, limit, ITEM_TEXTSTYLE_NORMAL, iMenuFont);
00312         }
00313         else
00314         {
00315                 // whole text fits fine, so print it all...
00316                 //
00317                 *maxX = x + iPixelLen;  // feedback the next position, as the caller expects            
00318                 CG_Text_Paint(x, y, scale, color, text, adjust, limit, ITEM_TEXTSTYLE_NORMAL, iMenuFont);
00319         }
00320 }
00321 
00322 
00323 
00324 #define PIC_WIDTH 12
00325 
00326 extern const char *CG_GetLocationString(const char *loc); //cg_main.c
00327 void CG_DrawNewTeamInfo(rectDef_t *rect, float text_x, float text_y, float scale, vec4_t color, qhandle_t shader) {
00328         int xx;
00329         float y;
00330         int i, j, len, count;
00331         const char *p;
00332         vec4_t          hcolor;
00333         float pwidth, lwidth, maxx, leftOver;
00334         clientInfo_t *ci;
00335         gitem_t *item;
00336         qhandle_t h;
00337 
00338         // max player name width
00339         pwidth = 0;
00340         count = (numSortedTeamPlayers > 8) ? 8 : numSortedTeamPlayers;
00341         for (i = 0; i < count; i++) {
00342                 ci = cgs.clientinfo + sortedTeamPlayers[i];
00343                 if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) {
00344                         len = CG_Text_Width( ci->name, scale, 0);
00345                         if (len > pwidth)
00346                                 pwidth = len;
00347                 }
00348         }
00349 
00350         // max location name width
00351         lwidth = 0;
00352         for (i = 1; i < MAX_LOCATIONS; i++) {
00353                 p = CG_GetLocationString(CG_ConfigString(CS_LOCATIONS+i));
00354                 if (p && *p) {
00355                         len = CG_Text_Width(p, scale, 0);
00356                         if (len > lwidth)
00357                                 lwidth = len;
00358                 }
00359         }
00360 
00361         y = rect->y;
00362 
00363         for (i = 0; i < count; i++) {
00364                 ci = cgs.clientinfo + sortedTeamPlayers[i];
00365                 if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) {
00366 
00367                         xx = rect->x + 1;
00368                         for (j = 0; j <= PW_NUM_POWERUPS; j++) {
00369                                 if (ci->powerups & (1 << j)) {
00370 
00371                                         item = BG_FindItemForPowerup( j );
00372 
00373                                         if (item) {
00374                                                 CG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, trap_R_RegisterShader( item->icon ) );
00375                                                 xx += PIC_WIDTH;
00376                                         }
00377                                 }
00378                         }
00379 
00380                         // FIXME: max of 3 powerups shown properly
00381                         xx = rect->x + (PIC_WIDTH * 3) + 2;
00382 
00383                         CG_GetColorForHealth( ci->health, ci->armor, hcolor );
00384                         trap_R_SetColor(hcolor);
00385                         CG_DrawPic( xx, y + 1, PIC_WIDTH - 2, PIC_WIDTH - 2, cgs.media.heartShader );
00386 
00387                         //Com_sprintf (st, sizeof(st), "%3i %3i", ci->health,   ci->armor);
00388                         //CG_Text_Paint(xx, y + text_y, scale, hcolor, st, 0, 0); 
00389 
00390                         // draw weapon icon
00391                         xx += PIC_WIDTH + 1;
00392 
00393 // weapon used is not that useful, use the space for task
00394 #if 0
00395                         if ( cg_weapons[ci->curWeapon].weaponIcon ) {
00396                                 CG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, cg_weapons[ci->curWeapon].weaponIcon );
00397                         } else {
00398                                 CG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, cgs.media.deferShader );
00399                         }
00400 #endif
00401 
00402                         trap_R_SetColor(NULL);
00403                         h = CG_StatusHandle(ci->teamTask);
00404 
00405                         if (h) {
00406                                 CG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, h);
00407                         }
00408 
00409                         xx += PIC_WIDTH + 1;
00410 
00411                         leftOver = rect->w - xx;
00412                         maxx = xx + leftOver / 3;
00413 
00414 
00415 
00416                         CG_Text_Paint_Limit(&maxx, xx, y + text_y, scale, color, ci->name, 0, 0, FONT_MEDIUM); 
00417 
00418                         p = CG_GetLocationString(CG_ConfigString(CS_LOCATIONS+ci->location));
00419                         if (!p || !*p) {
00420                                 p = "unknown";
00421                         }
00422 
00423                         xx += leftOver / 3 + 2;
00424                         maxx = rect->w - 4;
00425 
00426                         CG_Text_Paint_Limit(&maxx, xx, y + text_y, scale, color, p, 0, 0, FONT_MEDIUM); 
00427                         y += text_y + 2;
00428                         if ( y + text_y + 2 > rect->y + rect->h ) {
00429                                 break;
00430                         }
00431 
00432                 }
00433         }
00434 }
00435 
00436 
00437 void CG_DrawTeamSpectators(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {
00438         if (cg.spectatorLen) {
00439                 float maxX;
00440 
00441                 if (cg.spectatorWidth == -1) {
00442                         cg.spectatorWidth = 0;
00443                         cg.spectatorPaintX = rect->x + 1;
00444                         cg.spectatorPaintX2 = -1;
00445                 }
00446 
00447                 if (cg.spectatorOffset > cg.spectatorLen) {
00448                         cg.spectatorOffset = 0;
00449                         cg.spectatorPaintX = rect->x + 1;
00450                         cg.spectatorPaintX2 = -1;
00451                 }
00452 
00453                 if (cg.time > cg.spectatorTime) {
00454                         cg.spectatorTime = cg.time + 10;
00455                         if (cg.spectatorPaintX <= rect->x + 2) {
00456                                 if (cg.spectatorOffset < cg.spectatorLen) {
00457                                         cg.spectatorPaintX += CG_Text_Width(&cg.spectatorList[cg.spectatorOffset], scale, 1) - 1;
00458                                         cg.spectatorOffset++;
00459                                 } else {
00460                                         cg.spectatorOffset = 0;
00461                                         if (cg.spectatorPaintX2 >= 0) {
00462                                                 cg.spectatorPaintX = cg.spectatorPaintX2;
00463                                         } else {
00464                                                 cg.spectatorPaintX = rect->x + rect->w - 2;
00465                                         }
00466                                         cg.spectatorPaintX2 = -1;
00467                                 }
00468                         } else {
00469                                 cg.spectatorPaintX--;
00470                                 if (cg.spectatorPaintX2 >= 0) {
00471                                         cg.spectatorPaintX2--;
00472                                 }
00473                         }
00474                 }
00475 
00476                 maxX = rect->x + rect->w - 2;
00477                 CG_Text_Paint_Limit(&maxX, cg.spectatorPaintX, rect->y + rect->h - 3, scale, color, &cg.spectatorList[cg.spectatorOffset], 0, 0, FONT_MEDIUM); 
00478                 if (cg.spectatorPaintX2 >= 0) {
00479                         float maxX2 = rect->x + rect->w - 2;
00480                         CG_Text_Paint_Limit(&maxX2, cg.spectatorPaintX2, rect->y + rect->h - 3, scale, color, cg.spectatorList, 0, cg.spectatorOffset, FONT_MEDIUM); 
00481                 }
00482                 if (cg.spectatorOffset && maxX > 0) {
00483                         // if we have an offset ( we are skipping the first part of the string ) and we fit the string
00484                         if (cg.spectatorPaintX2 == -1) {
00485                                                 cg.spectatorPaintX2 = rect->x + rect->w - 2;
00486                         }
00487                 } else {
00488                         cg.spectatorPaintX2 = -1;
00489                 }
00490 
00491         }
00492 }
00493 
00494 
00495 
00496 void CG_DrawMedal(int ownerDraw, rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {
00497         score_t *score = &cg.scores[cg.selectedScore];
00498         float value = 0;
00499         char *text = NULL;
00500         color[3] = 0.25;
00501 
00502         switch (ownerDraw) {
00503                 case CG_ACCURACY:
00504                         value = score->accuracy;
00505                         break;
00506                 case CG_ASSISTS:
00507                         value = score->assistCount;
00508                         break;
00509                 case CG_DEFEND:
00510                         value = score->defendCount;
00511                         break;
00512                 case CG_EXCELLENT:
00513                         value = score->excellentCount;
00514                         break;
00515                 case CG_IMPRESSIVE:
00516                         value = score->impressiveCount;
00517                         break;
00518                 case CG_PERFECT:
00519                         value = score->perfect;
00520                         break;
00521                 case CG_GAUNTLET:
00522                         value = score->guantletCount;
00523                         break;
00524                 case CG_CAPTURES:
00525                         value = score->captures;
00526                         break;
00527         }
00528 
00529         if (value > 0) {
00530                 if (ownerDraw != CG_PERFECT) {
00531                         if (ownerDraw == CG_ACCURACY) {
00532                                 text = va("%i%%", (int)value);
00533                                 if (value > 50) {
00534                                         color[3] = 1.0;
00535                                 }
00536                         } else {
00537                                 text = va("%i", (int)value);
00538                                 color[3] = 1.0;
00539                         }
00540                 } else {
00541                         if (value) {
00542                                 color[3] = 1.0;
00543                         }
00544                         text = "Wow";
00545                 }
00546         }
00547 
00548         trap_R_SetColor(color);
00549         CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );
00550 
00551         if (text) {
00552                 color[3] = 1.0;
00553                 value = CG_Text_Width(text, scale, 0);
00554                 CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h + 10 , scale, color, text, 0, 0, 0, FONT_MEDIUM); 
00555         }
00556         trap_R_SetColor(NULL);
00557 
00558 }
00559 
00560         
00561 //
00562 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,int font) {
00563 
00564 //Ignore all this, at least for now. May put some stat stuff back in menu files later.
00565 #if 0
00566         rectDef_t rect;
00567 
00568   if ( cg_drawStatus.integer == 0 ) {
00569                 return;
00570         }
00571 
00572         //if (ownerDrawFlags != 0 && !CG_OwnerDrawVisible(ownerDrawFlags)) {
00573         //      return;
00574         //}
00575 
00576   rect.x = x;
00577   rect.y = y;
00578   rect.w = w;
00579   rect.h = h;
00580 
00581   switch (ownerDraw) {
00582   case CG_PLAYER_ARMOR_ICON:
00583     CG_DrawPlayerArmorIcon(&rect, ownerDrawFlags & CG_SHOW_2DONLY);
00584     break;
00585   case CG_PLAYER_ARMOR_ICON2D:
00586     CG_DrawPlayerArmorIcon(&rect, qtrue);
00587     break;
00588   case CG_PLAYER_ARMOR_VALUE:
00589     CG_DrawPlayerArmorValue(&rect, scale, color, shader, textStyle);
00590     break;
00591   case CG_PLAYER_FORCE_VALUE:
00592     CG_DrawPlayerForceValue(&rect, scale, color, shader, textStyle);
00593         return ;
00594   case CG_PLAYER_AMMO_ICON:
00595     CG_DrawPlayerAmmoIcon(&rect, ownerDrawFlags & CG_SHOW_2DONLY);
00596     break;
00597   case CG_PLAYER_AMMO_ICON2D:
00598     CG_DrawPlayerAmmoIcon(&rect, qtrue);
00599     break;
00600   case CG_PLAYER_AMMO_VALUE:
00601     CG_DrawPlayerAmmoValue(&rect, scale, color, shader, textStyle);
00602     break;
00603   case CG_SELECTEDPLAYER_HEAD:
00604     CG_DrawSelectedPlayerHead(&rect, ownerDrawFlags & CG_SHOW_2DONLY, qfalse);
00605     break;
00606   case CG_VOICE_HEAD:
00607     CG_DrawSelectedPlayerHead(&rect, ownerDrawFlags & CG_SHOW_2DONLY, qtrue);
00608     break;
00609   case CG_VOICE_NAME:
00610     CG_DrawSelectedPlayerName(&rect, scale, color, qtrue, textStyle);
00611     break;
00612   case CG_SELECTEDPLAYER_STATUS:
00613     CG_DrawSelectedPlayerStatus(&rect);
00614     break;
00615   case CG_SELECTEDPLAYER_ARMOR:
00616     CG_DrawSelectedPlayerArmor(&rect, scale, color, shader, textStyle);
00617     break;
00618   case CG_SELECTEDPLAYER_HEALTH:
00619     CG_DrawSelectedPlayerHealth(&rect, scale, color, shader, textStyle);
00620     break;
00621   case CG_SELECTEDPLAYER_NAME:
00622     CG_DrawSelectedPlayerName(&rect, scale, color, qfalse, textStyle);
00623     break;
00624   case CG_SELECTEDPLAYER_LOCATION:
00625     CG_DrawSelectedPlayerLocation(&rect, scale, color, textStyle);
00626     break;
00627   case CG_SELECTEDPLAYER_WEAPON:
00628     CG_DrawSelectedPlayerWeapon(&rect);
00629     break;
00630   case CG_SELECTEDPLAYER_POWERUP:
00631     CG_DrawSelectedPlayerPowerup(&rect, ownerDrawFlags & CG_SHOW_2DONLY);
00632     break;
00633   case CG_PLAYER_HEAD:
00634     CG_DrawPlayerHead(&rect, ownerDrawFlags & CG_SHOW_2DONLY);
00635     break;
00636   case CG_PLAYER_ITEM:
00637     CG_DrawPlayerItem(&rect, scale, ownerDrawFlags & CG_SHOW_2DONLY);
00638     break;
00639   case CG_PLAYER_SCORE:
00640     CG_DrawPlayerScore(&rect, scale, color, shader, textStyle);
00641     break;
00642   case CG_PLAYER_HEALTH:
00643     CG_DrawPlayerHealth(&rect, scale, color, shader, textStyle);
00644     break;
00645   case CG_RED_SCORE:
00646     CG_DrawRedScore(&rect, scale, color, shader, textStyle);
00647     break;
00648   case CG_BLUE_SCORE:
00649     CG_DrawBlueScore(&rect, scale, color, shader, textStyle);
00650     break;
00651   case CG_RED_NAME:
00652     CG_DrawRedName(&rect, scale, color, textStyle);
00653     break;
00654   case CG_BLUE_NAME:
00655     CG_DrawBlueName(&rect, scale, color, textStyle);
00656     break;
00657   case CG_BLUE_FLAGHEAD:
00658     CG_DrawBlueFlagHead(&rect);
00659     break;
00660   case CG_BLUE_FLAGSTATUS:
00661     CG_DrawBlueFlagStatus(&rect, shader);
00662     break;
00663   case CG_BLUE_FLAGNAME:
00664     CG_DrawBlueFlagName(&rect, scale, color, textStyle);
00665     break;
00666   case CG_RED_FLAGHEAD:
00667     CG_DrawRedFlagHead(&rect);
00668     break;
00669   case CG_RED_FLAGSTATUS:
00670     CG_DrawRedFlagStatus(&rect, shader);
00671     break;
00672   case CG_RED_FLAGNAME:
00673     CG_DrawRedFlagName(&rect, scale, color, textStyle);
00674     break;
00675   case CG_PLAYER_LOCATION:
00676     CG_DrawPlayerLocation(&rect, scale, color, textStyle);
00677     break;
00678   case CG_TEAM_COLOR:
00679     CG_DrawTeamColor(&rect, color);
00680     break;
00681   case CG_CTF_POWERUP:
00682     CG_DrawCTFPowerUp(&rect);
00683     break;
00684   case CG_AREA_POWERUP:
00685                 CG_DrawAreaPowerUp(&rect, align, special, scale, color);
00686     break;
00687   case CG_PLAYER_STATUS:
00688     CG_DrawPlayerStatus(&rect);
00689     break;
00690   case CG_PLAYER_HASFLAG:
00691     CG_DrawPlayerHasFlag(&rect, qfalse);
00692     break;
00693   case CG_PLAYER_HASFLAG2D:
00694     CG_DrawPlayerHasFlag(&rect, qtrue);
00695     break;
00696   case CG_AREA_SYSTEMCHAT:
00697     CG_DrawAreaSystemChat(&rect, scale, color, shader);
00698     break;
00699   case CG_AREA_TEAMCHAT:
00700     CG_DrawAreaTeamChat(&rect, scale, color, shader);
00701     break;
00702   case CG_AREA_CHAT:
00703     CG_DrawAreaChat(&rect, scale, color, shader);
00704     break;
00705   case CG_GAME_TYPE:
00706     CG_DrawGameType(&rect, scale, color, shader, textStyle);
00707     break;
00708   case CG_GAME_STATUS:
00709     CG_DrawGameStatus(&rect, scale, color, shader, textStyle);
00710                 break;
00711   case CG_KILLER:
00712     CG_DrawKiller(&rect, scale, color, shader, textStyle);
00713                 break;
00714         case CG_ACCURACY:
00715         case CG_ASSISTS:
00716         case CG_DEFEND:
00717         case CG_EXCELLENT:
00718         case CG_IMPRESSIVE:
00719         case CG_PERFECT:
00720         case CG_GAUNTLET:
00721         case CG_CAPTURES:
00722                 CG_DrawMedal(ownerDraw, &rect, scale, color, shader);
00723                 break;
00724   case CG_SPECTATORS:
00725                 CG_DrawTeamSpectators(&rect, scale, color, shader);
00726                 break;
00727   case CG_TEAMINFO:
00728                 if (cg_currentSelectedPlayer.integer == numSortedTeamPlayers) {
00729                         CG_DrawNewTeamInfo(&rect, text_x, text_y, scale, color, shader);
00730                 }
00731                 break;
00732   case CG_CAPFRAGLIMIT:
00733     CG_DrawCapFragLimit(&rect, scale, color, shader, textStyle);
00734                 break;
00735   case CG_1STPLACE:
00736     CG_Draw1stPlace(&rect, scale, color, shader, textStyle);
00737                 break;
00738   case CG_2NDPLACE:
00739     CG_Draw2ndPlace(&rect, scale, color, shader, textStyle);
00740                 break;
00741   default:
00742     break;
00743   }
00744 #endif
00745 }
00746 
00747 void CG_MouseEvent(int x, int y) {
00748         int n;
00749 
00750         if ( (cg.predictedPlayerState.pm_type == PM_NORMAL || cg.predictedPlayerState.pm_type == PM_JETPACK || cg.predictedPlayerState.pm_type == PM_FLOAT || cg.predictedPlayerState.pm_type == PM_SPECTATOR) && cg.showScores == qfalse) {
00751     trap_Key_SetCatcher(0);
00752                 return;
00753         }
00754 
00755         cgs.cursorX+= x;
00756         if (cgs.cursorX < 0)
00757                 cgs.cursorX = 0;
00758         else if (cgs.cursorX > 640)
00759                 cgs.cursorX = 640;
00760 
00761         cgs.cursorY += y;
00762         if (cgs.cursorY < 0)
00763                 cgs.cursorY = 0;
00764         else if (cgs.cursorY > 480)
00765                 cgs.cursorY = 480;
00766 
00767         n = Display_CursorType(cgs.cursorX, cgs.cursorY);
00768         cgs.activeCursor = 0;
00769         if (n == CURSOR_ARROW) {
00770                 cgs.activeCursor = cgs.media.selectCursor;
00771         } else if (n == CURSOR_SIZER) {
00772                 cgs.activeCursor = cgs.media.sizeCursor;
00773         }
00774 
00775   if (cgs.capturedItem) {
00776           Display_MouseMove(cgs.capturedItem, x, y);
00777   } else {
00778           Display_MouseMove(NULL, cgs.cursorX, cgs.cursorY);
00779   }
00780 
00781 }
00782 
00783 /*
00784 ==================
00785 CG_HideTeamMenus
00786 ==================
00787 
00788 */
00789 void CG_HideTeamMenu() {
00790   Menus_CloseByName("teamMenu");
00791   Menus_CloseByName("getMenu");
00792 }
00793 
00794 /*
00795 ==================
00796 CG_ShowTeamMenus
00797 ==================
00798 
00799 */
00800 void CG_ShowTeamMenu() {
00801   Menus_OpenByName("teamMenu");
00802 }
00803 
00804 
00805 
00806 
00807 /*
00808 ==================
00809 CG_EventHandling
00810 ==================
00811  type 0 - no event handling
00812       1 - team menu
00813       2 - hud editor
00814 
00815 */
00816 void CG_EventHandling(int type) {
00817         cgs.eventHandling = type;
00818   if (type == CGAME_EVENT_NONE) {
00819     CG_HideTeamMenu();
00820   } else if (type == CGAME_EVENT_TEAMMENU) {
00821     //CG_ShowTeamMenu();
00822   } else if (type == CGAME_EVENT_SCOREBOARD) {
00823   }
00824 
00825 }
00826 
00827 
00828 
00829 void CG_KeyEvent(int key, qboolean down) {
00830 
00831         if (!down) {
00832                 return;
00833         }
00834 
00835         if ( cg.predictedPlayerState.pm_type == PM_NORMAL || cg.predictedPlayerState.pm_type == PM_JETPACK || cg.predictedPlayerState.pm_type == PM_NORMAL || (cg.predictedPlayerState.pm_type == PM_SPECTATOR && cg.showScores == qfalse)) {
00836                 CG_EventHandling(CGAME_EVENT_NONE);
00837     trap_Key_SetCatcher(0);
00838                 return;
00839         }
00840 
00841   //if (key == trap_Key_GetKey("teamMenu") || !Display_CaptureItem(cgs.cursorX, cgs.cursorY)) {
00842     // if we see this then we should always be visible
00843   //  CG_EventHandling(CGAME_EVENT_NONE);
00844   //  trap_Key_SetCatcher(0);
00845   //}
00846 
00847 
00848 
00849   Display_HandleKey(key, down, cgs.cursorX, cgs.cursorY);
00850 
00851         if (cgs.capturedItem) {
00852                 cgs.capturedItem = NULL;
00853         }       else {
00854                 if (key == A_MOUSE2 && down) {
00855                         cgs.capturedItem = Display_CaptureItem(cgs.cursorX, cgs.cursorY);
00856                 }
00857         }
00858 }
00859 
00860 int CG_ClientNumFromName(const char *p) {
00861   int i;
00862   for (i = 0; i < cgs.maxclients; i++) {
00863     if (cgs.clientinfo[i].infoValid && Q_stricmp(cgs.clientinfo[i].name, p) == 0) {
00864       return i;
00865     }
00866   }
00867   return -1;
00868 }
00869 
00870 void CG_ShowResponseHead(void) {
00871   Menus_OpenByName("voiceMenu");
00872         trap_Cvar_Set("cl_conXOffset", "72");
00873         cg.voiceTime = cg.time;
00874 }
00875 
00876 void CG_RunMenuScript(char **args) {
00877 }
00878 
00879 qboolean CG_DeferMenuScript (char **args) 
00880 {
00881         return qfalse;
00882 }
00883 
00884 void CG_GetTeamColor(vec4_t *color) {
00885   if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED) {
00886     (*color)[0] = 1.0f;
00887     (*color)[3] = 0.25f;
00888     (*color)[1] = (*color)[2] = 0.0f;
00889   } else if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE) {
00890     (*color)[0] = (*color)[1] = 0.0f;
00891     (*color)[2] = 1.0f;
00892     (*color)[3] = 0.25f;
00893   } else {
00894     (*color)[0] = (*color)[2] = 0.0f;
00895     (*color)[1] = 0.17f;
00896     (*color)[3] = 0.25f;
00897         }
00898 }
00899