codemp/cgame/cg_newDraw.c File Reference

#include "cg_local.h"
#include "../ui/ui_shared.h"
#include "../namespace_begin.h"
#include "../namespace_end.h"

Go to the source code of this file.

Defines

#define PIC_WIDTH   12

Functions

int CG_GetSelectedPlayer ()
qhandle_t CG_StatusHandle (int task)
float CG_GetValue (int ownerDraw)
qboolean CG_OtherTeamHasFlag (void)
qboolean CG_YourTeamHasFlag (void)
qboolean CG_OwnerDrawVisible (int flags)
const char * CG_GetKillerText (void)
const char * CG_GetGameStatusText (void)
const char * CG_GameTypeString (void)
int MenuFontToHandle (int iMenuFont)
const char * CG_GetLocationString (const char *loc)
void CG_DrawNewTeamInfo (rectDef_t *rect, float text_x, float text_y, float scale, vec4_t color, qhandle_t shader)
void CG_DrawTeamSpectators (rectDef_t *rect, float scale, vec4_t color, qhandle_t shader)
void CG_DrawMedal (int ownerDraw, rectDef_t *rect, float scale, vec4_t color, qhandle_t shader)
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)
void CG_MouseEvent (int x, int y)
void CG_HideTeamMenu ()
void CG_ShowTeamMenu ()
void CG_EventHandling (int type)
void CG_KeyEvent (int key, qboolean down)
int CG_ClientNumFromName (const char *p)
void CG_ShowResponseHead (void)
void CG_RunMenuScript (char **args)
qboolean CG_DeferMenuScript (char **args)
void CG_GetTeamColor (vec4_t *color)

Variables

displayContextDef_t cgDC


Define Documentation

#define PIC_WIDTH   12
 

Definition at line 324 of file cg_newDraw.c.

Referenced by CG_DrawNewTeamInfo().


Function Documentation

int CG_ClientNumFromName const char *  p  ) 
 

Definition at line 860 of file cg_newDraw.c.

References cgs, cgs_t::clientinfo, clientInfo_t::infoValid, cgs_t::maxclients, clientInfo_t::name, and Q_stricmp().

00860                                         {
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 }

qboolean CG_DeferMenuScript char **  args  ) 
 

Definition at line 879 of file cg_newDraw.c.

References qboolean, and qfalse.

Referenced by CG_LoadHudMenu().

00880 {
00881         return qfalse;
00882 }

void CG_DrawMedal int  ownerDraw,
rectDef_t rect,
float  scale,
vec4_t  color,
qhandle_t  shader
 

Definition at line 496 of file cg_newDraw.c.

References score_t::accuracy, score_t::assistCount, score_t::captures, cg, CG_ACCURACY, CG_ASSISTS, CG_CAPTURES, CG_DEFEND, CG_DrawPic(), CG_EXCELLENT, CG_GAUNTLET, CG_IMPRESSIVE, CG_PERFECT, CG_Text_Paint(), CG_Text_Width(), score_t::defendCount, score_t::excellentCount, FONT_MEDIUM, score_t::guantletCount, rectDef_t::h, score_t::impressiveCount, NULL, score_t::perfect, qhandle_t, cg_t::scores, cg_t::selectedScore, trap_R_SetColor(), va(), vec4_t, rectDef_t::w, rectDef_t::x, and rectDef_t::y.

Referenced by CG_OwnerDraw().

00496                                                                                                {
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 }

void CG_DrawNewTeamInfo rectDef_t rect,
float  text_x,
float  text_y,
float  scale,
vec4_t  color,
qhandle_t  shader
 

Definition at line 327 of file cg_newDraw.c.

References clientInfo_t::armor, BG_FindItemForPowerup(), cg, CG_ConfigString(), CG_DrawPic(), CG_GetColorForHealth(), CG_GetLocationString(), CG_StatusHandle(), CG_Text_Width(), cg_weapons, cgs, cgs_t::clientinfo, CS_LOCATIONS, clientInfo_t::curWeapon, cgMedia_t::deferShader, FONT_MEDIUM, gitem_t, rectDef_t::h, clientInfo_t::health, cgMedia_t::heartShader, gitem_s::icon, clientInfo_t::infoValid, clientInfo_t::location, MAX_LOCATIONS, cgs_t::media, clientInfo_t::name, NULL, numSortedTeamPlayers, PERS_TEAM, playerState_s::persistant, PIC_WIDTH, clientInfo_t::powerups, snapshot_t::ps, PW_NUM_POWERUPS, qhandle_t, cg_t::snap, sortedTeamPlayers, clientInfo_t::team, clientInfo_t::teamTask, trap_R_RegisterShader(), trap_R_SetColor(), vec4_t, rectDef_t::w, rectDef_t::x, and rectDef_t::y.

Referenced by CG_OwnerDraw().

00327                                                                                                                   {
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 }

void CG_DrawTeamSpectators rectDef_t rect,
float  scale,
vec4_t  color,
qhandle_t  shader
 

Definition at line 437 of file cg_newDraw.c.

References cg, CG_Text_Width(), FONT_MEDIUM, rectDef_t::h, qhandle_t, cg_t::spectatorLen, cg_t::spectatorList, cg_t::spectatorOffset, cg_t::spectatorPaintX, cg_t::spectatorPaintX2, cg_t::spectatorTime, cg_t::spectatorWidth, cg_t::time, vec4_t, rectDef_t::w, rectDef_t::x, and rectDef_t::y.

Referenced by CG_OwnerDraw().

00437                                                                                          {
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 }

void CG_EventHandling int  type  ) 
 

Definition at line 816 of file cg_newDraw.c.

References CG_HideTeamMenu(), CGAME_EVENT_NONE, CGAME_EVENT_SCOREBOARD, CGAME_EVENT_TEAMMENU, cgs, and cgs_t::eventHandling.

Referenced by CG_KeyEvent(), and vmMain().

00816                                 {
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 }

const char* CG_GameTypeString void   ) 
 

Definition at line 242 of file cg_newDraw.c.

References cgs, cgs_t::gametype, GT_CTF, GT_CTY, GT_FFA, GT_HOLOCRON, GT_JEDIMASTER, GT_SIEGE, and GT_TEAM.

00242                                     {
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 }

const char* CG_GetGameStatusText void   ) 
 

Definition at line 213 of file cg_newDraw.c.

References cg, CG_GetStringEdString(), CG_PlaceString(), cgs, cgs_t::gametype, GT_POWERDUEL, GT_TEAM, PERS_RANK, PERS_SCORE, PERS_TEAM, playerState_s::persistant, snapshot_t::ps, cg_t::snap, TEAM_SPECTATOR, cg_t::teamScores, trap_SP_GetStringTextString(), and va().

00213                                        {
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 }

const char* CG_GetKillerText void   ) 
 

Definition at line 204 of file cg_newDraw.c.

References cg, CG_GetStringEdString(), cg_t::killerName, and va().

00204                                    {
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 }

const char* CG_GetLocationString const char *  loc  ) 
 

Definition at line 3936 of file cg_main.c.

References trap_SP_GetStringTextString().

Referenced by CG_DrawNewTeamInfo().

03937 {
03938         static char text[1024]={0};
03939 
03940         if (!loc || loc[0] != '@')
03941         { //just a raw string
03942                 return loc;
03943         }
03944 
03945         trap_SP_GetStringTextString(loc+1, text, sizeof(text));
03946         return text;
03947 }

int CG_GetSelectedPlayer  ) 
 

Definition at line 7 of file cg_newDraw.c.

References cg_currentSelectedPlayer, vmCvar_t::integer, and numSortedTeamPlayers.

Referenced by CG_GetValue().

void CG_GetTeamColor vec4_t color  ) 
 

Definition at line 884 of file cg_newDraw.c.

References cg, PERS_TEAM, playerState_s::persistant, snapshot_t::ps, cg_t::snap, TEAM_BLUE, TEAM_RED, and vec4_t.

Referenced by CG_LoadHudMenu().

00884                                     {
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 }

float CG_GetValue int  ownerDraw  ) 
 

Definition at line 46 of file cg_newDraw.c.

References playerState_s::ammo, clientInfo_t::armor, centity_t, cg, CG_BLUE_SCORE, cg_entities, CG_GetSelectedPlayer(), CG_PLAYER_AMMO_VALUE, CG_PLAYER_ARMOR_VALUE, CG_PLAYER_FORCE_VALUE, CG_PLAYER_HEALTH, CG_PLAYER_SCORE, CG_RED_SCORE, CG_SELECTEDPLAYER_ARMOR, CG_SELECTEDPLAYER_HEALTH, cgs, cgs_t::clientinfo, playerState_s::clientNum, centity_s::currentState, playerState_s::fd, forcedata_s::forcePower, clientInfo_t::health, PERS_SCORE, playerState_s::persistant, playerState_t, snapshot_t::ps, cgs_t::scores1, cgs_t::scores2, cg_t::snap, sortedTeamPlayers, STAT_ARMOR, STAT_HEALTH, playerState_s::stats, entityState_s::weapon, and weaponData.

Referenced by CG_LoadHudMenu().

00046                                  {
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 }

void CG_HideTeamMenu  ) 
 

Definition at line 789 of file cg_newDraw.c.

References Menus_CloseByName().

Referenced by CG_EventHandling().

00789                        {
00790   Menus_CloseByName("teamMenu");
00791   Menus_CloseByName("getMenu");
00792 }

void CG_KeyEvent int  key,
qboolean  down
 

Definition at line 829 of file cg_newDraw.c.

References A_MOUSE2, cgs_t::capturedItem, cg, CG_EventHandling(), CGAME_EVENT_NONE, cgs, cgs_t::cursorX, cgs_t::cursorY, Display_CaptureItem(), Display_HandleKey(), NULL, PM_JETPACK, PM_NORMAL, PM_SPECTATOR, playerState_s::pm_type, cg_t::predictedPlayerState, qfalse, cg_t::showScores, and trap_Key_SetCatcher().

Referenced by vmMain().

00829                                          {
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 }

void CG_MouseEvent int  x,
int  y
 

Definition at line 747 of file cg_newDraw.c.

References cgs_t::activeCursor, cgs_t::capturedItem, cg, cgs, CURSOR_ARROW, CURSOR_SIZER, cgs_t::cursorX, cgs_t::cursorY, Display_CursorType(), Display_MouseMove(), cgs_t::media, NULL, PM_FLOAT, PM_JETPACK, PM_NORMAL, PM_SPECTATOR, playerState_s::pm_type, cg_t::predictedPlayerState, qfalse, cgMedia_t::selectCursor, cg_t::showScores, cgMedia_t::sizeCursor, and trap_Key_SetCatcher().

Referenced by vmMain().

00747                                  {
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 }

qboolean CG_OtherTeamHasFlag void   ) 
 

Definition at line 93 of file cg_newDraw.c.

References cgs_t::blueflag, cg, cgs, FLAG_TAKEN, cgs_t::gametype, GT_CTF, GT_CTY, PERS_TEAM, playerState_s::persistant, snapshot_t::ps, qboolean, qfalse, qtrue, cgs_t::redflag, cg_t::snap, TEAM_BLUE, and TEAM_RED.

Referenced by CG_DrawFlagStatus(), and CG_OwnerDrawVisible().

00093                                    {
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 }

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
 

Definition at line 562 of file cg_newDraw.c.

References CG_1STPLACE, CG_2NDPLACE, CG_ACCURACY, CG_AREA_CHAT, CG_AREA_POWERUP, CG_AREA_SYSTEMCHAT, CG_AREA_TEAMCHAT, CG_ASSISTS, CG_BLUE_FLAGHEAD, CG_BLUE_FLAGNAME, CG_BLUE_FLAGSTATUS, CG_BLUE_NAME, CG_BLUE_SCORE, CG_CAPFRAGLIMIT, CG_CAPTURES, CG_CTF_POWERUP, cg_currentSelectedPlayer, CG_DEFEND, CG_DrawMedal(), CG_DrawNewTeamInfo(), cg_drawStatus, CG_DrawTeamSpectators(), CG_EXCELLENT, CG_GAME_STATUS, CG_GAME_TYPE, CG_GAUNTLET, CG_IMPRESSIVE, CG_KILLER, CG_PERFECT, CG_PLAYER_AMMO_ICON, CG_PLAYER_AMMO_ICON2D, CG_PLAYER_AMMO_VALUE, CG_PLAYER_ARMOR_ICON, CG_PLAYER_ARMOR_ICON2D, CG_PLAYER_ARMOR_VALUE, CG_PLAYER_FORCE_VALUE, CG_PLAYER_HASFLAG, CG_PLAYER_HASFLAG2D, CG_PLAYER_HEAD, CG_PLAYER_HEALTH, CG_PLAYER_ITEM, CG_PLAYER_LOCATION, CG_PLAYER_SCORE, CG_PLAYER_STATUS, CG_RED_FLAGHEAD, CG_RED_FLAGNAME, CG_RED_FLAGSTATUS, CG_RED_NAME, CG_RED_SCORE, CG_SELECTEDPLAYER_ARMOR, CG_SELECTEDPLAYER_HEAD, CG_SELECTEDPLAYER_HEALTH, CG_SELECTEDPLAYER_LOCATION, CG_SELECTEDPLAYER_NAME, CG_SELECTEDPLAYER_POWERUP, CG_SELECTEDPLAYER_STATUS, CG_SELECTEDPLAYER_WEAPON, CG_SHOW_2DONLY, CG_SPECTATORS, CG_TEAM_COLOR, CG_TEAMINFO, CG_VOICE_HEAD, CG_VOICE_NAME, rectDef_t::h, vmCvar_t::integer, numSortedTeamPlayers, qfalse, qhandle_t, qtrue, vec4_t, rectDef_t::w, rectDef_t::x, and rectDef_t::y.

Referenced by CG_LoadHudMenu().

00562                                                                                                                                                                                                                     {
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 }

qboolean CG_OwnerDrawVisible int  flags  ) 
 

Definition at line 123 of file cg_newDraw.c.

References cgs_t::blueflag, cg, cg_currentSelectedPlayer, CG_OtherTeamHasFlag(), CG_SHOW_ANYNONTEAMGAME, CG_SHOW_ANYTEAMGAME, CG_SHOW_BLUE_TEAM_HAS_REDFLAG, CG_SHOW_CTF, CG_SHOW_DURINGINCOMINGVOICE, CG_SHOW_HEALTHCRITICAL, CG_SHOW_HEALTHOK, CG_SHOW_IF_PLAYER_HAS_FLAG, CG_SHOW_NOTEAMINFO, CG_SHOW_OTHERTEAMHASFLAG, CG_SHOW_RED_TEAM_HAS_BLUEFLAG, CG_SHOW_SINGLEPLAYER, CG_SHOW_TEAMINFO, CG_SHOW_TOURNAMENT, CG_SHOW_YOURTEAMHASENEMYFLAG, CG_YourTeamHasFlag(), cgs, FLAG_TAKEN, FLAG_TAKEN_BLUE, FLAG_TAKEN_RED, cgs_t::flagStatus, cgs_t::gametype, GT_CTF, GT_CTY, GT_DUEL, GT_POWERDUEL, GT_SINGLE_PLAYER, GT_TEAM, vmCvar_t::integer, numSortedTeamPlayers, playerState_s::powerups, snapshot_t::ps, PW_BLUEFLAG, PW_NEUTRALFLAG, PW_REDFLAG, qboolean, qfalse, qtrue, cgs_t::redflag, cg_t::snap, STAT_HEALTH, and playerState_s::stats.

Referenced by CG_LoadHudMenu().

00123                                         {
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 }

void CG_RunMenuScript char **  args  ) 
 

Definition at line 876 of file cg_newDraw.c.

Referenced by CG_LoadHudMenu().

00876                                    {
00877 }

void CG_ShowResponseHead void   ) 
 

Definition at line 870 of file cg_newDraw.c.

References cg, Menus_OpenByName(), cg_t::time, trap_Cvar_Set(), and cg_t::voiceTime.

00870                                {
00871   Menus_OpenByName("voiceMenu");
00872         trap_Cvar_Set("cl_conXOffset", "72");
00873         cg.voiceTime = cg.time;
00874 }

void CG_ShowTeamMenu  ) 
 

Definition at line 800 of file cg_newDraw.c.

References Menus_OpenByName().

00800                        {
00801   Menus_OpenByName("teamMenu");
00802 }

qhandle_t CG_StatusHandle int  task  ) 
 

Definition at line 14 of file cg_newDraw.c.

References cgMedia_t::assaultShader, cgMedia_t::campShader, cgs, cgMedia_t::defendShader, cgMedia_t::escortShader, cgMedia_t::followShader, cgs_t::media, cgMedia_t::patrolShader, qhandle_t, cgMedia_t::retrieveShader, TEAMTASK_CAMP, TEAMTASK_DEFENSE, TEAMTASK_ESCORT, TEAMTASK_FOLLOW, TEAMTASK_OFFENSE, TEAMTASK_PATROL, and TEAMTASK_RETRIEVE.

Referenced by CG_DrawNewTeamInfo().

00014                                     {
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 }

qboolean CG_YourTeamHasFlag void   ) 
 

Definition at line 107 of file cg_newDraw.c.

References cgs_t::blueflag, cg, cgs, FLAG_TAKEN, cgs_t::gametype, GT_CTF, GT_CTY, PERS_TEAM, playerState_s::persistant, snapshot_t::ps, qboolean, qfalse, qtrue, cgs_t::redflag, cg_t::snap, TEAM_BLUE, and TEAM_RED.

Referenced by CG_DrawFlagStatus(), and CG_OwnerDrawVisible().

00107                                   {
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 }

int MenuFontToHandle int  iMenuFont  ) 
 

Definition at line 107 of file cg_draw.c.

00108 {
00109         switch (iMenuFont)
00110         {
00111                 case FONT_SMALL:        return cgDC.Assets.qhSmallFont;
00112                 case FONT_SMALL2:       return cgDC.Assets.qhSmall2Font;
00113                 case FONT_MEDIUM:       return cgDC.Assets.qhMediumFont;
00114                 case FONT_LARGE:        return cgDC.Assets.qhMediumFont;//cgDC.Assets.qhBigFont;
00115                         //fixme? Big fonr isn't registered...?
00116         }
00117 
00118         return cgDC.Assets.qhMediumFont;
00119 }


Variable Documentation

displayContextDef_t cgDC
 

Definition at line 4 of file cg_newDraw.c.