Title: la visualització d'alguns elements ja no depen de counter sino del rellotge. Quan apretes la tecla 2, per exemple, ja no fa coses rares el lletrero de PULSA PER A JUGAR

This commit is contained in:
2025-06-29 12:06:44 +02:00
parent 5006289a5d
commit c58e9714e2
4 changed files with 76 additions and 57 deletions

View File

@@ -61,38 +61,43 @@ struct Color
}
// Método estático para crear Color desde string hexadecimal
static Color fromHex(const std::string& hexStr)
static Color fromHex(const std::string &hexStr)
{
std::string hex = hexStr;
// Quitar '#' si existe
if (!hex.empty() && hex[0] == '#') {
if (!hex.empty() && hex[0] == '#')
{
hex = hex.substr(1);
}
// Verificar longitud válida (6 para RGB o 8 para RGBA)
if (hex.length() != 6 && hex.length() != 8) {
if (hex.length() != 6 && hex.length() != 8)
{
throw std::invalid_argument("String hexadecimal debe tener 6 o 8 caracteres");
}
// Verificar que todos los caracteres sean hexadecimales válidos
for (char c : hex) {
if (!std::isxdigit(c)) {
for (char c : hex)
{
if (!std::isxdigit(c))
{
throw std::invalid_argument("String contiene caracteres no hexadecimales");
}
}
// Convertir cada par de caracteres a valores RGB(A)
Uint8 r = static_cast<Uint8>(std::stoi(hex.substr(0, 2), nullptr, 16));
Uint8 g = static_cast<Uint8>(std::stoi(hex.substr(2, 2), nullptr, 16));
Uint8 b = static_cast<Uint8>(std::stoi(hex.substr(4, 2), nullptr, 16));
Uint8 a = 255; // Alpha por defecto
// Si tiene 8 caracteres, extraer el alpha
if (hex.length() == 8) {
if (hex.length() == 8)
{
a = static_cast<Uint8>(std::stoi(hex.substr(6, 2), nullptr, 16));
}
return Color(r, g, b, a);
}
};
@@ -106,14 +111,13 @@ struct HSV
// Estructura para definir el ciclo de color
enum class ColorCycleStyle
{
SubtlePulse, // Variación leve en brillo (por defecto)
HueWave, // Variación suave en tono (sin verde)
Vibrant, // Cambios agresivos en tono y brillo
DarkenGlow, // Oscurece hacia el centro y regresa
LightFlash // Ilumina hacia el centro y regresa
SubtlePulse, // Variación leve en brillo (por defecto)
HueWave, // Variación suave en tono (sin verde)
Vibrant, // Cambios agresivos en tono y brillo
DarkenGlow, // Oscurece hacia el centro y regresa
LightFlash // Ilumina hacia el centro y regresa
};
// Posiciones de las notificaciones
enum class NotifyPosition
{
@@ -173,6 +177,7 @@ using ColorCycle = std::array<Color, 2 * COLOR_CYCLE_SIZE>;
// Colores
constexpr Color NO_TEXT_COLOR = Color(0XFF, 0XFF, 0XFF);
constexpr Color SHADOW_TEXT_COLOR = Color(0X43, 0X43, 0X4F);
constexpr Color TITLE_SHADOW_TEXT_COLOR = Color(0x14, 0x87, 0xc4);
constexpr Color FLASH_COLOR = Color(0XFF, 0XFF, 0XFF);