mirror of
https://github.com/wiiu-env/homebrew_on_menu_plugin.git
synced 2024-11-27 20:54:16 +01:00
WUPS 0.8.0 support
This commit is contained in:
parent
9b96d26b5b
commit
11bd473803
@ -1,6 +1,6 @@
|
|||||||
FROM ghcr.io/wiiu-env/devkitppc:20230621
|
FROM ghcr.io/wiiu-env/devkitppc:20231112
|
||||||
|
|
||||||
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230719 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:0.8.0-dev-20231221-ca17105 /artifacts $DEVKITPRO
|
||||||
COPY --from=ghcr.io/wiiu-env/librpxloader:20230621 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/librpxloader:20230621 /artifacts $DEVKITPRO
|
||||||
COPY --from=ghcr.io/wiiu-env/libsdutils:20230621 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/libsdutils:20230621 /artifacts $DEVKITPRO
|
||||||
COPY --from=ghcr.io/wiiu-env/libwuhbutils:20230621 /artifacts $DEVKITPRO
|
COPY --from=ghcr.io/wiiu-env/libwuhbutils:20230621 /artifacts $DEVKITPRO
|
||||||
|
2
Makefile
2
Makefile
@ -36,7 +36,7 @@ CFLAGS := -Wall -O2 -ffunction-sections \
|
|||||||
|
|
||||||
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__
|
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__
|
||||||
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-exceptions -fno-rtti -std=c++20
|
CXXFLAGS := $(CFLAGS) -std=c++20
|
||||||
|
|
||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH)
|
||||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) $(WUPSSPECS)
|
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) $(WUPSSPECS)
|
||||||
|
130
src/main.cpp
130
src/main.cpp
@ -79,9 +79,14 @@ WUPS_USE_STORAGE("homebrew_on_menu"); // Use the storage API
|
|||||||
#define HOMEBREW_LAUNCHER_PATH HOMEBREW_APPS_DIRECTORY "/" HOMEBREW_LAUNCHER_FILENAME
|
#define HOMEBREW_LAUNCHER_PATH HOMEBREW_APPS_DIRECTORY "/" HOMEBREW_LAUNCHER_FILENAME
|
||||||
#define HOMEBREW_LAUNCHER_PATH2 HOMEBREW_APPS_DIRECTORY "/" HOMEBREW_LAUNCHER_OPTIONAL_DIRECTORY "/" HOMEBREW_LAUNCHER_FILENAME
|
#define HOMEBREW_LAUNCHER_PATH2 HOMEBREW_APPS_DIRECTORY "/" HOMEBREW_LAUNCHER_OPTIONAL_DIRECTORY "/" HOMEBREW_LAUNCHER_FILENAME
|
||||||
|
|
||||||
bool gHideHomebrew = false;
|
|
||||||
bool gPreferWUHBOverRPX = true;
|
#define DEFAULT_HIDE_HOMEBREW_VALUE false
|
||||||
bool gHideAllRPX = false;
|
#define DEFAULT_PREFER_WUHB_OVER_RPX_VALUE true
|
||||||
|
#define DEFAULT_HIDE_ALL_RPX_VALUE false
|
||||||
|
bool gHideHomebrew = DEFAULT_HIDE_HOMEBREW_VALUE;
|
||||||
|
bool gPreferWUHBOverRPX = DEFAULT_PREFER_WUHB_OVER_RPX_VALUE;
|
||||||
|
bool gHideAllRPX = DEFAULT_HIDE_ALL_RPX_VALUE;
|
||||||
|
|
||||||
bool prevHideValue = false;
|
bool prevHideValue = false;
|
||||||
bool prevPreferWUHBOverRPXValue = false;
|
bool prevPreferWUHBOverRPXValue = false;
|
||||||
bool prevHideAllRPX = false;
|
bool prevHideAllRPX = false;
|
||||||
@ -90,6 +95,9 @@ bool gHomebrewLauncherExists = false;
|
|||||||
|
|
||||||
std::vector<std::string> gIgnorePatterns;
|
std::vector<std::string> gIgnorePatterns;
|
||||||
|
|
||||||
|
WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle);
|
||||||
|
void ConfigMenuClosedCallback();
|
||||||
|
|
||||||
INITIALIZE_PLUGIN() {
|
INITIALIZE_PLUGIN() {
|
||||||
memset((void *) ¤t_launched_title_info, 0, sizeof(current_launched_title_info));
|
memset((void *) ¤t_launched_title_info, 0, sizeof(current_launched_title_info));
|
||||||
memset((void *) &gLaunchXML, 0, sizeof(gLaunchXML));
|
memset((void *) &gLaunchXML, 0, sizeof(gLaunchXML));
|
||||||
@ -129,55 +137,36 @@ INITIALIZE_PLUGIN() {
|
|||||||
OSFatal("Homebrew on Menu Plugin: Failed to init NotificationModule.");
|
OSFatal("Homebrew on Menu Plugin: Failed to init NotificationModule.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open storage to read values
|
WUPSConfigAPIOptionsV1 configOptions = {.name = "Homebrew On Menu Plugin"};
|
||||||
WUPSStorageError storageRes = WUPS_OpenStorage();
|
if (WUPSConfigAPI_Init(configOptions, ConfigMenuOpenedCallback, ConfigMenuClosedCallback) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||||
if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {
|
DEBUG_FUNCTION_LINE_ERR("Failed to init config api");
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to open storage %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes);
|
|
||||||
} else {
|
|
||||||
// Try to get value from storage
|
|
||||||
if ((storageRes = WUPS_GetBool(nullptr, HIDE_HOMEBREW_STRING, &gHideHomebrew)) == WUPS_STORAGE_ERROR_NOT_FOUND) {
|
|
||||||
// Add the value to the storage if it's missing.
|
|
||||||
storageRes = WUPS_StoreBool(nullptr, HIDE_HOMEBREW_STRING, gHideHomebrew);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((storageRes = WUPS_GetBool(nullptr, PREFER_WUHB_OVER_RPX_STRING, &gPreferWUHBOverRPX)) == WUPS_STORAGE_ERROR_NOT_FOUND) {
|
WUPSStorageError storageError;
|
||||||
// Add the value to the storage if it's missing.
|
storageError = WUPSStorageAPI::GetOrStoreDefault(HIDE_HOMEBREW_STRING, gHideHomebrew, DEFAULT_HIDE_HOMEBREW_VALUE);
|
||||||
storageRes = WUPS_StoreBool(nullptr, PREFER_WUHB_OVER_RPX_STRING, gPreferWUHBOverRPX);
|
if (storageError != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or set default bool: %s", WUPSStorageAPI::GetStatusStr(storageError).data());
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((storageRes = WUPS_GetBool(nullptr, HIDE_ALL_RPX_STRING, &gHideAllRPX)) == WUPS_STORAGE_ERROR_NOT_FOUND) {
|
storageError = WUPSStorageAPI::GetOrStoreDefault(PREFER_WUHB_OVER_RPX_STRING, gPreferWUHBOverRPX, DEFAULT_PREFER_WUHB_OVER_RPX_VALUE);
|
||||||
// Add the value to the storage if it's missing.
|
if (storageError != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
storageRes = WUPS_StoreBool(nullptr, HIDE_ALL_RPX_STRING, gHideAllRPX);
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or set default bool: %s", WUPSStorageAPI::GetStatusStr(storageError).data());
|
||||||
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) {
|
storageError = WUPSStorageAPI::GetOrStoreDefault(HIDE_ALL_RPX_STRING, gHideAllRPX, DEFAULT_HIDE_ALL_RPX_VALUE);
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to get bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes);
|
if (storageError != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or set default bool: %s", WUPSStorageAPI::GetStatusStr(storageError).data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// save storage
|
||||||
|
storageError = WUPSStorageAPI::SaveStorage();
|
||||||
|
if (storageError != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to save storage: %s", WUPSStorageAPI::GetStatusStr(storageError).data());
|
||||||
}
|
}
|
||||||
|
|
||||||
prevHideValue = gHideHomebrew;
|
prevHideValue = gHideHomebrew;
|
||||||
prevPreferWUHBOverRPXValue = gPreferWUHBOverRPX;
|
prevPreferWUHBOverRPXValue = gPreferWUHBOverRPX;
|
||||||
prevHideAllRPX = gHideAllRPX;
|
prevHideAllRPX = gHideAllRPX;
|
||||||
|
|
||||||
// Close storage
|
|
||||||
WUPS_CloseStorage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hideHomebrewChanged(ConfigItemBoolean *item, bool newValue) {
|
void hideHomebrewChanged(ConfigItemBoolean *item, bool newValue) {
|
||||||
@ -185,9 +174,9 @@ void hideHomebrewChanged(ConfigItemBoolean *item, bool newValue) {
|
|||||||
gHideHomebrew = newValue;
|
gHideHomebrew = newValue;
|
||||||
|
|
||||||
// If the value has changed, we store it in the storage.
|
// If the value has changed, we store it in the storage.
|
||||||
WUPSStorageError storageRes = WUPS_StoreBool(nullptr, HIDE_HOMEBREW_STRING, gHideHomebrew);
|
WUPSStorageError storageRes = WUPSStorageAPI::Store(HIDE_HOMEBREW_STRING, gHideHomebrew);
|
||||||
if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {
|
if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to store bool: %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes);
|
DEBUG_FUNCTION_LINE_ERR("Failed to store bool: %s", WUPSStorageAPI::GetStatusStr(storageRes).data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,9 +185,9 @@ void preferWUHBOverRPXChanged(ConfigItemBoolean *item, bool newValue) {
|
|||||||
gPreferWUHBOverRPX = newValue;
|
gPreferWUHBOverRPX = newValue;
|
||||||
|
|
||||||
// If the value has changed, we store it in the storage.
|
// If the value has changed, we store it in the storage.
|
||||||
WUPSStorageError storageRes = WUPS_StoreBool(nullptr, PREFER_WUHB_OVER_RPX_STRING, gPreferWUHBOverRPX);
|
WUPSStorageError storageRes = WUPSStorageAPI::Store(PREFER_WUHB_OVER_RPX_STRING, gPreferWUHBOverRPX);
|
||||||
if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {
|
if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to store bool: %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes);
|
DEBUG_FUNCTION_LINE_ERR("Failed to store bool: %s", WUPSStorageAPI::GetStatusStr(storageRes).data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,46 +196,49 @@ void hideAllRPXChanged(ConfigItemBoolean *item, bool newValue) {
|
|||||||
gHideAllRPX = newValue;
|
gHideAllRPX = newValue;
|
||||||
|
|
||||||
// If the value has changed, we store it in the storage.
|
// If the value has changed, we store it in the storage.
|
||||||
WUPSStorageError storageRes = WUPS_StoreBool(nullptr, HIDE_ALL_RPX_STRING, gHideAllRPX);
|
WUPSStorageError storageRes = WUPSStorageAPI::Store(HIDE_ALL_RPX_STRING, gHideAllRPX);
|
||||||
if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {
|
if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to store bool: %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes);
|
DEBUG_FUNCTION_LINE_ERR("Failed to store bool: %s", WUPSStorageAPI::GetStatusStr(storageRes).data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WUPS_GET_CONFIG() {
|
WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle) {
|
||||||
// We open the storage so we can persist the configuration the user did.
|
try {
|
||||||
WUPSStorageError storageRes;
|
WUPSConfigCategory root = WUPSConfigCategory(rootHandle);
|
||||||
DEBUG_FUNCTION_LINE_ERR("In WUPS_GET_CONFIG");
|
auto features = WUPSConfigCategory::Create("Features");
|
||||||
if ((storageRes = WUPS_OpenStorage()) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to open storage %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
WUPSConfigHandle config;
|
|
||||||
WUPSConfig_CreateHandled(&config, "Homebrew on Menu");
|
|
||||||
|
|
||||||
WUPSConfigCategoryHandle cat;
|
features.add(WUPSConfigItemBoolean::Create(HIDE_HOMEBREW_STRING,
|
||||||
WUPSConfig_AddCategoryByNameHandled(config, "Features", &cat);
|
|
||||||
|
|
||||||
WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, HIDE_HOMEBREW_STRING,
|
|
||||||
gHomebrewLauncherExists ? "Hide all homebrew except Homebrew Launcher" : "Hide all homebrew",
|
gHomebrewLauncherExists ? "Hide all homebrew except Homebrew Launcher" : "Hide all homebrew",
|
||||||
gHideHomebrew, &hideHomebrewChanged);
|
DEFAULT_HIDE_HOMEBREW_VALUE, gHideHomebrew,
|
||||||
|
&hideHomebrewChanged));
|
||||||
|
|
||||||
WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, PREFER_WUHB_OVER_RPX_STRING, "Prefer .wuhb over .rpx", gPreferWUHBOverRPX, &preferWUHBOverRPXChanged);
|
features.add(WUPSConfigItemBoolean::Create(PREFER_WUHB_OVER_RPX_STRING,
|
||||||
WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, HIDE_ALL_RPX_STRING, "Hide all .rpx", gHideAllRPX, &hideAllRPXChanged);
|
"Prefer .wuhb over .rpx",
|
||||||
|
DEFAULT_PREFER_WUHB_OVER_RPX_VALUE, gPreferWUHBOverRPX,
|
||||||
|
&preferWUHBOverRPXChanged));
|
||||||
|
|
||||||
return config;
|
features.add(WUPSConfigItemBoolean::Create(HIDE_ALL_RPX_STRING,
|
||||||
|
"Hide all .rpx",
|
||||||
|
DEFAULT_HIDE_ALL_RPX_VALUE, gHideAllRPX,
|
||||||
|
&hideAllRPXChanged));
|
||||||
|
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
OSReport("Exception T_T : %s\n", e.what());
|
||||||
|
return WUPSCONFIG_API_CALLBACK_RESULT_ERROR;
|
||||||
|
}
|
||||||
|
return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sSDUtilsInitDone = false;
|
bool sSDUtilsInitDone = false;
|
||||||
bool sSDIsMounted = false;
|
bool sSDIsMounted = false;
|
||||||
bool sTitleRebooting = false;
|
bool sTitleRebooting = false;
|
||||||
|
|
||||||
WUPS_CONFIG_CLOSED() {
|
void ConfigMenuClosedCallback() {
|
||||||
// Save all changes
|
// Save all changes
|
||||||
WUPSStorageError storageRes;
|
auto saveErr = WUPSStorageAPI::SaveStorage();
|
||||||
if ((storageRes = WUPS_CloseStorage()) != WUPS_STORAGE_ERROR_SUCCESS) {
|
if (saveErr != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to close storage %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes);
|
DEBUG_FUNCTION_LINE_ERR("Failed to save storage: %s", WUPSStorageAPI::GetStatusStr(saveErr).data());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prevHideValue != gHideHomebrew || prevPreferWUHBOverRPXValue != gPreferWUHBOverRPX || prevHideAllRPX != gHideAllRPX) {
|
if (prevHideValue != gHideHomebrew || prevPreferWUHBOverRPXValue != gPreferWUHBOverRPX || prevHideAllRPX != gHideAllRPX) {
|
||||||
|
Loading…
Reference in New Issue
Block a user