bfff, a casa a meitat enfangà.. be..

Estic acabant de convertir Title
This commit is contained in:
2025-03-03 14:26:07 +01:00
parent 8f1d1df5d6
commit c9e75ad5c8
9 changed files with 190 additions and 81 deletions

View File

@@ -428,6 +428,41 @@ Color stringToColor(Palette pal, const std::string &str)
}
}
// Convierte una cadena a un indice de la paleta
Uint8 stringToColor(const std::string &str)
{
// Mapas de colores para cada paleta
static const std::unordered_map<std::string, Uint8> paletteMap = {
{"black", 1},
{"bright_black", 2},
{"blue", 3},
{"bright_blue", 4},
{"red", 5},
{"bright_red", 6},
{"magenta", 7},
{"bright_magenta", 8},
{"green", 9},
{"bright_green", 10},
{"cyan", 11},
{"bright_cyan", 12},
{"yellow", 13},
{"bright_yellow", 14},
{"white", 15},
{"bright_white", 16}};
// Busca el color en el mapa
auto it = paletteMap.find(str);
if (it != paletteMap.end())
{
return it->second;
}
else
{
// Si no se encuentra el color, devolvemos negro por defecto
return {0};
}
}
// Convierte una cadena a un entero de forma segura
int safeStoi(const std::string &value, int defaultValue)
{