From c2228569bd874eac736666f76d1734c9f6391dc9 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 25 Aug 2022 18:13:18 +0200 Subject: [PATCH] Hide the option to boot into HBL when the 50_hbl_installer.rpx is missing for the environment --- source/MenuUtils.cpp | 12 +++++++++++- source/MenuUtils.h | 2 +- source/main.cpp | 17 ++++++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/source/MenuUtils.cpp b/source/MenuUtils.cpp index 84d2136..3564180 100644 --- a/source/MenuUtils.cpp +++ b/source/MenuUtils.cpp @@ -69,7 +69,7 @@ void writeAutobootOption(std::string &configPath, int32_t autobootOption) { } } -int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput) { +int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, bool showHBL) { auto screenBuffer = DrawUtils::InitOSScreen(); if (!screenBuffer) { OSFatal("Failed to alloc memory for screen"); @@ -91,11 +91,18 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput) { if (vpad.trigger & VPAD_BUTTON_UP) { if (selected > 0) { selected--; + if (!showHBL && selected == BOOT_OPTION_HOMEBREW_LAUNCHER) { + selected--; + } + redraw = true; } } else if (vpad.trigger & VPAD_BUTTON_DOWN) { if (selected < sizeof(menu_options) / sizeof(char *) - 1) { selected++; + if (!showHBL && selected == BOOT_OPTION_HOMEBREW_LAUNCHER) { + selected++; + } redraw = true; } } else if (vpad.trigger & VPAD_BUTTON_A) { @@ -115,6 +122,9 @@ int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput) { // draw buttons uint32_t index = 8 + 24 + 8 + 4; for (uint32_t i = 0; i < sizeof(menu_options) / sizeof(char *); i++) { + if (!showHBL && i == BOOT_OPTION_HOMEBREW_LAUNCHER) { + continue; + } if (i == selected) { DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16 * 2, 44, 4, COLOR_BORDER_HIGHLIGHTED); } else { diff --git a/source/MenuUtils.h b/source/MenuUtils.h index 8ee0ed3..18b38e5 100644 --- a/source/MenuUtils.h +++ b/source/MenuUtils.h @@ -27,6 +27,6 @@ int32_t readAutobootOption(std::string &configPath); void writeAutobootOption(std::string &configPath, int32_t autobootOption); -int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput); +int32_t handleMenuScreen(std::string &configPath, int32_t autobootOptionInput, bool showHBL); nn::act::SlotNo handleAccountSelectScreen(const std::vector> &data); \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index 2a2bbc5..28689f6 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "BootUtils.h" @@ -37,10 +38,16 @@ int32_t main(int32_t argc, char **argv) { deinitLogging(); return 0; } - + bool showHBL = false; std::string configPath = "fs:/vol/external01/wiiu/autoboot.cfg"; if (argc >= 1) { configPath = std::string(argv[0]) + "/autoboot.cfg"; + + auto hblInstallerPath = std::string(argv[0]) + "/modules/setup/50_hbl_installer.rpx"; + struct stat st {}; + if (stat(hblInstallerPath.c_str(), &st) >= 0) { + showHBL = true; + } } int32_t bootSelection = readAutobootOption(configPath); @@ -48,8 +55,8 @@ int32_t main(int32_t argc, char **argv) { VPADStatus vpad{}; VPADRead(VPAD_CHAN_0, &vpad, 1, nullptr); - if ((bootSelection == -1) || (vpad.hold & VPAD_BUTTON_PLUS)) { - bootSelection = handleMenuScreen(configPath, bootSelection); + if ((bootSelection == -1) || (bootSelection == BOOT_OPTION_HOMEBREW_LAUNCHER && !showHBL) || (vpad.hold & VPAD_BUTTON_PLUS)) { + bootSelection = handleMenuScreen(configPath, bootSelection, showHBL); } if (bootSelection >= 0) { @@ -58,6 +65,10 @@ int32_t main(int32_t argc, char **argv) { bootWiiUMenu(); break; case BOOT_OPTION_HOMEBREW_LAUNCHER: + if (!showHBL) { + bootWiiUMenu(); + break; + } bootHomebrewLauncher(); break; case BOOT_OPTION_VWII_SYSTEM_MENU: