diff --git a/data/notification/notify.png b/data/notification/notify.png deleted file mode 100644 index 753f74c..0000000 Binary files a/data/notification/notify.png and /dev/null differ diff --git a/source/director.cpp b/source/director.cpp index fa02cb7..bfdeb1f 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -330,9 +330,6 @@ bool Director::setFileList() asset->add(prefix + "/data/config/demo2.bin", t_data); asset->add(prefix + "/data/config/gamecontrollerdb.txt", t_data); - // Notificaciones - asset->add(prefix + "/data/notification/notify.png", t_bitmap); - // Musicas asset->add(prefix + "/data/music/intro.ogg", t_music); asset->add(prefix + "/data/music/playing.ogg", t_music); diff --git a/source/notify.cpp b/source/notify.cpp index 5cdfa73..54ab98d 100644 --- a/source/notify.cpp +++ b/source/notify.cpp @@ -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}); diff --git a/source/notify.h b/source/notify.h index 6a3a87c..6506282 100644 --- a/source/notify.h +++ b/source/notify.h @@ -67,6 +67,7 @@ private: std::vector 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 + bool hasIcons; // Indica si el notificador tiene textura para iconos // Elimina las notificaciones finalizadas void clearFinishedNotifications(); diff --git a/source/screen.cpp b/source/screen.cpp index b9de282..0653152 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -69,7 +69,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input * infoResolution = std::to_string(DM.w) + " X " + std::to_string(DM.h) + " AT " + std::to_string(DM.refresh_rate) + " HZ"; // Crea los objetos - notify = new Notify(renderer, asset->get("notify.png"), asset->get("8bithud.png"), asset->get("8bithud.txt"), asset->get("notify.wav")); + notify = new Notify(renderer, "", asset->get("8bithud.png"), asset->get("8bithud.txt"), asset->get("notify.wav")); // Define el color del borde para el modo de pantalla completa borderColor = {0x00, 0x00, 0x00};