diff --git a/data/config/param_320x240.txt b/data/config/param_320x240.txt index 067440e..f2a870b 100644 --- a/data/config/param_320x240.txt +++ b/data/config/param_320x240.txt @@ -31,10 +31,8 @@ title.arcade_edition_position 123 title.title_c_c_position 80 ## BACKGROUND -background.attenuate_color.r 255 -background.attenuate_color.g 255 -background.attenuate_color.b 255 -background.attenuate_alpha 0 +background.attenuate_color FFFFFF +background.attenuate_alpha 0 ## BALLOONS balloon_1.vel 2.75f @@ -50,6 +48,4 @@ balloon_4.grav 0.10f notification.pos_v TOP notification.pos_h LEFT notification.sound false -notification.color.r 48 -notification.color.g 48 -notification.color.b 48 \ No newline at end of file +notification.color 303030 \ No newline at end of file diff --git a/data/config/param_320x256.txt b/data/config/param_320x256.txt index 874eaa4..3a84a22 100644 --- a/data/config/param_320x256.txt +++ b/data/config/param_320x256.txt @@ -31,10 +31,8 @@ title.arcade_edition_position 123 title.title_c_c_position 80 ## BACKGROUND -background.attenuate_color.r 255 -background.attenuate_color.g 255 -background.attenuate_color.b 255 -background.attenuate_alpha 0 +background.attenuate_color FFFFFF +background.attenuate_alpha 0 ## BALLOONS balloon_1.vel 2.75f @@ -50,6 +48,4 @@ balloon_4.grav 0.10f notification.pos_v TOP notification.pos_h LEFT notification.sound false -notification.color.r 48 -notification.color.g 48 -notification.color.b 48 \ No newline at end of file +notification.color 303030 \ No newline at end of file diff --git a/source/director.cpp b/source/director.cpp index ed221ff..19c161c 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -142,6 +142,9 @@ void Director::loadParams() void Director::loadScoreFile() { auto manager = std::make_unique(Options::settings.hi_score_table); +#ifdef DEBUG + manager->clear(); +#else if (overrides.clear_hi_score_table) { manager->clear(); @@ -150,6 +153,7 @@ void Director::loadScoreFile() { manager->loadFromFile(Asset::get()->get("score.bin")); } +#endif } // Asigna los botones y teclas al objeto Input diff --git a/source/enter_name.h b/source/enter_name.h index 6d43093..139d7fc 100644 --- a/source/enter_name.h +++ b/source/enter_name.h @@ -5,7 +5,7 @@ #include "utils.h" // Archivo de utilidades // Tamaño máximo del nombre -constexpr size_t NAME_SIZE = 3; +constexpr size_t NAME_SIZE = 5; // Clase EnterName class EnterName @@ -32,9 +32,9 @@ private: std::string name_; // Nombre en proceso size_t position_ = 0; // Índice del carácter que se edita bool position_overflow_ = false; // Flag para exceder límite - std::array character_index_; // Índices a `character_list_` + std::array character_index_; // Índices a "character_list_" - void updateNameFromCharacterIndex(); // Actualiza `name_` según `character_index_` + void updateNameFromCharacterIndex(); // Actualiza "name_" según "character_index_" void initCharacterIndex(const std::string &name); // Inicializa índices desde el nombre - int findIndex(char character) const; // Busca el índice de un carácter en `character_list_` + int findIndex(char character) const; // Busca el índice de un carácter en "character_list_" }; \ No newline at end of file diff --git a/source/param.cpp b/source/param.cpp index 7426ac1..518cee9 100644 --- a/source/param.cpp +++ b/source/param.cpp @@ -240,19 +240,9 @@ bool setParams(const std::string &var, const std::string &value) } // BACKGROUND - else if (var == "background.attenuate_color.r") + else if (var == "background.attenuate_color") { - param.background.attenuate_color.r = std::stoi(value); - } - - else if (var == "background.attenuate_color.g") - { - param.background.attenuate_color.g = std::stoi(value); - } - - else if (var == "background.attenuate_color.b") - { - param.background.attenuate_color.b = std::stoi(value); + param.background.attenuate_color = Color::fromHex(value); } else if (var == "background.attenuate_alpha") @@ -328,19 +318,9 @@ bool setParams(const std::string &var, const std::string &value) param.notification.sound = stringToBool(value); } - else if (var == "notification.color.r") + else if (var == "notification.color") { - param.notification.color.r = std::stoi(value); - } - - else if (var == "notification.color.g") - { - param.notification.color.g = std::stoi(value); - } - - else if (var == "notification.color.b") - { - param.notification.color.b = std::stoi(value); + param.notification.color = Color::fromHex(value); } // RESTO diff --git a/source/utils.h b/source/utils.h index f91950f..ee0c06e 100644 --- a/source/utils.h +++ b/source/utils.h @@ -8,6 +8,7 @@ #include // Para string #include // Para vector #include // Para array +#include // --- Constantes --- constexpr int BLOCK = 8; @@ -19,10 +20,9 @@ struct Overrides { std::string param_file; // Fichero de parametros a utilizar bool clear_hi_score_table; // Reinicia la tabla de records - bool set_v_sync; // Establece el vsync Overrides() - : param_file(""), clear_hi_score_table(false), set_v_sync(false) {} + : param_file(""), clear_hi_score_table(false) {} }; extern Overrides overrides; @@ -57,6 +57,36 @@ struct Color std::max(0, g - amount), std::max(0, b - amount)); } + + // Método estático para crear Color desde string hexadecimal + static Color fromHex(const std::string& hexStr) + { + std::string hex = hexStr; + + // Quitar '#' si existe + if (!hex.empty() && hex[0] == '#') { + hex = hex.substr(1); + } + + // Verificar longitud válida (6 caracteres para RGB) + if (hex.length() != 6) { + throw std::invalid_argument("String hexadecimal debe tener 6 caracteres"); + } + + // Verificar que todos los caracteres sean hexadecimales válidos + 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 + Uint8 r = static_cast(std::stoi(hex.substr(0, 2), nullptr, 16)); + Uint8 g = static_cast(std::stoi(hex.substr(2, 2), nullptr, 16)); + Uint8 b = static_cast(std::stoi(hex.substr(4, 2), nullptr, 16)); + + return Color(r, g, b); + } }; // Estructura para definir un color HSV