mirror of
https://github.com/wiiu-env/sdcafiine_plugin.git
synced 2024-11-22 03:19:17 +01:00
Move wups config code into a new file
This commit is contained in:
parent
4a83db1ff7
commit
f0f849cd93
9
src/globals.cpp
Normal file
9
src/globals.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include "globals.h"
|
||||||
|
|
||||||
|
bool gAutoApplySingleModpack = DEFAULT_AUTO_APPLY_SINGLE_MODPACK;
|
||||||
|
bool gSkipPrepareIfSingleModpack = DEFAULT_SKIP_PREPARE_IF_SINGLE_MODPACK;
|
||||||
|
bool gSDCafiineEnabled = DEFAULT_SDCAFIINE_ENABLED;
|
||||||
|
|
||||||
|
|
||||||
|
CRLayerHandle gContentLayerHandle = 0;
|
||||||
|
CRLayerHandle gAocLayerHandle = 0;
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include <content_redirection/redirection.h>
|
||||||
|
|
||||||
#define VERSION "v0.1.3"
|
#define VERSION "v0.1.3"
|
||||||
#define VERSION_FULL VERSION VERSION_EXTRA
|
#define VERSION_FULL VERSION VERSION_EXTRA
|
||||||
@ -8,5 +9,13 @@
|
|||||||
#define SKIP_PREPARE_FOR_SINGLE_MODPACK_STRING "skipPrepareForSingleModpack"
|
#define SKIP_PREPARE_FOR_SINGLE_MODPACK_STRING "skipPrepareForSingleModpack"
|
||||||
#define SDCAFIINE_ENABLED_STRING "sdCafiineEnabled"
|
#define SDCAFIINE_ENABLED_STRING "sdCafiineEnabled"
|
||||||
|
|
||||||
|
#define DEFAULT_AUTO_APPLY_SINGLE_MODPACK false
|
||||||
|
#define DEFAULT_SKIP_PREPARE_IF_SINGLE_MODPACK false
|
||||||
|
#define DEFAULT_SDCAFIINE_ENABLED true
|
||||||
|
|
||||||
extern bool gAutoApplySingleModpack;
|
extern bool gAutoApplySingleModpack;
|
||||||
extern bool gSkipPrepareIfSingleModpack;
|
extern bool gSkipPrepareIfSingleModpack;
|
||||||
|
extern bool gSDCafiineEnabled;
|
||||||
|
|
||||||
|
extern CRLayerHandle gAocLayerHandle;
|
||||||
|
extern CRLayerHandle gContentLayerHandle;
|
121
src/main.cpp
121
src/main.cpp
@ -1,5 +1,6 @@
|
|||||||
#include "main.h"
|
#include "globals.h"
|
||||||
#include "modpackSelector.h"
|
#include "modpackSelector.h"
|
||||||
|
#include "utils/config.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include <content_redirection/redirection.h>
|
#include <content_redirection/redirection.h>
|
||||||
#include <coreinit/title.h>
|
#include <coreinit/title.h>
|
||||||
@ -13,52 +14,19 @@ WUPS_PLUGIN_AUTHOR("Maschell");
|
|||||||
WUPS_PLUGIN_LICENSE("GPL");
|
WUPS_PLUGIN_LICENSE("GPL");
|
||||||
|
|
||||||
WUPS_USE_WUT_DEVOPTAB();
|
WUPS_USE_WUT_DEVOPTAB();
|
||||||
WUPS_USE_STORAGE("sdcafiine"); // Unqiue id for the storage api
|
WUPS_USE_STORAGE("sdcafiine"); // Unique id for the storage api
|
||||||
|
|
||||||
CRLayerHandle sContentLayerHandle = 0;
|
|
||||||
CRLayerHandle sAocLayerHandle = 0;
|
|
||||||
|
|
||||||
#define DEFAULT_AUTO_APPLY_SINGLE_MODPACK false
|
|
||||||
#define DEFAULT_SKIP_PREPARE_IF_SINGLE_MODPACK false
|
|
||||||
#define DEFAULT_SDCAFIINE_ENABLED true
|
|
||||||
|
|
||||||
bool gAutoApplySingleModpack = DEFAULT_AUTO_APPLY_SINGLE_MODPACK;
|
|
||||||
bool gSkipPrepareIfSingleModpack = DEFAULT_SKIP_PREPARE_IF_SINGLE_MODPACK;
|
|
||||||
bool gSDCafiineEnabled = DEFAULT_SDCAFIINE_ENABLED;
|
|
||||||
|
|
||||||
WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle);
|
|
||||||
|
|
||||||
void ConfigMenuClosedCallback();
|
|
||||||
|
|
||||||
INITIALIZE_PLUGIN() {
|
INITIALIZE_PLUGIN() {
|
||||||
// But then use libcontentredirection instead.
|
|
||||||
ContentRedirectionStatus error;
|
ContentRedirectionStatus error;
|
||||||
if ((error = ContentRedirection_InitLibrary()) != CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
if ((error = ContentRedirection_InitLibrary()) != CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to init ContentRedirection. Error %s %d", ContentRedirection_GetStatusStr(error), error);
|
DEBUG_FUNCTION_LINE_ERR("Failed to init ContentRedirection. Error %s %d", ContentRedirection_GetStatusStr(error), error);
|
||||||
OSFatal("Failed to init ContentRedirection.");
|
OSFatal("Failed to init ContentRedirection.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WUPSStorageAPI::GetOrStoreDefault(AUTO_APPLY_SINGLE_MODPACK_STRING, gAutoApplySingleModpack, DEFAULT_AUTO_APPLY_SINGLE_MODPACK) != WUPS_STORAGE_ERROR_SUCCESS) {
|
InitStorageAndConfig();
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", AUTO_APPLY_SINGLE_MODPACK_STRING);
|
|
||||||
}
|
|
||||||
if (WUPSStorageAPI::GetOrStoreDefault(SDCAFIINE_ENABLED_STRING, gSDCafiineEnabled, DEFAULT_SDCAFIINE_ENABLED) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", SDCAFIINE_ENABLED_STRING);
|
|
||||||
}
|
|
||||||
if (WUPSStorageAPI::GetOrStoreDefault(SKIP_PREPARE_FOR_SINGLE_MODPACK_STRING, gSkipPrepareIfSingleModpack, DEFAULT_SKIP_PREPARE_IF_SINGLE_MODPACK) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", gSkipPrepareIfSingleModpack);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WUPSStorageAPI::SaveStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
gContentLayerHandle = 0;
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to save storage");
|
gAocLayerHandle = 0;
|
||||||
}
|
|
||||||
|
|
||||||
WUPSConfigAPIOptionsV1 configOptions = {.name = "SDCafiine"};
|
|
||||||
if (WUPSConfigAPI_Init(configOptions, ConfigMenuOpenedCallback, ConfigMenuClosedCallback) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to init config api");
|
|
||||||
}
|
|
||||||
|
|
||||||
sContentLayerHandle = 0;
|
|
||||||
sAocLayerHandle = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Entry point */
|
/* Entry point */
|
||||||
@ -71,79 +39,14 @@ ON_APPLICATION_START() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void autoApplySingleModpackChanged(ConfigItemBoolean *item, bool newValue) {
|
|
||||||
DEBUG_FUNCTION_LINE("New value in gAutoApplySingleModpack: %d", newValue);
|
|
||||||
gAutoApplySingleModpack = newValue;
|
|
||||||
// If the value has changed, we store it in the storage.
|
|
||||||
if (WUPSStorageAPI::Store(AUTO_APPLY_SINGLE_MODPACK_STRING, gAutoApplySingleModpack) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to close storage");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void skipPrepareIfSingleModpackChanged(ConfigItemBoolean *item, bool newValue) {
|
|
||||||
DEBUG_FUNCTION_LINE("New value in gSkipPrepareIfSingleModpack: %d", newValue);
|
|
||||||
gSkipPrepareIfSingleModpack = newValue;
|
|
||||||
// If the value has changed, we store it in the storage.
|
|
||||||
if (WUPSStorageAPI::Store(SKIP_PREPARE_FOR_SINGLE_MODPACK_STRING, gSkipPrepareIfSingleModpack) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to close storage");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sdCafiineEnabledChanged(ConfigItemBoolean *item, bool newValue) {
|
|
||||||
DEBUG_FUNCTION_LINE("New value in gSDCafiineEnabled: %d", newValue);
|
|
||||||
gSDCafiineEnabled = newValue;
|
|
||||||
// If the value has changed, we store it in the storage.
|
|
||||||
if (WUPSStorageAPI::Store(SDCAFIINE_ENABLED_STRING, gSDCafiineEnabled) != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to close storage");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle) {
|
|
||||||
try {
|
|
||||||
WUPSConfigCategory root = WUPSConfigCategory(rootHandle);
|
|
||||||
|
|
||||||
|
|
||||||
root.add(WUPSConfigItemBoolean::Create(SDCAFIINE_ENABLED_STRING,
|
|
||||||
"Enable SDCafiine (game needs to be restarted)",
|
|
||||||
DEFAULT_SDCAFIINE_ENABLED, gSDCafiineEnabled,
|
|
||||||
&sdCafiineEnabledChanged));
|
|
||||||
|
|
||||||
|
|
||||||
auto advancedSettings = WUPSConfigCategory::Create("Advanced settings");
|
|
||||||
|
|
||||||
advancedSettings.add(WUPSConfigItemBoolean::Create(AUTO_APPLY_SINGLE_MODPACK_STRING,
|
|
||||||
"Auto apply the modpack if only one modpack exists",
|
|
||||||
DEFAULT_AUTO_APPLY_SINGLE_MODPACK, gAutoApplySingleModpack,
|
|
||||||
&autoApplySingleModpackChanged));
|
|
||||||
|
|
||||||
advancedSettings.add(WUPSConfigItemBoolean::Create(SKIP_PREPARE_FOR_SINGLE_MODPACK_STRING,
|
|
||||||
"Skip \"Preparing modpack...\" screen",
|
|
||||||
DEFAULT_SKIP_PREPARE_IF_SINGLE_MODPACK, gSkipPrepareIfSingleModpack,
|
|
||||||
&skipPrepareIfSingleModpackChanged));
|
|
||||||
root.add(std::move(advancedSettings));
|
|
||||||
|
|
||||||
} catch (std::exception &e) {
|
|
||||||
OSReport("Exception T_T : %s\n", e.what());
|
|
||||||
return WUPSCONFIG_API_CALLBACK_RESULT_ERROR;
|
|
||||||
}
|
|
||||||
return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigMenuClosedCallback() {
|
|
||||||
// Save all changes
|
|
||||||
if (WUPSStorageAPI::SaveStorage() != WUPS_STORAGE_ERROR_SUCCESS) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to close storage");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ON_APPLICATION_ENDS() {
|
ON_APPLICATION_ENDS() {
|
||||||
if (sContentLayerHandle != 0) {
|
if (gContentLayerHandle != 0) {
|
||||||
ContentRedirection_RemoveFSLayer(sContentLayerHandle);
|
ContentRedirection_RemoveFSLayer(gContentLayerHandle);
|
||||||
sContentLayerHandle = 0;
|
gContentLayerHandle = 0;
|
||||||
}
|
}
|
||||||
if (sAocLayerHandle != 0) {
|
if (gAocLayerHandle != 0) {
|
||||||
ContentRedirection_RemoveFSLayer(sAocLayerHandle);
|
ContentRedirection_RemoveFSLayer(gAocLayerHandle);
|
||||||
sAocLayerHandle = 0;
|
gAocLayerHandle = 0;
|
||||||
}
|
}
|
||||||
deinitLogging();
|
deinitLogging();
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#include "modpackSelector.h"
|
#include "modpackSelector.h"
|
||||||
#include "main.h"
|
#include "globals.h"
|
||||||
#include "utils/input.h"
|
#include "utils/input.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include <content_redirection/redirection.h>
|
#include <content_redirection/redirection.h>
|
||||||
@ -111,7 +111,7 @@ void HandleMultiModPacks(uint64_t titleID) {
|
|||||||
DIR *dir = opendir(modTitleIDPathOld.c_str());
|
DIR *dir = opendir(modTitleIDPathOld.c_str());
|
||||||
if (dir) {
|
if (dir) {
|
||||||
if (!ScreenInit()) {
|
if (!ScreenInit()) {
|
||||||
OSFatal("Please migrate sd:/sdcafiine to sd:/wiiu/sdcafiine.");
|
OSFatal("SDCafiine plugin: Please migrate sd:/sdcafiine to sd:/wiiu/sdcafiine.");
|
||||||
}
|
}
|
||||||
OSScreenClearBufferEx(SCREEN_TV, 0);
|
OSScreenClearBufferEx(SCREEN_TV, 0);
|
||||||
OSScreenClearBufferEx(SCREEN_DRC, 0);
|
OSScreenClearBufferEx(SCREEN_DRC, 0);
|
||||||
@ -252,8 +252,12 @@ void HandleMultiModPacks(uint64_t titleID) {
|
|||||||
selected += per_page;
|
selected += per_page;
|
||||||
initScreen = 1;
|
initScreen = 1;
|
||||||
}
|
}
|
||||||
if (selected < 0) { selected = 0; }
|
if (selected < 0) {
|
||||||
if (selected >= modTitlePath.size()) { selected = modTitlePath.size() - 1; }
|
selected = 0;
|
||||||
|
}
|
||||||
|
if (selected >= (int) modTitlePath.size()) {
|
||||||
|
selected = modTitlePath.size() - 1;
|
||||||
|
}
|
||||||
page = selected / per_page;
|
page = selected / per_page;
|
||||||
|
|
||||||
if (initScreen) {
|
if (initScreen) {
|
||||||
@ -308,20 +312,18 @@ void HandleMultiModPacks(uint64_t titleID) {
|
|||||||
|
|
||||||
KPADShutdown();
|
KPADShutdown();
|
||||||
}
|
}
|
||||||
extern CRLayerHandle sContentLayerHandle;
|
|
||||||
extern CRLayerHandle sAocLayerHandle;
|
|
||||||
|
|
||||||
bool ReplaceContentInternal(const std::string &basePath, const std::string &subdir, CRLayerHandle *layerHandle);
|
bool ReplaceContentInternal(const std::string &basePath, const std::string &subdir, CRLayerHandle *layerHandle);
|
||||||
|
|
||||||
bool ReplaceContent(const std::string &basePath, const std::string &modpack) {
|
bool ReplaceContent(const std::string &basePath, const std::string &modpack) {
|
||||||
bool contentRes = ReplaceContentInternal(basePath, "content", &sContentLayerHandle);
|
bool contentRes = ReplaceContentInternal(basePath, "content", &gContentLayerHandle);
|
||||||
bool aocRes = ReplaceContentInternal(basePath, "aoc", &sAocLayerHandle);
|
bool aocRes = ReplaceContentInternal(basePath, "aoc", &gAocLayerHandle);
|
||||||
|
|
||||||
if (!contentRes && !aocRes) {
|
if (!contentRes && !aocRes) {
|
||||||
auto screenWasAllocated = screenBuffer_0 != nullptr;
|
auto screenWasAllocated = screenBuffer_0 != nullptr;
|
||||||
|
|
||||||
if (!ScreenInit()) {
|
if (!ScreenInit()) {
|
||||||
OSFatal("Failed to apply the modpack.");
|
OSFatal("SDCafiine plugin: Failed to apply the modpack.");
|
||||||
}
|
}
|
||||||
uint32_t sleepTime = 3000;
|
uint32_t sleepTime = 3000;
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to apply the modpack. Starting without mods.");
|
DEBUG_FUNCTION_LINE_ERR("Failed to apply the modpack. Starting without mods.");
|
||||||
@ -394,7 +396,6 @@ bool ReplaceContentInternal(const std::string &basePath, const std::string &subd
|
|||||||
DEBUG_FUNCTION_LINE("Redirect /vol/%s to %s", subdir.c_str(), fullPath.c_str());
|
DEBUG_FUNCTION_LINE("Redirect /vol/%s to %s", subdir.c_str(), fullPath.c_str());
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to redirect /vol/%s to %s", subdir.c_str(), fullPath.c_str());
|
DEBUG_FUNCTION_LINE_ERR("Failed to redirect /vol/%s to %s", subdir.c_str(), fullPath.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
92
src/utils/config.cpp
Normal file
92
src/utils/config.cpp
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#include "config.h"
|
||||||
|
#include "globals.h"
|
||||||
|
#include "logger.h"
|
||||||
|
#include <wups/config.h>
|
||||||
|
#include <wups/config/WUPSConfigItemBoolean.h>
|
||||||
|
#include <wups/config_api.h>
|
||||||
|
#include <wups/storage.h>
|
||||||
|
|
||||||
|
static void bool_item_callback(ConfigItemBoolean *item, bool newValue) {
|
||||||
|
if (!item || !item->identifier) {
|
||||||
|
DEBUG_FUNCTION_LINE_WARN("Invalid item or identifier in bool item callback");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("New value in %s changed: %d", item->identifier, newValue);
|
||||||
|
if (std::string_view(AUTO_APPLY_SINGLE_MODPACK_STRING) == item->identifier) {
|
||||||
|
gAutoApplySingleModpack = newValue;
|
||||||
|
} else if (std::string_view(SKIP_PREPARE_FOR_SINGLE_MODPACK_STRING) == item->identifier) {
|
||||||
|
gSkipPrepareIfSingleModpack = newValue;
|
||||||
|
} else if (std::string_view(SDCAFIINE_ENABLED_STRING) == item->identifier) {
|
||||||
|
gSDCafiineEnabled = newValue;
|
||||||
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE_WARN("Unexpected boolean item: %s", item->identifier);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WUPSStorageError err;
|
||||||
|
if ((err = WUPSStorageAPI::Store(item->identifier, newValue)) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_WARN("Failed to store value %d to storage item \"%s\": %s (%d)", newValue, item->identifier, WUPSStorageAPI_GetStatusStr(err), err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle) {
|
||||||
|
try {
|
||||||
|
WUPSConfigCategory root = WUPSConfigCategory(rootHandle);
|
||||||
|
|
||||||
|
|
||||||
|
root.add(WUPSConfigItemBoolean::Create(SDCAFIINE_ENABLED_STRING,
|
||||||
|
"Enable SDCafiine (game needs to be restarted)",
|
||||||
|
DEFAULT_SDCAFIINE_ENABLED, gSDCafiineEnabled,
|
||||||
|
&bool_item_callback));
|
||||||
|
|
||||||
|
|
||||||
|
auto advancedSettings = WUPSConfigCategory::Create("Advanced settings");
|
||||||
|
|
||||||
|
advancedSettings.add(WUPSConfigItemBoolean::Create(AUTO_APPLY_SINGLE_MODPACK_STRING,
|
||||||
|
"Auto apply the modpack if only one modpack exists",
|
||||||
|
DEFAULT_AUTO_APPLY_SINGLE_MODPACK, gAutoApplySingleModpack,
|
||||||
|
&bool_item_callback));
|
||||||
|
|
||||||
|
advancedSettings.add(WUPSConfigItemBoolean::Create(SKIP_PREPARE_FOR_SINGLE_MODPACK_STRING,
|
||||||
|
"Skip \"Preparing modpack...\" screen",
|
||||||
|
DEFAULT_SKIP_PREPARE_IF_SINGLE_MODPACK, gSkipPrepareIfSingleModpack,
|
||||||
|
&bool_item_callback));
|
||||||
|
root.add(std::move(advancedSettings));
|
||||||
|
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Exception: %s\n", e.what());
|
||||||
|
return WUPSCONFIG_API_CALLBACK_RESULT_ERROR;
|
||||||
|
}
|
||||||
|
return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ConfigMenuClosedCallback() {
|
||||||
|
// Save all changes
|
||||||
|
WUPSStorageError err;
|
||||||
|
if ((err = WUPSStorageAPI::SaveStorage()) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to close storage: %s (%d)", WUPSStorageAPI_GetStatusStr(err), err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InitStorageAndConfig() {
|
||||||
|
WUPSStorageError err;
|
||||||
|
if ((err = WUPSStorageAPI::GetOrStoreDefault(AUTO_APPLY_SINGLE_MODPACK_STRING, gAutoApplySingleModpack, DEFAULT_AUTO_APPLY_SINGLE_MODPACK)) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\": %s (%d)", AUTO_APPLY_SINGLE_MODPACK_STRING, WUPSStorageAPI_GetStatusStr(err), err);
|
||||||
|
}
|
||||||
|
if ((err = WUPSStorageAPI::GetOrStoreDefault(SDCAFIINE_ENABLED_STRING, gSDCafiineEnabled, DEFAULT_SDCAFIINE_ENABLED)) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\": %s (%d)", SDCAFIINE_ENABLED_STRING, WUPSStorageAPI_GetStatusStr(err), err);
|
||||||
|
}
|
||||||
|
if ((err = WUPSStorageAPI::GetOrStoreDefault(SKIP_PREPARE_FOR_SINGLE_MODPACK_STRING, gSkipPrepareIfSingleModpack, DEFAULT_SKIP_PREPARE_IF_SINGLE_MODPACK)) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\": %s (%d)", gSkipPrepareIfSingleModpack, WUPSStorageAPI_GetStatusStr(err), err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((err = WUPSStorageAPI::SaveStorage()) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to save storage: %s (%d)", WUPSStorageAPI_GetStatusStr(err), err);
|
||||||
|
}
|
||||||
|
|
||||||
|
WUPSConfigAPIOptionsV1 configOptions = {.name = "SDCafiine"};
|
||||||
|
WUPSConfigAPIStatus configErr;
|
||||||
|
if ((configErr = WUPSConfigAPI_Init(configOptions, ConfigMenuOpenedCallback, ConfigMenuClosedCallback)) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to init config api: %s (%d)", WUPSConfigAPI_GetStatusStr(configErr), configErr);
|
||||||
|
}
|
||||||
|
}
|
3
src/utils/config.h
Normal file
3
src/utils/config.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void InitStorageAndConfig();
|
Loading…
Reference in New Issue
Block a user