Modificadas las notificaciones a dos lineas de texto

This commit is contained in:
2022-12-29 09:42:57 +01:00
parent a2f1efd2a6
commit e963251fd9
7 changed files with 24 additions and 15 deletions

View File

@@ -55,10 +55,10 @@ void Cheevos::unlockCheevo(int id)
{
return;
}
if (!cheevos[index].completed)
{
cheevos[index].completed = true;
screen->showNotification(cheevos[index].caption);
screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption);
}
}

View File

@@ -124,12 +124,13 @@ void Notify::clearFinishedNotifications()
}
// Muestra una notificación de texto por pantalla;
void Notify::showText(std::string text)
void Notify::showText(std::string text1, std::string text2)
{
// Inicializa variables
const int width = this->text->lenght(text) + (this->text->getCharacterSize() * 2);
const int height = this->text->getCharacterSize() * 2;
const int padding = (this->text->getCharacterSize() / 2);
const std::string txt = text1.length() > text2.length() ? text1 : text2;
const int width = text->lenght(txt) + text->getCharacterSize();
const int height = text->getCharacterSize() * 3;
const int padding = text->getCharacterSize() / 2;
// Posición horizontal
int despH = 0;
@@ -178,7 +179,7 @@ void Notify::showText(std::string text)
n.travelDist = travelDist;
n.counter = 0;
n.state = ns_rising;
n.text = text;
n.text = text1;
if (options->notifications.posV == pos_top)
{
n.rect = {despH, offset - travelDist, width, height};
@@ -195,7 +196,15 @@ void Notify::showText(std::string text)
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
SDL_RenderClear(renderer);
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
this->text->writeDX(TXT_CENTER | TXT_STROKE, width / 2, padding, text, 1, {255, 255, 255}, 1, {0, 0, 0});
if (text2 != "")
{ // Dos lineas de texto
text->writeDX(TXT_STROKE, padding, padding, text1, 1, {255, 255, 255}, 1, {0, 0, 0});
text->writeDX(TXT_STROKE, padding, padding + text->getCharacterSize() + 1, text2, 1, {255, 255, 255}, 1, {0, 0, 0});
}
else
{ // Una linea de texto
text->writeDX(TXT_STROKE, padding, (height / 2) - (text->getCharacterSize() / 2), text1, 1, {255, 255, 255}, 1, {0, 0, 0});
}
SDL_SetRenderTarget(renderer, nullptr);
// Crea el sprite

View File

@@ -57,7 +57,7 @@ private:
color_t bgColor; // Color de fondo de las notificaciones
int waitTime; // Tiempo que se ve la notificación
std::vector<notification_t> notifications; // La lista de notificaciones activas
JA_Sound_t* sound; // Sonido a reproducir cuando suena la notificación
JA_Sound_t *sound; // Sonido a reproducir cuando suena la notificación
// Elimina las notificaciones finalizadas
void clearFinishedNotifications();
@@ -76,7 +76,7 @@ public:
~Notify();
// Muestra una notificación de texto por pantalla;
void showText(std::string text);
void showText(std::string text1 = "", std::string text2 = "");
// Indica si hay notificaciones activas
bool active();

View File

@@ -370,9 +370,9 @@ void Screen::updateNotifier()
}
// Muestra una notificación de texto por pantalla;
void Screen::showNotification(std::string text)
void Screen::showNotification(std::string text1, std::string text2)
{
notify->showText(text);
notify->showText(text1, text2);
}
// Dibuja las notificaciones

View File

@@ -132,7 +132,7 @@ public:
void updateNotifier();
// Muestra una notificación de texto por pantalla;
void showNotification(std::string text);
void showNotification(std::string text1 = "", std::string text2 = "");
};
#endif

View File

@@ -160,7 +160,7 @@ void Director::initOptions()
options->notifications.posV = pos_top;
options->notifications.posH = pos_left;
options->notifications.sound = true;
options->notifications.color = {64, 64, 64};
options->notifications.color = {48, 48, 48};
}
// Comprueba los parametros del programa

View File

@@ -161,7 +161,7 @@ void Game::checkEventHandler()
break;
case SDL_SCANCODE_F6:
screen->showNotification("MAMA MIRA! SIN MANOS!");
screen->showNotification("1234567890");
break;
#endif