fix: llevar el text de REDEFINE KEYS

This commit is contained in:
2025-03-01 09:28:17 +01:00
parent 4e525642a0
commit b34f4dda42

View File

@@ -389,7 +389,7 @@ void Title::fillTexture()
const int textSize = text_->getCharacterSize(); 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, 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, 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); 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 // Devuelve el puntero del renderizador a su sitio
@@ -401,50 +401,50 @@ void Title::createCheevosTexture()
{ {
// Crea la textura con el listado de logros // Crea la textura con el listado de logros
const auto cheevosList = Cheevos::get()->list(); const auto cheevosList = Cheevos::get()->list();
const int cheevosTextureWidth = 200; constexpr int CHEEVOS_TEXTURE_WIDTH = 200;
const int cheevosTextureViewHeight = 110; constexpr int CHEEVOS_TEXTURE_VIEW_HEIGHT = 110;
const int cheevosTexturePosY = 73; constexpr int CHEEVOS_TEXTURE_POS_Y = 73;
const int cheevosPadding = 10; constexpr int CHEEVOS_PADDING = 10;
const int cheevoHeight = cheevosPadding + (info_text_->getCharacterSize() * 2) + 1; const int CHEEVO_HEIGHT = CHEEVOS_PADDING + (info_text_->getCharacterSize() * 2) + 1;
const int cheevosTextureHeight = (cheevoHeight * cheevosList.size()) + 2 + info_text_->getCharacterSize() + 8; const int CHEEVOS_TEXTURE_HEIGHT = (CHEEVO_HEIGHT * cheevosList.size()) + 2 + info_text_->getCharacterSize() + 8;
cheevos_texture_ = std::make_shared<Texture>(renderer_); cheevos_texture_ = std::make_shared<Texture>(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_->setAsRenderTarget(renderer_);
cheevos_texture_->setBlendMode(SDL_BLENDMODE_BLEND); cheevos_texture_->setBlendMode(SDL_BLENDMODE_BLEND);
// Rellena la textura con color sólido // Rellena la textura con color sólido
const Color cheevosBGColor = stringToColor(options.video.palette, "black"); const Color CHEEVOS_BG_COLOR = stringToColor(options.video.palette, "black");
SDL_SetRenderDrawColor(renderer_, cheevosBGColor.r, cheevosBGColor.g, cheevosBGColor.b, 0xFF); SDL_SetRenderDrawColor(renderer_, CHEEVOS_BG_COLOR.r, CHEEVOS_BG_COLOR.g, CHEEVOS_BG_COLOR.b, 0xFF);
SDL_RenderClear(renderer_); SDL_RenderClear(renderer_);
// Escribe la lista de logros en la textura // Escribe la lista de logros en la textura
const std::string cheevosOwner = "ACHIEVEMENTS"; const std::string CHEEVOS_OWNER = "ACHIEVEMENTS";
const std::string cheevosListCaption = cheevosOwner + " (" + std::to_string(Cheevos::get()->unlocked()) + " / " + std::to_string(Cheevos::get()->count()) + ")"; const std::string CHEEVOS_LIST_CAPTION = CHEEVOS_OWNER + " (" + std::to_string(Cheevos::get()->unlocked()) + " / " + std::to_string(Cheevos::get()->count()) + ")";
int pos = 2; 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(); pos += info_text_->getCharacterSize();
const Color cheevoLockedColor = stringToColor(options.video.palette, "white"); const Color CHEEVO_LOCKED_COLOR = stringToColor(options.video.palette, "white");
const Color cheevoUnlockedColor = stringToColor(options.video.palette, "bright_green"); const Color CHEEVO_UNLOCKED_COLOR = stringToColor(options.video.palette, "bright_green");
Color cheevoColor; Color cheevoColor;
SDL_SetRenderDrawColor(renderer_, cheevoLockedColor.r, cheevoLockedColor.g, cheevoLockedColor.b, 0xFF); SDL_SetRenderDrawColor(renderer_, CHEEVO_LOCKED_COLOR.r, CHEEVO_LOCKED_COLOR.g, CHEEVO_LOCKED_COLOR.b, 0xFF);
const int lineX1 = (cheevosTextureWidth / 7) * 3; constexpr int LINE_X1 = (CHEEVOS_TEXTURE_WIDTH / 7) * 3;
const int lineX2 = lineX1 + ((cheevosTextureWidth / 7) * 1); constexpr int LINE_X2 = LINE_X1 + ((CHEEVOS_TEXTURE_WIDTH / 7) * 1);
for (auto cheevo : cheevosList) for (auto cheevo : cheevosList)
{ {
cheevoColor = cheevo.completed ? cheevoUnlockedColor : cheevoLockedColor; cheevoColor = cheevo.completed ? CHEEVO_UNLOCKED_COLOR : CHEEVO_LOCKED_COLOR;
pos += cheevosPadding; pos += CHEEVOS_PADDING;
int half = cheevosPadding / 2; constexpr int HALF = CHEEVOS_PADDING / 2;
SDL_RenderDrawLine(renderer_, lineX1, pos - half - 1, lineX2, pos - half - 1); SDL_RenderDrawLine(renderer_, LINE_X1, pos - HALF - 1, LINE_X2, pos - HALF - 1);
info_text_->writeDX(TEXT_CENTER | TEXT_COLOR, cheevosTextureWidth / 2, pos, cheevo.caption, 1, cheevoColor); info_text_->writeDX(TEXT_CENTER | TEXT_COLOR, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.caption, 1, cheevoColor);
pos += info_text_->getCharacterSize() + 1; 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(); pos += info_text_->getCharacterSize();
} }
// Crea el sprite para el listado de logros // Crea el sprite para el listado de logros
cheevos_sprite_ = std::make_shared<Sprite>(cheevos_texture_, (GAMECANVAS_WIDTH - cheevos_texture_->getWidth()) / 2, cheevosTexturePosY, cheevos_texture_->getWidth(), cheevos_texture_->getHeight()); cheevos_sprite_ = std::make_shared<Sprite>(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(), cheevosTextureViewHeight}; cheevos_texture_view_ = {0, 0, cheevos_texture_->getWidth(), CHEEVOS_TEXTURE_VIEW_HEIGHT};
cheevos_sprite_->setClip(cheevos_texture_view_); cheevos_sprite_->setClip(cheevos_texture_view_);
} }