mirror of
https://github.com/wiiu-env/NotificationModule.git
synced 2024-11-23 11:59:15 +01:00
Save Notifications in a queue until the overlay has been initialized
This commit is contained in:
parent
d9da174f4b
commit
1bf259db4b
@ -8,6 +8,8 @@
|
||||
void ExportCleanUp() {
|
||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||
gNotificationList.clear();
|
||||
std::lock_guard overlay_lock(gOverlayFrameMutex);
|
||||
gOverlayQueueDuringStartup.clear();
|
||||
}
|
||||
|
||||
NotificationModuleStatus NMAddStaticNotification(const char *text,
|
||||
@ -18,9 +20,6 @@ NotificationModuleStatus NMAddStaticNotification(const char *text,
|
||||
NMColor backgroundColor,
|
||||
void (*finishFunc)(NotificationModuleHandle, void *context),
|
||||
void *context) {
|
||||
if (!gOverlayFrame) {
|
||||
return NOTIFICATION_MODULE_RESULT_OVERLAY_NOT_READY;
|
||||
}
|
||||
|
||||
NotificationStatus status;
|
||||
switch (type) {
|
||||
@ -46,7 +45,14 @@ NotificationModuleStatus NMAddStaticNotification(const char *text,
|
||||
return NOTIFICATION_MODULE_RESULT_ALLOCATION_FAILED;
|
||||
}
|
||||
|
||||
gOverlayFrame->addNotification(notification);
|
||||
{
|
||||
std::lock_guard lock(gOverlayFrameMutex);
|
||||
if (gOverlayFrame) {
|
||||
gOverlayFrame->addNotification(std::move(notification));
|
||||
} else {
|
||||
gOverlayQueueDuringStartup.push_back(std::move(notification));
|
||||
}
|
||||
}
|
||||
|
||||
return NOTIFICATION_MODULE_RESULT_SUCCESS;
|
||||
}
|
||||
@ -70,9 +76,6 @@ NotificationModuleStatus NMAddDynamicNotification(const char *text,
|
||||
return NOTIFICATION_MODULE_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
*outHandle = 0;
|
||||
if (!gOverlayFrame) {
|
||||
return NOTIFICATION_MODULE_RESULT_OVERLAY_NOT_READY;
|
||||
}
|
||||
|
||||
auto notification = make_shared_nothrow<Notification>(
|
||||
text,
|
||||
@ -91,8 +94,15 @@ NotificationModuleStatus NMAddDynamicNotification(const char *text,
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||
*outHandle = notification->getHandle();
|
||||
gOverlayFrame->addNotification(notification);
|
||||
gNotificationList.push_front(notification);
|
||||
{
|
||||
std::lock_guard overlay_lock(gOverlayFrameMutex);
|
||||
if (gOverlayFrame) {
|
||||
gOverlayFrame->addNotification(notification);
|
||||
} else {
|
||||
gOverlayQueueDuringStartup.push_back(notification);
|
||||
}
|
||||
}
|
||||
gNotificationList.push_front(std::move(notification));
|
||||
}
|
||||
|
||||
return NOTIFICATION_MODULE_RESULT_SUCCESS;
|
||||
|
@ -110,12 +110,19 @@ bool drawScreenshotSavedTexture(const GX2ColorBuffer *colorBuffer, GX2ScanTarget
|
||||
DECL_FUNCTION(void, GX2Init, uint32_t attributes) {
|
||||
real_GX2Init(attributes);
|
||||
if (!gOverlayInitDone) {
|
||||
std::lock_guard overlay_lock(gOverlayFrameMutex);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Init Overlay");
|
||||
gOverlayFrame = new (std::nothrow) OverlayFrame(1280.0f, 720.0f);
|
||||
if (!gOverlayFrame) {
|
||||
OSFatal("Failed to alloc gOverlayFrame");
|
||||
}
|
||||
|
||||
// Add notification that had been called before the overlay was ready
|
||||
for (const auto ¬ification : gOverlayQueueDuringStartup) {
|
||||
gOverlayFrame->addNotification(notification);
|
||||
}
|
||||
gOverlayQueueDuringStartup.clear();
|
||||
|
||||
// Allocate shader.
|
||||
ColorShader::instance();
|
||||
Texture2DShader::instance();
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include "retain_vars.hpp"
|
||||
|
||||
GX2SurfaceFormat gTVSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
GX2SurfaceFormat gDRCSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
GX2ContextState *gContextState = nullptr;
|
||||
GX2ContextState *gOriginalContextState = nullptr;
|
||||
OverlayFrame *gOverlayFrame = nullptr;
|
||||
SchriftGX2 *gFontSystem = nullptr;
|
||||
bool gOverlayInitDone = false;
|
||||
bool gDrawReady = false;
|
||||
GX2SurfaceFormat gTVSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
GX2SurfaceFormat gDRCSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
GX2ContextState *gContextState = nullptr;
|
||||
GX2ContextState *gOriginalContextState = nullptr;
|
||||
std::mutex gOverlayFrameMutex = {};
|
||||
std::vector<std::shared_ptr<Notification>> gOverlayQueueDuringStartup = {};
|
||||
OverlayFrame *gOverlayFrame = nullptr;
|
||||
SchriftGX2 *gFontSystem = nullptr;
|
||||
bool gOverlayInitDone = false;
|
||||
bool gDrawReady = false;
|
@ -7,6 +7,8 @@ extern GX2SurfaceFormat gTVSurfaceFormat;
|
||||
extern GX2SurfaceFormat gDRCSurfaceFormat;
|
||||
extern GX2ContextState *gContextState;
|
||||
extern GX2ContextState *gOriginalContextState;
|
||||
extern std::mutex gOverlayFrameMutex;
|
||||
extern std::vector<std::shared_ptr<Notification>> gOverlayQueueDuringStartup;
|
||||
extern OverlayFrame *gOverlayFrame;
|
||||
extern SchriftGX2 *gFontSystem;
|
||||
extern bool gOverlayInitDone;
|
||||
|
Loading…
Reference in New Issue
Block a user