From 29b0dd6114fb338a8ef6b73c9fa505443f1c9cb3 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 28 Aug 2022 13:13:35 +0200 Subject: [PATCH] ConfigMenu: Render a proper message if not configurable plugins are loaded --- source/utils/ConfigUtils.cpp | 39 ++++++++++++++++++++++++++++++++---- source/utils/ConfigUtils.h | 1 + 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/source/utils/ConfigUtils.cpp b/source/utils/ConfigUtils.cpp index f5f2f71..a4237e6 100644 --- a/source/utils/ConfigUtils.cpp +++ b/source/utils/ConfigUtils.cpp @@ -141,10 +141,6 @@ void ConfigUtils::displayMenu() { } } - if (configs.empty()) { - return; - } - ConfigDisplayItem *currentConfig = nullptr; WUPSConfigCategory *currentCategory = nullptr; @@ -192,6 +188,11 @@ void ConfigUtils::displayMenu() { break; } + if (configs.empty()) { + renderNoConfigFoundScreen(); + continue; + } + if (!currentConfig || !currentConfig->config) { if (buttonsTriggered & VPAD_BUTTON_DOWN) { if (selectedBtn < configs.size() - 1) { @@ -615,3 +616,33 @@ error_exit: MEMFreeToMappedMemory(screenbuffer1); } } +void ConfigUtils::renderNoConfigFoundScreen() { + DrawUtils::beginDraw(); + DrawUtils::clear(COLOR_BACKGROUND); + DrawUtils::setFontColor(COLOR_TEXT); + + // draw top bar + DrawUtils::setFontSize(24); + DrawUtils::print(16, 6 + 24, "Wii U Plugin System Config Menu"); + DrawUtils::setFontSize(18); + DrawUtils::print(SCREEN_WIDTH - 16, 8 + 24, "v1.0", true); + DrawUtils::drawRectFilled(8, 8 + 24 + 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_BLACK); + + // draw bottom bar + DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_BLACK); + DrawUtils::setFontSize(18); + DrawUtils::print(16, SCREEN_HEIGHT - 8, "\ue07d Navigate "); + + const char *noConfigFoundText = "No configurable plugins loaded"; + DrawUtils::setFontSize(24); + uint32_t sz = DrawUtils::getTextWidth(noConfigFoundText); + + DrawUtils::print((SCREEN_WIDTH / 2) - (sz / 2), (SCREEN_HEIGHT / 2), noConfigFoundText); + + // draw home button + DrawUtils::setFontSize(18); + const char *exitHint = "\ue044 Exit"; + DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(exitHint) / 2, SCREEN_HEIGHT - 8, exitHint, true); + + DrawUtils::endDraw(); +} diff --git a/source/utils/ConfigUtils.h b/source/utils/ConfigUtils.h index 0de64ab..22f5647 100644 --- a/source/utils/ConfigUtils.h +++ b/source/utils/ConfigUtils.h @@ -16,4 +16,5 @@ public: private: static void displayMenu(); + static void renderNoConfigFoundScreen(); };