mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-12-23 11:31:49 +01:00
WIP, revert me
This commit is contained in:
parent
9052ecb2b2
commit
92bba66442
@ -87,6 +87,9 @@ WUMS_INITIALIZE() {
|
||||
}
|
||||
std::this_thread::sleep_for(16ms);
|
||||
}
|
||||
DrawUtils::beginDraw();
|
||||
DrawUtils::clear(COLOR_BLACK);
|
||||
DrawUtils::endDraw();
|
||||
});
|
||||
DEBUG_FUNCTION_LINE_INFO("Safe Mode activated!");
|
||||
auto tobeIgnoredFilePath = getNonBaseAromaPluginFilenames(getPluginPath());
|
||||
|
@ -76,7 +76,8 @@ WUPSStorageError PluginContainer::OpenStorage() {
|
||||
if (storageId.empty()) {
|
||||
return WUPS_STORAGE_ERROR_SUCCESS;
|
||||
}
|
||||
auto res = StorageUtils::API::Internal::OpenStorage(storageId, mStorageRootItem);
|
||||
|
||||
const auto res = StorageUtils::API::Internal::OpenStorage(storageId, mStorageRootItem);
|
||||
if (res != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||
mStorageRootItem = nullptr;
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ uint32_t DrawUtils::getTextWidth(const wchar_t *string) {
|
||||
return width;
|
||||
}
|
||||
|
||||
void DrawUtils::RenderScreen(const std::function<void()>& callback) {
|
||||
void DrawUtils::RenderScreen(const std::function<void()> &callback) {
|
||||
gOnlyAcceptFromThread = OSGetCurrentThread();
|
||||
bool wasHomeButtonMenuEnabled = OSIsHomeButtonMenuEnabled();
|
||||
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
|
||||
static uint32_t getTextWidth(const wchar_t *string);
|
||||
|
||||
static void RenderScreen(const std::function<void()>& callback);
|
||||
static void RenderScreen(const std::function<void()> &callback);
|
||||
|
||||
private:
|
||||
static bool mIsBackBuffer;
|
||||
|
@ -19,7 +19,7 @@ namespace WUPSBackendSettings {
|
||||
std::string folderPath = getModulePath() + "/configs/";
|
||||
std::string filePath = folderPath + "wupsbackend.json";
|
||||
|
||||
if (!ParseJsonFromFile(filePath, j)) {
|
||||
if (ParseJsonFromFile(filePath, j) != UTILS_IO_ERROR_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,6 @@ struct StoredBuffer {
|
||||
enum ConfigSubState {
|
||||
SUB_STATE_RUNNING = 0,
|
||||
SUB_STATE_RETURN = 1,
|
||||
SUB_STATE_RETURN_WITH_PLUGIN_RELOAD = 1,
|
||||
SUB_STATE_ERROR = 2,
|
||||
SUB_STATE_RETURN_WITH_PLUGIN_RELOAD = 2,
|
||||
SUB_STATE_ERROR = 3,
|
||||
};
|
@ -27,6 +27,7 @@ ConfigSubState ConfigRenderer::Update(Input &input, const WUPSConfigSimplePadDat
|
||||
auto subResult = mCategoryRenderer->Update(input, simpleInputData, complexInputData);
|
||||
if (subResult != SUB_STATE_RUNNING) {
|
||||
mNeedRedraw = true;
|
||||
mActivePluginsDirty = false;
|
||||
mState = STATE_MAIN;
|
||||
return SUB_STATE_RUNNING;
|
||||
}
|
||||
@ -76,7 +77,13 @@ void ConfigRenderer::ResetNeedsRedraw() {
|
||||
ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
|
||||
auto &configs = GetConfigList();
|
||||
|
||||
auto prevSelectedItem = mCursorPos;
|
||||
const auto prevSelectedItem = mCursorPos;
|
||||
|
||||
const auto& savePendingConfigFn = [&configs, this]() {
|
||||
for (const auto &element : configs) {
|
||||
CallOnCloseCallback(element.get().getConfigInformation(), element.get().getConfig());
|
||||
}
|
||||
};
|
||||
|
||||
if (input.data.buttons_d & Input::eButtons::BUTTON_DOWN) {
|
||||
mCursorPos++;
|
||||
@ -86,6 +93,7 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
|
||||
if (mSetActivePluginsMode) {
|
||||
mNeedRedraw = true;
|
||||
mCategoryRenderer.reset();
|
||||
savePendingConfigFn();
|
||||
return SUB_STATE_RETURN_WITH_PLUGIN_RELOAD;
|
||||
}
|
||||
} else if (input.data.buttons_d & Input::eButtons::BUTTON_X) {
|
||||
@ -115,15 +123,14 @@ ConfigSubState ConfigRenderer::UpdateStateMain(const Input &input) {
|
||||
for (auto &cur : mConfigs) {
|
||||
cur.resetIsActivePlugin();
|
||||
}
|
||||
mActivePluginsDirty = false;
|
||||
mNeedRedraw = true;
|
||||
mSetActivePluginsMode = false;
|
||||
return SUB_STATE_RUNNING;
|
||||
} else {
|
||||
mNeedRedraw = true;
|
||||
mCategoryRenderer.reset();
|
||||
for (const auto &element : configs) {
|
||||
CallOnCloseCallback(element.get().getConfigInformation(), element.get().getConfig());
|
||||
}
|
||||
savePendingConfigFn();
|
||||
return SUB_STATE_RETURN;
|
||||
}
|
||||
}
|
||||
|
@ -221,6 +221,9 @@ void ConfigUtils::displayMenu() {
|
||||
|
||||
std::vector<PluginLoadWrapper> newActivePluginsList;
|
||||
|
||||
DEBUG_FUNCTION_LINE_ERR("%d", subStateReturnValue);
|
||||
DEBUG_FUNCTION_LINE_ERR("%d", subStateReturnValue == SUB_STATE_RETURN_WITH_PLUGIN_RELOAD);
|
||||
|
||||
if (subStateReturnValue == SUB_STATE_RETURN_WITH_PLUGIN_RELOAD && renderer.GetActivePluginsIfChanged(newActivePluginsList)) {
|
||||
startTime = OSGetTime();
|
||||
renderBasicScreen("Applying changes, app will now restart...");
|
||||
|
@ -172,11 +172,20 @@ namespace StorageUtils {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
WUPSStorageError LoadFromFile(std::string_view plugin_id, nlohmann::json &outJson) {
|
||||
const std::string filePath = getPluginPath() + "/config/" + plugin_id.data() + ".json";
|
||||
if (ParseJsonFromFile(filePath, outJson)) {
|
||||
WUPSStorageError LoadFromFile(const std::string_view plugin_id, nlohmann::json &outJson) {
|
||||
switch (const std::string filePath = getPluginPath() + "/config/" + plugin_id.data() + ".json"; ParseJsonFromFile(filePath, outJson)) {
|
||||
case UTILS_IO_ERROR_SUCCESS:
|
||||
return WUPS_STORAGE_ERROR_SUCCESS;
|
||||
case UTILS_IO_ERROR_INVALID_ARGS:
|
||||
return WUPS_STORAGE_ERROR_INVALID_ARGS;
|
||||
case UTILS_IO_ERROR_MALLOC_FAILED:
|
||||
return WUPS_STORAGE_ERROR_MALLOC_FAILED;
|
||||
case UTILS_IO_ERROR_GENERIC:
|
||||
return WUPS_STORAGE_ERROR_IO_ERROR;
|
||||
case UTILS_IO_ERROR_NOT_FOUND:
|
||||
return WUPS_STORAGE_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
return WUPS_STORAGE_ERROR_IO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -116,22 +116,22 @@ void CustomDynLoadFree(void *addr) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ParseJsonFromFile(const std::string &filePath, nlohmann::json &outJson) {
|
||||
UtilsIOError ParseJsonFromFile(const std::string &filePath, nlohmann::json &outJson) {
|
||||
CFile file(filePath, CFile::ReadOnly);
|
||||
if (!file.isOpen() || file.size() == 0) {
|
||||
return false;
|
||||
return UTILS_IO_ERROR_NOT_FOUND;
|
||||
}
|
||||
auto *json_data = (uint8_t *) memalign(0x40, ROUNDUP(file.size() + 1, 0x40));
|
||||
auto *json_data = static_cast<uint8_t *>(memalign(0x40, ROUNDUP(file.size() + 1, 0x40)));
|
||||
if (!json_data) {
|
||||
return false;
|
||||
return UTILS_IO_ERROR_MALLOC_FAILED;
|
||||
}
|
||||
bool result = true;
|
||||
auto result = UTILS_IO_ERROR_SUCCESS;
|
||||
uint64_t readRes = file.read(json_data, file.size());
|
||||
if (readRes == file.size()) {
|
||||
json_data[file.size()] = '\0';
|
||||
outJson = nlohmann::json::parse(json_data, nullptr, false);
|
||||
} else {
|
||||
result = false;
|
||||
result = UTILS_IO_ERROR_GENERIC;
|
||||
}
|
||||
file.close();
|
||||
free(json_data);
|
||||
|
@ -136,6 +136,14 @@ void append_move_all_values(Container &dest, Container &src) {
|
||||
src.clear();
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
UTILS_IO_ERROR_SUCCESS = 0, /**< Success. */
|
||||
UTILS_IO_ERROR_INVALID_ARGS = -0x01, /**< Invalid arguments passed to the function. */
|
||||
UTILS_IO_ERROR_MALLOC_FAILED = -0x02, /**< Memory allocation failed. */
|
||||
UTILS_IO_ERROR_GENERIC = -0x03, /**< Generic IO error during saving or loading. */
|
||||
UTILS_IO_ERROR_NOT_FOUND = -0x4, /**< Item not found. */
|
||||
} UtilsIOError;
|
||||
|
||||
std::string getPluginPath();
|
||||
|
||||
std::string getModulePath();
|
||||
@ -144,7 +152,7 @@ OSDynLoad_Error CustomDynLoadAlloc(int32_t size, int32_t align, void **outAddr);
|
||||
|
||||
void CustomDynLoadFree(void *addr);
|
||||
|
||||
bool ParseJsonFromFile(const std::string &filePath, nlohmann::json &outJson);
|
||||
UtilsIOError ParseJsonFromFile(const std::string &filePath, nlohmann::json &outJson);
|
||||
|
||||
std::vector<std::string> getPluginFilePaths(std::string_view basePath);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user