int CG_LimboPanel_RenderCounter_ValueForButton(panel_button_t *button) { int i, count = 0; switch (button->data[0]) { case 0: // class counts if (CG_LimboPanel_GetTeam() == TEAM_SPECTATOR || CG_LimboPanel_GetRealTeam() != CG_LimboPanel_GetTeam()) { return 0; // dont give class counts unless we are on that team (or spec) } for (i = 0; i < MAX_CLIENTS; ++i) { if (!cgs.clientinfo[i].infoValid) { continue; } if (cgs.clientinfo[i].team != CG_LimboPanel_GetTeam() || cgs.clientinfo[i].cls != button->data[1]) { continue; } count++; } return count; case 1: // team counts for (i = 0; i < MAX_CLIENTS; ++i) { if (!cgs.clientinfo[i].infoValid) { continue; } if (cgs.clientinfo[i].team != teamOrder[button->data[1]]) { continue; } count++; } return count; case 4: // skills return (1 << count) - 1; default: break; } return 0; }
qboolean CG_CommandCentreSpawnPointClick(void) { int i; vec2_t point; if (cgs.ccFilter & CC_FILTER_SPAWNS) { return qfalse; } for (i = 1; i < cg.spawnCount; i++) { if ((cgs.clientinfo[cg.clientNum].team != TEAM_SPECTATOR) && cg.spawnTeams[i] && cg.spawnTeams[i] != CG_LimboPanel_GetRealTeam()) { continue; } if (cg.spawnTeams[i] & 256) { continue; } if (cgs.ccLayers) { if (CG_CurLayerForZ((int)cg.spawnCoords[i][2]) != cgs.ccSelectedLayer) { continue; } } point[0] = cg.spawnCoords[i][0]; point[1] = cg.spawnCoords[i][1]; if (BG_RectContainsPoint((point[0] - FLAGSIZE_NORMAL * 0.5f) + cgs.wideXoffset, point[1] - FLAGSIZE_NORMAL * 0.5f, FLAGSIZE_NORMAL, FLAGSIZE_NORMAL, cgDC.cursorx, cgDC.cursory)) { trap_SendConsoleCommand(va("setspawnpt %i\n", i)); cg.selectedSpawnPoint = i; cgs.ccRequestedObjective = -1; return qtrue; } } return qfalse; }
void CG_DrawMap(float x, float y, float w, float h, int mEntFilter, mapScissor_t *scissor, qboolean interactive, float alpha, qboolean borderblend) { int i; snapshot_t *snap; mapEntityData_t *mEnt = &mapEntities[0]; int icon_size; int exspawn = qfalse; if (cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport) { snap = cg.nextSnap; } else { snap = cg.snap; } if (scissor) { //icon_size = AUTOMAP_PLAYER_ICON_SIZE; icon_size = h / 26; if (icon_size < 4) { icon_size = 4; } if (scissor->br[0] >= scissor->tl[0]) { float s0, s1, t0, t1; float sc_x = x, sc_y = y, sc_w = w, sc_h = h; CG_DrawPic(sc_x, sc_y, sc_w, sc_h, cgs.media.commandCentreAutomapMaskShader); s0 = (scissor->tl[0]) / (w * scissor->zoomFactor); s1 = (scissor->br[0]) / (w * scissor->zoomFactor); t0 = (scissor->tl[1]) / (h * scissor->zoomFactor); t1 = (scissor->br[1]) / (h * scissor->zoomFactor); CG_AdjustFrom640(&sc_x, &sc_y, &sc_w, &sc_h); if (cgs.ccLayers) { trap_R_DrawStretchPic(sc_x, sc_y, sc_w, sc_h, s0, t0, s1, t1, cgs.media.commandCentreAutomapShader[cgs.ccSelectedLayer]); } else { trap_R_DrawStretchPic(sc_x, sc_y, sc_w, sc_h, s0, t0, s1, t1, cgs.media.commandCentreAutomapShader[0]); } trap_R_DrawStretchPic(0, 0, 0, 0, 0, 0, 0, 0, cgs.media.whiteShader); // HACK : the code above seems to do weird things to // the next trap_R_DrawStretchPic issued. This works // around this. } // Draw the grid //CG_DrawGrid(x, y, w, h, scissor); } else { vec4_t color; icon_size = COMMANDMAP_PLAYER_ICON_SIZE; Vector4Set(color, 1.f, 1.f, 1.f, alpha); trap_R_SetColor(color); if (cgs.ccLayers) { CG_DrawPic(x, y, w, h, cgs.media.commandCentreMapShaderTrans[cgs.ccSelectedLayer]); } else { CG_DrawPic(x, y, w, h, cgs.media.commandCentreMapShaderTrans[0]); } trap_R_SetColor(NULL); // Draw the grid CG_DrawGrid(x, y, w, h, NULL); } if (borderblend) { vec4_t clr = { 0.f, 0.f, 0.f, 0.75f }; trap_R_SetColor(clr); CG_DrawPic(x, y, w, h, cgs.media.limboBlendThingy); trap_R_SetColor(NULL); } exspawn = CG_DrawSpawnPointInfo(x, y, w, h, qfalse, scissor, -1); for (i = 0, mEnt = &mapEntities[0]; i < mapEntityCount; i++, mEnt++) { if (mEnt->team != CG_LimboPanel_GetRealTeam()) { continue; } if (mEnt->type == ME_PLAYER || mEnt->type == ME_PLAYER_DISGUISED || mEnt->type == ME_PLAYER_REVIVE) { continue; } CG_DrawMapEntity(mEnt, x, y, w, h, mEntFilter, scissor, interactive, snap, icon_size); } CG_DrawSpawnPointInfo(x, y, w, h, qtrue, scissor, exspawn); CG_DrawMortarMarker(x, y, w, h, qtrue, scissor, exspawn); for (i = 0, mEnt = &mapEntities[0]; i < mapEntityCount; i++, mEnt++) { if (mEnt->team != CG_LimboPanel_GetRealTeam()) { continue; } if (mEnt->type != ME_PLAYER && mEnt->type != ME_PLAYER_DISGUISED && mEnt->type != ME_PLAYER_REVIVE) { continue; } CG_DrawMapEntity(mEnt, x, y, w, h, mEntFilter, scissor, interactive, snap, icon_size); } }
int CG_DrawSpawnPointInfo(int px, int py, int pw, int ph, qboolean draw, mapScissor_t *scissor, int expand) { int i; char buffer[64]; vec2_t point; int e = -1; vec2_t icon_extends; team_t team = CG_LimboPanel_GetRealTeam(); if (cgs.ccFilter & CC_FILTER_SPAWNS) { return -1; } for (i = 1; i < cg.spawnCount; i++) { float changetime = 0; if (cg.spawnTeams_changeTime[i]) { changetime = (cg.time - cg.spawnTeams_changeTime[i]); if (changetime > SPAWN_SIZEUPTIME || changetime < 0) { changetime = cg.spawnTeams_changeTime[i] = 0; } } // added parens around ambiguity if (((cgs.clientinfo[cg.clientNum].team != TEAM_SPECTATOR) && (cg.spawnTeams[i] != team)) || ((cg.spawnTeams[i] & 256) && !changetime)) { continue; } if (cgs.ccLayers) { if (CG_CurLayerForZ((int)cg.spawnCoords[i][2]) != cgs.ccSelectedLayer) { break; } } if (scissor) { point[0] = ((cg.spawnCoordsUntransformed[i][0] - cg.mapcoordsMins[0]) * cg.mapcoordsScale[0]) * pw * scissor->zoomFactor; point[1] = ((cg.spawnCoordsUntransformed[i][1] - cg.mapcoordsMins[1]) * cg.mapcoordsScale[1]) * ph * scissor->zoomFactor; } else { point[0] = px + (((cg.spawnCoordsUntransformed[i][0] - cg.mapcoordsMins[0]) * cg.mapcoordsScale[0]) * pw); point[1] = py + (((cg.spawnCoordsUntransformed[i][1] - cg.mapcoordsMins[1]) * cg.mapcoordsScale[1]) * ph); } if (scissor && CG_ScissorPointIsCulled(point, scissor)) { continue; } if (scissor) { point[0] += px - scissor->tl[0]; point[1] += py - scissor->tl[1]; } icon_extends[0] = FLAGSIZE_NORMAL; icon_extends[1] = FLAGSIZE_NORMAL; if (scissor) { icon_extends[0] *= (scissor->zoomFactor / 5.159); icon_extends[1] *= (scissor->zoomFactor / 5.159); } else { icon_extends[0] *= cgs.ccZoomFactor; icon_extends[1] *= cgs.ccZoomFactor; } point[0] -= (icon_extends[0] * (39 / 128.f)); point[1] += (icon_extends[1] * (31 / 128.f)); if (changetime) { if (draw) { float size; if (cg.spawnTeams[i] == team) { size = 20 * (changetime / SPAWN_SIZEUPTIME); } else { size = 20 * (1 - (changetime / SPAWN_SIZEUPTIME)); } if (scissor) { size *= (scissor->zoomFactor / 5.159); } else { size *= cgs.ccZoomFactor; } CG_DrawPic(point[0] - FLAG_LEFTFRAC * size, point[1] - FLAG_TOPFRAC * size, size, size, cgs.media.commandCentreSpawnShader[cg.spawnTeams[i] == TEAM_AXIS ? 0 : 1]); } } else if ((draw && i == expand) || (!expanded && BG_RectContainsPoint(point[0] - FLAGSIZE_NORMAL * 0.5f, point[1] - FLAGSIZE_NORMAL * 0.5f, FLAGSIZE_NORMAL, FLAGSIZE_NORMAL, cgDC.cursorx, cgDC.cursory))) { if (draw) { float size = FLAGSIZE_EXPANDED; if (scissor) { size *= (scissor->zoomFactor / 5.159); } else { size *= cgs.ccZoomFactor; } CG_DrawPic(point[0] - FLAG_LEFTFRAC * size, point[1] - FLAG_TOPFRAC * size, size, size, cgs.media.commandCentreSpawnShader[cg.spawnTeams[i] == TEAM_AXIS ? 0 : 1]); } else { if (!scissor) { float w; Com_sprintf(buffer, sizeof(buffer), "%s (Troops: %i)", cg.spawnPoints[i], cg.spawnPlayerCounts[i]); w = CG_Text_Width_Ext(buffer, 0.2f, 0, &cgs.media.limboFont2); CG_CommandMap_SetHighlightText(buffer, point[0] - (w * 0.5f), point[1] - 8); } e = i; } } else { if (draw) { float size = FLAGSIZE_NORMAL; if (scissor) { size *= (scissor->zoomFactor / 5.159); } else { size *= cgs.ccZoomFactor; } CG_DrawPic(point[0] - FLAG_LEFTFRAC * size, point[1] - FLAG_TOPFRAC * size, size, size, cgs.media.commandCentreSpawnShader[cg.spawnTeams[i] == TEAM_AXIS ? 0 : 1]); if (!scissor) { Com_sprintf(buffer, sizeof(buffer), "(Troops: %i)", cg.spawnPlayerCounts[i]); CG_Text_Paint_Ext(point[0] + FLAGSIZE_NORMAL * 0.25f, point[1], 0.2f, 0.2f, colorWhite, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2); } } } } return e; }
void CG_DrawMap(float x, float y, float w, float h, int mEntFilter, mapScissor_t *scissor, qboolean interactive, float alpha, qboolean borderblend) { int i; snapshot_t *snap; mapEntityData_t *mEnt = &mapEntities[0]; int icon_size; int exspawn; team_t RealTeam = CG_LimboPanel_GetRealTeam(); expanded = qfalse; if (cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport) { snap = cg.nextSnap; } else { snap = cg.snap; } if (scissor) { icon_size = AUTOMAP_PLAYER_ICON_SIZE; if (scissor->br[0] >= scissor->tl[0]) { float s0, s1, t0, t1; float sc_x = x, sc_y = y, sc_w = w, sc_h = h; CG_DrawPic(sc_x, sc_y, sc_w, sc_h, cgs.media.commandCentreAutomapMaskShader); s0 = (scissor->tl[0]) / (w * scissor->zoomFactor); s1 = (scissor->br[0]) / (w * scissor->zoomFactor); t0 = (scissor->tl[1]) / (h * scissor->zoomFactor); t1 = (scissor->br[1]) / (h * scissor->zoomFactor); CG_AdjustFrom640(&sc_x, &sc_y, &sc_w, &sc_h); if (cgs.ccLayers) { trap_R_DrawStretchPic(sc_x, sc_y, sc_w, sc_h, s0, t0, s1, t1, cgs.media.commandCentreAutomapShader[cgs.ccSelectedLayer]); } else { trap_R_DrawStretchPic(sc_x, sc_y, sc_w, sc_h, s0, t0, s1, t1, cgs.media.commandCentreAutomapShader[0]); } // FIXME: the code above seems to do weird things to the next trap_R_DrawStretchPic issued. // This hack works around this. trap_R_DrawStretchPic(0, 0, 0, 0, 0, 0, 0, 0, cgs.media.whiteShader); } // Draw the grid CG_DrawGrid(x, y, w, h, scissor); } else { vec4_t color; icon_size = COMMANDMAP_PLAYER_ICON_SIZE; Vector4Set(color, 1.f, 1.f, 1.f, alpha); trap_R_SetColor(color); CG_DrawPic(x, y, w, h, cgs.media.blackmask); if (cgs.ccLayers) { CG_DrawPic(x, y, w, h, cgs.media.commandCentreMapShaderTrans[cgs.ccSelectedLayer]); } else { CG_DrawPic(x, y, w, h, cgs.media.commandCentreMapShaderTrans[0]); } trap_R_SetColor(NULL); // Draw the grid CG_DrawGrid(x, y, w, h, NULL); } if (borderblend) { trap_R_SetColor(clrBorderblend); CG_DrawPic(x, y, w, h, cgs.media.limboBlendThingy); trap_R_SetColor(NULL); } exspawn = CG_DrawSpawnPointInfo(x, y, w, h, qfalse, scissor, -1); // entnfo data for (i = 0, mEnt = &mapEntities[0]; i < mapEntityCount; ++i, ++mEnt) { // spectators can see icons of both teams if ((interactive && mEnt->team != RealTeam) || (mEnt->team != snap->ps.persistant[PERS_TEAM] && snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR)) { goto CG_DrawMap_check; } if (mEnt->type == ME_PLAYER || mEnt->type == ME_PLAYER_DISGUISED || mEnt->type == ME_PLAYER_OBJECTIVE || mEnt->type == ME_PLAYER_REVIVE) { goto CG_DrawMap_check; } goto CG_DrawMap_draw; CG_DrawMap_check: if (mEnt->team != RealTeam && !CG_DisguiseMapCheck(mEnt)) { continue; } if (mEnt->type != ME_PLAYER && mEnt->type != ME_PLAYER_DISGUISED && mEnt->type != ME_PLAYER_OBJECTIVE && mEnt->type != ME_PLAYER_REVIVE) { continue; } CG_DrawMap_draw: CG_DrawMapEntity(mEnt, x, y, w, h, mEntFilter, scissor, interactive, snap, icon_size); } // entnfo2 data, draw non-players & non-tanks //for(i = 0, mEnt = &mapEntities2[0]; i < mapEntityCount2; ++i, ++mEnt ) { // CG_DrawMapEntity( mEnt, x, y, w, h, mEntFilter, scissor, interactive, snap, icon_size ); //} CG_DrawSpawnPointInfo(x, y, w, h, qtrue, scissor, exspawn); CG_DrawMortarMarker(x, y, w, h, qtrue, scissor, exspawn); // draw spectator position and direction if (cgs.clientinfo[cg.clientNum].team == TEAM_SPECTATOR) { vec2_t pos, size; bg_playerclass_t *classInfo; if (snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR) { size[0] = size[1] = 16; } else { size[0] = size[1] = 12; } if (scissor) { size[0] *= (scissor->zoomFactor / AUTOMAP_ZOOM); size[1] *= (scissor->zoomFactor / AUTOMAP_ZOOM); } else { size[0] *= cgs.ccZoomFactor; size[1] *= cgs.ccZoomFactor; } if (scissor) { pos[0] = ((cg.predictedPlayerEntity.lerpOrigin[0] - cg.mapcoordsMins[0]) * cg.mapcoordsScale[0]) * w * scissor->zoomFactor - scissor->tl[0] + x; pos[1] = ((cg.predictedPlayerEntity.lerpOrigin[1] - cg.mapcoordsMins[1]) * cg.mapcoordsScale[1]) * h * scissor->zoomFactor - scissor->tl[1] + y; } else { pos[0] = x + ((cg.predictedPlayerEntity.lerpOrigin[0] - cg.mapcoordsMins[0]) * cg.mapcoordsScale[0]) * w; pos[1] = y + ((cg.predictedPlayerEntity.lerpOrigin[1] - cg.mapcoordsMins[1]) * cg.mapcoordsScale[1]) * h; } if (snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR) { // draw a arrow when free-spectating. // FIXME: don't reuse the ccMortarTargetArrow CG_DrawRotatedPic(pos[0] - (size[0] * 0.5f), pos[1] - (size[1] * 0.5f), size[0], size[1], cgs.media.ccMortarTargetArrow, (0.625 - (cg.predictedPlayerState.viewangles[YAW] - 180.f) / 360.f)); } else { // show only current player position to spectators classInfo = CG_PlayerClassForClientinfo(&cgs.clientinfo[snap->ps.clientNum], &cg_entities[snap->ps.clientNum]); if (snap->ps.powerups[PW_OPS_DISGUISED]) { CG_DrawPic(pos[0] - (size[0] * 0.5f), pos[1] - (size[1] * 0.5f), size[0], size[1], classInfo->icon); CG_DrawPic(pos[0] - (size[0] * 0.5f), pos[1] - (size[1] * 0.5f), size[0], size[1], cgs.media.friendShader); } else if (snap->ps.powerups[PW_REDFLAG] || snap->ps.powerups[PW_BLUEFLAG]) { CG_DrawPic(pos[0] - (size[0] * 0.5f), pos[1] - (size[1] * 0.5f), size[0], size[1], cgs.media.objectiveShader); } else { CG_DrawPic(pos[0] - (size[0] * 0.5f), pos[1] - (size[1] * 0.5f), size[0], size[1], classInfo->icon); } CG_DrawRotatedPic(pos[0] - (size[0] * 0.5f) - 1, pos[1] - (size[1] * 0.5f) - 1, size[0] + 2, size[1] + 2, classInfo->arrow, (0.5 - (cg.predictedPlayerState.viewangles[YAW] - 180.f) / 360.f)); } } }