Hide the option to boot into HBL when the 50_hbl_installer.rpx is missing for the environment

This commit is contained in:
Maschell 2022-08-25 18:13:18 +02:00
parent 0419bdd838
commit c2228569bd
3 changed files with 26 additions and 5 deletions

View File

@ -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 {

View File

@ -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<std::shared_ptr<AccountInfo>> &data);

View File

@ -6,6 +6,7 @@
#include <gx2/state.h>
#include <malloc.h>
#include <string>
#include <sys/stat.h>
#include <vpad/input.h>
#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: