mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-09-08 03:48:10 -05:00
Add initial support for persisting a lsit inactive plugins
This commit is contained in:
@@ -23,7 +23,8 @@ struct StoredBuffer {
|
||||
};
|
||||
|
||||
enum ConfigSubState {
|
||||
SUB_STATE_RUNNING = 0,
|
||||
SUB_STATE_RETURN = 1,
|
||||
SUB_STATE_ERROR = 2,
|
||||
SUB_STATE_RUNNING = 0,
|
||||
SUB_STATE_RETURN = 1,
|
||||
SUB_STATE_RETURN_WITH_PLUGIN_RELOAD = 1,
|
||||
SUB_STATE_ERROR = 2,
|
||||
};
|
||||
@@ -90,18 +90,16 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
|
||||
mCursorPos--;
|
||||
} else if (input.data.buttons_d & Input::eButtons::BUTTON_PLUS) {
|
||||
if (mSetActivePluginsMode) {
|
||||
if (mActivePluginsDirty) {
|
||||
for (const auto &cur : mConfigs) {
|
||||
gLoadOnNextLaunch.emplace_back(cur.getConfigInformation().pluginData, cur.isActivePlugin());
|
||||
}
|
||||
_SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), nullptr);
|
||||
}
|
||||
mNeedRedraw = true;
|
||||
mCategoryRenderer.reset();
|
||||
return SUB_STATE_RETURN;
|
||||
return SUB_STATE_RETURN_WITH_PLUGIN_RELOAD;
|
||||
}
|
||||
} else if (input.data.buttons_d & Input::eButtons::BUTTON_X) {
|
||||
mSetActivePluginsMode = !mSetActivePluginsMode;
|
||||
if (!mSetActivePluginsMode) {
|
||||
mSetActivePluginsMode = true;
|
||||
mNeedRedraw = true;
|
||||
return SUB_STATE_RUNNING;
|
||||
}
|
||||
} else if (input.data.buttons_d & Input::eButtons::BUTTON_A) {
|
||||
if (mSetActivePluginsMode) {
|
||||
mActivePluginsDirty = true;
|
||||
@@ -123,7 +121,7 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
|
||||
for (auto &cur : mConfigs) {
|
||||
cur.resetIsActivePlugin();
|
||||
}
|
||||
mNeedRedraw = true;
|
||||
mNeedRedraw = true;
|
||||
mSetActivePluginsMode = false;
|
||||
return SUB_STATE_RUNNING;
|
||||
} else {
|
||||
@@ -252,6 +250,18 @@ void ConfigRenderer::CallOnCloseCallback(const GeneralConfigInformation &info, c
|
||||
}
|
||||
}
|
||||
|
||||
bool ConfigRenderer::GetActivePluginsIfChanged(std::vector<PluginLoadWrapper> &result) {
|
||||
if (mActivePluginsDirty) {
|
||||
std::vector<std::string> inactive_plugins;
|
||||
result.clear();
|
||||
for (const auto &cur : mConfigs) {
|
||||
result.emplace_back(cur.getConfigInformation().pluginData, cur.isActivePlugin());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ConfigRenderer::CallOnCloseCallback(const GeneralConfigInformation &info, const WUPSConfigAPIBackend::WUPSConfig &config) {
|
||||
CallOnCloseCallback(info, config.getCategories());
|
||||
for (const auto &item : config.getItems()) {
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
#include "CategoryRenderer.h"
|
||||
#include "ConfigDefines.h"
|
||||
#include "ConfigDisplayItem.h"
|
||||
#include "plugin/PluginLoadWrapper.h"
|
||||
#include "utils/input/Input.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <wups/config.h>
|
||||
|
||||
class ConfigRenderer {
|
||||
@@ -26,6 +27,8 @@ public:
|
||||
|
||||
void ResetNeedsRedraw();
|
||||
|
||||
bool GetActivePluginsIfChanged(std::vector<PluginLoadWrapper> &result);
|
||||
|
||||
private:
|
||||
ConfigSubState UpdateStateMain(const Input &input);
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
#include "ConfigRenderer.h"
|
||||
#include "config/WUPSConfigAPI.h"
|
||||
#include "hooks.h"
|
||||
#include "plugin/PluginLoadWrapper.h"
|
||||
#include "utils/DrawUtils.h"
|
||||
#include "utils/WUPSBackendSettings.h"
|
||||
#include "utils/dc.h"
|
||||
#include "utils/input/CombinedInput.h"
|
||||
#include "utils/input/Input.h"
|
||||
@@ -13,9 +15,11 @@
|
||||
#include "version.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <coreinit/title.h>
|
||||
#include <globals.h>
|
||||
#include <memory/mappedmemory.h>
|
||||
#include <memory>
|
||||
#include <sysapp/launch.h>
|
||||
#include <vector>
|
||||
#include <wups/config.h>
|
||||
|
||||
@@ -214,16 +218,51 @@ void ConfigUtils::displayMenu() {
|
||||
}
|
||||
|
||||
startTime = OSGetTime();
|
||||
renderBasicScreen("Saving configs...");
|
||||
|
||||
for (const auto &plugin : gLoadedPlugins) {
|
||||
const auto configData = plugin.getConfigData();
|
||||
if (configData) {
|
||||
if (configData->CallMenuClosedCallback() == WUPSCONFIG_API_RESULT_MISSING_CALLBACK) {
|
||||
DEBUG_FUNCTION_LINE_WARN("CallMenuClosedCallback is missing for %s", plugin.getMetaInformation().getName().c_str());
|
||||
DEBUG_FUNCTION_LINE_INFO(".");
|
||||
std::vector<PluginLoadWrapper> newActivePluginsList;
|
||||
|
||||
if (renderer.GetActivePluginsIfChanged(newActivePluginsList)) {
|
||||
startTime = OSGetTime();
|
||||
renderBasicScreen("Applying changes, app will now restart...");
|
||||
|
||||
// Get list of inactive plugins to save them in the config
|
||||
// Note: this does only consider plugin loaded from the sd card.
|
||||
std::vector<std::string> newInactivePluginsList;
|
||||
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")) {
|
||||
std::size_t found = source.find_last_of("/\\");
|
||||
std::string filename = source.substr(found + 1);
|
||||
newInactivePluginsList.push_back(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
gLoadOnNextLaunch = newActivePluginsList;
|
||||
WUPSBackendSettings::SetInactivePluginFilenames(newInactivePluginsList);
|
||||
WUPSBackendSettings::SaveSettings();
|
||||
|
||||
_SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), nullptr);
|
||||
// Make sure to wait at least 2 seconds so user can read the screen and
|
||||
// are aware the app will restart now.
|
||||
auto diffTime = OSTicksToMilliseconds(OSGetTime() - startTime);
|
||||
if (diffTime < 2000) {
|
||||
OSSleepTicks(OSTicksToMilliseconds(2000 - diffTime));
|
||||
}
|
||||
} else {
|
||||
renderBasicScreen("Saving configs...");
|
||||
for (const auto &plugin : gLoadedPlugins) {
|
||||
const auto configData = plugin.getConfigData();
|
||||
if (configData) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user