Mejoras en la presentación de la lista de logros

This commit is contained in:
2023-09-15 22:33:59 +02:00
parent d6c100379e
commit 2db0b43d23
2 changed files with 83 additions and 70 deletions

View File

@@ -501,6 +501,7 @@ void Director::loadResources(section_t *section)
textureList.push_back("loading_screen_color_zxarne.png"); textureList.push_back("loading_screen_color_zxarne.png");
textureList.push_back("smb2.png"); textureList.push_back("smb2.png");
textureList.push_back("debug.png"); textureList.push_back("debug.png");
textureList.push_back("notify.png");
resource->loadTextures(textureList); resource->loadTextures(textureList);

View File

@@ -66,16 +66,28 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
const vector<cheevos_t> cheevosList = cheevos->list(); const vector<cheevos_t> cheevosList = cheevos->list();
int pos = 2; int pos = 2;
const color_t cheevoLockedColor = stringToColor(options->palette, "white"); 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; 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) for (auto cheevo : cheevosList)
{ {
cheevoColor = cheevo.completed ? cheevoUnlockedColor : cheevoLockedColor; 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; pos += 6;
infoText->writeColored(2, pos, cheevo.description, cheevoColor); infoText->writeColored(2 + iconSize + 2, pos, cheevo.description, cheevoColor);
pos += 8; pos += 9;
} }
delete sp;
delete iconTexture;
// Crea el sprite para el listado de logros // Crea el sprite para el listado de logros
cheevosSprite = new Sprite(4, 4, cheevosTexture->getWidth(), cheevosTexture->getHeight(), cheevosTexture, renderer); cheevosSprite = new Sprite(4, 4, cheevosTexture->getWidth(), cheevosTexture->getHeight(), cheevosTexture, renderer);
@@ -276,9 +288,9 @@ void Title::update()
} }
} }
// Dibuja en pantalla // Dibuja en pantalla
void Title::render() void Title::render()
{ {
// Prepara para empezar a dibujar en la textura de juego // Prepara para empezar a dibujar en la textura de juego
screen->start(); screen->start();
@@ -305,21 +317,21 @@ void Title::update()
// Vuelca el contenido del renderizador en pantalla // Vuelca el contenido del renderizador en pantalla
screen->blit(); screen->blit();
} }
// Bucle para el logo del juego // Bucle para el logo del juego
void Title::run() void Title::run()
{ {
while (section->name == SECTION_PROG_TITLE) while (section->name == SECTION_PROG_TITLE)
{ {
update(); update();
render(); render();
} }
} }
// Recarga las texturas // Recarga las texturas
void Title::reLoadTextures() void Title::reLoadTextures()
{ {
// Carga la textura adecuada // Carga la textura adecuada
if (options->palette == p_zxspectrum) if (options->palette == p_zxspectrum)
{ {
@@ -333,11 +345,11 @@ void Title::update()
} }
texture->reLoad(); texture->reLoad();
} }
// Cambia la paleta // Cambia la paleta
void Title::switchPalette() void Title::switchPalette()
{ {
if (options->palette == p_zxspectrum) if (options->palette == p_zxspectrum)
{ {
options->palette = p_zxarne; options->palette = p_zxarne;
@@ -351,4 +363,4 @@ void Title::update()
// Cambia el color del borde // Cambia el color del borde
screen->setBorderColor(stringToColor(options->palette, "bright_blue")); screen->setBorderColor(stringToColor(options->palette, "bright_blue"));
} }