This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/services/notifications/notification_service.hpp
Andreas Maerten cba19d0c33
refactor!: Rewrite of the old notification service (#2866)
The main goal was improving the readability of the original code however some ugliness remains.

- Swapped from pointer singleton to instance singleton
- Actually make use of the alpha logic that used to be present
- Added a counter to notifications to indicate if something is being spammed
- Notification timeouts reset if they're sent to the queue again
2024-03-23 00:04:49 +01:00

32 lines
813 B
C++

#pragma once
#include "notification.hpp"
namespace big
{
class notification_service final
{
std::unordered_map<std::size_t, notification> m_notifications;
public:
notification_service() = default;
virtual ~notification_service() = default;
bool initialise();
void push(const std::string& title, const std::string& message);
void push_warning(const std::string& title, const std::string& message);
void push_error(const std::string& title, const std::string& message);
void push_success(const std::string& title, const std::string& message);
// cleans up old notifications from the map and returns a sorted list based on the destroy time
std::vector<notification> get();
private:
void push(notification notification);
};
inline notification_service g_notification_service{};
}