From dc80552d5f108e0108926356da328a1dc34b71dc Mon Sep 17 00:00:00 2001 From: Maschell Date: Tue, 21 Mar 2023 12:44:02 +0100 Subject: [PATCH] Add option to hide all .rpx --- README.md | 3 +++ src/main.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4cea41e..2f71973 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,9 @@ Via the plugin config menu (press L, DPAD Down and Minus on the gamepad) you can - Hides all homebrew from the Wii U Menu except the `sd:/wiiu/apps/homebrew_launcher.wuhb` and `sd:/wiiu/apps/homebrew_launcher/homebrew_launcher.wuhb` - Prefer .wuhb over .rpx (Default is true) - Hides a `.rpx` from the Wii U Menu if a `.wuhb` with the same name exists in the same directory. + - Hide all .rpx (Default is false) + - Hides all `.rpx` from the Wii U Menu. + ## Save data redirection In order to preserve the order of homebrew apps even when you run the Wii U Menu without this plugin, this plugin will redirect the Wii U Menu save data to `sd:/wiiu/homebrew_on_menu_plugin`. When no save data is found on the sd card, the current save data is copied from the console, but after that it's never updated. diff --git a/src/main.cpp b/src/main.cpp index acc421b..fa0651b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,6 +64,7 @@ WUPS_USE_STORAGE("homebrew_on_menu"); // Use the storage API #define HIDE_HOMEBREW_STRING "hideHomebrew" #define PREFER_WUHB_OVER_RPX_STRING "hideRPXIfWUHBExists" +#define HIDE_ALL_RPX_STRING "hideAllRPX" #define HOMEBREW_APPS_DIRECTORY "fs:/vol/external01/wiiu/apps" #define HOMEBREW_LAUNCHER_FILENAME "homebrew_launcher.wuhb" @@ -74,8 +75,10 @@ WUPS_USE_STORAGE("homebrew_on_menu"); // Use the storage API bool gHideHomebrew = false; bool gPreferWUHBOverRPX = true; +bool gHideAllRPX = false; bool prevHideValue = false; bool prevPreferWUHBOverRPXValue = false; +bool prevHideAllRPX = false; INITIALIZE_PLUGIN() { memset((void *) ¤t_launched_title_info, 0, sizeof(current_launched_title_info)); @@ -133,8 +136,21 @@ INITIALIZE_PLUGIN() { } } + if ((storageRes = WUPS_GetBool(nullptr, HIDE_ALL_RPX_STRING, &gHideAllRPX)) == WUPS_STORAGE_ERROR_NOT_FOUND) { + // Add the value to the storage if it's missing. + storageRes = WUPS_StoreBool(nullptr, HIDE_ALL_RPX_STRING, gHideAllRPX); + if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to store bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); + } + } else { + if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to get bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); + } + } + prevHideValue = gHideHomebrew; prevPreferWUHBOverRPXValue = gPreferWUHBOverRPX; + prevHideAllRPX = gHideAllRPX; // Close storage WUPS_CloseStorage(); @@ -163,6 +179,17 @@ void preferWUHBOverRPXChanged(ConfigItemBoolean *item, bool newValue) { } } +void hideAllRPXChanged(ConfigItemBoolean *item, bool newValue) { + DEBUG_FUNCTION_LINE_VERBOSE("New value in gHideAllRPX: %d", newValue); + gHideAllRPX = newValue; + + // If the value has changed, we store it in the storage. + WUPSStorageError storageRes = WUPS_StoreBool(nullptr, HIDE_ALL_RPX_STRING, gHideAllRPX); + if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to store bool: %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); + } +} + WUPS_GET_CONFIG() { // We open the storage so we can persist the configuration the user did. WUPSStorageError storageRes; @@ -180,6 +207,7 @@ WUPS_GET_CONFIG() { WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, HIDE_HOMEBREW_STRING, "Hide all homebrew except Homebrew Launcher", gHideHomebrew, &hideHomebrewChanged); WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, PREFER_WUHB_OVER_RPX_STRING, "Prefer .wuhb over .rpx", gPreferWUHBOverRPX, &preferWUHBOverRPXChanged); + WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, HIDE_ALL_RPX_STRING, "Hide all .rpx", gHideAllRPX, &hideAllRPXChanged); return config; } @@ -195,7 +223,7 @@ WUPS_CONFIG_CLOSED() { DEBUG_FUNCTION_LINE_ERR("Failed to close storage %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); } - if (prevHideValue != gHideHomebrew || prevPreferWUHBOverRPXValue != gPreferWUHBOverRPX) { + if (prevHideValue != gHideHomebrew || prevPreferWUHBOverRPXValue != gPreferWUHBOverRPX || prevHideAllRPX != gHideAllRPX) { if (!sTitleRebooting) { _SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), nullptr); sTitleRebooting = true; @@ -203,6 +231,7 @@ WUPS_CONFIG_CLOSED() { } prevHideValue = gHideHomebrew; prevPreferWUHBOverRPXValue = gPreferWUHBOverRPX; + prevHideAllRPX = gHideAllRPX; } void Cleanup() { @@ -357,7 +386,13 @@ void readCustomTitlesFromSD() { DirList dirList(HOMEBREW_APPS_DIRECTORY, ".rpx,.wuhb", DirList::Files | DirList::CheckSubfolders, 1); dirList.SortList(); - if (gPreferWUHBOverRPX) { + if (gHideAllRPX) { + for (int i = 0; i < dirList.GetFilecount(); i++) { + if (dirList.GetFilepath(i) != nullptr && !std::string_view(dirList.GetFilepath(i)).ends_with(".rpx")) { + listOfExecutables.emplace_back(dirList.GetFilepath(i)); + } + } + } else if (gPreferWUHBOverRPX) { // map<[path without extension], vector<[extension]>> std::map> pathWithoutExtensionMap; for (int i = 0; i < dirList.GetFilecount(); i++) {