CARACTERÍSTICAS:
- Notificaciones con fondo personalizado por tema (15 temas)
- Soporte completo para temas estáticos y dinámicos
- Interpolación LERP de colores durante transiciones
- Actualización por frame durante animaciones de temas
IMPLEMENTACIÓN:
Theme System:
- Añadido getNotificationBackgroundColor() a interfaz Theme
- StaticTheme: Color fijo por tema
- DynamicTheme: Interpolación entre keyframes
- ThemeManager: LERP durante transiciones (PHASE 3)
- ThemeSnapshot: Captura color para transiciones suaves
Colores por Tema:
Estáticos (9):
- SUNSET: Púrpura oscuro (120, 40, 80)
- OCEAN: Azul marino (20, 50, 90)
- NEON: Púrpura oscuro (60, 0, 80)
- FOREST: Marrón tierra (70, 50, 30)
- RGB: Gris claro (220, 220, 220)
- MONOCHROME: Gris oscuro (50, 50, 50)
- LAVENDER: Violeta oscuro (80, 50, 100)
- CRIMSON: Rojo oscuro (80, 10, 10)
- EMERALD: Verde oscuro (10, 80, 10)
Dinámicos (6, 20 keyframes totales):
- SUNRISE: 3 keyframes (noche→alba→día)
- OCEAN_WAVES: 2 keyframes (profundo→claro)
- NEON_PULSE: 2 keyframes (apagado→encendido)
- FIRE: 4 keyframes (brasas→llamas→inferno→llamas)
- AURORA: 4 keyframes (verde→violeta→cian→violeta)
- VOLCANIC: 4 keyframes (ceniza→erupción→lava→enfriamiento)
Notifier:
- Añadido SDL_Color bg_color a estructura Notification
- Método show() acepta parámetro bg_color
- renderBackground() usa color dinámico (no negro fijo)
- Soporte para cambios de color cada frame
Engine:
- Obtiene color de fondo desde ThemeManager
- Pasa bg_color al notifier en cada notificación
- Sincronizado con tema activo y transiciones
FIXES:
- TEXT_ABSOLUTE_SIZE cambiado de 16px a 12px (múltiplo nativo)
- Centrado de notificaciones corregido en F3 fullscreen
- updatePhysicalWindowSize() usa SDL_GetCurrentDisplayMode en F3
- Notificaciones centradas correctamente en ventana/F3/F4
🎨 Generated with Claude Code
114 lines
5.6 KiB
C++
114 lines
5.6 KiB
C++
#pragma once
|
|
|
|
#include <memory> // for unique_ptr
|
|
#include <vector> // for vector
|
|
|
|
#include "ball.h" // for Ball class
|
|
#include "defines.h" // for Color, ColorTheme
|
|
#include "themes/theme.h" // for Theme interface
|
|
#include "themes/theme_snapshot.h" // for ThemeSnapshot
|
|
|
|
/**
|
|
* ThemeManager: Gestiona el sistema de temas visuales (unificado, estáticos y dinámicos)
|
|
*
|
|
* PHASE 2 - Sistema Unificado:
|
|
* - Vector unificado de 15 temas (9 estáticos + 6 dinámicos)
|
|
* - Índices 0-14 mapeados a ColorTheme enum (SUNSET=0, OCEAN=1, ..., VOLCANIC=14)
|
|
* - API simplificada: switchToTheme(0-14) para cualquier tema
|
|
* - Sin lógica dual (eliminados if(dynamic_theme_active_) scattered)
|
|
*
|
|
* PHASE 3 - LERP Universal:
|
|
* - Transiciones suaves entre CUALQUIER par de temas (estático↔estático, estático↔dinámico, dinámico↔dinámico)
|
|
* - Sistema de snapshots: Captura estado del tema origen antes de cambiar
|
|
* - LERP durante transición: snapshot origen → tema destino
|
|
* - Duración configurable (THEME_TRANSITION_DURATION = 0.5s por defecto)
|
|
*
|
|
* Responsabilidades:
|
|
* - Mantener 15 temas polimórficos (StaticTheme / DynamicTheme)
|
|
* - Actualizar animación de tema activo si es dinámico
|
|
* - Gestionar transiciones LERP suaves entre temas
|
|
* - Proporcionar colores interpolados para renderizado (con LERP si hay transición activa)
|
|
*
|
|
* Uso desde Engine:
|
|
* - initialize() al inicio
|
|
* - update(delta_time) cada frame (actualiza tema activo + transición LERP)
|
|
* - switchToTheme(0-14) para cambiar tema con transición suave (Numpad/Shift+Numpad, Tecla B)
|
|
* - getInterpolatedColor(index) en render loop (retorna color con LERP si transitioning)
|
|
*/
|
|
class ThemeManager {
|
|
public:
|
|
// Constructor/Destructor
|
|
ThemeManager() = default;
|
|
~ThemeManager() = default;
|
|
|
|
// Inicialización
|
|
void initialize(); // Inicializa 15 temas unificados (9 estáticos + 6 dinámicos)
|
|
|
|
// Interfaz unificada (PHASE 2 + PHASE 3)
|
|
void switchToTheme(int theme_index); // Cambia a tema 0-14 con transición LERP suave (PHASE 3)
|
|
void update(float delta_time); // Actualiza transición LERP + tema activo si es dinámico
|
|
void cycleTheme(); // Cicla al siguiente tema (0→1→...→14→0) - Tecla B
|
|
void cyclePrevTheme(); // Cicla al tema anterior (14→...→1→0) - Shift+B
|
|
void pauseDynamic(); // Toggle pausa de animación (Shift+D, solo dinámicos)
|
|
|
|
// Queries de colores (usado en rendering)
|
|
Color getInterpolatedColor(size_t ball_index) const; // Obtiene color interpolado para pelota
|
|
void getBackgroundColors(float& top_r, float& top_g, float& top_b,
|
|
float& bottom_r, float& bottom_g, float& bottom_b) const; // Obtiene colores de fondo degradado
|
|
|
|
// Queries de estado (para debug display y lógica)
|
|
int getCurrentThemeIndex() const { return current_theme_index_; }
|
|
bool isCurrentThemeDynamic() const;
|
|
bool isTransitioning() const { return transitioning_; } // ¿Hay transición LERP activa? (PHASE 3)
|
|
|
|
// Obtener información de tema actual para debug display
|
|
const char* getCurrentThemeNameEN() const;
|
|
const char* getCurrentThemeNameES() const;
|
|
void getCurrentThemeTextColor(int& r, int& g, int& b) const;
|
|
void getCurrentNotificationBackgroundColor(int& r, int& g, int& b) const;
|
|
|
|
// Obtener color inicial para nuevas pelotas (usado en initBalls)
|
|
Color getInitialBallColor(int random_index) const;
|
|
|
|
private:
|
|
// ========================================
|
|
// DATOS UNIFICADOS (PHASE 2)
|
|
// ========================================
|
|
|
|
// Vector unificado de 15 temas (índices 0-14)
|
|
// 0-8: Estáticos (SUNSET, OCEAN, NEON, FOREST, RGB, MONOCHROME, LAVENDER, CRIMSON, EMERALD)
|
|
// 9-14: Dinámicos (SUNRISE, OCEAN_WAVES, NEON_PULSE, FIRE, AURORA, VOLCANIC)
|
|
std::vector<std::unique_ptr<Theme>> themes_;
|
|
|
|
// Índice de tema activo actual (0-14)
|
|
int current_theme_index_ = 0; // Por defecto SUNSET
|
|
|
|
// ========================================
|
|
// SISTEMA DE TRANSICIÓN LERP (PHASE 3)
|
|
// ========================================
|
|
|
|
// Estado de transición
|
|
bool transitioning_ = false; // ¿Hay transición LERP activa?
|
|
float transition_progress_ = 0.0f; // Progreso 0.0-1.0 (0.0 = origen, 1.0 = destino)
|
|
float transition_duration_ = THEME_TRANSITION_DURATION; // Duración en segundos (configurable en defines.h)
|
|
|
|
// Índices de temas involucrados en transición
|
|
int source_theme_index_ = 0; // Tema origen (del que venimos)
|
|
int target_theme_index_ = 0; // Tema destino (al que vamos)
|
|
|
|
// Snapshot del tema origen (capturado al iniciar transición)
|
|
std::unique_ptr<ThemeSnapshot> source_snapshot_; // nullptr si no hay transición
|
|
|
|
// ========================================
|
|
// MÉTODOS PRIVADOS
|
|
// ========================================
|
|
|
|
// Inicialización
|
|
void initializeStaticThemes(); // Crea 9 temas estáticos (índices 0-8)
|
|
void initializeDynamicThemes(); // Crea 6 temas dinámicos (índices 9-14)
|
|
|
|
// Sistema de transición LERP (PHASE 3)
|
|
std::unique_ptr<ThemeSnapshot> captureCurrentSnapshot() const; // Captura snapshot del tema actual
|
|
float lerp(float a, float b, float t) const { return a + (b - a) * t; } // Interpolación lineal
|
|
};
|