Notify fix: Estaba duplicada la textura con los bitmaps del texto
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
|
Notify::Notify(SDL_Renderer *renderer, string iconFile, string bitmapFile, string textFile, string soundFile, options_t *options)
|
||||||
{
|
{
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -14,8 +14,7 @@ Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapF
|
|||||||
|
|
||||||
// Crea objetos
|
// Crea objetos
|
||||||
iconTexture = new Texture(renderer, iconFile);
|
iconTexture = new Texture(renderer, iconFile);
|
||||||
textTexture = new Texture(renderer, bitmapFile);
|
text = new Text(textFile, bitmapFile, renderer);
|
||||||
text = new Text(textFile, textTexture, renderer);
|
|
||||||
sound = JA_LoadSound(soundFile.c_str());
|
sound = JA_LoadSound(soundFile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +22,6 @@ Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapF
|
|||||||
Notify::~Notify()
|
Notify::~Notify()
|
||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
delete textTexture;
|
|
||||||
delete iconTexture;
|
delete iconTexture;
|
||||||
delete text;
|
delete text;
|
||||||
JA_DeleteSound(sound);
|
JA_DeleteSound(sound);
|
||||||
@@ -126,13 +124,13 @@ void Notify::clearFinishedNotifications()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void Notify::showText(std::string text1, std::string text2, int icon)
|
void Notify::showText(string text1, string text2, int icon)
|
||||||
{
|
{
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
const int iconSize = 16;
|
const int iconSize = 16;
|
||||||
const int padding = text->getCharacterSize();
|
const int padding = text->getCharacterSize();
|
||||||
const int iconSpace = icon >= 0 ? iconSize + padding : 0;
|
const int iconSpace = icon >= 0 ? iconSize + padding : 0;
|
||||||
const std::string txt = text1.length() > text2.length() ? text1 : text2;
|
const string txt = text1.length() > text2.length() ? text1 : text2;
|
||||||
const int width = text->lenght(txt) + (padding * 2) + iconSpace;
|
const int width = text->lenght(txt) + (padding * 2) + iconSpace;
|
||||||
const int height = (text->getCharacterSize() * 2) + (padding * 2);
|
const int height = (text->getCharacterSize() * 2) + (padding * 2);
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ private:
|
|||||||
|
|
||||||
struct notification_t
|
struct notification_t
|
||||||
{
|
{
|
||||||
std::string text1;
|
string text1;
|
||||||
std::string text2;
|
string text2;
|
||||||
int counter;
|
int counter;
|
||||||
notification_state_e state;
|
notification_state_e state;
|
||||||
notification_position_e position;
|
notification_position_e position;
|
||||||
@@ -50,16 +50,15 @@ private:
|
|||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Texture *textTexture; // Textura para la fuente de las notificaciones
|
|
||||||
Texture *iconTexture; // Textura para los iconos de las notificaciones
|
Texture *iconTexture; // Textura para los iconos de las notificaciones
|
||||||
Text *text; // Objeto para dibujar texto
|
Text *text; // Objeto para dibujar texto
|
||||||
options_t *options; // Variable con todas las opciones del programa
|
options_t *options; // Variable con todas las opciones del programa
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
color_t bgColor; // Color de fondo de las notificaciones
|
color_t bgColor; // Color de fondo de las notificaciones
|
||||||
int waitTime; // Tiempo que se ve la notificación
|
int waitTime; // Tiempo que se ve la notificación
|
||||||
std::vector<notification_t> notifications; // La lista de notificaciones activas
|
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
|
// Elimina las notificaciones finalizadas
|
||||||
void clearFinishedNotifications();
|
void clearFinishedNotifications();
|
||||||
@@ -72,13 +71,13 @@ public:
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
|
Notify(SDL_Renderer *renderer, string iconFile, string bitmapFile, string textFile, string soundFile, options_t *options);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Notify();
|
~Notify();
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void showText(std::string text1 = "", std::string text2 = "", int icon = -1);
|
void showText(string text1 = "", string text2 = "", int icon = -1);
|
||||||
|
|
||||||
// Indica si hay notificaciones activas
|
// Indica si hay notificaciones activas
|
||||||
bool active();
|
bool active();
|
||||||
|
|||||||
Reference in New Issue
Block a user