From 2db0b43d23cf429412f013f31e2aae36ac00ed06 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 15 Sep 2023 22:33:59 +0200 Subject: [PATCH] =?UTF-8?q?Mejoras=20en=20la=20presentaci=C3=B3n=20de=20la?= =?UTF-8?q?=20lista=20de=20logros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/director.cpp | 1 + source/title.cpp | 152 ++++++++++++++++++++++++-------------------- 2 files changed, 83 insertions(+), 70 deletions(-) diff --git a/source/director.cpp b/source/director.cpp index 4bc0f52..988e501 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -501,6 +501,7 @@ void Director::loadResources(section_t *section) textureList.push_back("loading_screen_color_zxarne.png"); textureList.push_back("smb2.png"); textureList.push_back("debug.png"); + textureList.push_back("notify.png"); resource->loadTextures(textureList); diff --git a/source/title.cpp b/source/title.cpp index 90a39ae..c5d2a6b 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -66,16 +66,28 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset * const vector cheevosList = cheevos->list(); int pos = 2; const color_t cheevoLockedColor = stringToColor(options->palette, "white"); - const color_t cheevoUnlockedColor = stringToColor(options->palette, "white"); + const color_t cheevoUnlockedColor = stringToColor(options->palette, "bright_white"); color_t cheevoColor; + + Texture *iconTexture = new Texture(renderer, asset->get("notify.png")); + const int iconSize = 16; + Sprite *sp = new Sprite({0, 0, iconSize, iconSize}, iconTexture, renderer); for (auto cheevo : cheevosList) { cheevoColor = cheevo.completed ? cheevoUnlockedColor : cheevoLockedColor; - infoText->writeColored(2, pos, cheevo.caption, cheevoColor); + //const int iconIndex = cheevo.completed ? 3 : 2; + sp->setPos({2, pos, iconSize, iconSize}); + sp->setSpriteClip({iconSize * 2, 0, iconSize, iconSize}); + sp->getTexture()->setColor(cheevoColor.r, cheevoColor.g, cheevoColor.b); + sp->render(); + pos += 2; + infoText->writeColored(2 + iconSize + 2, pos, cheevo.caption, cheevoColor); pos += 6; - infoText->writeColored(2, pos, cheevo.description, cheevoColor); - pos += 8; + infoText->writeColored(2 + iconSize + 2, pos, cheevo.description, cheevoColor); + pos += 9; } + delete sp; + delete iconTexture; // Crea el sprite para el listado de logros cheevosSprite = new Sprite(4, 4, cheevosTexture->getWidth(), cheevosTexture->getHeight(), cheevosTexture, renderer); @@ -276,79 +288,79 @@ void Title::update() } } - // Dibuja en pantalla - void Title::render() +// Dibuja en pantalla +void Title::render() +{ + // Prepara para empezar a dibujar en la textura de juego + screen->start(); + + // Dibuja el fondo del titulo + sprite->render(); + + // Dibuja el texto de PRESS ENTER TO PLAY + if (counter % 80 < 60) { - // Prepara para empezar a dibujar en la textura de juego - screen->start(); - - // Dibuja el fondo del titulo - sprite->render(); - - // Dibuja el texto de PRESS ENTER TO PLAY - if (counter % 80 < 60) - { - pressEnterSprite->render(); - } - - // Dibuja la marquesina - renderMarquee(); - - // Dibuja la linea de información inferior - renderInfo(); - - // Dibuja la información de logros - if (showCheevos) - { - cheevosSprite->render(); - } - - // Vuelca el contenido del renderizador en pantalla - screen->blit(); + pressEnterSprite->render(); } - // Bucle para el logo del juego - void Title::run() + // Dibuja la marquesina + renderMarquee(); + + // Dibuja la linea de información inferior + renderInfo(); + + // Dibuja la información de logros + if (showCheevos) { - while (section->name == SECTION_PROG_TITLE) - { - update(); - render(); - } + cheevosSprite->render(); } - // Recarga las texturas - void Title::reLoadTextures() - { - // Carga la textura adecuada - if (options->palette == p_zxspectrum) - { - // texture->loadFromFile(asset->get("loading_screen_color.png"), renderer); - texture = resource->getTexture("loading_screen_color.png"); - } - else if (options->palette == p_zxarne) - { - // texture->loadFromFile(asset->get("loading_screen_color_zxarne.png"), renderer); - texture = resource->getTexture("loading_screen_color_zxarne.png"); - } + // Vuelca el contenido del renderizador en pantalla + screen->blit(); +} - texture->reLoad(); +// Bucle para el logo del juego +void Title::run() +{ + while (section->name == SECTION_PROG_TITLE) + { + update(); + render(); + } +} + +// Recarga las texturas +void Title::reLoadTextures() +{ + // Carga la textura adecuada + if (options->palette == p_zxspectrum) + { + // texture->loadFromFile(asset->get("loading_screen_color.png"), renderer); + texture = resource->getTexture("loading_screen_color.png"); + } + else if (options->palette == p_zxarne) + { + // texture->loadFromFile(asset->get("loading_screen_color_zxarne.png"), renderer); + texture = resource->getTexture("loading_screen_color_zxarne.png"); } - // Cambia la paleta - void Title::switchPalette() - { - if (options->palette == p_zxspectrum) - { - options->palette = p_zxarne; - sprite->setTexture(resource->getTexture("loading_screen_color_zxarne.png")); - } - else - { - options->palette = p_zxspectrum; - sprite->setTexture(resource->getTexture("loading_screen_color.png")); - } + texture->reLoad(); +} - // Cambia el color del borde - screen->setBorderColor(stringToColor(options->palette, "bright_blue")); - } \ No newline at end of file +// Cambia la paleta +void Title::switchPalette() +{ + if (options->palette == p_zxspectrum) + { + options->palette = p_zxarne; + sprite->setTexture(resource->getTexture("loading_screen_color_zxarne.png")); + } + else + { + options->palette = p_zxspectrum; + sprite->setTexture(resource->getTexture("loading_screen_color.png")); + } + + // Cambia el color del borde + screen->setBorderColor(stringToColor(options->palette, "bright_blue")); +} \ No newline at end of file