WiiUPluginLoaderBackend/source/NotificationsUtils.cpp

34 lines
1.4 KiB
C++
Raw Normal View History

2023-08-16 10:08:44 +02:00
#include "NotificationsUtils.h"
#include "globals.h"
#include "utils/logger.h"
#include <cstring>
#include <notifications/notifications.h>
bool DisplayNotificationMessage(std::string_view text, NotificationModuleNotificationType type, float duration) {
2023-08-16 10:08:44 +02:00
if (!gNotificationModuleLoaded) {
return false;
}
if (type == NOTIFICATION_MODULE_NOTIFICATION_TYPE_DYNAMIC) {
return false;
}
2024-03-01 11:53:16 +01:00
if (type == NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO) {
NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, duration);
NotificationModule_AddInfoNotification(text.data());
} else if (type == NOTIFICATION_MODULE_NOTIFICATION_TYPE_ERROR) {
NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_ERROR, NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, duration);
NotificationModule_AddErrorNotification(text.data());
} else {
DEBUG_FUNCTION_LINE_WARN("Unsupported notification type: %d", type);
2023-08-16 10:08:44 +02:00
}
2024-03-01 11:53:16 +01:00
2023-08-16 10:08:44 +02:00
return true;
}
bool DisplayInfoNotificationMessage(std::string_view text, float duration) {
2023-08-16 10:08:44 +02:00
return DisplayNotificationMessage(text, NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, duration);
}
bool DisplayErrorNotificationMessage(std::string_view text, float duration) {
2023-08-16 10:08:44 +02:00
return DisplayNotificationMessage(text, NOTIFICATION_MODULE_NOTIFICATION_TYPE_ERROR, duration);
}