More fixes and changes

This commit is contained in:
Maschell 2024-08-10 09:42:13 +02:00
parent de15764367
commit 9052ecb2b2
5 changed files with 43 additions and 21 deletions

View File

@ -50,7 +50,7 @@ WUMS_INITIALIZE() {
vpadInput.update(1280, 720); vpadInput.update(1280, 720);
auto buttomComboSafeMode = Input::eButtons::BUTTON_L | Input::eButtons::BUTTON_UP | Input::eButtons::BUTTON_MINUS; auto buttomComboSafeMode = Input::eButtons::BUTTON_L | Input::eButtons::BUTTON_UP | Input::eButtons::BUTTON_MINUS;
if ((vpadInput.data.buttons_h & (buttomComboSafeMode)) == buttomComboSafeMode) { if ((vpadInput.data.buttons_h & (buttomComboSafeMode)) == buttomComboSafeMode) {
DrawUtils::RenderScreen([] { DrawUtils::RenderScreen([&vpadInput] {
DrawUtils::beginDraw(); DrawUtils::beginDraw();
DrawUtils::clear(COLOR_BACKGROUND_WARN); DrawUtils::clear(COLOR_BACKGROUND_WARN);
DrawUtils::setFontColor(COLOR_WARNING); DrawUtils::setFontColor(COLOR_WARNING);
@ -69,18 +69,24 @@ WUMS_INITIALIZE() {
message = "To enable them again, open the plugin config menu (\ue004 + \ue07a + \ue046)."; message = "To enable them again, open the plugin config menu (\ue004 + \ue07a + \ue046).";
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(message) / 2, SCREEN_HEIGHT / 2 + 24, message, true); DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(message) / 2, SCREEN_HEIGHT / 2 + 24, message, true);
message = "Press then \ue002 to manage active plugins"; message = "Then press \ue002 to manage active plugins";
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(message) / 2, SCREEN_HEIGHT / 2 + 48, message, true); DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(message) / 2, SCREEN_HEIGHT / 2 + 48, message, true);
// draw bottom bar // draw bottom bar
DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_WHITE); DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_WHITE);
DrawUtils::setFontSize(18); DrawUtils::setFontSize(18);
const char *exitHints = "The console will continue to boot in 10 seconds."; const char *exitHints = "Continuing in 10 seconds.";
DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(exitHints) / 2, SCREEN_HEIGHT - 8, exitHints, true); DrawUtils::print(SCREEN_WIDTH / 2 + DrawUtils::getTextWidth(exitHints) / 2, SCREEN_HEIGHT - 8, exitHints, true);
DrawUtils::endDraw(); DrawUtils::endDraw();
std::this_thread::sleep_for(10s); for (int i = 0; i < 10000 / 16; i++) {
vpadInput.update(1280, 720);
if ((vpadInput.data.buttons_d & (ANY_BUTTON_MASK))) {
break;
}
std::this_thread::sleep_for(16ms);
}
}); });
DEBUG_FUNCTION_LINE_INFO("Safe Mode activated!"); DEBUG_FUNCTION_LINE_INFO("Safe Mode activated!");
auto tobeIgnoredFilePath = getNonBaseAromaPluginFilenames(getPluginPath()); auto tobeIgnoredFilePath = getNonBaseAromaPluginFilenames(getPluginPath());

View File

@ -211,7 +211,7 @@ void ConfigRenderer::RenderStateMain() const {
DrawUtils::setFontSize(18); DrawUtils::setFontSize(18);
DrawUtils::print(16, SCREEN_HEIGHT - 10, "\ue07d Navigate "); DrawUtils::print(16, SCREEN_HEIGHT - 10, "\ue07d Navigate ");
if (mSetActivePluginsMode) { if (mSetActivePluginsMode) {
DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, "\ue000 Activate | \uE045 Apply", true); DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, "\ue000 Activate | \uE045 Apply", true);
} else if (totalElementSize > 0) { } else if (totalElementSize > 0) {
DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, "\ue000 Select | \uE002 Manage plugins", true); DrawUtils::print(SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, "\ue000 Select | \uE002 Manage plugins", true);
} }

View File

@ -161,7 +161,8 @@ void ConfigUtils::displayMenu() {
OSTime startTime; OSTime startTime;
bool skipFirstInput = true; bool skipFirstInput = true;
gOnlyAcceptFromThread = OSGetCurrentThread(); gOnlyAcceptFromThread = OSGetCurrentThread();
ConfigSubState subStateReturnValue = SUB_STATE_ERROR;
while (true) { while (true) {
startTime = OSGetTime(); startTime = OSGetTime();
if (gConfigMenuShouldClose) { if (gConfigMenuShouldClose) {
@ -201,8 +202,8 @@ void ConfigUtils::displayMenu() {
complexData.kpad.data[i] = wpadInputs[i].kpad; complexData.kpad.data[i] = wpadInputs[i].kpad;
} }
auto subState = renderer.Update(baseInput, simpleData, complexData); subStateReturnValue = renderer.Update(baseInput, simpleData, complexData);
if (subState != SUB_STATE_RUNNING) { if (subStateReturnValue != SUB_STATE_RUNNING) {
break; break;
} }
if (renderer.NeedsRedraw() || baseInput.data.buttons_d || baseInput.data.buttons_r) { if (renderer.NeedsRedraw() || baseInput.data.buttons_d || baseInput.data.buttons_r) {
@ -220,7 +221,7 @@ void ConfigUtils::displayMenu() {
std::vector<PluginLoadWrapper> newActivePluginsList; std::vector<PluginLoadWrapper> newActivePluginsList;
if (renderer.GetActivePluginsIfChanged(newActivePluginsList)) { if (subStateReturnValue == SUB_STATE_RETURN_WITH_PLUGIN_RELOAD && renderer.GetActivePluginsIfChanged(newActivePluginsList)) {
startTime = OSGetTime(); startTime = OSGetTime();
renderBasicScreen("Applying changes, app will now restart..."); renderBasicScreen("Applying changes, app will now restart...");
@ -230,9 +231,7 @@ void ConfigUtils::displayMenu() {
for (const auto &cur : newActivePluginsList) { for (const auto &cur : newActivePluginsList) {
if (!cur.isLoadAndLink()) { if (!cur.isLoadAndLink()) {
auto &source = cur.getPluginData()->getSource(); auto &source = cur.getPluginData()->getSource();
// TODO: Make sure to only use plugins from the actual plugin directory? if (source.starts_with(getPluginPath()) && source.ends_with(".wps")) {
// atm nothing (to my knowledge) is using the WUPS API to load any plugin from a path though
if (source.ends_with(".wps")) {
std::size_t found = source.find_last_of("/\\"); std::size_t found = source.find_last_of("/\\");
std::string filename = source.substr(found + 1); std::string filename = source.substr(found + 1);
newInactivePluginsList.push_back(filename); newInactivePluginsList.push_back(filename);
@ -241,7 +240,9 @@ void ConfigUtils::displayMenu() {
} }
gLoadOnNextLaunch = newActivePluginsList; gLoadOnNextLaunch = newActivePluginsList;
WUPSBackendSettings::SetInactivePluginFilenames(newInactivePluginsList); WUPSBackendSettings::SetInactivePluginFilenames(newInactivePluginsList);
WUPSBackendSettings::SaveSettings(); if (!WUPSBackendSettings::SaveSettings()) {
DEBUG_FUNCTION_LINE_WARN("Failed to save WUPSBackendSettings");
}
_SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), nullptr); _SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), nullptr);
// Make sure to wait at least 2 seconds so user can read the screen and // Make sure to wait at least 2 seconds so user can read the screen and
@ -252,18 +253,19 @@ void ConfigUtils::displayMenu() {
} }
} else { } else {
renderBasicScreen("Saving configs..."); renderBasicScreen("Saving configs...");
for (const auto &plugin : gLoadedPlugins) { }
const auto configData = plugin.getConfigData(); for (const auto &plugin : gLoadedPlugins) {
if (configData) { const auto configData = plugin.getConfigData();
if (configData->CallMenuClosedCallback() == WUPSCONFIG_API_RESULT_MISSING_CALLBACK) { if (configData) {
DEBUG_FUNCTION_LINE_WARN("CallMenuClosedCallback is missing for %s", plugin.getMetaInformation().getName().c_str()); if (configData->CallMenuClosedCallback() == WUPSCONFIG_API_RESULT_MISSING_CALLBACK) {
} DEBUG_FUNCTION_LINE_WARN("CallMenuClosedCallback is missing for %s", plugin.getMetaInformation().getName().c_str());
} else {
CallHook(plugin, WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED);
} }
} else {
CallHook(plugin, WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED);
} }
} }
WUPSConfigAPIBackend::Intern::CleanAllHandles(); WUPSConfigAPIBackend::Intern::CleanAllHandles();
// we want wait at least 300ms to avoid leaking inputs from the config menu to the application // we want wait at least 300ms to avoid leaking inputs from the config menu to the application

View File

@ -45,6 +45,19 @@ public:
STICK_L_DOWN = 0x08000000 STICK_L_DOWN = 0x08000000
}; };
#define ANY_BUTTON_MASK (Input::eButtons::BUTTON_L | \
Input::eButtons::BUTTON_R | \
Input::eButtons::BUTTON_PLUS | \
Input::eButtons::BUTTON_MINUS | \
Input::eButtons::BUTTON_A | \
Input::eButtons::BUTTON_B | \
Input::eButtons::BUTTON_X | \
Input::eButtons::BUTTON_Y | \
Input::eButtons::BUTTON_DOWN | \
Input::eButtons::BUTTON_LEFT | \
Input::eButtons::BUTTON_RIGHT | \
Input::eButtons::BUTTON_UP)
typedef struct { typedef struct {
uint32_t buttons_h; uint32_t buttons_h;
uint32_t buttons_d; uint32_t buttons_d;

View File

@ -34,6 +34,7 @@ std::string getEnvironmentPath() {
sEnvironmentPath = environmentPath; sEnvironmentPath = environmentPath;
return sEnvironmentPath; return sEnvironmentPath;
} }
std::string getPluginPath() { std::string getPluginPath() {
if (!sPluginPath.empty()) { if (!sPluginPath.empty()) {
return sPluginPath; return sPluginPath;