Show Dead players in gray on scoreboard

This is done for all cases, but that is probably a bad idea. While this
does not matter in public games, in small tournaments this could be an
advantage. Ideally, the server could disable giving players this
information
This commit is contained in:
notafile 2017-09-07 20:32:24 +02:00
parent bfe62a0a2c
commit 79689848dd

View File

@ -231,6 +231,7 @@ namespace spades {
int id; int id;
int score; int score;
std::string name; std::string name;
bool alive;
bool operator<(const ScoreboardEntry &ent) const { return score > ent.score; } bool operator<(const ScoreboardEntry &ent) const { return score > ent.score; }
}; };
@ -241,6 +242,7 @@ namespace spades {
char buf[256]; char buf[256];
Vector2 size; Vector2 size;
Vector4 white = {1, 1, 1, 1}; Vector4 white = {1, 1, 1, 1};
Vector4 gray = {0.5, 0.5, 0.5, 1};
int maxRows = (int)floorf(height / rowHeight); int maxRows = (int)floorf(height / rowHeight);
int numPlayers = 0; int numPlayers = 0;
int cols; int cols;
@ -256,6 +258,7 @@ namespace spades {
ScoreboardEntry ent; ScoreboardEntry ent;
ent.name = p->GetName(); ent.name = p->GetName();
ent.score = world->GetPlayerPersistent(i).kills; ent.score = world->GetPlayerPersistent(i).kills;
ent.alive = p->IsAlive();
ent.id = i; ent.id = i;
entries.push_back(ent); entries.push_back(ent);
@ -295,8 +298,12 @@ namespace spades {
font->Draw(buf, MakeVector2(colX + 35.f - size.x, rowY), 1.f, white); font->Draw(buf, MakeVector2(colX + 35.f - size.x, rowY), 1.f, white);
} }
color = ent.alive ? white : gray;
font->Draw(ent.name, MakeVector2(colX + 45.f, rowY), 1.f, color); font->Draw(ent.name, MakeVector2(colX + 45.f, rowY), 1.f, color);
color = white;
sprintf(buf, "%d", ent.score); sprintf(buf, "%d", ent.score);
size = font->Measure(buf); size = font->Measure(buf);
font->Draw(buf, MakeVector2(colX + colWidth - 10.f - size.x, rowY), 1.f, color); font->Draw(buf, MakeVector2(colX + colWidth - 10.f - size.x, rowY), 1.f, color);