tweak(hud): jugador inactiu = marcador apagat (tot atenuat, no en blanc)
This commit is contained in:
@@ -165,6 +165,7 @@ namespace Systems::InitHud {
|
||||
const std::string& score,
|
||||
SDL_Color bright,
|
||||
SDL_Color dim,
|
||||
bool active,
|
||||
float x,
|
||||
float top_y,
|
||||
float scale,
|
||||
@@ -172,7 +173,10 @@ namespace Systems::InitHud {
|
||||
if (score.empty()) {
|
||||
return;
|
||||
}
|
||||
// Primer dígit significatiu; si són tots zeros, força l'últim a encès.
|
||||
// Jugador inactiu → marcador apagat: tots els dígits atenuats (no té
|
||||
// "zero punts", simplement no en té). Jugador actiu → l'últim dígit
|
||||
// sempre encès (puntuació 0 → cinc zeros atenuats + "0" encès).
|
||||
const SDL_Color REST_COLOR = active ? bright : dim;
|
||||
const size_t FIRST_SIG = score.find_first_not_of('0');
|
||||
const size_t SIG = (FIRST_SIG == std::string::npos) ? (score.size() - 1) : FIRST_SIG;
|
||||
const std::string PREFIX = score.substr(0, SIG);
|
||||
@@ -184,7 +188,7 @@ namespace Systems::InitHud {
|
||||
x += Graphics::VectorText::getTextWidth(PREFIX, scale, spacing) + (spacing * scale);
|
||||
}
|
||||
if (!REST.empty()) {
|
||||
text.render(REST, {.x = x, .y = top_y}, scale, spacing, 1.0F, bright);
|
||||
text.render(REST, {.x = x, .y = top_y}, scale, spacing, 1.0F, REST_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,16 +219,13 @@ namespace Systems::InitHud {
|
||||
float center_y,
|
||||
float scale,
|
||||
float spacing) {
|
||||
// Jugador inactiu → bloc apagat: no es dibuixa res (es reserva l'ample
|
||||
// igualment a drawScoreboardAt perquè NIVELL i el bloc actiu no es moguin).
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
// Jugador inactiu → bloc apagat: es dibuixa igual però tot atenuat
|
||||
// (punts i slots), com un display físic sense encendre.
|
||||
const float TOP_Y = center_y - (Graphics::VectorText::getTextHeight(scale) / 2.0F);
|
||||
const float W_SCORE = Graphics::VectorText::getTextWidth(score, scale, spacing);
|
||||
|
||||
float x = x_left;
|
||||
drawScore(text, score, bright, dim, x, TOP_Y, scale, spacing);
|
||||
drawScore(text, score, bright, dim, active, x, TOP_Y, scale, spacing);
|
||||
x += W_SCORE + blockInnerGap(scale, spacing);
|
||||
drawSlots(renderer, shape, lives, bright, dim, x, center_y, scale, spacing);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user