#pragma once #include // for SDL_Rect #include // for SDL_Renderer #include // for basic_string, string #include // for vector #include #include "utils.h" // for color_t #include "text.h" #include "texture.h" #include "sprite.h" struct JA_Sound_t; class Notify { private: enum notification_state_e { ns_rising, ns_stay, ns_vanishing, ns_finished }; enum notification_position_e { upperLeft, upperCenter, upperRight, middleLeft, middleRight, bottomLeft, bottomCenter, bottomRight }; enum notification_shape_t { notification_shape_rounded, notification_shape_squared, }; struct notification_t { std::unique_ptr texture; std::unique_ptr sprite; std::string text1; std::string text2; int counter; notification_state_e state; notification_position_e position; SDL_Rect rect; int y; int travelDist; notification_shape_t shape; // Constructor notification_t(std::unique_ptr texture, std::unique_ptr sprite) : texture(std::move(texture)), sprite(std::move(sprite)) {} // Constructor de movimiento notification_t(notification_t &&other) noexcept : texture(std::move(other.texture)), sprite(std::move(other.sprite)) { // Mover otros miembros si es necesario } // Operador de asignación por movimiento notification_t &operator=(notification_t &&other) noexcept { if (this != &other) { texture = std::move(other.texture); sprite = std::move(other.sprite); // Mover otros miembros si es necesario } return *this; } // Deshabilitar el constructor de copia y operador de asignación por copia notification_t(const notification_t &) = delete; notification_t &operator=(const notification_t &) = delete; }; // Objetos y punteros SDL_Renderer *renderer; // El renderizador de la ventana std::unique_ptr iconTexture; // Textura para los iconos de las notificaciones std::unique_ptr text; // Objeto para dibujar texto // Variables color_t bgColor; // Color de fondo de las notificaciones int waitTime; // Tiempo que se ve la notificación 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(); // Finaliza y elimnina todas las notificaciones activas void clearNotifications(); public: // Constructor Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile); // 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); // Indica si hay notificaciones activas bool active(); };