Creada la clase Notify
This commit is contained in:
60
source/common/notify.h
Normal file
60
source/common/notify.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "text.h"
|
||||
#include "texture.h"
|
||||
#include "sprite.h"
|
||||
#include "utils.h"
|
||||
#include <vector>
|
||||
|
||||
#ifndef NOTIFY_H
|
||||
#define NOTIFY_H
|
||||
|
||||
class Notify
|
||||
{
|
||||
private:
|
||||
enum notification_state_e
|
||||
{
|
||||
ns_rising,
|
||||
ns_stay,
|
||||
ns_vanishing
|
||||
};
|
||||
|
||||
struct notification_t
|
||||
{
|
||||
std::string text;
|
||||
int counter;
|
||||
notification_state_e state;
|
||||
Texture *texture;
|
||||
Sprite *sprite;
|
||||
};
|
||||
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Text *text; // Objeto para dibujar texto
|
||||
|
||||
// Variables
|
||||
color_t bgColor; // Color de fondo de las notificaciones
|
||||
std::vector<notification_t> notifications; // La lista de notificaciones activas
|
||||
|
||||
// Dibuja las notificaciones por pantalla
|
||||
void render();
|
||||
|
||||
// Actualiza el estado de las notificaiones
|
||||
void update();
|
||||
|
||||
// Elimina las notificaciones finalizadas
|
||||
void clearFinishedNotifications();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Notify(SDL_Renderer *renderer, std::string bitmapFile, std::string textFile);
|
||||
|
||||
// Destructor
|
||||
~Notify();
|
||||
|
||||
// Muestra una notificación de texto por pantalla;
|
||||
void showText(std::string text);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user