Las notificaciones se pueden configurar para que no se apilen
This commit is contained in:
@@ -11,6 +11,7 @@ Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapF
|
||||
this->options = options;
|
||||
bgColor = options->notification.color;
|
||||
waitTime = 100;
|
||||
stack = false;
|
||||
|
||||
// Crea objetos
|
||||
iconTexture = new Texture(renderer, iconFile);
|
||||
@@ -149,6 +150,11 @@ void Notify::clearFinishedNotifications()
|
||||
// Muestra una notificación de texto por pantalla;
|
||||
void Notify::showText(std::string text1, std::string text2, int icon)
|
||||
{
|
||||
if (!stack)
|
||||
{
|
||||
clearNotifications();
|
||||
}
|
||||
|
||||
// Inicializa variables
|
||||
const int iconSize = 16;
|
||||
const int paddingOut = 1;
|
||||
@@ -250,7 +256,6 @@ void Notify::showText(std::string text1, std::string text2, int icon)
|
||||
SDL_RenderClear(renderer);
|
||||
}
|
||||
|
||||
|
||||
// Dibuja el icono de la notificación
|
||||
if (icon >= 0 && numTexts == 2)
|
||||
{
|
||||
@@ -295,4 +300,15 @@ bool Notify::active()
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Finaliza y elimnina todas las notificaciones activas
|
||||
void Notify::clearNotifications()
|
||||
{
|
||||
for (int i = 0; i < (int)notifications.size(); ++i)
|
||||
{
|
||||
notifications[i].state = ns_finished;
|
||||
}
|
||||
|
||||
clearFinishedNotifications();
|
||||
}
|
||||
@@ -67,22 +67,26 @@ private:
|
||||
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
|
||||
bool stack; // Indica si las notificaciones se apilan
|
||||
|
||||
// Elimina las notificaciones finalizadas
|
||||
void clearFinishedNotifications();
|
||||
|
||||
// Finaliza y elimnina todas las notificaciones activas
|
||||
void clearNotifications();
|
||||
|
||||
public:
|
||||
// Dibuja las notificaciones por pantalla
|
||||
void render();
|
||||
|
||||
// Actualiza el estado de las notificaiones
|
||||
void update();
|
||||
|
||||
// Constructor
|
||||
Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
|
||||
|
||||
// Destructor
|
||||
~Notify();
|
||||
|
||||
// Dibuja las notificaciones por pantalla
|
||||
void render();
|
||||
|
||||
// Actualiza el estado de las notificaiones
|
||||
void update();
|
||||
|
||||
// Muestra una notificación de texto por pantalla;
|
||||
void showText(std::string text1 = "", std::string text2 = "", int icon = -1);
|
||||
|
||||
Reference in New Issue
Block a user