2019-03-02 16:06:33 +01:00
|
|
|
#ifndef FEIS_NOTIFICATIONSQUEUE_H
|
|
|
|
#define FEIS_NOTIFICATIONSQUEUE_H
|
|
|
|
|
|
|
|
#include <SFML/System.hpp>
|
2021-12-31 14:59:39 +01:00
|
|
|
#include <deque>
|
|
|
|
|
2021-12-31 00:57:06 +01:00
|
|
|
#include "notification.hpp"
|
2019-03-02 16:06:33 +01:00
|
|
|
|
2019-03-27 20:37:30 +01:00
|
|
|
/*
|
|
|
|
* Responsible for displaying the notifications with a fadeout effect
|
|
|
|
*/
|
2019-03-02 16:06:33 +01:00
|
|
|
class NotificationsQueue {
|
|
|
|
public:
|
2021-12-31 14:59:39 +01:00
|
|
|
explicit NotificationsQueue(int max_size = 10) : max_size(max_size) {};
|
2019-03-02 16:06:33 +01:00
|
|
|
|
2021-12-31 14:59:39 +01:00
|
|
|
void push(const std::shared_ptr<Notification>& notification);
|
2019-03-02 16:06:33 +01:00
|
|
|
|
|
|
|
void display();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void update();
|
2021-12-31 14:59:39 +01:00
|
|
|
float time_to_alpha(float seconds) {
|
|
|
|
return std::max(0.0f, 2.0f * (0.5f - seconds));
|
|
|
|
}
|
2019-03-02 16:06:33 +01:00
|
|
|
sf::Clock last_push;
|
|
|
|
const int max_size;
|
|
|
|
std::deque<std::shared_ptr<Notification>> queue;
|
|
|
|
};
|
|
|
|
|
2021-12-31 14:59:39 +01:00
|
|
|
#endif // FEIS_NOTIFICATIONSQUEUE_H
|