mirror of
https://github.com/wiiu-env/EnvironmentLoader.git
synced 2025-02-21 15:17:12 +01:00
Add warning when no environment was found
This commit is contained in:
parent
9d95d6ad29
commit
66d282afcc
@ -3,6 +3,7 @@
|
|||||||
#include <elfio/elfio.hpp>
|
#include <elfio/elfio.hpp>
|
||||||
#include <proc_ui/procui.h>
|
#include <proc_ui/procui.h>
|
||||||
#include <sysapp/launch.h>
|
#include <sysapp/launch.h>
|
||||||
|
#include <sysapp/title.h>
|
||||||
#include <coreinit/foreground.h>
|
#include <coreinit/foreground.h>
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
#include <coreinit/ios.h>
|
#include <coreinit/ios.h>
|
||||||
@ -13,6 +14,7 @@
|
|||||||
#include <whb/log_module.h>
|
#include <whb/log_module.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <coreinit/dynload.h>
|
#include <coreinit/dynload.h>
|
||||||
|
#include <coreinit/title.h>
|
||||||
#include <coreinit/screen.h>
|
#include <coreinit/screen.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
@ -111,6 +113,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
auto gModuleData = (module_information_t *) (textSectionStart - sizeof(module_information_t));
|
auto gModuleData = (module_information_t *) (textSectionStart - sizeof(module_information_t));
|
||||||
|
|
||||||
|
bool noEnvironmentsFound = false;
|
||||||
|
|
||||||
std::string environment_path = std::string(environmentPath);
|
std::string environment_path = std::string(environmentPath);
|
||||||
if (strncmp(environmentPath, "fs:/vol/external01/wiiu/environments/", strlen("fs:/vol/external01/wiiu/environments/")) != 0) {
|
if (strncmp(environmentPath, "fs:/vol/external01/wiiu/environments/", strlen("fs:/vol/external01/wiiu/environments/")) != 0) {
|
||||||
DirList environmentDirs("fs:/vol/external01/wiiu/environments/", nullptr, DirList::Dirs, 1);
|
DirList environmentDirs("fs:/vol/external01/wiiu/environments/", nullptr, DirList::Dirs, 1);
|
||||||
@ -150,15 +154,19 @@ int main(int argc, char **argv) {
|
|||||||
if (forceMenu || (btn & VPAD_BUTTON_X) == VPAD_BUTTON_X) {
|
if (forceMenu || (btn & VPAD_BUTTON_X) == VPAD_BUTTON_X) {
|
||||||
DEBUG_FUNCTION_LINE("Open menu!");
|
DEBUG_FUNCTION_LINE("Open menu!");
|
||||||
environment_path = EnvironmentSelectionScreen(environmentPaths, autobootIndex);
|
environment_path = EnvironmentSelectionScreen(environmentPaths, autobootIndex);
|
||||||
|
if (environmentPaths.empty()) {
|
||||||
|
noEnvironmentsFound = true;
|
||||||
|
} else {
|
||||||
DEBUG_FUNCTION_LINE("Selected %s", environment_path.c_str());
|
DEBUG_FUNCTION_LINE("Selected %s", environment_path.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
RevertMainHook();
|
||||||
|
|
||||||
|
if (!noEnvironmentsFound) {
|
||||||
DirList setupModules(environment_path + "/modules/setup", ".rpx", DirList::Files, 1);
|
DirList setupModules(environment_path + "/modules/setup", ".rpx", DirList::Files, 1);
|
||||||
setupModules.SortList();
|
setupModules.SortList();
|
||||||
|
|
||||||
RevertMainHook();
|
|
||||||
|
|
||||||
for (int i = 0; i < setupModules.GetFilecount(); i++) {
|
for (int i = 0; i < setupModules.GetFilecount(); i++) {
|
||||||
uint32_t destination_address_end = ((uint32_t) gModuleData) & 0xFFFF0000;
|
uint32_t destination_address_end = ((uint32_t) gModuleData) & 0xFFFF0000;
|
||||||
memset((void *) gModuleData, 0, sizeof(module_information_t));
|
memset((void *) gModuleData, 0, sizeof(module_information_t));
|
||||||
@ -186,6 +194,22 @@ int main(int argc, char **argv) {
|
|||||||
((int (*)(int, char **)) moduleData.value()->getEntrypoint())(1, arr);
|
((int (*)(int, char **)) moduleData.value()->getEntrypoint())(1, arr);
|
||||||
DEBUG_FUNCTION_LINE("Back from module");
|
DEBUG_FUNCTION_LINE("Back from module");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE("Return to Wii U Menu");
|
||||||
|
ProcUIInit(OSSavesDone_ReadyToRelease);
|
||||||
|
for (int i = 0; i < argc; i++) {
|
||||||
|
if(strcmp(argv[i], "void forceDefaultTitleIDToWiiUMenu(void)") == 0){
|
||||||
|
if((i + 1) < argc){
|
||||||
|
i++;
|
||||||
|
DEBUG_FUNCTION_LINE("call forceDefaultTitleIDToWiiUMenu");
|
||||||
|
auto forceDefaultTitleIDToWiiUMenu = (void (*)()) argv[i];
|
||||||
|
forceDefaultTitleIDToWiiUMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DEBUG_FUNCTION_LINE("Launch menu");
|
||||||
|
SYSLaunchMenu();
|
||||||
|
}
|
||||||
|
|
||||||
ProcUIInit(OSSavesDone_ReadyToRelease);
|
ProcUIInit(OSSavesDone_ReadyToRelease);
|
||||||
|
|
||||||
@ -201,6 +225,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
#define COLOR_WHITE Color(0xffffffff)
|
#define COLOR_WHITE Color(0xffffffff)
|
||||||
#define COLOR_BLACK Color(0, 0, 0, 255)
|
#define COLOR_BLACK Color(0, 0, 0, 255)
|
||||||
|
#define COLOR_RED Color(237, 28, 36, 255)
|
||||||
#define COLOR_BACKGROUND Color(0, 40, 100, 255)
|
#define COLOR_BACKGROUND Color(0, 40, 100, 255)
|
||||||
#define COLOR_TEXT COLOR_WHITE
|
#define COLOR_TEXT COLOR_WHITE
|
||||||
#define COLOR_TEXT2 Color(0xB3ffffff)
|
#define COLOR_TEXT2 Color(0xB3ffffff)
|
||||||
@ -264,6 +289,7 @@ std::string EnvironmentSelectionScreen(const std::map<std::string, std::string>
|
|||||||
// draw buttons
|
// draw buttons
|
||||||
uint32_t index = 8 + 24 + 8 + 4;
|
uint32_t index = 8 + 24 + 8 + 4;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
if (!payloads.empty()) {
|
||||||
for (auto const&[key, val]: payloads) {
|
for (auto const&[key, val]: payloads) {
|
||||||
if (i == selected) {
|
if (i == selected) {
|
||||||
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16 * 2, 44, 4, COLOR_BORDER_HIGHLIGHTED);
|
DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16 * 2, 44, 4, COLOR_BORDER_HIGHLIGHTED);
|
||||||
@ -277,6 +303,12 @@ std::string EnvironmentSelectionScreen(const std::map<std::string, std::string>
|
|||||||
index += 42 + 8;
|
index += 42 + 8;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
DrawUtils::setFontSize(24);
|
||||||
|
DrawUtils::setFontColor(COLOR_RED);
|
||||||
|
const char *noEnvironmentsWarning = "No valid environments found. Press \ue000 to launch the Wii U Menu";
|
||||||
|
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(noEnvironmentsWarning) / 2, SCREEN_HEIGHT / 2, noEnvironmentsWarning, true);
|
||||||
|
}
|
||||||
|
|
||||||
DrawUtils::setFontColor(COLOR_TEXT);
|
DrawUtils::setFontColor(COLOR_TEXT);
|
||||||
|
|
||||||
@ -305,7 +337,11 @@ std::string EnvironmentSelectionScreen(const std::map<std::string, std::string>
|
|||||||
|
|
||||||
DrawUtils::deinitFont();
|
DrawUtils::deinitFont();
|
||||||
|
|
||||||
|
if (OSGetTitleID() == _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_MII_MAKER)) {
|
||||||
|
// When we're in the Mii Maker "OSScreenShutdown" will cause a black screen.
|
||||||
|
} else {
|
||||||
OSScreenShutdown();
|
OSScreenShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
free(screenBuffer);
|
free(screenBuffer);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user