Fix: Transición instantánea dinámico→estático (evita fondo negro)
PROBLEMA: Al cambiar de tema dinámico (SUNRISE/OCEAN WAVES/NEON PULSE) a tema estático (SUNSET/LAVENDER/etc), el fondo se volvía negro o mostraba colores corruptos durante la transición LERP. CAUSA: 1. activateDynamicTheme() NO actualiza current_theme_ (queda en valor previo) 2. startThemeTransition() desactiva dynamic_theme_active_ 3. renderGradientBackground() intenta LERP desde themes_[current_theme_] 4. Si current_theme_ era LAVENDER (índice 6), accede themes_[6] OK 5. Pero si era cualquier valor >= 7, accede fuera de bounds → basura SOLUCIÓN IMPLEMENTADA: ✅ Detectar transición desde tema dinámico en startThemeTransition() ✅ Si dynamic_theme_active_ == true: - Hacer transición INSTANTÁNEA (sin LERP) - Cambiar current_theme_ inmediatamente al tema destino - Actualizar colores de pelotas sin interpolación - Evitar acceso a themes_[] con índices inválidos ✅ Eliminar asignación de current_theme_ en activateDynamicTheme() - Cuando dynamic_theme_active_=true, se usa current_dynamic_theme_index_ - current_theme_ solo se usa cuando dynamic_theme_active_=false RESULTADO: - Dinámico → Estático: Cambio instantáneo limpio ✅ - Estático → Estático: Transición LERP suave (sin cambios) ✅ - Estático → Dinámico: Cambio instantáneo (sin cambios) ✅ - Dinámico → Dinámico: Cambio instantáneo (sin cambios) ✅ TRADE-OFF: - Perdemos transición suave dinámico→estático - Ganamos estabilidad y eliminamos fondo negro/corrupto - Para implementar LERP correcto se requiere refactor mayor (unificar todos los temas bajo sistema dinámico) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1575,12 +1575,34 @@ void Engine::initializeDynamicThemes() {
|
||||
void Engine::startThemeTransition(ColorTheme new_theme) {
|
||||
if (new_theme == current_theme_) return; // Ya estamos en ese tema
|
||||
|
||||
// Desactivar tema dinámico si estaba activo
|
||||
// Si venimos de tema dinámico, hacer transición instantánea (sin LERP)
|
||||
// porque current_theme_ apunta a DYNAMIC_X (índice >= 7) y no existe en themes_[]
|
||||
if (dynamic_theme_active_) {
|
||||
dynamic_theme_active_ = false;
|
||||
current_dynamic_theme_index_ = -1;
|
||||
|
||||
// Cambio instantáneo: sin transición LERP
|
||||
current_theme_ = new_theme;
|
||||
transitioning_ = false;
|
||||
|
||||
// Actualizar colores de pelotas al tema final
|
||||
const ThemeColors& theme = themes_[static_cast<int>(new_theme)];
|
||||
for (size_t i = 0; i < balls_.size(); i++) {
|
||||
size_t color_index = i % theme.ball_colors.size();
|
||||
balls_[i]->setColor(theme.ball_colors[color_index]);
|
||||
}
|
||||
|
||||
// Mostrar nombre del tema
|
||||
if (current_app_mode_ == AppMode::MANUAL) {
|
||||
text_ = theme.name_es;
|
||||
text_pos_ = (current_screen_width_ - static_cast<int>(text_.length() * 8)) / 2;
|
||||
show_text_ = true;
|
||||
text_init_time_ = SDL_GetTicks();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Transición normal entre temas estáticos
|
||||
target_theme_ = new_theme;
|
||||
transitioning_ = true;
|
||||
transition_progress_ = 0.0f;
|
||||
@@ -1646,8 +1668,8 @@ void Engine::activateDynamicTheme(int index) {
|
||||
dynamic_transition_progress_ = 0.0f;
|
||||
dynamic_theme_paused_ = false;
|
||||
|
||||
// Actualizar current_theme_ al enum correspondiente
|
||||
current_theme_ = static_cast<ColorTheme>(static_cast<int>(ColorTheme::DYNAMIC_1) + index);
|
||||
// NOTA: No actualizamos current_theme_ porque cuando dynamic_theme_active_=true,
|
||||
// todo el código usa current_dynamic_theme_index_ en su lugar
|
||||
|
||||
// Establecer colores iniciales del keyframe 0
|
||||
DynamicTheme& theme = dynamic_themes_[index];
|
||||
|
||||
Reference in New Issue
Block a user