callvote map preview

This commit is contained in:
Andrei Drexler 2011-03-10 11:22:13 +00:00
parent 0cd2e5b0f2
commit 738aca928b
3 changed files with 49 additions and 9 deletions

View File

@ -2213,7 +2213,9 @@ static void CG_DrawVote(void)
{ {
char *s, *s2; char *s, *s2;
int sec, y = 58; int sec, y = 58;
int line;
float Color1[4]; float Color1[4];
float xmin;
if (!cgs.voteTime) { if (!cgs.voteTime) {
return; return;
@ -2230,25 +2232,42 @@ static void CG_DrawVote(void)
sec = 0; sec = 0;
} }
s = va("Vote[%i seconds left] Yes[%i] No[%i]", sec, cgs.voteYes, cgs.voteNo); s = va("Vote: %s (%d seconds left)", cgs.voteString, sec);
s2 = va("Vote: %s", cgs.voteString); s2 = va("Yes(%d) No(%d)", cgs.voteYes, cgs.voteNo);
MAKERGBA(Color1, 0.0f, 0.0f, 0.0f, 0.4f); MAKERGBA(Color1, 0.0f, 0.0f, 0.0f, 0.4f);
CG_FillRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4, xmin = cgs.screenXMin;
SMALLCHAR_HEIGHT + 4, Color1); line = SMALLCHAR_HEIGHT + 5;
CG_DrawCleanRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, 1, colorBlack);
CG_DrawStringExt(cgs.screenXMin + 3, y+2, s, colorWhite, qtrue, qfalse,
SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100);
y += SMALLCHAR_HEIGHT + 3;
CG_FillRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4, if (cgs.media.voteMapShader)
{
int width = 64;
int height = 48;
CG_FillRect(xmin + 1, y, width + 4, height + 4, Color1);
CG_DrawCleanRect(xmin + 1, y, width + 4, height + 4, 1, colorBlack);
CG_DrawPic(xmin + 3, y + 2, width, height, cgs.media.voteMapShader);
xmin += width + 4 + 4;
y += ((height + 4) - (line + line)) / 2;
}
CG_FillRect(xmin + 1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, Color1); SMALLCHAR_HEIGHT + 4, Color1);
CG_DrawCleanRect(cgs.screenXMin + 1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4, CG_DrawCleanRect(xmin + 1, y, CG_DrawStrlen(s) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, 1, colorBlack); SMALLCHAR_HEIGHT + 4, 1, colorBlack);
CG_DrawStringExt(cgs.screenXMin + 3, y + 2, s2, colorWhite, qtrue, qfalse, CG_DrawStringExt(xmin + 3, y+2, s, colorWhite, qtrue, qfalse,
SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100); SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100);
y += line;
CG_FillRect(xmin + 1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, Color1);
CG_DrawCleanRect(xmin + 1, y, CG_DrawStrlen(s2) * SMALLCHAR_WIDTH + 4,
SMALLCHAR_HEIGHT + 4, 1, colorBlack);
CG_DrawStringExt(xmin + 3, y + 2, s2, colorWhite, qtrue, qfalse,
SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100);
y += line;
} }
/* /*

View File

@ -1663,6 +1663,9 @@ typedef struct {
qhandle_t snowImpactShader; qhandle_t snowImpactShader;
//Makro - generic particle impact shader //Makro - generic particle impact shader
qhandle_t particleImpactShader; qhandle_t particleImpactShader;
// Makro - map preview
qhandle_t voteMapShader;
} cgMedia_t; } cgMedia_t;
// The client game static (cgs) structure hold everything // The client game static (cgs) structure hold everything

View File

@ -643,6 +643,22 @@ void CG_ShaderStateChanged(void)
} }
} }
static void CG_UpdateVoteMapShader(void)
{
const char* vote = cgs.voteString;
cgs.media.voteMapShader = 0;
if (!*vote)
return;
if (Q_stricmpn(vote, "map ", 4) == 0)
{
vote += 4;
vote = va("levelshots/%s.tga", vote);
cgs.media.voteMapShader = trap_R_RegisterShaderNoMip(vote);
}
}
/* /*
================ ================
CG_ConfigStringModified CG_ConfigStringModified
@ -679,6 +695,7 @@ static void CG_ConfigStringModified(void)
} else if (num == CS_VOTE_TIME) { } else if (num == CS_VOTE_TIME) {
cgs.voteTime = atoi(str); cgs.voteTime = atoi(str);
cgs.voteModified = qtrue; cgs.voteModified = qtrue;
CG_UpdateVoteMapShader();
} else if (num == CS_VOTE_YES) { } else if (num == CS_VOTE_YES) {
cgs.voteYes = atoi(str); cgs.voteYes = atoi(str);
cgs.voteModified = qtrue; cgs.voteModified = qtrue;
@ -687,6 +704,7 @@ static void CG_ConfigStringModified(void)
cgs.voteModified = qtrue; cgs.voteModified = qtrue;
} else if (num == CS_VOTE_STRING) { } else if (num == CS_VOTE_STRING) {
Q_strncpyz(cgs.voteString, str, sizeof(cgs.voteString)); Q_strncpyz(cgs.voteString, str, sizeof(cgs.voteString));
CG_UpdateVoteMapShader();
} else if (num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1) { } else if (num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1) {
cgs.teamVoteTime[num - CS_TEAMVOTE_TIME] = atoi(str); cgs.teamVoteTime[num - CS_TEAMVOTE_TIME] = atoi(str);
cgs.teamVoteModified[num - CS_TEAMVOTE_TIME] = qtrue; cgs.teamVoteModified[num - CS_TEAMVOTE_TIME] = qtrue;