forked from jaildesigner-jailgames/jaildoctors_dilemma
Mejorada la apariencia visual de la lista de logros
This commit is contained in:
@@ -49,7 +49,7 @@ EnterID::~EnterID()
|
|||||||
delete eventHandler;
|
delete eventHandler;
|
||||||
delete text;
|
delete text;
|
||||||
delete texture;
|
delete texture;
|
||||||
SDL_DestroyTexture(textTexture);
|
SDL_DestroyTexture(textTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
@@ -77,17 +77,6 @@ void EnterID::checkEvents()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// El ENTER solo se comprueba cuando se suelta, para no saltarse la siguiente sección
|
|
||||||
if ((eventHandler->type == SDL_KEYUP && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONUP))
|
|
||||||
{
|
|
||||||
if (eventHandler->key.keysym.scancode == SDL_SCANCODE_RETURN)
|
|
||||||
{
|
|
||||||
options->online.jailerID = (std::string)name;
|
|
||||||
endSection();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba las teclas que se han pulsado
|
// Comprueba las teclas que se han pulsado
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
||||||
{
|
{
|
||||||
@@ -219,10 +208,9 @@ void EnterID::iniTexts()
|
|||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"ONLINE CONFIGURATION:", stringToColor(options->palette, "red")});
|
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"YOU HAVE NOT SPECIFIED ANY ID", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"FOR THE ONLINE SERVICE", stringToColor(options->palette, "white")});
|
texts.push_back({"ONLINE CONFIGURATION:", stringToColor(options->palette, "red")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"PLEASE ENTER AN ID OR", stringToColor(options->palette, "white")});
|
texts.push_back({"PLEASE ENTER AN ID OR", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"LEAVE BLANK FOR OFFLINE MODE", stringToColor(options->palette, "white")});
|
texts.push_back({"LEAVE BLANK FOR OFFLINE MODE", stringToColor(options->palette, "white")});
|
||||||
@@ -230,15 +218,8 @@ void EnterID::iniTexts()
|
|||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"JAILER_ID:", stringToColor(options->palette, "red")});
|
texts.push_back({"JAILER_ID:", stringToColor(options->palette, "red")});
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
jailerIDPos = ((int)texts.size() + 1) * text->getCharacterSize();
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
|
||||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto en la textura
|
// Escribe el texto en la textura
|
||||||
|
|||||||
118
source/title.cpp
118
source/title.cpp
@@ -48,48 +48,8 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
initMarquee();
|
initMarquee();
|
||||||
showCheevos = false;
|
showCheevos = false;
|
||||||
|
|
||||||
// Crea la textura con el listado de logros
|
// Crea y rellena la textura para mostrar los logros
|
||||||
const std::vector<cheevos_t> cheevosList = cheevos->list();
|
createCheevosTexture();
|
||||||
const int iconSize = 16; // Altura del icono que representa a cada logro
|
|
||||||
const int cheevoHeight = iconSize + 2; // EL espacio que ocupa cada logro es igual a la altura del icono mas dos pixeles de separación
|
|
||||||
const int cheevosTextureWidth = 200;
|
|
||||||
const int cheevosTextureViewHeight = GAMECANVAS_HEIGHT - 32;
|
|
||||||
cheevosTexture = new Texture(renderer);
|
|
||||||
cheevosTexture->createBlank(renderer, cheevosTextureWidth, cheevoHeight * cheevosList.size(), SDL_TEXTUREACCESS_TARGET);
|
|
||||||
cheevosTexture->setAsRenderTarget(renderer);
|
|
||||||
cheevosTexture->setBlendMode(SDL_BLENDMODE_BLEND);
|
|
||||||
const color_t cheevosBGColor = stringToColor(options->palette, "blue");
|
|
||||||
SDL_SetRenderDrawColor(renderer, cheevosBGColor.r, cheevosBGColor.g, cheevosBGColor.b, 0xFF);
|
|
||||||
SDL_RenderClear(renderer);
|
|
||||||
const std::string cheevosListCaption = "ACHIEVEMENTS (" + std::to_string(cheevos->unlocked()) + " / " + std::to_string(cheevos->count()) + ")";
|
|
||||||
infoText->writeDX(TXT_CENTER | TXT_COLOR, cheevosTexture->getWidth() / 2, 2, cheevosListCaption, 1, stringToColor(options->palette, "bright_white"));
|
|
||||||
int pos = 9;
|
|
||||||
const color_t cheevoLockedColor = 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"));
|
|
||||||
Sprite *sp = new Sprite({0, 0, iconSize, iconSize}, iconTexture, renderer);
|
|
||||||
for (auto cheevo : cheevosList)
|
|
||||||
{
|
|
||||||
cheevoColor = cheevo.completed ? cheevoUnlockedColor : cheevoLockedColor;
|
|
||||||
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 + iconSize + 2, pos, cheevo.description, cheevoColor);
|
|
||||||
pos += 9;
|
|
||||||
}
|
|
||||||
delete sp;
|
|
||||||
delete iconTexture;
|
|
||||||
|
|
||||||
// Crea el sprite para el listado de logros
|
|
||||||
cheevosSprite = new Sprite((GAMECANVAS_WIDTH - cheevosTexture->getWidth()) / 2, (GAMECANVAS_HEIGHT - cheevosTextureViewHeight) / 2, cheevosTexture->getWidth(), cheevosTexture->getHeight(), cheevosTexture, renderer);
|
|
||||||
cheevosTextureView = {0, 0, cheevosTexture->getWidth(), cheevosTextureViewHeight};
|
|
||||||
cheevosSprite->setSpriteClip(cheevosTextureView);
|
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
@@ -153,7 +113,6 @@ void Title::checkEvents()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_2:
|
case SDL_SCANCODE_2:
|
||||||
|
|
||||||
showCheevos = true;
|
showCheevos = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -187,7 +146,7 @@ void Title::checkInput()
|
|||||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
if (showCheevos)
|
if (showCheevos)
|
||||||
showCheevos = false;
|
hideCheevosList();
|
||||||
else
|
else
|
||||||
section->name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_QUIT;
|
||||||
}
|
}
|
||||||
@@ -225,8 +184,8 @@ void Title::checkInput()
|
|||||||
{
|
{
|
||||||
if (!showCheevos)
|
if (!showCheevos)
|
||||||
{
|
{
|
||||||
section->name = SECTION_PROG_GAME;
|
// section->name = SECTION_PROG_GAME;
|
||||||
section->subsection = 0;
|
// section->subsection = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -454,3 +413,70 @@ void Title::fillTexture()
|
|||||||
// Devuelve el puntero del renderizador a su sitio
|
// Devuelve el puntero del renderizador a su sitio
|
||||||
SDL_SetRenderTarget(renderer, nullptr);
|
SDL_SetRenderTarget(renderer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Crea y rellena la textura para mostrar los logros
|
||||||
|
void Title::createCheevosTexture()
|
||||||
|
{
|
||||||
|
// Crea la textura con el listado de logros
|
||||||
|
const std::vector<cheevos_t> cheevosList = cheevos->list();
|
||||||
|
const int iconSize = 16; // Altura del icono que representa a cada logro
|
||||||
|
const int cheevoHeight = iconSize + 2; // EL espacio que ocupa cada logro es igual a la altura del icono mas dos pixeles de separación
|
||||||
|
const int cheevosTextureWidth = 200;
|
||||||
|
const int cheevosTextureViewHeight = 110;
|
||||||
|
const int cheevosTexturePosY = 73;
|
||||||
|
cheevosTexture = new Texture(renderer);
|
||||||
|
cheevosTexture->createBlank(renderer, cheevosTextureWidth, cheevoHeight * cheevosList.size(), SDL_TEXTUREACCESS_TARGET);
|
||||||
|
cheevosTexture->setAsRenderTarget(renderer);
|
||||||
|
cheevosTexture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
|
// Rellena la textura con color sólido
|
||||||
|
const color_t cheevosBGColor = stringToColor(options->palette, "black");
|
||||||
|
SDL_SetRenderDrawColor(renderer, cheevosBGColor.r, cheevosBGColor.g, cheevosBGColor.b, 0xFF);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
// Escribe la lista de logros en la textura
|
||||||
|
const std::string cheevosListCaption = "ACHIEVEMENTS (" + std::to_string(cheevos->unlocked()) + " / " + std::to_string(cheevos->count()) + ")";
|
||||||
|
infoText->writeDX(TXT_CENTER | TXT_COLOR, cheevosTexture->getWidth() / 2, 2, cheevosListCaption, 1, stringToColor(options->palette, "bright_green"));
|
||||||
|
int pos = 11;
|
||||||
|
const color_t cheevoLockedColor = stringToColor(options->palette, "white");
|
||||||
|
const color_t cheevoUnlockedColor = stringToColor(options->palette, "bright_green");
|
||||||
|
color_t cheevoColor;
|
||||||
|
SDL_SetRenderDrawColor(renderer, cheevoLockedColor.r, cheevoLockedColor.g, cheevoLockedColor.b, 0xFF);
|
||||||
|
const int lineX1 = (cheevosTextureWidth / 7) * 3;
|
||||||
|
const int lineX2 = lineX1 + ((cheevosTextureWidth / 7) * 1);
|
||||||
|
|
||||||
|
Texture *iconTexture = new Texture(renderer, asset->get("notify.png"));
|
||||||
|
Sprite *sp = new Sprite({0, 0, iconSize, iconSize}, iconTexture, renderer);
|
||||||
|
for (auto cheevo : cheevosList)
|
||||||
|
{
|
||||||
|
cheevoColor = cheevo.completed ? cheevoUnlockedColor : cheevoLockedColor;
|
||||||
|
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;
|
||||||
|
SDL_RenderDrawLine(renderer, lineX1, pos - 3, lineX2, pos - 3);
|
||||||
|
// infoText->writeColored(2 + iconSize + 2, pos, cheevo.caption, cheevoColor);
|
||||||
|
infoText->writeDX(TXT_CENTER | TXT_COLOR, cheevosTextureWidth / 2, pos, cheevo.caption, 1, cheevoColor);
|
||||||
|
pos += 6;
|
||||||
|
// infoText->writeColored(2 + iconSize + 2, pos, cheevo.description, cheevoColor);
|
||||||
|
infoText->writeDX(TXT_CENTER | TXT_COLOR, cheevosTextureWidth / 2, pos, cheevo.description, 1, cheevoColor);
|
||||||
|
pos += 9;
|
||||||
|
}
|
||||||
|
delete sp;
|
||||||
|
delete iconTexture;
|
||||||
|
|
||||||
|
// Crea el sprite para el listado de logros
|
||||||
|
// cheevosSprite = new Sprite((GAMECANVAS_WIDTH - cheevosTexture->getWidth()) / 2, (GAMECANVAS_HEIGHT - cheevosTextureViewHeight) / 2, cheevosTexture->getWidth(), cheevosTexture->getHeight(), cheevosTexture, renderer);
|
||||||
|
cheevosSprite = new Sprite((GAMECANVAS_WIDTH - cheevosTexture->getWidth()) / 2, cheevosTexturePosY, cheevosTexture->getWidth(), cheevosTexture->getHeight(), cheevosTexture, renderer);
|
||||||
|
cheevosTextureView = {0, 0, cheevosTexture->getWidth(), cheevosTextureViewHeight};
|
||||||
|
cheevosSprite->setSpriteClip(cheevosTextureView);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Oculta la lista de logros
|
||||||
|
void Title::hideCheevosList()
|
||||||
|
{
|
||||||
|
showCheevos = false;
|
||||||
|
cheevosTextureView.y = 0;
|
||||||
|
cheevosSprite->setSpriteClip(cheevosTextureView);
|
||||||
|
}
|
||||||
@@ -28,23 +28,23 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
Input *input; // Objeto pata gestionar la entrada
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Texture *texture; // Textura con los graficos
|
Texture *texture; // Textura con los graficos
|
||||||
Sprite *sprite; // Sprite para manejar la textura
|
Sprite *sprite; // Sprite para manejar la textura
|
||||||
SDL_Texture *bgTexture; // Textura para dibujar el fondo de la pantalla
|
SDL_Texture *bgTexture; // Textura para dibujar el fondo de la pantalla
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
Text *infoText; // Objeto para escribir texto en pantalla
|
Text *infoText; // Objeto para escribir texto en pantalla
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
Texture *cheevosTexture; // Textura con lo lista de logros
|
Texture *cheevosTexture; // Textura con lo lista de logros
|
||||||
Sprite *cheevosSprite; // Sprite para manejar la textura con la 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
|
Cheevos *cheevos; // Objeto encargado de gestionar los logros del juego
|
||||||
EnterID *enterID; // Objeto para recoger el JailerID desde el teclado
|
EnterID *enterID; // Objeto para recoger el JailerID desde el teclado
|
||||||
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
@@ -95,6 +95,12 @@ private:
|
|||||||
// Rellena la textura de fondo con todos los gráficos
|
// Rellena la textura de fondo con todos los gráficos
|
||||||
void fillTexture();
|
void fillTexture();
|
||||||
|
|
||||||
|
// Crea y rellena la textura para mostrar los logros
|
||||||
|
void createCheevosTexture();
|
||||||
|
|
||||||
|
// Oculta la lista de logros
|
||||||
|
void hideCheevosList();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|||||||
Reference in New Issue
Block a user