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);
auto buttomComboSafeMode = Input::eButtons::BUTTON_L | Input::eButtons::BUTTON_UP | Input::eButtons::BUTTON_MINUS;
if ((vpadInput.data.buttons_h & (buttomComboSafeMode)) == buttomComboSafeMode) {
DrawUtils::RenderScreen([] {
DrawUtils::RenderScreen([&vpadInput] {
DrawUtils::beginDraw();
DrawUtils::clear(COLOR_BACKGROUND_WARN);
DrawUtils::setFontColor(COLOR_WARNING);
@ -69,18 +69,24 @@ WUMS_INITIALIZE() {
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);
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);
// draw bottom bar
DrawUtils::drawRectFilled(8, SCREEN_HEIGHT - 24 - 8 - 4, SCREEN_WIDTH - 8 * 2, 3, COLOR_WHITE);
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::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!");
auto tobeIgnoredFilePath = getNonBaseAromaPluginFilenames(getPluginPath());

View File

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

View File

@ -45,6 +45,19 @@ public:
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 {
uint32_t buttons_h;
uint32_t buttons_d;

View File

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