Eliminades les icones de les notificacions (herencia del CC original)

This commit is contained in:
2024-09-28 12:46:53 +02:00
parent 3f24f38a0c
commit 878518babe
5 changed files with 20 additions and 9 deletions

View File

@@ -12,9 +12,16 @@ Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapF
bgColor = options.notification.color;
waitTime = 150;
stack = false;
hasIcons = iconFile == "" ? false : true;
iconTexture = nullptr;
textTexture = nullptr;
text = nullptr;
// Crea objetos
iconTexture = new Texture(renderer, iconFile);
if (hasIcons)
{
iconTexture = new Texture(renderer, iconFile);
}
textTexture = new Texture(renderer, bitmapFile);
text = new Text(textFile, textTexture, renderer);
sound = JA_LoadSound(soundFile.c_str());
@@ -24,9 +31,15 @@ Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapF
Notify::~Notify()
{
// Libera la memoria de los objetos
delete textTexture;
delete iconTexture;
delete text;
if (textTexture)
delete textTexture;
if (iconTexture)
delete iconTexture;
if (text)
delete text;
JA_DeleteSound(sound);
for (auto notification : notifications)
@@ -276,7 +289,7 @@ void Notify::showText(std::string text1, std::string text2, int icon)
}
// Dibuja el icono de la notificación
if (icon >= 0 && numTexts == 2)
if (hasIcons && icon >= 0 && numTexts == 2)
{
Sprite *sp = new Sprite({0, 0, iconSize, iconSize}, iconTexture);
sp->setPos({paddingIn, paddingIn, iconSize, iconSize});