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>
37 lines
1.5 KiB
C++
37 lines
1.5 KiB
C++
#include "static_theme.h"
|
|
|
|
StaticTheme::StaticTheme(const char* name_en, const char* name_es,
|
|
int text_r, int text_g, int text_b,
|
|
float bg_top_r, float bg_top_g, float bg_top_b,
|
|
float bg_bottom_r, float bg_bottom_g, float bg_bottom_b,
|
|
std::vector<Color> ball_colors)
|
|
: name_en_(name_en),
|
|
name_es_(name_es),
|
|
text_r_(text_r), text_g_(text_g), text_b_(text_b),
|
|
bg_top_r_(bg_top_r), bg_top_g_(bg_top_g), bg_top_b_(bg_top_b),
|
|
bg_bottom_r_(bg_bottom_r), bg_bottom_g_(bg_bottom_g), bg_bottom_b_(bg_bottom_b),
|
|
ball_colors_(std::move(ball_colors)) {
|
|
}
|
|
|
|
Color StaticTheme::getBallColor(size_t ball_index, float progress) const {
|
|
// Tema estático: siempre retorna color de paleta según índice
|
|
// (progress se ignora aquí, pero será usado en PHASE 3 para LERP externo)
|
|
if (ball_colors_.empty()) {
|
|
return {255, 255, 255}; // Blanco por defecto si paleta vacía
|
|
}
|
|
return ball_colors_[ball_index % ball_colors_.size()];
|
|
}
|
|
|
|
void StaticTheme::getBackgroundColors(float progress,
|
|
float& tr, float& tg, float& tb,
|
|
float& br, float& bg, float& bb) const {
|
|
// Tema estático: siempre retorna colores de fondo fijos
|
|
// (progress se ignora aquí, pero será usado en PHASE 3 para LERP externo)
|
|
tr = bg_top_r_;
|
|
tg = bg_top_g_;
|
|
tb = bg_top_b_;
|
|
br = bg_bottom_r_;
|
|
bg = bg_bottom_g_;
|
|
bb = bg_bottom_b_;
|
|
}
|