afegit window_message a param

This commit is contained in:
2025-08-16 11:24:28 +02:00
parent 81d486f2d3
commit a123b3aa93
7 changed files with 225 additions and 138 deletions

View File

@@ -75,9 +75,23 @@ notification.color 303030 # Color de fondo de la notificación (hexadecimal)
service_menu.title_color 99FF62 # Color del título del menú de servicio service_menu.title_color 99FF62 # Color del título del menú de servicio
service_menu.text_color FFFFFF # Color del texto del menú de servicio service_menu.text_color FFFFFF # Color del texto del menú de servicio
service_menu.selected_color FFDC44 # Color de la opción seleccionada en el menú de servicio service_menu.selected_color FFDC44 # Color de la opción seleccionada en el menú de servicio
service_menu.bg_color 003000F5 # Color de fondo del menú de servicio (RGBA hexadecimal) service_menu.bg_color 000F00F5 # Color de fondo del menú de servicio (RGBA hexadecimal)
service_menu.drop_shadow false # ¿El menú de servicio tiene sombra? service_menu.drop_shadow false # ¿El menú de servicio tiene sombra?
service_menu.window_message.bg_color 141E32F0 # Color de fondo de ventanas de mensaje (RGBA hexadecimal)
service_menu.window_message.border_color 6496C8FF # Color del borde de ventanas de mensaje (RGBA hexadecimal)
service_menu.window_message.title_color 6496C8FF # Color del título en ventanas de mensaje (RGBA hexadecimal)
service_menu.window_message.text_color DCDCDCFF # Color del texto en ventanas de mensaje (RGBA hexadecimal)
service_menu.window_message.padding 15.0f # Espaciado interno de ventanas de mensaje (píxeles)
service_menu.window_message.line_spacing 5.0f # Espaciado entre líneas de texto (píxeles)
service_menu.window_message.title_separator_spacing 10.0f # Espaciado entre título y contenido (píxeles)
service_menu.window_message.min_width 250.0f # Ancho mínimo de ventanas de mensaje (píxeles)
service_menu.window_message.min_height 32.0f # Alto mínimo de ventanas de mensaje (píxeles)
service_menu.window_message.max_width_ratio 0.8f # Ratio máximo de ancho respecto a pantalla (0.0-1.0)
service_menu.window_message.max_height_ratio 0.8f # Ratio máximo de alto respecto a pantalla (0.0-1.0)
service_menu.window_message.text_safety_margin 15.0f # Margen de seguridad para el texto (píxeles)
service_menu.window_message.animation_duration 0.3f # Duración de animaciones de ventanas (segundos)
# --- INTRO --- # --- INTRO ---
intro.bg_color 4664BD # Color de fondo de la intro intro.bg_color 4664BD # Color de fondo de la intro
intro.card_color CBDBFC # Color de las tarjetas en la intro intro.card_color CBDBFC # Color de las tarjetas en la intro

View File

@@ -78,19 +78,32 @@ service_menu.selected_color FFDC44 # Color de la opción seleccionada en el
service_menu.bg_color 000F00F5 # Color de fondo del menú de servicio (RGBA hexadecimal) service_menu.bg_color 000F00F5 # Color de fondo del menú de servicio (RGBA hexadecimal)
service_menu.drop_shadow false # ¿El menú de servicio tiene sombra? service_menu.drop_shadow false # ¿El menú de servicio tiene sombra?
service_menu.window_message.bg_color 141E32F0 # Color de fondo de ventanas de mensaje (RGBA hexadecimal)
service_menu.window_message.border_color 6496C8FF # Color del borde de ventanas de mensaje (RGBA hexadecimal)
service_menu.window_message.title_color 6496C8FF # Color del título en ventanas de mensaje (RGBA hexadecimal)
service_menu.window_message.text_color DCDCDCFF # Color del texto en ventanas de mensaje (RGBA hexadecimal)
service_menu.window_message.padding 15.0f # Espaciado interno de ventanas de mensaje (píxeles)
service_menu.window_message.line_spacing 5.0f # Espaciado entre líneas de texto (píxeles)
service_menu.window_message.title_separator_spacing 10.0f # Espaciado entre título y contenido (píxeles)
service_menu.window_message.min_width 250.0f # Ancho mínimo de ventanas de mensaje (píxeles)
service_menu.window_message.min_height 32.0f # Alto mínimo de ventanas de mensaje (píxeles)
service_menu.window_message.max_width_ratio 0.8f # Ratio máximo de ancho respecto a pantalla (0.0-1.0)
service_menu.window_message.max_height_ratio 0.8f # Ratio máximo de alto respecto a pantalla (0.0-1.0)
service_menu.window_message.text_safety_margin 15.0f # Margen de seguridad para el texto (píxeles)
service_menu.window_message.animation_duration 0.3f # Duración de animaciones de ventanas (segundos)
# --- INTRO --- # --- INTRO ---
intro.bg_color 4664BD # Color de fondo de la intro intro.bg_color 4664BD # Color de fondo de la intro
intro.card_color CBDBFC # Color de las tarjetas en la intro intro.card_color CBDBFC # Color de las tarjetas en la intro
intro.shadow_color 00000080 # Color de la sombra de las tarjetas en la intro intro.shadow_color 00000080 # Color de la sombra de las tarjetas en la intro
intro.text_distance_from_bottom 48 # Posicion del texto intro.text_distance_from_bottom 48 # Posición del texto desde la parte inferior
# --- DEBUG --- # --- DEBUG ---
debug.color 00FFFF # Color para elementos de depuración debug.color 00FFFF # Color para elementos de depuración
# --- RESOURCE --- # --- RESOURCE ---
resource.color FFFFFF # Color de recurso 1 resource.color FFFFFF # Color de recursos
resource.color FFFFFF # Color de recurso 2
# --- TABE --- # --- TABE ---
tabe.min_spawn_time 2.0f # Tiempo mínimo en minutos para que aparezca el Tabe tabe.min_spawn_time 2.0f # Tiempo mínimo en segundos para que aparezca el Tabe
tabe.max_spawn_time 3.0f # Tiempo máximo en minutos para que aparezca el Tabe tabe.max_spawn_time 3.0f # Tiempo máximo en segundos para que aparezca el Tabe

View File

@@ -104,6 +104,23 @@ constexpr const char* TEXT_COLOR = "FFFFFF";
constexpr const char* SELECTED_COLOR = "FFDC44"; constexpr const char* SELECTED_COLOR = "FFDC44";
constexpr const char* BG_COLOR = "000F00F5"; constexpr const char* BG_COLOR = "000F00F5";
constexpr bool DROP_SHADOW = false; constexpr bool DROP_SHADOW = false;
// WindowMessage defaults
namespace WindowMessage {
constexpr const char* BG_COLOR = "141E32F0"; // Color(20, 30, 50, 240)
constexpr const char* BORDER_COLOR = "6496C8FF"; // Color(100, 150, 200, 255)
constexpr const char* TITLE_COLOR = "6496C8FF"; // Color(100, 150, 200, 255)
constexpr const char* TEXT_COLOR = "DCDCDCFF"; // Color(220, 220, 220, 255)
constexpr float PADDING = 15.0f;
constexpr float LINE_SPACING = 5.0f;
constexpr float TITLE_SEPARATOR_SPACING = 10.0f; // Cambiado a float
constexpr float MIN_WIDTH = 250.0f;
constexpr float MIN_HEIGHT = 32.0f; // Cambiado a float
constexpr float MAX_WIDTH_RATIO = 0.8f; // Nuevo
constexpr float MAX_HEIGHT_RATIO = 0.8f; // Nuevo
constexpr float TEXT_SAFETY_MARGIN = 15.0f;
constexpr float ANIMATION_DURATION = 0.3f;
} // namespace WindowMessage
} // namespace ServiceMenu } // namespace ServiceMenu
// --- INTRO --- // --- INTRO ---

View File

@@ -24,20 +24,7 @@ DefineButtons::DefineButtons()
} }
// Crear la ventana de mensaje // Crear la ventana de mensaje
WindowMessage::Config config; WindowMessage::Config config(param.service_menu.window_message);
config.bg_color = Color{20, 30, 50, 240}; // Fondo azul oscuro semi-transparente
config.border_color = Color{100, 150, 200, 255}; // Borde azul claro
config.title_color = Color{100, 150, 200, 255}; // Titulo azul claro
config.text_color = Color{220, 220, 220, 255}; // Texto gris claro
config.padding = 15.0F;
config.line_spacing = 5.0F;
config.title_separator_spacing = 15;
config.min_width = 250.0F;
config.text_safety_margin = 15.0F;
config.min_width = 100;
config.min_height = 32;
config.animation_duration = 0.3F;
auto text_renderer = Resource::get()->getText("04b_25_flat"); auto text_renderer = Resource::get()->getText("04b_25_flat");
window_message_ = std::make_unique<WindowMessage>( window_message_ = std::make_unique<WindowMessage>(
text_renderer, text_renderer,

View File

@@ -11,13 +11,14 @@
#include "color.h" #include "color.h"
#include "utils.h" #include "utils.h"
#include "ui/notifier.h"
// Variable global - ahora se inicializa automáticamente con valores por defecto // Variable global - ahora se inicializa automáticamente con valores por defecto
Param param; Param param;
// Declaraciones de funciones privadas // Declaraciones de funciones privadas
namespace { namespace {
auto setParams(const std::string& var, const std::string& value) -> bool; auto setParams(const std::string& var, const std::string& value) -> bool;
} }
// Implementación del método privado de Param // Implementación del método privado de Param
@@ -81,7 +82,7 @@ void loadParamsFromFile(const std::string& file_path) {
// Implementación local de setParams // Implementación local de setParams
namespace { namespace {
auto setParams(const std::string& var, const std::string& value) -> bool { auto setParams(const std::string& var, const std::string& value) -> bool {
// Mapas estáticos para diferentes tipos de parámetros // Mapas estáticos para diferentes tipos de parámetros
static const std::unordered_map<std::string, std::function<void(const std::string&)>> INT_PARAMS = { static const std::unordered_map<std::string, std::function<void(const std::string&)>> INT_PARAMS = {
{"game.width", [](const std::string& v) { param.game.width = std::stoi(v); }}, {"game.width", [](const std::string& v) { param.game.width = std::stoi(v); }},
@@ -109,7 +110,8 @@ auto setParams(const std::string& var, const std::string& value) -> bool {
{"title.title_duration", [](const std::string& v) { param.title.title_duration = std::stoi(v); }}, {"title.title_duration", [](const std::string& v) { param.title.title_duration = std::stoi(v); }},
{"title.arcade_edition_position", [](const std::string& v) { param.title.arcade_edition_position = std::stoi(v); }}, {"title.arcade_edition_position", [](const std::string& v) { param.title.arcade_edition_position = std::stoi(v); }},
{"title.title_c_c_position", [](const std::string& v) { param.title.title_c_c_position = std::stoi(v); }}, {"title.title_c_c_position", [](const std::string& v) { param.title.title_c_c_position = std::stoi(v); }},
{"intro.text_distance_from_bottom", [](const std::string& v) { param.intro.text_distance_from_bottom = std::stoi(v); }}}; {"intro.text_distance_from_bottom", [](const std::string& v) { param.intro.text_distance_from_bottom = std::stoi(v); }}
};
static const std::unordered_map<std::string, std::function<void(const std::string&)>> COLOR_PARAMS = { static const std::unordered_map<std::string, std::function<void(const std::string&)>> COLOR_PARAMS = {
{"fade.color", [](const std::string& v) { param.fade.color = Color::fromHex(v); }}, {"fade.color", [](const std::string& v) { param.fade.color = Color::fromHex(v); }},
@@ -126,11 +128,16 @@ auto setParams(const std::string& var, const std::string& value) -> bool {
{"service_menu.text_color", [](const std::string& v) { param.service_menu.text_color = Color::fromHex(v); }}, {"service_menu.text_color", [](const std::string& v) { param.service_menu.text_color = Color::fromHex(v); }},
{"service_menu.selected_color", [](const std::string& v) { param.service_menu.selected_color = Color::fromHex(v); }}, {"service_menu.selected_color", [](const std::string& v) { param.service_menu.selected_color = Color::fromHex(v); }},
{"service_menu.bg_color", [](const std::string& v) { param.service_menu.bg_color = Color::fromHex(v); }}, {"service_menu.bg_color", [](const std::string& v) { param.service_menu.bg_color = Color::fromHex(v); }},
{"service_menu.window_message.bg_color", [](const std::string& v) { param.service_menu.window_message.bg_color = Color::fromHex(v); }},
{"service_menu.window_message.border_color", [](const std::string& v) { param.service_menu.window_message.border_color = Color::fromHex(v); }},
{"service_menu.window_message.title_color", [](const std::string& v) { param.service_menu.window_message.title_color = Color::fromHex(v); }},
{"service_menu.window_message.text_color", [](const std::string& v) { param.service_menu.window_message.text_color = Color::fromHex(v); }},
{"intro.bg_color", [](const std::string& v) { param.intro.bg_color = Color::fromHex(v); }}, {"intro.bg_color", [](const std::string& v) { param.intro.bg_color = Color::fromHex(v); }},
{"intro.card_color", [](const std::string& v) { param.intro.card_color = Color::fromHex(v); }}, {"intro.card_color", [](const std::string& v) { param.intro.card_color = Color::fromHex(v); }},
{"intro.shadow_color", [](const std::string& v) { param.intro.shadow_color = Color::fromHex(v); }}, {"intro.shadow_color", [](const std::string& v) { param.intro.shadow_color = Color::fromHex(v); }},
{"debug.color", [](const std::string& v) { param.debug.color = Color::fromHex(v); }}, {"debug.color", [](const std::string& v) { param.debug.color = Color::fromHex(v); }},
{"resource.color", [](const std::string& v) { param.resource.color = Color::fromHex(v); }}}; {"resource.color", [](const std::string& v) { param.resource.color = Color::fromHex(v); }}
};
static const std::unordered_map<std::string, std::function<void(const std::string&)>> BOOL_PARAMS = { static const std::unordered_map<std::string, std::function<void(const std::string&)>> BOOL_PARAMS = {
{"game.hit_stop", [](const std::string& v) { param.game.hit_stop = stringToBool(v); }}, {"game.hit_stop", [](const std::string& v) { param.game.hit_stop = stringToBool(v); }},
@@ -138,7 +145,8 @@ auto setParams(const std::string& var, const std::string& value) -> bool {
{"scoreboard.text_autocolor", [](const std::string& v) { param.scoreboard.text_autocolor = stringToBool(v); }}, {"scoreboard.text_autocolor", [](const std::string& v) { param.scoreboard.text_autocolor = stringToBool(v); }},
{"balloon.bouncing_sound", [](const std::string& v) { param.balloon.bouncing_sound = stringToBool(v); }}, {"balloon.bouncing_sound", [](const std::string& v) { param.balloon.bouncing_sound = stringToBool(v); }},
{"notification.sound", [](const std::string& v) { param.notification.sound = stringToBool(v); }}, {"notification.sound", [](const std::string& v) { param.notification.sound = stringToBool(v); }},
{"service_menu.drop_shadow", [](const std::string& v) { param.service_menu.drop_shadow = stringToBool(v); }}}; {"service_menu.drop_shadow", [](const std::string& v) { param.service_menu.drop_shadow = stringToBool(v); }}
};
static const std::unordered_map<std::string, std::function<void(const std::string&)>> FLOAT_PARAMS = { static const std::unordered_map<std::string, std::function<void(const std::string&)>> FLOAT_PARAMS = {
{"balloon.settings[0].vel", [](const std::string& v) { param.balloon.settings.at(0).vel = std::stof(v); }}, {"balloon.settings[0].vel", [](const std::string& v) { param.balloon.settings.at(0).vel = std::stof(v); }},
@@ -150,13 +158,27 @@ auto setParams(const std::string& var, const std::string& value) -> bool {
{"balloon.settings[3].vel", [](const std::string& v) { param.balloon.settings.at(3).vel = std::stof(v); }}, {"balloon.settings[3].vel", [](const std::string& v) { param.balloon.settings.at(3).vel = std::stof(v); }},
{"balloon.settings[3].grav", [](const std::string& v) { param.balloon.settings.at(3).grav = std::stof(v); }}, {"balloon.settings[3].grav", [](const std::string& v) { param.balloon.settings.at(3).grav = std::stof(v); }},
{"tabe.min_spawn_time", [](const std::string& v) { param.tabe.min_spawn_time = std::stof(v); }}, {"tabe.min_spawn_time", [](const std::string& v) { param.tabe.min_spawn_time = std::stof(v); }},
{"tabe.max_spawn_time", [](const std::string& v) { param.tabe.max_spawn_time = std::stof(v); }}}; {"tabe.max_spawn_time", [](const std::string& v) { param.tabe.max_spawn_time = std::stof(v); }},
{"service_menu.window_message.padding", [](const std::string& v) { param.service_menu.window_message.padding = std::stof(v); }},
{"service_menu.window_message.line_spacing", [](const std::string& v) { param.service_menu.window_message.line_spacing = std::stof(v); }},
{"service_menu.window_message.title_separator_spacing", [](const std::string& v) { param.service_menu.window_message.title_separator_spacing = std::stof(v); }},
{"service_menu.window_message.min_width", [](const std::string& v) { param.service_menu.window_message.min_width = std::stof(v); }},
{"service_menu.window_message.min_height", [](const std::string& v) { param.service_menu.window_message.min_height = std::stof(v); }},
{"service_menu.window_message.max_width_ratio", [](const std::string& v) { param.service_menu.window_message.max_width_ratio = std::stof(v); }},
{"service_menu.window_message.max_height_ratio", [](const std::string& v) { param.service_menu.window_message.max_height_ratio = std::stof(v); }},
{"service_menu.window_message.text_safety_margin", [](const std::string& v) { param.service_menu.window_message.text_safety_margin = std::stof(v); }},
{"service_menu.window_message.animation_duration", [](const std::string& v) { param.service_menu.window_message.animation_duration = std::stof(v); }}
};
static const std::unordered_map<std::string, std::function<void(const std::string&)>> INT_PARAMS_EXTRA = {
};
static const std::unordered_map<std::string, std::function<void(const std::string&)>> STRING_PARAMS = { 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[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[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[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[3]", [](const std::string& v) { param.balloon.color.at(3) = v; }}
};
// Lambda para intentar cada mapa de parámetros // Lambda para intentar cada mapa de parámetros
auto try_map = [&](const auto& param_map) -> bool { auto try_map = [&](const auto& param_map) -> bool {
@@ -192,5 +214,5 @@ auto setParams(const std::string& var, const std::string& value) -> bool {
} }
return false; // Parámetro no encontrado return false; // Parámetro no encontrado
}
} }
} // namespace

View File

@@ -7,7 +7,8 @@
#include "color.h" // Para Color #include "color.h" // Para Color
#include "defaults.h" // Para los valores por defecto #include "defaults.h" // Para los valores por defecto
#include "utils.h" // Para NotifyPosition, Zone #include "ui/notifier.h" // Para Notifier
#include "utils.h" // Para zone
// --- Parámetros del juego --- // --- Parámetros del juego ---
struct ParamGame { struct ParamGame {
@@ -106,6 +107,23 @@ struct ParamServiceMenu {
Color selected_color = Color::fromHex(GameDefaults::ServiceMenu::SELECTED_COLOR); Color selected_color = Color::fromHex(GameDefaults::ServiceMenu::SELECTED_COLOR);
Color bg_color = Color::fromHex(GameDefaults::ServiceMenu::BG_COLOR); Color bg_color = Color::fromHex(GameDefaults::ServiceMenu::BG_COLOR);
bool drop_shadow = GameDefaults::ServiceMenu::DROP_SHADOW; bool drop_shadow = GameDefaults::ServiceMenu::DROP_SHADOW;
// Configuración para ventanas de mensaje
struct WindowMessage {
Color bg_color = Color::fromHex(GameDefaults::ServiceMenu::WindowMessage::BG_COLOR);
Color border_color = Color::fromHex(GameDefaults::ServiceMenu::WindowMessage::BORDER_COLOR);
Color title_color = Color::fromHex(GameDefaults::ServiceMenu::WindowMessage::TITLE_COLOR);
Color text_color = Color::fromHex(GameDefaults::ServiceMenu::WindowMessage::TEXT_COLOR);
float padding = GameDefaults::ServiceMenu::WindowMessage::PADDING;
float line_spacing = GameDefaults::ServiceMenu::WindowMessage::LINE_SPACING;
float title_separator_spacing = GameDefaults::ServiceMenu::WindowMessage::TITLE_SEPARATOR_SPACING;
float min_width = GameDefaults::ServiceMenu::WindowMessage::MIN_WIDTH;
float min_height = GameDefaults::ServiceMenu::WindowMessage::MIN_HEIGHT;
float max_width_ratio = GameDefaults::ServiceMenu::WindowMessage::MAX_WIDTH_RATIO;
float max_height_ratio = GameDefaults::ServiceMenu::WindowMessage::MAX_HEIGHT_RATIO;
float text_safety_margin = GameDefaults::ServiceMenu::WindowMessage::TEXT_SAFETY_MARGIN;
float animation_duration = GameDefaults::ServiceMenu::WindowMessage::ANIMATION_DURATION;
} window_message;
}; };
// --- Parámetros de la intro --- // --- Parámetros de la intro ---

View File

@@ -8,6 +8,7 @@
#include <vector> // Para vector #include <vector> // Para vector
#include "color.h" // Para Color #include "color.h" // Para Color
#include "param.h" // Para param
#include "text.h" // Para Text #include "text.h" // Para Text
class WindowMessage { class WindowMessage {
@@ -43,9 +44,24 @@ class WindowMessage {
// Constructor con valores por defecto // Constructor con valores por defecto
Config() Config()
: bg_color{40, 40, 60, 220}, border_color{100, 100, 120, 255}, title_color{255, 255, 255, 255}, text_color{200, 200, 200, 255} : bg_color{40, 40, 60, 220},
border_color{100, 100, 120, 255},
title_color{255, 255, 255, 255},
text_color{200, 200, 200, 255} {}
{} // Constructor que convierte desde ParamServiceMenu::WindowMessage
Config(const ParamServiceMenu::WindowMessage& param_config)
: bg_color(param_config.bg_color),
border_color(param_config.border_color),
title_color(param_config.title_color),
text_color(param_config.text_color),
padding(param_config.padding),
line_spacing(param_config.line_spacing),
title_separator_spacing(param_config.title_separator_spacing),
min_width(param_config.min_width),
text_safety_margin(param_config.text_safety_margin),
min_height(param_config.min_height),
animation_duration(param_config.animation_duration) {}
}; };
WindowMessage( WindowMessage(