creat param_red.txt
afegides guardes en setParams
This commit is contained in:
@@ -194,11 +194,48 @@ auto setParams(const std::string& var, const std::string& value) -> bool {
|
||||
|
||||
static const std::unordered_map<std::string, std::function<void(const std::string&)>> INT_PARAMS_EXTRA = {};
|
||||
|
||||
// Colores válidos para globos
|
||||
static const std::unordered_map<std::string, bool> VALID_BALLOON_COLORS = {
|
||||
{"blue", true}, {"orange", true}, {"red", true}, {"green", true}
|
||||
};
|
||||
|
||||
auto validateBalloonColor = [](const std::string& color) -> bool {
|
||||
return VALID_BALLOON_COLORS.find(color) != VALID_BALLOON_COLORS.end();
|
||||
};
|
||||
|
||||
static const std::unordered_map<std::string, std::function<void(const std::string&)>> STRING_PARAMS = {
|
||||
{"balloon.color[0]", [](const std::string& v) { param.balloon.color.at(0) = v; }},
|
||||
{"balloon.color[1]", [](const std::string& v) { param.balloon.color.at(1) = v; }},
|
||||
{"balloon.color[2]", [](const std::string& v) { param.balloon.color.at(2) = v; }},
|
||||
{"balloon.color[3]", [](const std::string& v) { param.balloon.color.at(3) = v; }}};
|
||||
{"balloon.color[0]", [validateBalloonColor](const std::string& v) {
|
||||
if (!validateBalloonColor(v)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Color de globo inválido '%s'. Usando 'blue' por defecto.", v.c_str());
|
||||
param.balloon.color.at(0) = "blue";
|
||||
} else {
|
||||
param.balloon.color.at(0) = v;
|
||||
}
|
||||
}},
|
||||
{"balloon.color[1]", [validateBalloonColor](const std::string& v) {
|
||||
if (!validateBalloonColor(v)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Color de globo inválido '%s'. Usando 'orange' por defecto.", v.c_str());
|
||||
param.balloon.color.at(1) = "orange";
|
||||
} else {
|
||||
param.balloon.color.at(1) = v;
|
||||
}
|
||||
}},
|
||||
{"balloon.color[2]", [validateBalloonColor](const std::string& v) {
|
||||
if (!validateBalloonColor(v)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Color de globo inválido '%s'. Usando 'red' por defecto.", v.c_str());
|
||||
param.balloon.color.at(2) = "red";
|
||||
} else {
|
||||
param.balloon.color.at(2) = v;
|
||||
}
|
||||
}},
|
||||
{"balloon.color[3]", [validateBalloonColor](const std::string& v) {
|
||||
if (!validateBalloonColor(v)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Color de globo inválido '%s'. Usando 'green' por defecto.", v.c_str());
|
||||
param.balloon.color.at(3) = "green";
|
||||
} else {
|
||||
param.balloon.color.at(3) = v;
|
||||
}
|
||||
}}};
|
||||
|
||||
// Lambda para intentar cada mapa de parámetros
|
||||
auto try_map = [&](const auto& param_map) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user