From 1f8588e9752ecb89d681b29af340029a3f40d0d7 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Thu, 26 Jun 2025 18:34:32 +0200 Subject: [PATCH] Mes colorets --- data/config/param_320x240.txt | 13 ++++++++++++- data/config/param_320x256.txt | 13 ++++++++++++- source/intro.cpp | 3 ++- source/param.cpp | 23 +++++++++++++++++++++++ source/param.h | 22 ++++++++++++++++++++++ source/resource.cpp | 32 ++++++++++++++++++-------------- source/screen.cpp | 4 ++-- source/utils.h | 2 -- 8 files changed, 91 insertions(+), 21 deletions(-) diff --git a/data/config/param_320x240.txt b/data/config/param_320x240.txt index bee5fc2..ce2bb9c 100644 --- a/data/config/param_320x240.txt +++ b/data/config/param_320x240.txt @@ -63,4 +63,15 @@ service_menu.title_color 99FF62 service_menu.text_color FFFFFF service_menu.selected_color FFDC44 service_menu.bg_color 000000F0 -service_menu.drop_shadow false \ No newline at end of file +service_menu.drop_shadow false + +## --- INTRO --- +intro.bg_color 000000 +intro.card_color FFFFFF + +## --- DEBUG --- +debug.color 00FFFF + +## --- RESOURCE --- +resource.color CDD1CD +resource.color 17E97A \ No newline at end of file diff --git a/data/config/param_320x256.txt b/data/config/param_320x256.txt index 5341263..a2a9cb0 100644 --- a/data/config/param_320x256.txt +++ b/data/config/param_320x256.txt @@ -63,4 +63,15 @@ service_menu.title_color 99FF62 service_menu.text_color FFFFFF service_menu.selected_color FFDC44 service_menu.bg_color 000000F0 -service_menu.drop_shadow false \ No newline at end of file +service_menu.drop_shadow false + +## --- INTRO --- +intro.bg_color 000000 +intro.card_color 543149 + +## --- DEBUG --- +debug.color 00FFFF + +## --- RESOURCE --- +resource.color CDD1CD +resource.color 17E97A \ No newline at end of file diff --git a/source/intro.cpp b/source/intro.cpp index fbf66e2..de9a054 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -348,7 +348,8 @@ void Intro::initSprites() auto temp = SDL_GetRenderTarget(Screen::get()->getRenderer()); shadow_texture->setAsRenderTarget(Screen::get()->getRenderer()); - SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0xFF, 0x00, 0x00, 0xFF); + auto color = param.intro.card_color; + SDL_SetRenderDrawColor(Screen::get()->getRenderer(), color.r, color.g, color.b, color.a); SDL_RenderClear(Screen::get()->getRenderer()); SDL_FRect rect = {BORDER / 2, BORDER / 2, SPRITE_WIDTH, SPRITE_HEIGHT}; diff --git a/source/param.cpp b/source/param.cpp index d5c3d6c..1c7aa4a 100644 --- a/source/param.cpp +++ b/source/param.cpp @@ -388,6 +388,29 @@ bool setParams(const std::string &var, const std::string &value) param.service_menu.drop_shadow = stringToBool(value); } + // INTRO + else if (var == "intro.bg_color") + { + param.intro.bg_color = Color::fromHex(value); + } + + else if (var == "intro.card_color") + { + param.intro.card_color = Color::fromHex(value); + } + + // DEBUG + else if (var == "debug.color") + { + param.debug.color = Color::fromHex(value); + } + + // RESOURCE + else if (var == "resource.color") + { + param.resource.color = Color::fromHex(value); + } + // RESTO else { diff --git a/source/param.h b/source/param.h index 51cc769..410e696 100644 --- a/source/param.h +++ b/source/param.h @@ -91,6 +91,25 @@ struct ParamServiceMenu bool drop_shadow; }; +// --- Parámetros de la intro --- +struct ParamIntro +{ + Color bg_color; + Color card_color; +}; + +// --- Parámetros para Debug --- +struct ParamDebug +{ + Color color; +}; + +// --- Parámetros para Resource --- +struct ParamResource +{ + Color color; +}; + // --- Estructura principal para almacenar todos los parámetros del juego --- struct Param { @@ -102,6 +121,9 @@ struct Param std::vector balloon; // Parámetros de los globos ParamNotification notification; // Parámetros de las notificaciones ParamServiceMenu service_menu; // Parámetros del menú de servicio + ParamIntro intro; // Parámetros de la intro + ParamDebug debug; // Parámetros para Debug + ParamResource resource; // Parámetros para Resource // Constructor Param() : game(), fade(), scoreboard(), title(), background(), notification() diff --git a/source/resource.cpp b/source/resource.cpp index 7a0ed0a..3223280 100644 --- a/source/resource.cpp +++ b/source/resource.cpp @@ -3,14 +3,15 @@ #include #include // Para find_if #include -#include // Para runtime_error -#include "asset.h" // Para Asset, AssetType +#include // Para runtime_error +#include "asset.h" // Para Asset, AssetType #include "external/jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic -#include "lang.h" // Para getText -#include "screen.h" // Para Screen -#include "text.h" // Para Text, loadTextFile -struct JA_Music_t; // lines 11-11 -struct JA_Sound_t; // lines 12-12 +#include "lang.h" // Para getText +#include "screen.h" // Para Screen +#include "text.h" // Para Text, loadTextFile +#include "param.h" +struct JA_Music_t; // lines 11-11 +struct JA_Sound_t; // lines 12-12 // Singleton Resource *Resource::instance_ = nullptr; @@ -435,19 +436,22 @@ void Resource::renderProgress() screen->start(); screen->clean(); - // Establece el color de dibujo a blanco - SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + auto color = param.resource.color.darken(); - // Dibuja la barra de progreso (marco y barra llena) - SDL_RenderRect(renderer, &loading_wired_rect_); + // Dibuja el interior de la barra de progreso + SDL_SetRenderDrawColor(renderer, param.resource.color.r, param.resource.color.g, param.resource.color.b, param.resource.color.a); SDL_RenderFillRect(renderer, &loading_full_rect_); + + // Dibuja el marco de la barra de progreso + SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a); + SDL_RenderRect(renderer, &loading_wired_rect_); // Escribe el texto de carga encima de la barra - loading_text_->write( + loading_text_->writeColored( loading_wired_rect_.x, loading_wired_rect_.y - 9, - Lang::getText("[RESOURCE] LOADING") + " : " + loading_resource_name_ - ); + Lang::getText("[RESOURCE] LOADING") + " : " + loading_resource_name_, + param.resource.color); // Renderiza el frame en pantalla screen->coreRender(); diff --git a/source/screen.cpp b/source/screen.cpp index 4ac9de0..1bc58e1 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -248,11 +248,11 @@ void Screen::renderInfo() if (debug_info_.show) { // Resolution - debug_info_.text->writeDX(TEXT_COLOR | TEXT_SHADOW, param.game.width - debug_info_.text->lenght(Options::video.info) - 2, 1, Options::video.info, 1, DEBUG_COLOR, 1, DEBUG_COLOR.darken(150)); + debug_info_.text->writeDX(TEXT_COLOR | TEXT_STROKE, param.game.width - debug_info_.text->lenght(Options::video.info) - 2, 1, Options::video.info, 1, param.debug.color, 1, param.debug.color.darken(150)); // FPS const std::string FPS_TEXT = std::to_string(fps_.lastValue) + " FPS"; - debug_info_.text->writeDX(TEXT_COLOR | TEXT_SHADOW, param.game.width - debug_info_.text->lenght(FPS_TEXT) - 2, 1 + debug_info_.text->getCharacterSize(), FPS_TEXT, 1, DEBUG_COLOR, 1, DEBUG_COLOR.darken(150)); + debug_info_.text->writeDX(TEXT_COLOR | TEXT_STROKE, param.game.width - debug_info_.text->lenght(FPS_TEXT) - 2, 1 + debug_info_.text->getCharacterSize(), FPS_TEXT, 1, param.debug.color, 1, param.debug.color.darken(150)); } } #endif diff --git a/source/utils.h b/source/utils.h index a455d0f..776244a 100644 --- a/source/utils.h +++ b/source/utils.h @@ -180,8 +180,6 @@ constexpr Color BLUE_SKY_COLOR = Color(0X02, 0X88, 0XD1); constexpr Color PINK_SKY_COLOR = Color(0XFF, 0X6B, 0X97); constexpr Color GREEN_SKY_COLOR = Color(0X00, 0X79, 0X6B); -constexpr Color DEBUG_COLOR = Color(0xFF, 0xFF, 0x00); - // Colores y gráficos Color getColorLikeKnightRider(const std::vector &colors, int counter_); constexpr HSV rgbToHsv(Color color);