This commit is contained in:
2025-10-19 22:01:31 +02:00
parent 16306f2325
commit 2b4523d644
101 changed files with 2058 additions and 1564 deletions

View File

@@ -1,18 +1,19 @@
#include "param.hpp"
#include <SDL3/SDL.h> // Para SDL_LogCategory, SDL_LogError, SDL_LogInfo
#include <SDL3/SDL.h> // Para SDL_LogWarn, SDL_LogCategory, SDL_LogError
#include <fstream> // Para basic_istream, basic_ifstream, ifstream
#include <functional>
#include <sstream> // Para basic_istringstream
#include <stdexcept> // Para runtime_error
#include <string> // Para operator==, stoi, char_traits, string, ope...
#include <unordered_map>
#include <fstream> // Para basic_istream, basic_ifstream, ifstream, istringstream
#include <functional> // Para function
#include <sstream> // Para basic_istringstream
#include <stdexcept> // Para runtime_error
#include <string> // Para string, basic_string, stoi, stof, hash, allocator, operator==, char_traits, operator+, operator>>, getline
#include <unordered_map> // Para unordered_map, operator==, _Node_iterator_base
#include <utility> // Para pair
#include "color.hpp"
#include "ui/notifier.hpp" // Para Notifier::Position
#include "utils.hpp"
#include "ui/logger.hpp" // Para Logger
#include "color.hpp" // Para Color
#include "ui/logger.hpp" // Para info, YELLOW
#include "ui/notifier.hpp" // Para Notifier
#include "utils.hpp" // Para Zone, stringToBool, getFileName
// Variable global - ahora se inicializa automáticamente con valores por defecto
Param param;
@@ -53,7 +54,7 @@ void loadParamsFromFile(const std::string& file_path) {
throw std::runtime_error("No se pudo abrir el archivo: " + file_path);
}
//SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\nReading file: %s", getFileName(file_path).c_str());
// SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\nReading file: %s", getFileName(file_path).c_str());
Logger::info("Reading file: " + getFileName(file_path));
std::string line;
@@ -202,37 +203,37 @@ auto setParams(const std::string& var, const std::string& value) -> bool {
{"red", true},
{"green", true}};
auto validateBalloonColor = [](const std::string& color) -> bool {
auto validate_balloon_color = [](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]", [validateBalloonColor](const std::string& v) {
if (!validateBalloonColor(v)) {
{"balloon.color[0]", [validate_balloon_color](const std::string& v) {
if (!validate_balloon_color(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)) {
{"balloon.color[1]", [validate_balloon_color](const std::string& v) {
if (!validate_balloon_color(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)) {
{"balloon.color[2]", [validate_balloon_color](const std::string& v) {
if (!validate_balloon_color(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)) {
{"balloon.color[3]", [validate_balloon_color](const std::string& v) {
if (!validate_balloon_color(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 {