transparency options for console and votes (resolves #45)

This commit is contained in:
Lucas GAUTHERON
2014-05-14 14:28:54 +02:00
committed by ac-stef
parent 4fd4e09f43
commit 8e0796a6ae
2 changed files with 14 additions and 11 deletions
+2 -1
View File
@@ -8,6 +8,7 @@ VARP(altconsize, 0, 0, 100);
VARP(fullconsize, 0, 40, 100);
VARP(consize, 0, 6, 100);
VARP(confade, 0, 20, 60);
VARP(conalpha, 0, 255, 255);
VAR(conopen, 0, 0, 1);
VAR(numconlines, 0, 0, 1);
@@ -68,7 +69,7 @@ struct console : consolebuffer<cline>
{
int idx = offset + numl-i-1;
char *line = conlines[idx].line;
draw_text(line, CONSPAD+FONTH/3, y, 0xFF, 0xFF, 0xFF, 0xFF, -1, conwidth);
draw_text(line, CONSPAD+FONTH/3, y, 0xFF, 0xFF, 0xFF, fullconsole ? 0xFF : conalpha, -1, conwidth);
int width, height;
text_bounds(line, width, height, conwidth);
y += height;
+12 -10
View File
@@ -61,6 +61,7 @@ void drawctficon(float x, float y, float s, int col, int row, float ts, int alph
}
}
VARP(votealpha, 0, 255, 255);
void drawvoteicon(float x, float y, int col, int row, bool noblend)
{
static Texture *tex = NULL;
@@ -68,7 +69,7 @@ void drawvoteicon(float x, float y, int col, int row, bool noblend)
if(tex)
{
if(noblend) glDisable(GL_BLEND);
else turn_on_transparency(); // if(transparency && !noblend)
else turn_on_transparency(votealpha); // if(transparency && !noblend)
drawicon(tex, x, y, 240, col, row, 1/2.0f);
if(noblend) glEnable(GL_BLEND);
}
@@ -994,23 +995,24 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat
if(curvote && curvote->millis >= totalmillis && !(hidevote == 1 && curvote->localplayervoted && curvote->result == VOTE_NEUTRAL))
{
const int left = 20*2, top = VIRTH;
draw_textf("%s called a vote:", left, top+240, curvote->owner ? colorname(curvote->owner) : "");
draw_textf("%s", left, top+320, curvote->desc);
draw_textf("----", left, top+400);
draw_textf("%d yes vs. %d no", left, top+480, curvote->stats[VOTE_YES], curvote->stats[VOTE_NO]);
defformatstring(str)("%s called a vote:", curvote->owner ? colorname(curvote->owner) : "");
draw_text(str, left, top + 240, 255, 255, 255, votealpha);
draw_text(curvote->desc, left, top + 320, 255, 255, 255, votealpha);
draw_text("----", left, top + 400, 255, 255, 255, votealpha);
formatstring(str)("%d yes vs. %d no", curvote->stats[VOTE_YES], curvote->stats[VOTE_NO]);
draw_text(str, left, top + 480, 255, 255, 255, votealpha);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glColor4f(1.0f, 1.0f, 1.0f, (sinf(lastmillis/100.0f)+1.0f) / 2.0f);
switch(curvote->result)
{
case VOTE_NEUTRAL:
drawvoteicon(left, top, 0, 0, true);
drawvoteicon(left, top, 0, 0, false);
if(!curvote->localplayervoted)
draw_textf("\f3press F1/F2 to vote yes or no", left, top+560);
draw_text("\f3press F1/F2 to vote yes or no", left, top+560, 255, 255, 255, votealpha);
break;
default:
drawvoteicon(left, top, (curvote->result-1)&1, 1, false);
draw_textf("\f3vote %s", left, top+560, curvote->result == VOTE_YES ? "PASSED" : "FAILED");
formatstring(str)("\f3vote %s", curvote->result == VOTE_YES ? "PASSED" : "FAILED");
draw_text(str, left, top + 560, 255, 255, 255, votealpha);
break;
}
}