linter: varios

This commit is contained in:
2025-10-24 13:45:56 +02:00
parent 5362c5b022
commit fd4136a882
13 changed files with 232 additions and 201 deletions

View File

@@ -107,15 +107,15 @@ void Scoreboard::setCarouselAnimation(Id id, int selected_index, EnterName* ente
// ===== Inicialización (primera vez) =====
if (carousel_prev_index_.at(idx) == -1) {
carousel_position_.at(idx) = static_cast<float>(selected_index);
carousel_target_.at(idx) = static_cast<float>(selected_index);
carousel_position_.at(idx) = static_cast<float>(selected_index);
carousel_target_.at(idx) = static_cast<float>(selected_index);
carousel_prev_index_.at(idx) = selected_index;
return;
}
int prev_index = carousel_prev_index_.at(idx);
if (selected_index == prev_index) {
return; // nada que hacer
return; // nada que hacer
}
// ===== Bloquear si aún animando =====
@@ -126,8 +126,11 @@ void Scoreboard::setCarouselAnimation(Id id, int selected_index, EnterName* ente
// ===== Calcular salto circular =====
int delta = selected_index - prev_index;
const int LIST_SIZE = static_cast<int>(enter_name_ptr->getCharacterList().size());
if (delta > LIST_SIZE / 2) delta -= LIST_SIZE;
else if (delta < -LIST_SIZE / 2) delta += LIST_SIZE;
if (delta > LIST_SIZE / 2) {
delta -= LIST_SIZE;
} else if (delta < -LIST_SIZE / 2) {
delta += LIST_SIZE;
}
// ===== Alinear posición actual antes de moverse =====
carousel_position_.at(idx) = std::round(carousel_position_.at(idx));
@@ -141,8 +144,8 @@ void Scoreboard::setCarouselAnimation(Id id, int selected_index, EnterName* ente
} else {
// Movimiento largo → animado pero limitado en tiempo
// Normalizamos el salto para que visualmente tarde como mucho el doble
const float MAX_DURATION_FACTOR = 2.0f; // máximo 2x la duración de una letra
const float SPEED_SCALE = std::min(1.0f, MAX_DURATION_FACTOR / static_cast<float>(ABS_DELTA));
const float MAX_DURATION_FACTOR = 2.0F; // máximo 2x la duración de una letra
const float SPEED_SCALE = std::min(1.0F, MAX_DURATION_FACTOR / static_cast<float>(ABS_DELTA));
// Guardamos el destino real
float target = std::round(carousel_position_.at(idx)) + static_cast<float>(delta);
@@ -257,7 +260,7 @@ void Scoreboard::updateCarouselAnimation(float delta_time) {
} else {
// Forzar al target exacto cuando estamos muy cerca
carousel_position_.at(i) = carousel_target_.at(i);
carousel_speed_scale_.at(i) = 1.0f; // restaurar velocidad normal
carousel_speed_scale_.at(i) = 1.0F; // restaurar velocidad normal
}
}
}
@@ -302,7 +305,7 @@ void Scoreboard::updatePanelPulses(float delta_time) {
// Desactivar el pulso si ha terminado
if (pulse.elapsed_s >= pulse.duration_s) {
pulse.active = false;
pulse.elapsed_s = 0.0f;
pulse.elapsed_s = 0.0F;
}
}
}
@@ -311,7 +314,7 @@ void Scoreboard::updatePanelPulses(float delta_time) {
void Scoreboard::triggerPanelPulse(Id id, float duration_s) {
auto idx = static_cast<size_t>(id);
panel_pulse_.at(idx).active = true;
panel_pulse_.at(idx).elapsed_s = 0.0f;
panel_pulse_.at(idx).elapsed_s = 0.0F;
panel_pulse_.at(idx).duration_s = duration_s;
}
@@ -381,7 +384,7 @@ void Scoreboard::fillPanelTextures() {
// Interpolar entre color base y color aclarado
Color target_color = color_.LIGHTEN(PANEL_PULSE_LIGHTEN_AMOUNT);
//Color target_color = color_.INVERSE();
// Color target_color = color_.INVERSE();
background_color = color_.LERP(target_color, pulse_intensity);
background_color.a = 255; // Opaco durante el pulso
}
@@ -737,7 +740,7 @@ void Scoreboard::renderCarousel(size_t panel_index, int center_x, int y) {
constexpr int HALF_VISIBLE = CAROUSEL_VISIBLE_LETTERS / 2; // 4 letras a cada lado
// Posición flotante actual del carrusel (índice en la lista de caracteres)
float CAROUSEL_POS = carousel_position_.at(panel_index);
float carousel_pos = carousel_position_.at(panel_index);
const int CHAR_LIST_SIZE = static_cast<int>(char_list.size());
// Calcular ancho promedio de una letra (asumimos ancho uniforme)
@@ -745,17 +748,17 @@ void Scoreboard::renderCarousel(size_t panel_index, int center_x, int y) {
const int CHAR_STEP = AVG_CHAR_WIDTH + EXTRA_SPACING;
// --- Corrección visual de residuales flotantes (evita “baile”) ---
float frac = CAROUSEL_POS - std::floor(CAROUSEL_POS);
if (frac > 0.999f || frac < 0.001f) {
CAROUSEL_POS = std::round(CAROUSEL_POS);
frac = 0.0f;
float frac = carousel_pos - std::floor(carousel_pos);
if (frac > 0.999F || frac < 0.001F) {
carousel_pos = std::round(carousel_pos);
frac = 0.0F;
}
const float FRACTIONAL_OFFSET = frac;
const int PIXEL_OFFSET = static_cast<int>(FRACTIONAL_OFFSET * CHAR_STEP + 0.5f);
// Índice base en la lista de caracteres (posición central)
const int BASE_INDEX = static_cast<int>(std::floor(CAROUSEL_POS));
const int BASE_INDEX = static_cast<int>(std::floor(carousel_pos));
// Calcular posición X inicial (centrar las 9 letras visibles)
int start_x = center_x - (HALF_VISIBLE * CHAR_STEP) - (AVG_CHAR_WIDTH / 2) - PIXEL_OFFSET;
@@ -770,24 +773,24 @@ void Scoreboard::renderCarousel(size_t panel_index, int center_x, int y) {
}
// --- Calcular distancia circular correcta (corregido el bug de wrap) ---
float normalized_pos = std::fmod(CAROUSEL_POS, static_cast<float>(CHAR_LIST_SIZE));
if (normalized_pos < 0.0f) normalized_pos += static_cast<float>(CHAR_LIST_SIZE);
float normalized_pos = std::fmod(carousel_pos, static_cast<float>(CHAR_LIST_SIZE));
if (normalized_pos < 0.0F) normalized_pos += static_cast<float>(CHAR_LIST_SIZE);
float diff = std::abs(static_cast<float>(char_index) - normalized_pos);
if (diff > static_cast<float>(CHAR_LIST_SIZE) / 2.0f)
if (diff > static_cast<float>(CHAR_LIST_SIZE) / 2.0F)
diff = static_cast<float>(CHAR_LIST_SIZE) - diff;
const float distance_from_center = diff;
const float DISTANCE_FROM_CENTER = diff;
// --- Seleccionar color con LERP según la distancia ---
Color letter_color;
if (distance_from_center < 0.5F) {
if (DISTANCE_FROM_CENTER < 0.5F) {
// Letra central → transiciona hacia animated_color_
float lerp_to_animated = distance_from_center / 0.5F; // 0.0 a 1.0
float lerp_to_animated = DISTANCE_FROM_CENTER / 0.5F; // 0.0 a 1.0
letter_color = animated_color_.LERP(text_color1_, lerp_to_animated);
} else {
// Letras alejadas → degradan hacia color_ base
float base_lerp = (distance_from_center - 0.5F) / (HALF_VISIBLE - 0.5F);
float base_lerp = (DISTANCE_FROM_CENTER - 0.5F) / (HALF_VISIBLE - 0.5F);
base_lerp = std::min(base_lerp, 1.0F);
const float LERP_FACTOR = base_lerp * 0.85F;
letter_color = text_color1_.LERP(color_, LERP_FACTOR);