/** * @file color.cpp * @brief Implementación de la gestión de colores de la paleta Amstrad CPC */ #include "color.hpp" #include auto Color::fromString(const std::string& name) -> Uint8 { // Mapa de nombres de colores a índices de paleta // Incluye nombres oficiales del CPC y aliases para compatibilidad static const std::unordered_map COLOR_MAP = { // Transparente {"transparent", index(Cpc::CLEAR)}, // Colores oficiales Amstrad CPC {"black", index(Cpc::BLACK)}, {"blue", index(Cpc::BLUE)}, {"bright_blue", index(Cpc::BRIGHT_BLUE)}, {"red", index(Cpc::RED)}, {"magenta", index(Cpc::MAGENTA)}, {"mauve", index(Cpc::MAUVE)}, {"bright_red", index(Cpc::BRIGHT_RED)}, {"purple", index(Cpc::PURPLE)}, {"bright_magenta", index(Cpc::BRIGHT_MAGENTA)}, {"green", index(Cpc::GREEN)}, {"cyan", index(Cpc::CYAN)}, {"sky_blue", index(Cpc::SKY_BLUE)}, {"yellow", index(Cpc::YELLOW)}, {"white", index(Cpc::WHITE)}, {"pastel_blue", index(Cpc::PASTEL_BLUE)}, {"orange", index(Cpc::ORANGE)}, {"pink", index(Cpc::PINK)}, {"pastel_magenta", index(Cpc::PASTEL_MAGENTA)}, {"bright_green", index(Cpc::BRIGHT_GREEN)}, {"sea_green", index(Cpc::SEA_GREEN)}, {"bright_cyan", index(Cpc::BRIGHT_CYAN)}, {"lime", index(Cpc::LIME)}, {"pastel_green", index(Cpc::PASTEL_GREEN)}, {"pastel_cyan", index(Cpc::PASTEL_CYAN)}, {"bright_yellow", index(Cpc::BRIGHT_YELLOW)}, {"pastel_yellow", index(Cpc::PASTEL_YELLOW)}, {"bright_white", index(Cpc::BRIGHT_WHITE)}, // Aliases para compatibilidad con archivos YAML existentes (Spectrum) {"bright_black", index(Cpc::BLACK)}, // No existe en CPC, mapea a negro }; auto it = COLOR_MAP.find(name); if (it != COLOR_MAP.end()) { return it->second; } // Si no se encuentra, devuelve negro por defecto return index(Cpc::BLACK); }