PHASE 2: Refactorización completa del sistema de temas unificado

Arquitectura polimórfica implementada:
- Jerarquía: Theme (base) → StaticTheme / DynamicTheme (derivadas)
- Vector unificado de 10 temas (7 estáticos + 3 dinámicos)
- Eliminada lógica dual (if(dynamic_theme_active_) scattered)

Nuevos archivos:
- source/themes/theme.h: Interfaz base abstracta
- source/themes/static_theme.h/cpp: Temas estáticos (1 keyframe)
- source/themes/dynamic_theme.h/cpp: Temas dinámicos (N keyframes animados)
- source/theme_manager.h/cpp: Gestión unificada de temas

Mejoras de API:
- switchToTheme(0-9): Cambio a cualquier tema (índice 0-9)
- cycleTheme(): Cicla por todos los temas (Tecla B)
- update(delta_time): Actualización simplificada
- getInterpolatedColor(idx): Sin parámetro balls_

Bugs corregidos:
- Tecla B ahora cicla TODOS los 10 temas (antes solo 6)
- DEMO mode elige de TODOS los temas (antes excluía LAVENDER + dinámicos)
- Eliminada duplicación de keyframes en temas dinámicos (loop=true lo maneja)

Código reducido:
- theme_manager.cpp: 558 → 320 líneas (-43%)
- engine.cpp: Eliminados ~470 líneas de lógica de temas
- Complejidad significativamente reducida

Preparado para PHASE 3 (LERP universal entre cualquier par de temas)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-09 13:17:54 +02:00
parent b93028396a
commit a134ae428f
11 changed files with 988 additions and 680 deletions

View File

@@ -48,6 +48,16 @@ struct Color {
int r, g, b; // Componentes rojo, verde, azul (0-255)
};
// Estructura de tema de colores estático
struct ThemeColors {
const char* name_en; // Nombre en inglés (para debug)
const char* name_es; // Nombre en español (para display)
int text_color_r, text_color_g, text_color_b; // Color del texto del tema
float bg_top_r, bg_top_g, bg_top_b;
float bg_bottom_r, bg_bottom_g, bg_bottom_b;
std::vector<Color> ball_colors;
};
// Estructura para keyframe de tema dinámico
struct DynamicThemeKeyframe {
// Fondo degradado
@@ -62,14 +72,8 @@ struct DynamicThemeKeyframe {
float duration;
};
// Estructura para tema dinámico (animado)
struct DynamicTheme {
const char* name_en; // Nombre en inglés
const char* name_es; // Nombre en español
int text_color_r, text_color_g, text_color_b; // Color del texto del tema
std::vector<DynamicThemeKeyframe> keyframes; // Mínimo 2 keyframes
bool loop; // ¿Volver al inicio al terminar?
};
// NOTA: La clase DynamicTheme (tema dinámico animado) está definida en themes/dynamic_theme.h
// Esta estructura de datos es solo para definir keyframes que se pasan al constructor
// Enum para dirección de gravedad
enum class GravityDirection {