diff --git a/.github/workflows/push_image.yml b/.github/workflows/push_image.yml index 8976048..5472ea5 100644 --- a/.github/workflows/push_image.yml +++ b/.github/workflows/push_image.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Extract Docker metadata id: meta uses: docker/metadata-action@v4 diff --git a/Dockerfile b/Dockerfile index a659647..7afb775 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/wiiu-env/devkitppc:20230621 +FROM ghcr.io/wiiu-env/devkitppc:20240423 WORKDIR tmp_build COPY . . diff --git a/Dockerfile.buildlocal b/Dockerfile.buildlocal index 2c69585..bb8c5c8 100644 --- a/Dockerfile.buildlocal +++ b/Dockerfile.buildlocal @@ -1,3 +1,3 @@ -FROM ghcr.io/wiiu-env/devkitppc:20230621 +FROM ghcr.io/wiiu-env/devkitppc:20240423 WORKDIR project \ No newline at end of file diff --git a/include/notifications/notification_defines.h b/include/notifications/notification_defines.h index 916d464..5b6f005 100644 --- a/include/notifications/notification_defines.h +++ b/include/notifications/notification_defines.h @@ -47,4 +47,5 @@ typedef enum NotificationModuleNotificationOption { NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, /* Time in seconds before the Notification will fade out: Type: float. Example: 2.5f = 2.5 seconds*/ NOTIFICATION_MODULE_DEFAULT_OPTION_FINISH_FUNCTION, /* Function that will be called when the Notification starts to fade out. Type: NotificationModuleNotificationFinishedCallback*/ NOTIFICATION_MODULE_DEFAULT_OPTION_FINISH_FUNCTION_CONTEXT, /* Context that will be passed to the NOTIFICATION_MODULE_DEFAULT_TYPE_FINISH_FUNCTION callback. Type: void* */ + NOTIFICATION_MODULE_DEFAULT_OPTION_KEEP_UNTIL_SHOWN, /* Keeps the notification in memory until it was actually shown */ } NotificationModuleNotificationOption; diff --git a/include/notifications/notifications.h b/include/notifications/notifications.h index c4fa23d..8dd0a8f 100644 --- a/include/notifications/notifications.h +++ b/include/notifications/notifications.h @@ -94,6 +94,7 @@ NotificationModuleStatus NotificationModule_SetDefaultValue(NotificationModuleNo * @param backgroundColor Background color of the Notification * @param callback Function that will be called then the Notification fades out. * @param callbackContext Context that will be passed to the callback. + * @param keepUntilShown The Notification will be stored in a queue until can be shown - even accross application starts * @return NOTIFICATION_MODULE_RESULT_SUCCESS: The default value has been set.
* NOTIFICATION_MODULE_RESULT_INVALID_ARGUMENT: text was NULL.
* NOTIFICATION_MODULE_RESULT_UNSUPPORTED_COMMAND: The loaded module version doesn't not support this function.
@@ -106,7 +107,8 @@ NotificationModuleStatus NotificationModule_AddInfoNotificationEx(const char *te NMColor textColor, NMColor backgroundColor, NotificationModuleNotificationFinishedCallback callback, - void *callbackContext); + void *callbackContext, + bool keepUntilShown); /** * Displays a Notification that fade outs after a given time.
@@ -161,6 +163,7 @@ NotificationModuleStatus NotificationModule_AddInfoNotificationWithCallback(cons * @param backgroundColor Background color of the Notification * @param callback Function that will be called then the Notification fades out. * @param callbackContext Context that will be passed to the callback. + * @param keepUntilShown The Notification will be stored in a queue until can be shown - even accross application starts * @return NOTIFICATION_MODULE_RESULT_SUCCESS: The default value has been set.
* NOTIFICATION_MODULE_RESULT_INVALID_ARGUMENT: text was NULL.
* NOTIFICATION_MODULE_RESULT_UNSUPPORTED_COMMAND: The loaded module version doesn't not support this function.
@@ -174,7 +177,8 @@ NotificationModuleStatus NotificationModule_AddErrorNotificationEx(const char *t NMColor textColor, NMColor backgroundColor, NotificationModuleNotificationFinishedCallback callback, - void *callbackContext); + void *callbackContext, + bool keepUntilShown); /** * Displays a (error) Notification (default background color: red) that shakes and fade outs after a given time.
@@ -227,6 +231,7 @@ NotificationModuleStatus NotificationModule_AddErrorNotificationWithCallback(con * @param backgroundColor Background color of the notification * @param callback Function that will be called then the Notification fades out. * @param callbackContext Context that will be passed to the callback. + * @param keepUntilShown The Notification will be stored in a queue until can be shown - even accross application starts * @return NOTIFICATION_MODULE_RESULT_SUCCESS: The default value has been set.
* NOTIFICATION_MODULE_RESULT_INVALID_ARGUMENT: text or outHandle was NULL
* NOTIFICATION_MODULE_RESULT_UNSUPPORTED_COMMAND: The loaded module version doesn't not support this function.
@@ -239,7 +244,8 @@ NotificationModuleStatus NotificationModule_AddDynamicNotificationEx(const char NMColor textColor, NMColor backgroundColor, NotificationModuleNotificationFinishedCallback callback, - void *callbackContext); + void *callbackContext, + bool keepUntilShown); /** * Displays a Notification that can be updated and stays on the screen until `NotificationModule_FinishDynamicNotification*` has been called.
diff --git a/source/internal.h b/source/internal.h index c9ff274..a666bbc 100644 --- a/source/internal.h +++ b/source/internal.h @@ -9,4 +9,5 @@ struct NMDefaultValueStore { NMColor textColor = {255, 255, 255, 255}; void (*finishFunc)(NotificationModuleHandle, void *context) = nullptr; void *finishFuncContext = nullptr; + bool keepUntilShown = false; }; \ No newline at end of file diff --git a/source/utils.cpp b/source/utils.cpp index a1051b2..a8f46c6 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -16,14 +16,33 @@ static NotificationModuleStatus (*sNMAddStaticNotification)(const char *, float, NMColor, NMColor, - void (*)(void *context), + void (*)(NotificationModuleHandle, void *), void *) = nullptr; static NotificationModuleStatus (*sNMAddDynamicNotification)(const char *, NMColor, NMColor, - void (*)(void *context), - void *) = nullptr; + void (*)(NotificationModuleHandle, void *), + void *, + NotificationModuleHandle *) = nullptr; + +static NotificationModuleStatus (*sNMAddStaticNotificationV2)(const char *, + NotificationModuleNotificationType, + float, + float, + NMColor, + NMColor, + void (*)(NotificationModuleHandle, void *), + void *, + bool) = nullptr; + +static NotificationModuleStatus (*sNMAddDynamicNotificationV2)(const char *, + NMColor, + NMColor, + void (*)(NotificationModuleHandle, void *), + void *, + bool, + NotificationModuleHandle *) = nullptr; static NotificationModuleStatus (*sNMUpdateDynamicNotificationText)(NotificationModuleHandle, const char *) = nullptr; @@ -104,27 +123,36 @@ NotificationModuleStatus NotificationModule_InitLibrary() { } if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "NMAddDynamicNotification", (void **) &sNMAddDynamicNotification) != OS_DYNLOAD_OK) { DEBUG_FUNCTION_LINE_ERR("FindExport NMAddDynamicNotification failed."); - sNMAddStaticNotification = nullptr; + sNMAddDynamicNotification = nullptr; } if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "NMUpdateDynamicNotificationText", (void **) &sNMUpdateDynamicNotificationText) != OS_DYNLOAD_OK) { DEBUG_FUNCTION_LINE_ERR("FindExport NMUpdateDynamicNotificationText failed."); - sNMAddStaticNotification = nullptr; + sNMUpdateDynamicNotificationText = nullptr; } if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "NMUpdateDynamicNotificationBackgroundColor", (void **) &sNMUpdateDynamicNotificationBackgroundColor) != OS_DYNLOAD_OK) { DEBUG_FUNCTION_LINE_ERR("FindExport NMUpdateDynamicNotificationBackgroundColor failed."); - sNMAddStaticNotification = nullptr; + sNMUpdateDynamicNotificationBackgroundColor = nullptr; } if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "NMUpdateDynamicNotificationTextColor", (void **) &sNMUpdateDynamicNotificationTextColor) != OS_DYNLOAD_OK) { DEBUG_FUNCTION_LINE_ERR("FindExport NMUpdateDynamicNotificationTextColor failed."); - sNMAddStaticNotification = nullptr; + sNMUpdateDynamicNotificationTextColor = nullptr; } if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "NMFinishDynamicNotification", (void **) &sNMFinishDynamicNotification) != OS_DYNLOAD_OK) { DEBUG_FUNCTION_LINE_ERR("FindExport NMFinishDynamicNotification failed."); - sNMAddStaticNotification = nullptr; + sNMFinishDynamicNotification = nullptr; + } + + if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "NMAddDynamicNotificationV2", (void **) &sNMAddDynamicNotificationV2) != OS_DYNLOAD_OK) { + DEBUG_FUNCTION_LINE_ERR("FindExport NMAddDynamicNotificationV2 failed."); + sNMAddDynamicNotificationV2 = nullptr; + } + if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "NMAddStaticNotificationV2", (void **) &sNMAddStaticNotificationV2) != OS_DYNLOAD_OK) { + DEBUG_FUNCTION_LINE_ERR("FindExport NMAddStaticNotificationV2 failed."); + sNMAddStaticNotificationV2 = nullptr; } sDefaultValues.clear(); @@ -180,19 +208,13 @@ NotificationModuleStatus NotificationModule_IsOverlayReady(bool *outIsReady) { return reinterpret_cast(sNMIsOverlayReady)(outIsReady); } -NotificationModuleStatus NotificationModule_AddDynamicNotificationExDeclare(const char *text, - NMColor textColor, - NMColor backgroundColor, - NotificationModuleNotificationFinishedCallback callback, - void *callbackContext, - NotificationModuleHandle *outHandle); - NotificationModuleStatus NotificationModule_AddDynamicNotificationEx(const char *text, NotificationModuleHandle *outHandle, NMColor textColor, NMColor backgroundColor, void (*finishFunc)(NotificationModuleHandle, void *context), - void *context) { + void *context, + bool keepUntilShown) { if (sNotificationModuleVersion == NOTIFICATION_MODULE_API_VERSION_ERROR) { return NOTIFICATION_MODULE_RESULT_LIB_UNINITIALIZED; } @@ -204,12 +226,25 @@ NotificationModuleStatus NotificationModule_AddDynamicNotificationEx(const char return NOTIFICATION_MODULE_RESULT_INVALID_ARGUMENT; } - return reinterpret_cast(sNMAddDynamicNotification)(text, - textColor, - backgroundColor, - finishFunc, - context, - outHandle); + if (sNotificationModuleVersion == 2) { + if (sNMAddDynamicNotificationV2 == nullptr) { + return NOTIFICATION_MODULE_RESULT_UNSUPPORTED_COMMAND; + } + return reinterpret_cast(sNMAddDynamicNotificationV2)(text, + textColor, + backgroundColor, + finishFunc, + context, + keepUntilShown, + outHandle); + } + + return reinterpret_cast(sNMAddDynamicNotification)(text, + textColor, + backgroundColor, + finishFunc, + context, + outHandle); } NotificationModuleStatus NotificationModule_AddDynamicNotification(const char *text, NotificationModuleHandle *outHandle) { @@ -219,7 +254,8 @@ NotificationModuleStatus NotificationModule_AddDynamicNotification(const char *t cur.textColor, cur.backgroundColor, cur.finishFunc, - cur.finishFuncContext); + cur.finishFuncContext, + cur.keepUntilShown); } NotificationModuleStatus NotificationModule_AddDynamicNotificationWithCallback(const char *text, @@ -232,7 +268,8 @@ NotificationModuleStatus NotificationModule_AddDynamicNotificationWithCallback(c cur.textColor, cur.backgroundColor, callback, - callbackContext); + callbackContext, + cur.keepUntilShown); } static NotificationModuleStatus NotificationModule_AddStaticNotification(const char *text, @@ -242,7 +279,8 @@ static NotificationModuleStatus NotificationModule_AddStaticNotification(const c NMColor textColor, NMColor backgroundColor, NotificationModuleNotificationFinishedCallback callback, - void *callbackContext) { + void *callbackContext, + bool keepUntilShown) { if (sNotificationModuleVersion == NOTIFICATION_MODULE_API_VERSION_ERROR) { return NOTIFICATION_MODULE_RESULT_LIB_UNINITIALIZED; } @@ -254,14 +292,28 @@ static NotificationModuleStatus NotificationModule_AddStaticNotification(const c return NOTIFICATION_MODULE_RESULT_INVALID_ARGUMENT; } - return reinterpret_cast(sNMAddStaticNotification)(text, - type, - durationBeforeFadeOutInSeconds, - shakeDurationInSeconds, - textColor, - backgroundColor, - callback, - callbackContext); + if (sNotificationModuleVersion == 2) { + if (sNMAddStaticNotificationV2 == nullptr) { + return NOTIFICATION_MODULE_RESULT_UNSUPPORTED_COMMAND; + } + return reinterpret_cast(sNMAddStaticNotificationV2)(text, + type, + durationBeforeFadeOutInSeconds, + shakeDurationInSeconds, + textColor, + backgroundColor, + callback, + callbackContext, + keepUntilShown); + } + return reinterpret_cast(sNMAddStaticNotification)(text, + type, + durationBeforeFadeOutInSeconds, + shakeDurationInSeconds, + textColor, + backgroundColor, + callback, + callbackContext); } #undef NotificationModule_SetDefaultValue @@ -306,6 +358,11 @@ NotificationModuleStatus NotificationModule_SetDefaultValue(NotificationModuleNo cur.finishFuncContext = arg; break; } + case NOTIFICATION_MODULE_DEFAULT_OPTION_KEEP_UNTIL_SHOWN: { + auto arg = va_arg(va, int); + cur.keepUntilShown = (bool) arg; + break; + } default: res = NOTIFICATION_MODULE_RESULT_INVALID_ARGUMENT; break; @@ -321,7 +378,8 @@ NotificationModuleStatus NotificationModule_AddInfoNotificationEx(const char *te NMColor textColor, NMColor backgroundColor, NotificationModuleNotificationFinishedCallback callback, - void *callbackContext) { + void *callbackContext, + bool keepUntilShown) { return NotificationModule_AddStaticNotification(text, NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, durationBeforeFadeOutInSeconds, @@ -329,7 +387,8 @@ NotificationModuleStatus NotificationModule_AddInfoNotificationEx(const char *te textColor, backgroundColor, callback, - callbackContext); + callbackContext, + keepUntilShown); } NotificationModuleStatus NotificationModule_AddInfoNotification(const char *text) { @@ -339,7 +398,8 @@ NotificationModuleStatus NotificationModule_AddInfoNotification(const char *text cur.textColor, cur.backgroundColor, cur.finishFunc, - cur.finishFuncContext); + cur.finishFuncContext, + cur.keepUntilShown); } NotificationModuleStatus NotificationModule_AddInfoNotificationWithCallback(const char *text, NotificationModuleNotificationFinishedCallback callback, @@ -350,7 +410,8 @@ NotificationModuleStatus NotificationModule_AddInfoNotificationWithCallback(cons cur.textColor, cur.backgroundColor, callback, - callbackContext); + callbackContext, + cur.keepUntilShown); } NotificationModuleStatus NotificationModule_AddErrorNotificationEx(const char *text, @@ -359,7 +420,8 @@ NotificationModuleStatus NotificationModule_AddErrorNotificationEx(const char *t NMColor textColor, NMColor backgroundColor, NotificationModuleNotificationFinishedCallback callback, - void *callbackContext) { + void *callbackContext, + bool keepUntilShown) { return NotificationModule_AddStaticNotification(text, NOTIFICATION_MODULE_NOTIFICATION_TYPE_ERROR, durationBeforeFadeOutInSeconds, @@ -367,7 +429,8 @@ NotificationModuleStatus NotificationModule_AddErrorNotificationEx(const char *t textColor, backgroundColor, callback, - callbackContext); + callbackContext, + keepUntilShown); } NotificationModuleStatus NotificationModule_AddErrorNotification(const char *text) { @@ -382,7 +445,8 @@ NotificationModuleStatus NotificationModule_AddErrorNotification(const char *tex cur.textColor, cur.backgroundColor, cur.finishFunc, - cur.finishFuncContext); + cur.finishFuncContext, + cur.keepUntilShown); } NotificationModuleStatus NotificationModule_AddErrorNotificationWithCallback(const char *text, @@ -399,7 +463,8 @@ NotificationModuleStatus NotificationModule_AddErrorNotificationWithCallback(con cur.textColor, cur.backgroundColor, callback, - callbackContext); + callbackContext, + cur.keepUntilShown); } NotificationModuleStatus NotificationModule_UpdateDynamicNotificationText(NotificationModuleHandle handle,