From b34f4dda42f6472256ea0147855d2d76753fb071 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 1 Mar 2025 09:28:17 +0100 Subject: [PATCH] fix: llevar el text de REDEFINE KEYS --- source/title.cpp | 52 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/source/title.cpp b/source/title.cpp index 3b49671..bab546e 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -389,7 +389,7 @@ void Title::fillTexture() const int textSize = text_->getCharacterSize(); text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 11 * textSize, "1.PLAY", 1, textColor); text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 13 * textSize, "2.ACHIEVEMENTS", 1, textColor); - text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 15 * textSize, "3.REDEFINE KEYS", 1, textColor); + //text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 15 * textSize, "3.REDEFINE KEYS", 1, textColor); text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 20 * textSize, "ESC.EXIT GAME", 1, textColor); // Devuelve el puntero del renderizador a su sitio @@ -401,50 +401,50 @@ void Title::createCheevosTexture() { // Crea la textura con el listado de logros const auto cheevosList = Cheevos::get()->list(); - const int cheevosTextureWidth = 200; - const int cheevosTextureViewHeight = 110; - const int cheevosTexturePosY = 73; - const int cheevosPadding = 10; - const int cheevoHeight = cheevosPadding + (info_text_->getCharacterSize() * 2) + 1; - const int cheevosTextureHeight = (cheevoHeight * cheevosList.size()) + 2 + info_text_->getCharacterSize() + 8; + constexpr int CHEEVOS_TEXTURE_WIDTH = 200; + constexpr int CHEEVOS_TEXTURE_VIEW_HEIGHT = 110; + constexpr int CHEEVOS_TEXTURE_POS_Y = 73; + constexpr int CHEEVOS_PADDING = 10; + const int CHEEVO_HEIGHT = CHEEVOS_PADDING + (info_text_->getCharacterSize() * 2) + 1; + const int CHEEVOS_TEXTURE_HEIGHT = (CHEEVO_HEIGHT * cheevosList.size()) + 2 + info_text_->getCharacterSize() + 8; cheevos_texture_ = std::make_shared(renderer_); - cheevos_texture_->createBlank(cheevosTextureWidth, cheevosTextureHeight, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET); + cheevos_texture_->createBlank(CHEEVOS_TEXTURE_WIDTH, CHEEVOS_TEXTURE_HEIGHT, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET); cheevos_texture_->setAsRenderTarget(renderer_); cheevos_texture_->setBlendMode(SDL_BLENDMODE_BLEND); // Rellena la textura con color sólido - const Color cheevosBGColor = stringToColor(options.video.palette, "black"); - SDL_SetRenderDrawColor(renderer_, cheevosBGColor.r, cheevosBGColor.g, cheevosBGColor.b, 0xFF); + const Color CHEEVOS_BG_COLOR = stringToColor(options.video.palette, "black"); + SDL_SetRenderDrawColor(renderer_, CHEEVOS_BG_COLOR.r, CHEEVOS_BG_COLOR.g, CHEEVOS_BG_COLOR.b, 0xFF); SDL_RenderClear(renderer_); // Escribe la lista de logros en la textura - const std::string cheevosOwner = "ACHIEVEMENTS"; - const std::string cheevosListCaption = cheevosOwner + " (" + std::to_string(Cheevos::get()->unlocked()) + " / " + std::to_string(Cheevos::get()->count()) + ")"; + const std::string CHEEVOS_OWNER = "ACHIEVEMENTS"; + const std::string CHEEVOS_LIST_CAPTION = CHEEVOS_OWNER + " (" + std::to_string(Cheevos::get()->unlocked()) + " / " + std::to_string(Cheevos::get()->count()) + ")"; int pos = 2; - info_text_->writeDX(TEXT_CENTER | TEXT_COLOR, cheevos_texture_->getWidth() / 2, pos, cheevosListCaption, 1, stringToColor(options.video.palette, "bright_green")); + info_text_->writeDX(TEXT_CENTER | TEXT_COLOR, cheevos_texture_->getWidth() / 2, pos, CHEEVOS_LIST_CAPTION, 1, stringToColor(options.video.palette, "bright_green")); pos += info_text_->getCharacterSize(); - const Color cheevoLockedColor = stringToColor(options.video.palette, "white"); - const Color cheevoUnlockedColor = stringToColor(options.video.palette, "bright_green"); + const Color CHEEVO_LOCKED_COLOR = stringToColor(options.video.palette, "white"); + const Color CHEEVO_UNLOCKED_COLOR = stringToColor(options.video.palette, "bright_green"); Color cheevoColor; - SDL_SetRenderDrawColor(renderer_, cheevoLockedColor.r, cheevoLockedColor.g, cheevoLockedColor.b, 0xFF); - const int lineX1 = (cheevosTextureWidth / 7) * 3; - const int lineX2 = lineX1 + ((cheevosTextureWidth / 7) * 1); + SDL_SetRenderDrawColor(renderer_, CHEEVO_LOCKED_COLOR.r, CHEEVO_LOCKED_COLOR.g, CHEEVO_LOCKED_COLOR.b, 0xFF); + constexpr int LINE_X1 = (CHEEVOS_TEXTURE_WIDTH / 7) * 3; + constexpr int LINE_X2 = LINE_X1 + ((CHEEVOS_TEXTURE_WIDTH / 7) * 1); for (auto cheevo : cheevosList) { - cheevoColor = cheevo.completed ? cheevoUnlockedColor : cheevoLockedColor; - pos += cheevosPadding; - int half = cheevosPadding / 2; - SDL_RenderDrawLine(renderer_, lineX1, pos - half - 1, lineX2, pos - half - 1); - info_text_->writeDX(TEXT_CENTER | TEXT_COLOR, cheevosTextureWidth / 2, pos, cheevo.caption, 1, cheevoColor); + cheevoColor = cheevo.completed ? CHEEVO_UNLOCKED_COLOR : CHEEVO_LOCKED_COLOR; + pos += CHEEVOS_PADDING; + constexpr int HALF = CHEEVOS_PADDING / 2; + SDL_RenderDrawLine(renderer_, LINE_X1, pos - HALF - 1, LINE_X2, pos - HALF - 1); + info_text_->writeDX(TEXT_CENTER | TEXT_COLOR, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.caption, 1, cheevoColor); pos += info_text_->getCharacterSize() + 1; - info_text_->writeDX(TEXT_CENTER | TEXT_COLOR, cheevosTextureWidth / 2, pos, cheevo.description, 1, cheevoColor); + info_text_->writeDX(TEXT_CENTER | TEXT_COLOR, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.description, 1, cheevoColor); pos += info_text_->getCharacterSize(); } // Crea el sprite para el listado de logros - cheevos_sprite_ = std::make_shared(cheevos_texture_, (GAMECANVAS_WIDTH - cheevos_texture_->getWidth()) / 2, cheevosTexturePosY, cheevos_texture_->getWidth(), cheevos_texture_->getHeight()); - cheevos_texture_view_ = {0, 0, cheevos_texture_->getWidth(), cheevosTextureViewHeight}; + cheevos_sprite_ = std::make_shared(cheevos_texture_, (GAMECANVAS_WIDTH - cheevos_texture_->getWidth()) / 2, CHEEVOS_TEXTURE_POS_Y, cheevos_texture_->getWidth(), cheevos_texture_->getHeight()); + cheevos_texture_view_ = {0, 0, cheevos_texture_->getWidth(), CHEEVOS_TEXTURE_VIEW_HEIGHT}; cheevos_sprite_->setClip(cheevos_texture_view_); }