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,
|
const std::string& score,
|
||||||
SDL_Color bright,
|
SDL_Color bright,
|
||||||
SDL_Color dim,
|
SDL_Color dim,
|
||||||
|
bool active,
|
||||||
float x,
|
float x,
|
||||||
float top_y,
|
float top_y,
|
||||||
float scale,
|
float scale,
|
||||||
@@ -172,7 +173,10 @@ namespace Systems::InitHud {
|
|||||||
if (score.empty()) {
|
if (score.empty()) {
|
||||||
return;
|
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 FIRST_SIG = score.find_first_not_of('0');
|
||||||
const size_t SIG = (FIRST_SIG == std::string::npos) ? (score.size() - 1) : FIRST_SIG;
|
const size_t SIG = (FIRST_SIG == std::string::npos) ? (score.size() - 1) : FIRST_SIG;
|
||||||
const std::string PREFIX = score.substr(0, 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);
|
x += Graphics::VectorText::getTextWidth(PREFIX, scale, spacing) + (spacing * scale);
|
||||||
}
|
}
|
||||||
if (!REST.empty()) {
|
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 center_y,
|
||||||
float scale,
|
float scale,
|
||||||
float spacing) {
|
float spacing) {
|
||||||
// Jugador inactiu → bloc apagat: no es dibuixa res (es reserva l'ample
|
// Jugador inactiu → bloc apagat: es dibuixa igual però tot atenuat
|
||||||
// igualment a drawScoreboardAt perquè NIVELL i el bloc actiu no es moguin).
|
// (punts i slots), com un display físic sense encendre.
|
||||||
if (!active) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const float TOP_Y = center_y - (Graphics::VectorText::getTextHeight(scale) / 2.0F);
|
const float TOP_Y = center_y - (Graphics::VectorText::getTextHeight(scale) / 2.0F);
|
||||||
const float W_SCORE = Graphics::VectorText::getTextWidth(score, scale, spacing);
|
const float W_SCORE = Graphics::VectorText::getTextWidth(score, scale, spacing);
|
||||||
|
|
||||||
float x = x_left;
|
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);
|
x += W_SCORE + blockInnerGap(scale, spacing);
|
||||||
drawSlots(renderer, shape, lives, bright, dim, x, center_y, scale, spacing);
|
drawSlots(renderer, shape, lives, bright, dim, x, center_y, scale, spacing);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user