forked from jaildesigner-jailgames/jaildoctors_dilemma
Nou engine de notificacions
This commit is contained in:
@@ -10,9 +10,19 @@ class Sprite; // lines 9-9
|
||||
class Text; // lines 10-10
|
||||
class Texture; // lines 11-11
|
||||
|
||||
enum class NotificationText
|
||||
{
|
||||
LEFT,
|
||||
CENTER,
|
||||
};
|
||||
|
||||
class Notifier
|
||||
{
|
||||
private:
|
||||
// Constantes
|
||||
static constexpr int ICON_SIZE_ = 16;
|
||||
static constexpr int PADDING_OUT_ = 0;
|
||||
|
||||
// [SINGLETON] Objeto notifier
|
||||
static Notifier *notifier_;
|
||||
|
||||
@@ -42,11 +52,14 @@ private:
|
||||
int y;
|
||||
int travel_dist;
|
||||
std::string code; // Permite asignar un código a la notificación
|
||||
bool can_be_removed;
|
||||
int height;
|
||||
|
||||
// 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("") {}
|
||||
shape(NotificationShape::SQUARED), rect{0, 0, 0, 0}, y(0), travel_dist(0), code(""),
|
||||
can_be_removed(true), height(0) {}
|
||||
};
|
||||
|
||||
// Objetos y punteros
|
||||
@@ -71,14 +84,14 @@ private:
|
||||
// [SINGLETON] Ahora el constructor y el destructor son privados, para no poder crear objetos notifier desde fuera
|
||||
|
||||
// Constructor
|
||||
Notifier(std::string icon_file, std::shared_ptr<Text> text);
|
||||
Notifier(const std::string &icon_file, const std::string &text);
|
||||
|
||||
// Destructor
|
||||
~Notifier() = default;
|
||||
|
||||
public:
|
||||
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||
static void init(const std::string &icon_file, std::shared_ptr<Text> text);
|
||||
static void init(const std::string &icon_file, const std::string &text);
|
||||
|
||||
// [SINGLETON] Destruiremos el objeto con esta función estática
|
||||
static void destroy();
|
||||
@@ -93,7 +106,7 @@ public:
|
||||
void update();
|
||||
|
||||
// Muestra una notificación de texto por pantalla
|
||||
void show(std::vector<std::string> texts, int icon = -1, const std::string &code = std::string());
|
||||
void show(std::vector<std::string> texts, NotificationText text_is = NotificationText::LEFT, int icon = -1, bool can_be_removed = true, const std::string &code = std::string());
|
||||
|
||||
// Indica si hay notificaciones activas
|
||||
bool isActive();
|
||||
|
||||
Reference in New Issue
Block a user