Ya muestra la lista de logros de forma preliminar

This commit is contained in:
2023-09-15 21:31:23 +02:00
parent d0c0715640
commit 22e8579337
3 changed files with 56 additions and 9 deletions

View File

@@ -87,7 +87,6 @@ void Logo::checkEventHandler()
// Comprueba las entradas
void Logo::checkInput()
{
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_PROG_TITLE;

View File

@@ -47,9 +47,9 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
// Crea el cartel de PRESS ENTER
#ifdef GAME_CONSOLE
const std::string caption = "PRESS START TO PLAY";
const string caption = "PRESS START TO PLAY";
#else
const std::string caption = "PRESS ENTER TO PLAY";
const string caption = "PRESS ENTER TO PLAY";
#endif
const color_t textColor = stringToColor(options->palette, "white");
const color_t strokeColor = stringToColor(options->palette, "bright_blue");
@@ -64,6 +64,29 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
// Crea el sprite
pressEnterSprite = new Sprite(128 - (pressEnterTexture->getWidth() / 2), 192 / 5 * 4, pressEnterTexture->getWidth(), pressEnterTexture->getHeight(), pressEnterTexture, renderer);
// Crea la textura con el listado de logros
cheevosTexture = new Texture(renderer);
cheevosTexture->createBlank(renderer, GAMECANVAS_WIDTH - 16, GAMECANVAS_HEIGHT - 16, SDL_TEXTUREACCESS_TARGET);
cheevosTexture->setAsRenderTarget(renderer);
cheevosTexture->setBlendMode(SDL_BLENDMODE_BLEND);
const color_t cheevosBGColor = stringToColor(options->palette, "bright_blue");
SDL_SetRenderDrawColor(renderer, cheevosBGColor.r, cheevosBGColor.g, cheevosBGColor.b, 0xFF);
SDL_RenderClear(renderer);
const vector<cheevos_t> cheevosList = cheevos->list();
int pos = 1;
const color_t cheevoLockedColor = stringToColor(options->palette, "white");
const color_t cheevoUnlockedColor = stringToColor(options->palette, "white");
color_t cheevoColor;
for (auto cheevo : cheevosList)
{
cheevoColor = cheevo.completed ? cheevoUnlockedColor : cheevoLockedColor;
infoText->writeColored(1, pos, cheevo.caption, cheevoColor);
pos += 6;
}
// Crea el sprite para el listado de logros
cheevosSprite = new Sprite(8, 8, cheevosTexture->getWidth(), cheevosTexture->getHeight(), cheevosTexture, renderer);
// Cambia el color del borde
screen->setBorderColor(stringToColor(options->palette, "bright_blue"));
}
@@ -76,6 +99,8 @@ Title::~Title()
delete sprite;
delete pressEnterSprite;
delete pressEnterTexture;
delete cheevosSprite;
delete cheevosTexture;
delete text;
delete infoText;
}
@@ -92,6 +117,18 @@ void Title::checkEventHandler()
section->name = SECTION_PROG_QUIT;
break;
}
if (eventHandler->type == SDL_KEYDOWN)
{
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_A:
showCheevos = !showCheevos;
break;
default:
break;
}
}
}
}
@@ -179,7 +216,7 @@ void Title::renderMarquee()
// Dibuja la linea de información inferior
void Title::renderInfo()
{
const std::string loginText = options->online.enabled ? "OnLine: " + options->online.jailerID : "OnLine: OFF";
const string loginText = options->online.enabled ? "OnLine: " + options->online.jailerID : "OnLine: OFF";
infoText->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_FIRST_QUARTER_X, 1, loginText, 1, stringToColor(options->palette, "white"));
infoText->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 1, "H: Help", 1, stringToColor(options->palette, "white"));
infoText->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_THIRD_QUARTER_X, 1, "A: Achievements", 1, stringToColor(options->palette, "white"));
@@ -239,6 +276,12 @@ void Title::render()
// 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();
}

View File

@@ -16,12 +16,14 @@
#ifndef TITLE_H
#define TITLE_H
using namespace std;
class Title
{
private:
struct letter_t
{
std::string letter; // Letra a escribir
string letter; // Letra a escribir
int x; // Posición en el eje x
bool enabled; // Solo se escriben y mueven si estan habilitadas
};
@@ -40,16 +42,19 @@ private:
options_t *options; // Puntero a las opciones del juego
Texture *pressEnterTexture; // Textura con los graficos de PRESS ENTER
Sprite *pressEnterSprite; // Sprite para manejar la textura de PRESS ENTER
Texture *cheevosTexture; // Textura con lo lista de logros
Sprite *cheevosSprite; // Sprite para manejar la textura con la lista de logros
Cheevos *cheevos; // Objeto encargado de gestionar los logros del juego
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables
int counter; // Contador
std::string longText; // Texto que aparece en la parte inferior del titulo
string longText; // Texto que aparece en la parte inferior del titulo
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
std::vector<letter_t> letters; // Vector con las letras de la marquesina
vector<letter_t> letters; // Vector con las letras de la marquesina
int marqueeSpeed; // Velocidad de desplazamiento de la marquesina
bool showCheevos; // Indica si se muestra por pantalla el listado de logros
// Actualiza las variables
void update();