Callvote HUD improvements.

This commit is contained in:
Andrei Drexler 2011-03-10 18:56:12 +00:00
parent 3fa530a26a
commit 9d325810d4
4 changed files with 132 additions and 22 deletions

View file

@ -2208,9 +2208,16 @@ static void CG_DrawVote(void)
const char *s;
int len;
int sec, y = 58;
float Color1[4];
vec4_t color1;
float xmin;
int lines = 3;
int offset = 0;
float alpha = 1.f;
const int previewWidth = 64;
const int previewHeight = 48;
int height;
if (!cgs.voteTime) {
return;
@ -2227,37 +2234,72 @@ static void CG_DrawVote(void)
sec = 0;
}
s = va( "Vote called: %s\n"
"Yes(%d) No(%d)\n"
"%d %s left\n",
cgs.voteString,
cgs.voteYes, cgs.voteNo,
sec, sec == 1 ? "second" : "seconds"
);
# define VOTE_FMT(msg) msg "(%d)"
MAKERGBA(Color1, 0.0f, 0.0f, 0.0f, 0.4f);
if ((cg.snap && EF_VOTED == (cg.snap->ps.eFlags & EF_VOTED)) || !cgs.voteYesKey[0] || !cgs.voteNoKey[0])
{
s = va( "Vote called: %s\n"
VOTE_FMT("Yes") " " VOTE_FMT("No") "\n"
"%d %s left\n",
cgs.voteString,
cgs.voteYes, cgs.voteNo,
sec, sec == 1 ? "second" : "seconds"
);
}
else
{
# define KEY_FMT S_COLOR_CYAN "%s" S_COLOR_RESET
s = va( "Vote called: %s\n"
KEY_FMT "=" VOTE_FMT("Yes") " " KEY_FMT "=" VOTE_FMT("No") "\n"
"%d %s left\n",
cgs.voteString,
cgs.voteYesKey, cgs.voteYes, cgs.voteNoKey, cgs.voteNo,
sec, sec == 1 ? "second" : "seconds"
);
# undef KEY_FMT
}
# undef VOTE_FMT
len = CG_DrawStrlen(s) * SMALLCHAR_WIDTH;
height = lines * SMALLCHAR_HEIGHT + 4;
xmin = cgs.screenXMin + 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) - (SMALLCHAR_HEIGHT * lines + 4)) / 2;
offset += previewWidth + 4 + 4;
if (height < previewHeight + 4 + 4)
height = previewHeight + 4;
}
len = CG_DrawStrlen(s) * SMALLCHAR_WIDTH;
alpha = SmoothLerp(Com_Clamp(0.f, 1.f, (cg.time - cgs.voteTime) / (1000.f * 0.125f)));
// slide in //
xmin -= (1.f - alpha) * (len + offset);
CG_FillRect(xmin + 1, y, len + 4, SMALLCHAR_HEIGHT * lines + 4, Color1);
CG_DrawCleanRect(xmin + 1, y, len + 4, SMALLCHAR_HEIGHT * lines + 4, 1, colorBlack);
CG_DrawStringExt(xmin + 3, y+2, s, colorWhite, qtrue, qfalse,
{
const int inflatex = 32;
const int inflatey = 24;
CG_DrawFuzzyShadow(xmin + 1 - inflatex, y - inflatey, len + 4 + offset + inflatex + inflatex, height + inflatey + inflatey, 32, 0.75f * alpha);
}
MAKERGBA(color1, 1.0f, 1.0f, 1.0f, alpha);
if (cgs.media.voteMapShader)
{
CG_FillRect(xmin + 1, y, previewWidth + 4, previewHeight + 4, color1);
trap_R_SetColor(color1);
CG_DrawPic(xmin + 3, y + 2, previewWidth, previewHeight, cgs.media.voteMapShader);
xmin += offset;
}
CG_DrawStringExt(xmin + 3, y+2, s, color1, qfalse, qfalse,
SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 100);
trap_R_SetColor(NULL);
}
/*

View file

@ -136,6 +136,47 @@ void CG_DrawRect(float x, float y, float width, float height, float size, const
trap_R_SetColor(NULL);
}
void CG_DrawFuzzyRect(float x, float y, float w, float h, float corner, vec4_t color, qhandle_t shader)
{
float xcorner = corner * cgs.screenXScale;
float ycorner = corner * cgs.screenYScale;
CG_AdjustFrom640(&x, &y, &w, &h);
trap_R_SetColor(color);
// top //
trap_R_DrawStretchPic(x, y, xcorner, ycorner, 0, 0, 0.5f, 0.5f, shader);
trap_R_DrawStretchPic(x+xcorner, y, w-xcorner-xcorner, ycorner, 0.5f, 0, 0.5f, 0.5f, shader);
trap_R_DrawStretchPic(x+w-xcorner, y, xcorner, ycorner, 0.5f, 0, 1, 0.5f, shader);
// middle //
trap_R_DrawStretchPic(x, y+ycorner, xcorner, h-ycorner-ycorner, 0, 0.5f, 0.5f, 0.5f, shader);
trap_R_DrawStretchPic(x+xcorner, y+ycorner, w-xcorner-xcorner, h-ycorner-ycorner, 0.5f, 0.5f, 0.5f, 0.5f, shader);
trap_R_DrawStretchPic(x+w-xcorner, y+ycorner, xcorner, h-ycorner-ycorner, 0.5f, 0.5f, 1, 0.5f, shader);
// bottom //
trap_R_DrawStretchPic(x, y+h-ycorner, xcorner, ycorner, 0, 0.5f, 0.5f, 1, shader);
trap_R_DrawStretchPic(x+xcorner, y+h-ycorner, w-xcorner-xcorner, ycorner, 0.5f, 0.5f, 0.5f, 1, shader);
trap_R_DrawStretchPic(x+w-xcorner, y+h-ycorner, xcorner, ycorner, 0.5f, 0.5f, 1, 1, shader);
trap_R_SetColor(NULL);
}
void CG_DrawFuzzyShadow(float x, float y, float w, float h, float corner, float alpha)
{
vec4_t color;
color[0] = color[1] = color[2] = alpha;
color[3] = 1.f;
CG_DrawFuzzyRect(x, y, w, h, corner, color, cgs.media.fuzzyShadowShader);
}
void CG_DrawFuzzyGlow(float x, float y, float w, float h, float corner, vec4_t color)
{
CG_DrawFuzzyRect(x, y, w, h, corner, color, cgs.media.fuzzyGlowShader);
}
/*
================
UI_DrawRect -- Added by NiceAss

View file

@ -1217,6 +1217,8 @@ typedef struct {
qhandle_t whiteShader;
qhandle_t blackHackShader;
qhandle_t fuzzyShadowShader;
qhandle_t fuzzyGlowShader;
#ifdef MISSIONPACK
qhandle_t redCubeModel;
@ -1706,6 +1708,9 @@ typedef struct {
qboolean voteModified; // beep whenever changed
char voteString[MAX_STRING_TOKENS];
char voteYesKey[32];
char voteNoKey[32];
int teamVoteTime[2];
int teamVoteYes[2];
int teamVoteNo[2];
@ -2126,6 +2131,10 @@ void CG_DrawBigStringColor(int x, int y, const char *s, vec4_t color);
void CG_DrawSmallString(int x, int y, const char *s, float alpha);
void CG_DrawSmallStringColor(int x, int y, const char *s, vec4_t color);
void CG_DrawFuzzyRect(float x, float y, float w, float h, float corner, vec4_t color, qhandle_t shader);
void CG_DrawFuzzyShadow(float x, float y, float w, float h, float corner, float alpha);
void CG_DrawFuzzyGlow(float x, float y, float w, float h, float corner, vec4_t color);
int CG_DrawStrlen(const char *str);
float *CG_FadeColor(int startMsec, int totalMsec);
@ -2574,6 +2583,7 @@ void trap_startCamera(int time);
qboolean trap_getCameraInfo(int time, vec3_t * origin, vec3_t * angles);
qboolean trap_GetEntityToken(char *buffer, int bufferSize);
void trap_RQ3_Key_KeynumToStringBuf(int keynum, char *buf, int buflen);
void CG_ClearParticles(void);
void CG_AddParticles(void);

View file

@ -659,6 +659,22 @@ static void CG_UpdateVoteMapShader(void)
}
}
static void CG_UpdateVoteKeys(void)
{
int yesKey = trap_Key_GetKey("vote yes");
int noKey = trap_Key_GetKey("vote no");
if (yesKey != -1 && noKey != -1)
{
trap_RQ3_Key_KeynumToStringBuf(yesKey, cgs.voteYesKey, sizeof(cgs.voteYesKey));
trap_RQ3_Key_KeynumToStringBuf(noKey, cgs.voteNoKey, sizeof(cgs.voteNoKey));
}
else
{
cgs.voteYesKey[0] = 0;
cgs.voteNoKey[0] = 0;
}
}
/*
================
CG_ConfigStringModified
@ -695,6 +711,7 @@ static void CG_ConfigStringModified(void)
} else if (num == CS_VOTE_TIME) {
cgs.voteTime = atoi(str);
cgs.voteModified = qtrue;
CG_UpdateVoteKeys();
CG_UpdateVoteMapShader();
} else if (num == CS_VOTE_YES) {
cgs.voteYes = atoi(str);