forked from jaildesigner-jailgames/jaildoctors_dilemma
canvi de pc enmig de la enfangà
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
|
||||
#include <SDL2/SDL_rect.h> // Para SDL_Rect
|
||||
#include <SDL2/SDL_render.h> // Para SDL_Renderer
|
||||
#include <string> // Para basic_string, string
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string, basic_string
|
||||
#include <vector> // Para vector
|
||||
#include "utils.h" // Para color_t
|
||||
class Sprite;
|
||||
class Text;
|
||||
class Texture;
|
||||
struct JA_Sound_t;
|
||||
#include "utils.h" // Para Color
|
||||
class Sprite; // lines 9-9
|
||||
class Text; // lines 10-10
|
||||
class Texture; // lines 11-11
|
||||
|
||||
class Notifier
|
||||
{
|
||||
@@ -16,64 +16,69 @@ private:
|
||||
// [SINGLETON] Objeto notifier
|
||||
static Notifier *notifier_;
|
||||
|
||||
enum notification_state_e
|
||||
enum class NotificationStatus
|
||||
{
|
||||
ns_rising,
|
||||
ns_stay,
|
||||
ns_vanishing,
|
||||
ns_finished
|
||||
RISING,
|
||||
STAY,
|
||||
VANISHING,
|
||||
FINISHED,
|
||||
};
|
||||
|
||||
enum notification_position_e
|
||||
enum class NotificationShape
|
||||
{
|
||||
upperLeft,
|
||||
upperCenter,
|
||||
upperRight,
|
||||
middleLeft,
|
||||
middleRight,
|
||||
bottomLeft,
|
||||
bottomCenter,
|
||||
bottomRight
|
||||
ROUNDED,
|
||||
SQUARED,
|
||||
};
|
||||
|
||||
struct notification_t
|
||||
struct Notification
|
||||
{
|
||||
std::string text1;
|
||||
std::string text2;
|
||||
std::shared_ptr<Texture> texture;
|
||||
std::shared_ptr<Sprite> sprite;
|
||||
std::vector<std::string> texts;
|
||||
int counter;
|
||||
notification_state_e state;
|
||||
notification_position_e position;
|
||||
Texture *texture;
|
||||
Sprite *sprite;
|
||||
NotificationStatus state;
|
||||
NotificationShape shape;
|
||||
SDL_Rect rect;
|
||||
int y;
|
||||
int travelDist;
|
||||
int travel_dist;
|
||||
std::string code; // Permite asignar un código a la notificación
|
||||
|
||||
// Constructor
|
||||
explicit Notification()
|
||||
: texture(nullptr), sprite(nullptr), texts(), counter(0), state(NotificationStatus::RISING),
|
||||
shape(NotificationShape::SQUARED), rect{0, 0, 0, 0}, y(0), travel_dist(0), code("") {}
|
||||
};
|
||||
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||
Texture *text_texture_; // Textura para la fuente de las notificaciones
|
||||
Texture *icon_texture_; // Textura para los iconos de las notificaciones
|
||||
Text *text_; // Objeto para dibujar texto
|
||||
|
||||
std::shared_ptr<Texture> icon_texture_; // Textura para los iconos de las notificaciones
|
||||
std::shared_ptr<Text> text_; // Objeto para dibujar texto
|
||||
|
||||
// Variables
|
||||
Color bg_color_; // Color de fondo de las notificaciones
|
||||
int wait_time_; // 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
|
||||
Color bg_color_; // Color de fondo de las notificaciones
|
||||
int wait_time_; // Tiempo que se ve la notificación
|
||||
std::vector<Notification> notifications_; // La lista de notificaciones activas
|
||||
bool stack_; // Indica si las notificaciones se apilan
|
||||
bool has_icons_; // Indica si el notificador tiene textura para iconos
|
||||
|
||||
// Elimina las notificaciones finalizadas
|
||||
void clearFinishedNotifications();
|
||||
|
||||
// Finaliza y elimnina todas las notificaciones activas
|
||||
void clearNotifications();
|
||||
|
||||
// [SINGLETON] Ahora el constructor y el destructor son privados, para no poder crear objetos notifier desde fuera
|
||||
|
||||
// Constructor
|
||||
Notifier(std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile);
|
||||
Notifier(std::string icon_file, std::shared_ptr<Text> text);
|
||||
|
||||
// Destructor
|
||||
~Notifier();
|
||||
~Notifier() = default;
|
||||
|
||||
public:
|
||||
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||
static void init(std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile);
|
||||
static void init(const std::string &icon_file, std::shared_ptr<Text> text);
|
||||
|
||||
// [SINGLETON] Destruiremos el objeto con esta función estática
|
||||
static void destroy();
|
||||
@@ -87,9 +92,12 @@ public:
|
||||
// Actualiza el estado de las notificaiones
|
||||
void update();
|
||||
|
||||
// Muestra una notificación de texto por pantalla;
|
||||
void show(std::string text1 = "", std::string text2 = "", int icon = -1);
|
||||
// Muestra una notificación de texto por pantalla
|
||||
void show(std::vector<std::string> texts, int icon = -1, const std::string &code = std::string());
|
||||
|
||||
// Getters
|
||||
bool active() const { return !notifications_.empty(); }
|
||||
// Indica si hay notificaciones activas
|
||||
bool isActive();
|
||||
|
||||
// Obtiene los códigos de las notificaciones
|
||||
std::vector<std::string> getCodes();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user