feat(hud): paleta per segments (P1 blanc, vides ambre, nivell verd, P2 rosa)
This commit is contained in:
@@ -710,7 +710,7 @@ void GameScene::drawInitHudState() {
|
||||
}
|
||||
|
||||
if (score_progress > 0.0F) {
|
||||
Systems::InitHud::drawScoreboardAnimated(text_, buildScoreboard(), score_progress);
|
||||
Systems::InitHud::drawScoreboardAnimated(text_, buildScoreboardSegments(), score_progress);
|
||||
}
|
||||
|
||||
if (ship1_progress > 0.0F && match_config_.player1_active && ships_[0].isActive()) {
|
||||
@@ -816,59 +816,49 @@ void GameScene::tocado(uint8_t player_id, const Vec2& bullet_velocity) {
|
||||
}
|
||||
|
||||
void GameScene::drawScoreboard() {
|
||||
// Construir text del marcador
|
||||
std::string text = buildScoreboard();
|
||||
|
||||
// Parámetros de renderització
|
||||
const float SCALE = Defaults::Hud::SCOREBOARD_TEXT_SCALE;
|
||||
const float SPACING = Defaults::Hud::SCOREBOARD_TEXT_SPACING;
|
||||
|
||||
// Calcular centro de la zone del marcador
|
||||
const SDL_FRect& scoreboard_zone = Defaults::Zones::SCOREBOARD;
|
||||
float center_x = scoreboard_zone.w / 2.0F;
|
||||
float center_y = scoreboard_zone.y + (scoreboard_zone.h / 2.0F);
|
||||
|
||||
// Renderizar centrat
|
||||
text_.renderCentered(text, {.x = center_x, .y = center_y}, SCALE, SPACING);
|
||||
const Vec2 CENTER = {
|
||||
.x = scoreboard_zone.w / 2.0F,
|
||||
.y = scoreboard_zone.y + (scoreboard_zone.h / 2.0F),
|
||||
};
|
||||
Systems::InitHud::drawScoreboardSegmentsAt(text_, buildScoreboardSegments(), CENTER, SCALE, SPACING);
|
||||
}
|
||||
|
||||
auto GameScene::buildScoreboard() const -> std::string {
|
||||
// Puntuación P1 (6 dígits) - mostrar zeros si inactiu
|
||||
std::string score_p1;
|
||||
std::string vides_p1;
|
||||
auto GameScene::buildScoreboardSegments() const -> Systems::InitHud::ScoreboardSegments {
|
||||
Systems::InitHud::ScoreboardSegments out;
|
||||
|
||||
// Puntuació P1 (6 dígits) - zeros si inactiu
|
||||
if (match_config_.player1_active) {
|
||||
score_p1 = std::to_string(score_per_player_[0]);
|
||||
score_p1 = std::string(6 - std::min(6, static_cast<int>(score_p1.length())), '0') + score_p1;
|
||||
vides_p1 = (lives_per_player_[0] < 10)
|
||||
std::string s = std::to_string(score_per_player_[0]);
|
||||
out.score_p1 = std::string(6 - std::min(6, static_cast<int>(s.length())), '0') + s;
|
||||
out.lives_p1 = (lives_per_player_[0] < 10)
|
||||
? "0" + std::to_string(lives_per_player_[0])
|
||||
: std::to_string(lives_per_player_[0]);
|
||||
} else {
|
||||
score_p1 = "000000";
|
||||
vides_p1 = "00";
|
||||
out.score_p1 = "000000";
|
||||
out.lives_p1 = "00";
|
||||
}
|
||||
|
||||
// Nivel (2 dígits)
|
||||
uint8_t stage_num = stage_manager_->getCurrentStage();
|
||||
std::string stage_str = (stage_num < 10) ? "0" + std::to_string(stage_num)
|
||||
: std::to_string(stage_num);
|
||||
// Nivell (2 dígits) amb label localitzat
|
||||
const uint8_t STAGE_NUM = stage_manager_->getCurrentStage();
|
||||
const std::string STAGE_STR = (STAGE_NUM < 10) ? "0" + std::to_string(STAGE_NUM)
|
||||
: std::to_string(STAGE_NUM);
|
||||
out.level = Locale::get().text("hud.level") + STAGE_STR;
|
||||
|
||||
// Puntuación P2 (6 dígits) - mostrar zeros si inactiu
|
||||
std::string score_p2;
|
||||
std::string vides_p2;
|
||||
// Puntuació P2 (6 dígits) - zeros si inactiu
|
||||
if (match_config_.player2_active) {
|
||||
score_p2 = std::to_string(score_per_player_[1]);
|
||||
score_p2 = std::string(6 - std::min(6, static_cast<int>(score_p2.length())), '0') + score_p2;
|
||||
vides_p2 = (lives_per_player_[1] < 10)
|
||||
std::string s = std::to_string(score_per_player_[1]);
|
||||
out.score_p2 = std::string(6 - std::min(6, static_cast<int>(s.length())), '0') + s;
|
||||
out.lives_p2 = (lives_per_player_[1] < 10)
|
||||
? "0" + std::to_string(lives_per_player_[1])
|
||||
: std::to_string(lives_per_player_[1]);
|
||||
} else {
|
||||
score_p2 = "000000";
|
||||
vides_p2 = "00";
|
||||
out.score_p2 = "000000";
|
||||
out.lives_p2 = "00";
|
||||
}
|
||||
|
||||
// Format: "123456 03 LEVEL 01 654321 02"
|
||||
// Nota: dos espais entre seccions, mantenir ambdós slots siempre visibles
|
||||
return score_p1 + " " + vides_p1 + " " + Locale::get().text("hud.level") + stage_str + " " + score_p2 + " " + vides_p2;
|
||||
return out;
|
||||
}
|
||||
|
||||
// [NEW] Stage system helper methods
|
||||
|
||||
Reference in New Issue
Block a user