forked from jaildesigner-jailgames/jaildoctors_dilemma
85 lines
2.0 KiB
C++
85 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <SDL2/SDL_rect.h> // Para SDL_Rect
|
|
#include <SDL2/SDL_render.h> // Para SDL_Renderer
|
|
#include <string> // Para basic_string, string
|
|
#include <vector> // Para vector
|
|
#include "utils.h" // Para color_t
|
|
class Sprite;
|
|
class Text;
|
|
class Texture;
|
|
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
|
|
};
|
|
|
|
struct notification_t
|
|
{
|
|
std::string text1;
|
|
std::string text2;
|
|
int counter;
|
|
notification_state_e state;
|
|
notification_position_e position;
|
|
Texture *texture;
|
|
Sprite *sprite;
|
|
SDL_Rect rect;
|
|
int y;
|
|
int travelDist;
|
|
};
|
|
|
|
// Objetos y punteros
|
|
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
|
|
Text *text; // Objeto para dibujar texto
|
|
options_t *options; // Variable con todas las opciones del programa
|
|
|
|
// Variables
|
|
color_t bgColor; // Color de fondo de las notificaciones
|
|
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
|
|
|
|
// Elimina las notificaciones finalizadas
|
|
void clearFinishedNotifications();
|
|
|
|
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();
|
|
|
|
// 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();
|
|
};
|