Experimento parcial de migración a C++20 modules
- Creados módulos core, themes, physics, rendering, input - Integrados core y themes exitosamente en main.cpp - Physics, rendering, input comentados por conflictos SDL - Aplicación funcional con módulos parciales - Experimento archivado para futuras referencias 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
export module vibe2.themes;
|
||||
|
||||
import vibe2.core;
|
||||
|
||||
export namespace vibe2::themes {
|
||||
|
||||
// Estructura para datos de un tema
|
||||
struct ThemeData {
|
||||
// Colores de fondo (superior -> inferior) en formato float [0-1]
|
||||
float bg_top_r, bg_top_g, bg_top_b;
|
||||
float bg_bottom_r, bg_bottom_g, bg_bottom_b;
|
||||
|
||||
// Paletas de colores para elementos (RGB 0-255)
|
||||
int element_colors[8][3]; // 8 colores por tema
|
||||
|
||||
// Nombres del tema
|
||||
const char* name_en;
|
||||
const char* name_es;
|
||||
};
|
||||
|
||||
// Definición de todos los temas disponibles
|
||||
constexpr ThemeData THEME_DATA[4] = {
|
||||
// SUNSET: Naranjas, rojos, amarillos, rosas
|
||||
{
|
||||
180.0f / 255.0f, 140.0f / 255.0f, 100.0f / 255.0f, // Fondo superior
|
||||
40.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, // Fondo inferior
|
||||
{{255, 140, 0}, {255, 69, 0}, {255, 215, 0}, {255, 20, 147},
|
||||
{255, 99, 71}, {255, 165, 0}, {255, 192, 203}, {220, 20, 60}},
|
||||
"SUNSET", "ATARDECER"
|
||||
},
|
||||
// OCEAN: Azules, cianes, verdes agua, blancos
|
||||
{
|
||||
100.0f / 255.0f, 150.0f / 255.0f, 200.0f / 255.0f, // Fondo superior
|
||||
20.0f / 255.0f, 40.0f / 255.0f, 80.0f / 255.0f, // Fondo inferior
|
||||
{{0, 191, 255}, {0, 255, 255}, {32, 178, 170}, {176, 224, 230},
|
||||
{70, 130, 180}, {0, 206, 209}, {240, 248, 255}, {64, 224, 208}},
|
||||
"OCEAN", "OCEANO"
|
||||
},
|
||||
// NEON: Cian, magenta, verde lima, amarillo vibrante
|
||||
{
|
||||
20.0f / 255.0f, 20.0f / 255.0f, 40.0f / 255.0f, // Fondo superior
|
||||
0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, // Fondo inferior
|
||||
{{0, 255, 255}, {255, 0, 255}, {50, 205, 50}, {255, 255, 0},
|
||||
{255, 20, 147}, {0, 255, 127}, {138, 43, 226}, {255, 69, 0}},
|
||||
"NEON", "NEON"
|
||||
},
|
||||
// FOREST: Verdes, marrones, amarillos otoño
|
||||
{
|
||||
144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, // Fondo superior
|
||||
101.0f / 255.0f, 67.0f / 255.0f, 33.0f / 255.0f, // Fondo inferior
|
||||
{{34, 139, 34}, {107, 142, 35}, {154, 205, 50}, {255, 215, 0},
|
||||
{210, 180, 140}, {160, 82, 45}, {218, 165, 32}, {50, 205, 50}},
|
||||
"FOREST", "BOSQUE"
|
||||
}
|
||||
};
|
||||
|
||||
// Colores específicos para debug UI por tema
|
||||
constexpr int DEBUG_COLORS[4][3] = {
|
||||
{255, 140, 60}, // ATARDECER: Naranja cálido
|
||||
{80, 200, 255}, // OCEANO: Azul océano
|
||||
{255, 60, 255}, // NEON: Magenta brillante
|
||||
{100, 255, 100} // BOSQUE: Verde natural
|
||||
};
|
||||
|
||||
// Gestor de temas
|
||||
class ThemeManager {
|
||||
private:
|
||||
ColorTheme current_theme_;
|
||||
|
||||
public:
|
||||
ThemeManager(ColorTheme initial_theme = ColorTheme::SUNSET)
|
||||
: current_theme_(initial_theme) {}
|
||||
|
||||
// Cambiar tema
|
||||
void setTheme(ColorTheme theme) {
|
||||
current_theme_ = theme;
|
||||
}
|
||||
|
||||
// Ciclar al siguiente tema
|
||||
void cycleTheme() {
|
||||
int next = (static_cast<int>(current_theme_) + 1) % 4;
|
||||
current_theme_ = static_cast<ColorTheme>(next);
|
||||
}
|
||||
|
||||
// Obtener tema actual
|
||||
ColorTheme getCurrentTheme() const {
|
||||
return current_theme_;
|
||||
}
|
||||
|
||||
// Obtener datos del tema actual
|
||||
const ThemeData& getCurrentThemeData() const {
|
||||
return THEME_DATA[static_cast<int>(current_theme_)];
|
||||
}
|
||||
|
||||
// Obtener color aleatorio de la paleta actual
|
||||
Color getRandomColor() const {
|
||||
const auto& theme_data = getCurrentThemeData();
|
||||
// Usar random simple para evitar dependencias
|
||||
static int seed = 1;
|
||||
seed = seed * 1103515245 + 12345;
|
||||
int color_index = (seed / 65536) % 8;
|
||||
|
||||
return Color(
|
||||
theme_data.element_colors[color_index][0],
|
||||
theme_data.element_colors[color_index][1],
|
||||
theme_data.element_colors[color_index][2]
|
||||
);
|
||||
}
|
||||
|
||||
// Obtener color específico de la paleta actual
|
||||
Color getColor(int index) const {
|
||||
const auto& theme_data = getCurrentThemeData();
|
||||
index = index % 8; // Asegurar que esté en rango
|
||||
return Color(
|
||||
theme_data.element_colors[index][0],
|
||||
theme_data.element_colors[index][1],
|
||||
theme_data.element_colors[index][2]
|
||||
);
|
||||
}
|
||||
|
||||
// Obtener nombre del tema en inglés
|
||||
const char* getThemeName() const {
|
||||
return getCurrentThemeData().name_en;
|
||||
}
|
||||
|
||||
// Obtener nombre del tema en español
|
||||
const char* getThemeNameES() const {
|
||||
return getCurrentThemeData().name_es;
|
||||
}
|
||||
|
||||
// Obtener color de debug para el tema actual
|
||||
Color getDebugColor() const {
|
||||
int theme_idx = static_cast<int>(current_theme_);
|
||||
return Color(
|
||||
DEBUG_COLORS[theme_idx][0],
|
||||
DEBUG_COLORS[theme_idx][1],
|
||||
DEBUG_COLORS[theme_idx][2]
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// Funciones de utilidad
|
||||
inline const char* getThemeNameEN(ColorTheme theme) {
|
||||
return THEME_DATA[static_cast<int>(theme)].name_en;
|
||||
}
|
||||
|
||||
inline const char* getThemeNameES(ColorTheme theme) {
|
||||
return THEME_DATA[static_cast<int>(theme)].name_es;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user