carrusel funcional i acabat
This commit is contained in:
@@ -301,7 +301,7 @@ void Scoreboard::renderEnterNameMode(size_t panel_index) {
|
||||
text_->writeDX(Text::CENTER | Text::COLOR, slot4_3_.x, slot4_3_.y, enter_name_.at(panel_index), 1, text_color2_);
|
||||
|
||||
// CARRUSEL
|
||||
text_->writeDX(Text::CENTER | Text::COLOR, slot4_4_.x, slot4_4_.y, carousel_.at(panel_index), 1, animated_color_);
|
||||
renderCarousel(panel_index, slot4_4_.x, slot4_4_.y);
|
||||
}
|
||||
|
||||
void Scoreboard::renderShowNameMode(size_t panel_index) {
|
||||
@@ -430,4 +430,57 @@ void Scoreboard::renderSeparator() {
|
||||
auto color = param.scoreboard.separator_autocolor ? color_.DARKEN() : param.scoreboard.separator_color;
|
||||
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 255);
|
||||
SDL_RenderLine(renderer_, 0, 0, rect_.w, 0);
|
||||
}
|
||||
|
||||
// Pinta el carrusel de caracteres con efecto de color LERP
|
||||
void Scoreboard::renderCarousel(size_t panel_index, int center_x, int y) {
|
||||
const std::string& carousel = carousel_.at(panel_index);
|
||||
if (carousel.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Espacio extra entre letras (además del ancho natural de cada letra)
|
||||
constexpr int EXTRA_SPACING = 2;
|
||||
|
||||
// Índice de la letra central
|
||||
const int CENTER_INDEX = carousel.size() / 2;
|
||||
|
||||
// Calcular el ancho acumulado antes de la letra central
|
||||
int width_before_center = 0;
|
||||
for (int i = 0; i < CENTER_INDEX; ++i) {
|
||||
std::string ch(1, carousel[i]);
|
||||
width_before_center += text_->length(ch, 1) + EXTRA_SPACING;
|
||||
}
|
||||
|
||||
// Calcular posición inicial para que la letra central esté centrada en center_x
|
||||
std::string center_char(1, carousel[CENTER_INDEX]);
|
||||
const int CENTER_CHAR_WIDTH = text_->length(center_char, 1);
|
||||
const int CAROUSEL_START_X = center_x - width_before_center - (CENTER_CHAR_WIDTH / 2);
|
||||
|
||||
// Pintar cada letra individualmente
|
||||
int current_x = CAROUSEL_START_X;
|
||||
for (size_t i = 0; i < carousel.size(); ++i) {
|
||||
std::string single_char(1, carousel[i]);
|
||||
|
||||
Color letter_color;
|
||||
|
||||
if (static_cast<int>(i) == CENTER_INDEX) {
|
||||
// Letra central: usa animated_color_ sin modificar
|
||||
letter_color = animated_color_;
|
||||
} else {
|
||||
// Letras laterales: LERP desde text_color1_ hacia color_, pero sin llegar al 100%
|
||||
const int DISTANCE = std::abs(static_cast<int>(i) - CENTER_INDEX);
|
||||
const float MAX_DISTANCE = static_cast<float>(CENTER_INDEX);
|
||||
// Limitar el fade al 70% para que las letras sigan siendo visibles
|
||||
const float LERP_FACTOR = (MAX_DISTANCE > 0) ? ((DISTANCE / MAX_DISTANCE) * 0.7f) : 0.0f;
|
||||
|
||||
letter_color = text_color1_.LERP(color_, LERP_FACTOR);
|
||||
}
|
||||
|
||||
// Pintar la letra
|
||||
text_->writeDX(Text::COLOR, current_x, y, single_char, 1, letter_color);
|
||||
|
||||
// Avanzar posición X: ancho del caracter + espacio extra
|
||||
current_x += text_->length(single_char, 1) + EXTRA_SPACING;
|
||||
}
|
||||
}
|
||||
@@ -130,6 +130,7 @@ class Scoreboard {
|
||||
void renderNameInputField(size_t panel_index);
|
||||
void renderShowNameMode(size_t panel_index);
|
||||
void renderGameCompletedMode(size_t panel_index);
|
||||
void renderCarousel(size_t panel_index, int center_x, int y); // Pinta el carrusel de caracteres con colores LERP
|
||||
|
||||
// --- Constructores y destructor privados (singleton) ---
|
||||
Scoreboard(); // Constructor privado
|
||||
|
||||
Reference in New Issue
Block a user