
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
32 lines
813 B
C++
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{};
|
|
}
|