/* ================ SCR_ExecuteLayoutString ================ */ void SCR_ExecuteLayoutString (char *s) { int x, y; int value; char *token; int width; int index; clientinfo_t *ci; if (cls.state != ca_active || !cl.refresh_prepped) return; if (!s[0]) return; x = 0; y = 0; width = 3; while (s) { token = COM_Parse (&s); if (!strcmp(token, "xl")) { token = COM_Parse (&s); x = atoi(token); continue; } if (!strcmp(token, "xr")) { token = COM_Parse (&s); x = viddef.width + atoi(token); continue; } if (!strcmp(token, "xv")) { token = COM_Parse (&s); x = viddef.width/2 - 160 + atoi(token); continue; } if (!strcmp(token, "yt")) { token = COM_Parse (&s); y = atoi(token); continue; } if (!strcmp(token, "yb")) { token = COM_Parse (&s); y = viddef.height + atoi(token); continue; } if (!strcmp(token, "yv")) { token = COM_Parse (&s); y = viddef.height/2 - 120 + atoi(token); continue; } if (!strcmp(token, "pic")) { // draw a pic from a stat number token = COM_Parse (&s); value = cl.frame.playerstate.stats[atoi(token)]; if (value >= MAX_IMAGES) Com_Error (ERR_DROP, "Pic >= MAX_IMAGES"); if (cl.configstrings[CS_IMAGES+value]) { SCR_AddDirtyPoint (x, y); SCR_AddDirtyPoint (x+23, y+23); re.DrawPic (x, y, cl.configstrings[CS_IMAGES+value]); } continue; } if (!strcmp(token, "client")) { // draw a deathmatch client block int score, ping, time; token = COM_Parse (&s); x = viddef.width/2 - 160 + atoi(token); token = COM_Parse (&s); y = viddef.height/2 - 120 + atoi(token); SCR_AddDirtyPoint (x, y); SCR_AddDirtyPoint (x+159, y+31); token = COM_Parse (&s); value = atoi(token); if (value >= MAX_CLIENTS || value < 0) Com_Error (ERR_DROP, "client >= MAX_CLIENTS"); ci = &cl.clientinfo[value]; token = COM_Parse (&s); score = atoi(token); token = COM_Parse (&s); ping = atoi(token); token = COM_Parse (&s); time = atoi(token); DrawAltString (x+32, y, ci->name); #if defined (__APPLE__) || defined (MACOSX) Con_DrawString (x+32, y+8, "Score: "); #else DrawString (x+32, y+8, "Score: "); #endif /* __APPLE__ || MACOSX */ DrawAltString (x+32+7*8, y+8, va("%i", score)); #if defined (__APPLE__) || defined (MACOSX) Con_DrawString (x+32, y+16, va("Ping: %i", ping)); Con_DrawString (x+32, y+24, va("Time: %i", time)); #else DrawString (x+32, y+16, va("Ping: %i", ping)); DrawString (x+32, y+24, va("Time: %i", time)); #endif /* __APPLE__ || MACOSX */ if (!ci->icon) ci = &cl.baseclientinfo; re.DrawPic (x, y, ci->iconname); continue; } if (!strcmp(token, "ctf")) { // draw a ctf client block int score, ping; char block[80]; token = COM_Parse (&s); x = viddef.width/2 - 160 + atoi(token); token = COM_Parse (&s); y = viddef.height/2 - 120 + atoi(token); SCR_AddDirtyPoint (x, y); SCR_AddDirtyPoint (x+159, y+31); token = COM_Parse (&s); value = atoi(token); if (value >= MAX_CLIENTS || value < 0) Com_Error (ERR_DROP, "client >= MAX_CLIENTS"); ci = &cl.clientinfo[value]; token = COM_Parse (&s); score = atoi(token); token = COM_Parse (&s); ping = atoi(token); if (ping > 999) ping = 999; #if defined (__APPLE__) || defined (MACOSX) snprintf(block, 80, "%3d %3d %-12.12s", score, ping, ci->name); #else sprintf(block, "%3d %3d %-12.12s", score, ping, ci->name); #endif /* __APPLE__ || MACOSX */ if (value == cl.playernum) DrawAltString (x, y, block); else #if defined (__APPLE__) || defined (MACOSX) Con_DrawString (x, y, block); #else DrawString (x, y, block); #endif /* __APPLE__ ||ÊMACOSX */ continue; } if (!strcmp(token, "picn")) { // draw a pic from a name token = COM_Parse (&s); SCR_AddDirtyPoint (x, y); SCR_AddDirtyPoint (x+23, y+23); re.DrawPic (x, y, token); continue; } if (!strcmp(token, "num")) { // draw a number token = COM_Parse (&s); width = atoi(token); token = COM_Parse (&s); value = cl.frame.playerstate.stats[atoi(token)]; SCR_DrawField (x, y, 0, width, value); continue; } if (!strcmp(token, "hnum")) { // health number int color; width = 3; value = cl.frame.playerstate.stats[STAT_HEALTH]; if (value > 25) color = 0; // green else if (value > 0) color = (cl.frame.serverframe>>2) & 1; // flash else color = 1; if (cl.frame.playerstate.stats[STAT_FLASHES] & 1) re.DrawPic (x, y, "field_3"); SCR_DrawField (x, y, color, width, value); continue; }
void SCR_ExecuteLayoutString(char *s) { int x, y; int value; char *token; int width; int index; clientinfo_t *ci; if ((cls.state != ca_active) || !cl.refresh_prepped) { return; } if (!s[0]) { return; } x = 0; y = 0; while (s) { token = COM_Parse(&s); if (!strcmp(token, "xl")) { token = COM_Parse(&s); x = (int)strtol(token, (char **)NULL, 10); continue; } if (!strcmp(token, "xr")) { token = COM_Parse(&s); x = viddef.width + (int)strtol(token, (char **)NULL, 10); continue; } if (!strcmp(token, "xv")) { token = COM_Parse(&s); x = viddef.width / 2 - 160 + (int)strtol(token, (char **)NULL, 10); continue; } if (!strcmp(token, "yt")) { token = COM_Parse(&s); y = (int)strtol(token, (char **)NULL, 10); continue; } if (!strcmp(token, "yb")) { token = COM_Parse(&s); y = viddef.height + (int)strtol(token, (char **)NULL, 10); continue; } if (!strcmp(token, "yv")) { token = COM_Parse(&s); y = viddef.height / 2 - 120 + (int)strtol(token, (char **)NULL, 10); continue; } if (!strcmp(token, "pic")) { /* draw a pic from a stat number */ token = COM_Parse(&s); index = (int)strtol(token, (char **)NULL, 10); if ((index < 0) || (index >= sizeof(cl.frame.playerstate.stats))) { Com_Error(ERR_DROP, "bad stats index %d (0x%x)", index, index); } value = cl.frame.playerstate.stats[index]; if (value >= MAX_IMAGES) { Com_Error(ERR_DROP, "Pic >= MAX_IMAGES"); } if (cl.configstrings[CS_IMAGES + value]) { SCR_AddDirtyPoint(x, y); SCR_AddDirtyPoint(x + 23, y + 23); Draw_Pic(x, y, cl.configstrings[CS_IMAGES + value]); } continue; } if (!strcmp(token, "client")) { /* draw a deathmatch client block */ int score, ping, time; token = COM_Parse(&s); x = viddef.width / 2 - 160 + (int)strtol(token, (char **)NULL, 10); token = COM_Parse(&s); y = viddef.height / 2 - 120 + (int)strtol(token, (char **)NULL, 10); SCR_AddDirtyPoint(x, y); SCR_AddDirtyPoint(x + 159, y + 31); token = COM_Parse(&s); value = (int)strtol(token, (char **)NULL, 10); if ((value >= MAX_CLIENTS) || (value < 0)) { Com_Error(ERR_DROP, "client >= MAX_CLIENTS"); } ci = &cl.clientinfo[value]; token = COM_Parse(&s); score = (int)strtol(token, (char **)NULL, 10); token = COM_Parse(&s); ping = (int)strtol(token, (char **)NULL, 10); token = COM_Parse(&s); time = (int)strtol(token, (char **)NULL, 10); DrawAltString(x + 32, y, ci->name); DrawString(x + 32, y + 8, "Score: "); DrawAltString(x + 32 + 7 * 8, y + 8, va("%i", score)); DrawString(x + 32, y + 16, va("Ping: %i", ping)); DrawString(x + 32, y + 24, va("Time: %i", time)); if (!ci->icon) { ci = &cl.baseclientinfo; } Draw_Pic(x, y, ci->iconname); continue; } if (!strcmp(token, "ctf")) { /* draw a ctf client block */ int score, ping; char block[80]; token = COM_Parse(&s); x = viddef.width / 2 - 160 + (int)strtol(token, (char **)NULL, 10); token = COM_Parse(&s); y = viddef.height / 2 - 120 + (int)strtol(token, (char **)NULL, 10); SCR_AddDirtyPoint(x, y); SCR_AddDirtyPoint(x + 159, y + 31); token = COM_Parse(&s); value = (int)strtol(token, (char **)NULL, 10); if ((value >= MAX_CLIENTS) || (value < 0)) { Com_Error(ERR_DROP, "client >= MAX_CLIENTS"); } ci = &cl.clientinfo[value]; token = COM_Parse(&s); score = (int)strtol(token, (char **)NULL, 10); token = COM_Parse(&s); ping = (int)strtol(token, (char **)NULL, 10); if (ping > 999) { ping = 999; } sprintf(block, "%3d %3d %-12.12s", score, ping, ci->name); if (value == cl.playernum) { DrawAltString(x, y, block); } else { DrawString(x, y, block); } continue; } if (!strcmp(token, "picn")) { /* draw a pic from a name */ token = COM_Parse(&s); SCR_AddDirtyPoint(x, y); SCR_AddDirtyPoint(x + 23, y + 23); Draw_Pic(x, y, (char *)token); continue; } if (!strcmp(token, "num")) { /* draw a number */ token = COM_Parse(&s); width = (int)strtol(token, (char **)NULL, 10); token = COM_Parse(&s); value = cl.frame.playerstate.stats[(int)strtol(token, (char **)NULL, 10)]; SCR_DrawField(x, y, 0, width, value); continue; } if (!strcmp(token, "hnum")) { /* health number */ int color; width = 3; value = cl.frame.playerstate.stats[STAT_HEALTH]; if (value > 25) { color = 0; /* green */ } else if (value > 0) { color = (cl.frame.serverframe >> 2) & 1; /* flash */ } else {