mirror of
https://github.com/wiiu-env/sdcafiine_plugin.git
synced 2024-11-16 16:39:22 +01:00
Add a option to disable/enable this feature under "SdCaffine->Advanced Settings->Enable Save Redirection"
This commit is contained in:
parent
ed641b2e85
commit
d2922bcd3a
@ -3,6 +3,7 @@
|
||||
bool gAutoApplySingleModpack = DEFAULT_AUTO_APPLY_SINGLE_MODPACK;
|
||||
bool gSkipPrepareIfSingleModpack = DEFAULT_SKIP_PREPARE_IF_SINGLE_MODPACK;
|
||||
bool gSDCafiineEnabled = DEFAULT_SDCAFIINE_ENABLED;
|
||||
bool gSaveRedirectionEnabled = DEFAULT_SAVE_REDIRECTION_ENABLED;
|
||||
|
||||
|
||||
CRLayerHandle gContentLayerHandle = 0;
|
||||
|
@ -8,14 +8,17 @@
|
||||
#define AUTO_APPLY_SINGLE_MODPACK_STRING "autoApplySingleModpack"
|
||||
#define SKIP_PREPARE_FOR_SINGLE_MODPACK_STRING "skipPrepareForSingleModpack"
|
||||
#define SDCAFIINE_ENABLED_STRING "sdCafiineEnabled"
|
||||
#define SAVE_REDIRECTION_ENABLED_STRING "saveRedirectionEnabled"
|
||||
|
||||
#define DEFAULT_AUTO_APPLY_SINGLE_MODPACK false
|
||||
#define DEFAULT_SKIP_PREPARE_IF_SINGLE_MODPACK false
|
||||
#define DEFAULT_SDCAFIINE_ENABLED true
|
||||
#define DEFAULT_SAVE_REDIRECTION_ENABLED true
|
||||
|
||||
extern bool gAutoApplySingleModpack;
|
||||
extern bool gSkipPrepareIfSingleModpack;
|
||||
extern bool gSDCafiineEnabled;
|
||||
extern bool gSaveRedirectionEnabled;
|
||||
|
||||
extern CRLayerHandle gAocLayerHandle;
|
||||
extern CRLayerHandle gContentLayerHandle;
|
||||
|
@ -13,10 +13,10 @@
|
||||
#include <malloc.h>
|
||||
#include <map>
|
||||
#include <memory/mappedmemory.h>
|
||||
#include <nn/act.h>
|
||||
#include <string>
|
||||
#include <utils/logger.h>
|
||||
#include <wups/storage.h>
|
||||
#include <nn/act.h>
|
||||
|
||||
#define TEXT_SEL(x, text1, text2) ((x) ? (text1) : (text2))
|
||||
|
||||
@ -314,37 +314,39 @@ void HandleMultiModPacks(uint64_t titleID) {
|
||||
KPADShutdown();
|
||||
}
|
||||
|
||||
bool ReplaceContentInternal(const std::string &basePath, const std::string &subdir, CRLayerHandle *layerHandle,FSLayerType layerType);
|
||||
bool ReplaceContentInternal(const std::string &basePath, const std::string &subdir, CRLayerHandle *layerHandle, FSLayerType layerType);
|
||||
|
||||
bool ReplaceContent(const std::string &basePath, const std::string &modpack) {
|
||||
bool saveRes = ReplaceContentInternal(basePath, "save", &gSaveLayerHandle,FS_LAYER_TYPE_SAVE_REPLACE);
|
||||
if (gSaveRedirectionEnabled) {
|
||||
bool saveRes = ReplaceContentInternal(basePath, "save", &gSaveLayerHandle, FS_LAYER_TYPE_SAVE_REPLACE);
|
||||
|
||||
if(!saveRes){
|
||||
if (!saveRes) {
|
||||
|
||||
auto screenWasAllocated = screenBuffer_0 != nullptr;
|
||||
auto screenWasAllocated = screenBuffer_0 != nullptr;
|
||||
|
||||
if (!ScreenInit()) {
|
||||
OSFatal("SDCafiine plugin: Failed to apply the modpack.");
|
||||
if (!ScreenInit()) {
|
||||
OSFatal("SDCafiine plugin: Failed to apply the modpack.");
|
||||
}
|
||||
uint32_t sleepTime = 3000;
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to apply the save redirection. Starting without mods.");
|
||||
OSScreenClearBufferEx(SCREEN_TV, 0);
|
||||
OSScreenClearBufferEx(SCREEN_DRC, 0);
|
||||
console_print_pos(-2, -1, "SDCafiine plugin " VERSION VERSION_EXTRA);
|
||||
console_print_pos(-2, 1, "Failed to apply the save redirection. Starting without mods...");
|
||||
|
||||
OSScreenFlipBuffersEx(SCREEN_TV);
|
||||
OSScreenFlipBuffersEx(SCREEN_DRC);
|
||||
|
||||
OSSleepTicks(OSMillisecondsToTicks(sleepTime));
|
||||
if (!screenWasAllocated) {
|
||||
ScreenDeInit();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
uint32_t sleepTime = 3000;
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to apply the save redirection. Starting without mods.");
|
||||
OSScreenClearBufferEx(SCREEN_TV, 0);
|
||||
OSScreenClearBufferEx(SCREEN_DRC, 0);
|
||||
console_print_pos(-2, -1, "SDCafiine plugin " VERSION VERSION_EXTRA);
|
||||
console_print_pos(-2, 1, "Failed to apply the save redirection. Starting without mods...");
|
||||
|
||||
OSScreenFlipBuffersEx(SCREEN_TV);
|
||||
OSScreenFlipBuffersEx(SCREEN_DRC);
|
||||
|
||||
OSSleepTicks(OSMillisecondsToTicks(sleepTime));
|
||||
if (!screenWasAllocated) {
|
||||
ScreenDeInit();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool contentRes = ReplaceContentInternal(basePath, "content", &gContentLayerHandle,FS_LAYER_TYPE_CONTENT_MERGE);
|
||||
bool aocRes = ReplaceContentInternal(basePath, "aoc", &gAocLayerHandle,FS_LAYER_TYPE_AOC_MERGE);
|
||||
bool contentRes = ReplaceContentInternal(basePath, "content", &gContentLayerHandle, FS_LAYER_TYPE_CONTENT_MERGE);
|
||||
bool aocRes = ReplaceContentInternal(basePath, "aoc", &gAocLayerHandle, FS_LAYER_TYPE_AOC_MERGE);
|
||||
|
||||
if (!contentRes && !aocRes) {
|
||||
auto screenWasAllocated = screenBuffer_0 != nullptr;
|
||||
@ -406,10 +408,10 @@ bool ReplaceContent(const std::string &basePath, const std::string &modpack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReplaceContentInternal(const std::string &basePath, const std::string &subdir, CRLayerHandle *layerHandle,FSLayerType layerType) {
|
||||
bool ReplaceContentInternal(const std::string &basePath, const std::string &subdir, CRLayerHandle *layerHandle, FSLayerType layerType) {
|
||||
std::string layerName = "SDCafiine Plus /vol/" + subdir;
|
||||
std::string fullPath = basePath + "/" + subdir;
|
||||
if(layerType == FS_LAYER_TYPE_SAVE_REPLACE){
|
||||
if (layerType == FS_LAYER_TYPE_SAVE_REPLACE) {
|
||||
nn::act::Initialize();
|
||||
nn::act::PersistentId id = nn::act::GetPersistentId();
|
||||
nn::act::Finalize();
|
||||
@ -418,8 +420,8 @@ bool ReplaceContentInternal(const std::string &basePath, const std::string &subd
|
||||
snprintf(user, 9, "%08x", 0x80000000 | id);
|
||||
|
||||
mkdir(fullPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
mkdir((fullPath+"/"+"common").c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
mkdir((fullPath+"/"+user).c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
mkdir((fullPath + "/" + "common").c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
mkdir((fullPath + "/" + user).c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
}
|
||||
struct stat st {};
|
||||
if (stat(fullPath.c_str(), &st) < 0) {
|
||||
|
@ -18,6 +18,8 @@ static void bool_item_callback(ConfigItemBoolean *item, bool newValue) {
|
||||
gSkipPrepareIfSingleModpack = newValue;
|
||||
} else if (std::string_view(SDCAFIINE_ENABLED_STRING) == item->identifier) {
|
||||
gSDCafiineEnabled = newValue;
|
||||
} else if (std::string_view(SAVE_REDIRECTION_ENABLED_STRING) == item->identifier) {
|
||||
gSaveRedirectionEnabled = newValue;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE_WARN("Unexpected boolean item: %s", item->identifier);
|
||||
return;
|
||||
@ -50,6 +52,11 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa
|
||||
"Skip \"Preparing modpack...\" screen",
|
||||
DEFAULT_SKIP_PREPARE_IF_SINGLE_MODPACK, gSkipPrepareIfSingleModpack,
|
||||
&bool_item_callback));
|
||||
|
||||
advancedSettings.add(WUPSConfigItemBoolean::Create(SAVE_REDIRECTION_ENABLED_STRING,
|
||||
"Enable Save Redirection (game needs to be restarted)",
|
||||
DEFAULT_SAVE_REDIRECTION_ENABLED, gSaveRedirectionEnabled,
|
||||
&bool_item_callback));
|
||||
root.add(std::move(advancedSettings));
|
||||
|
||||
} catch (std::exception &e) {
|
||||
@ -79,7 +86,9 @@ void InitStorageAndConfig() {
|
||||
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::GetOrStoreDefault(SAVE_REDIRECTION_ENABLED_STRING, gSaveRedirectionEnabled, DEFAULT_SAVE_REDIRECTION_ENABLED)) != WUPS_STORAGE_ERROR_SUCCESS) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\": %s (%d)", gSaveRedirectionEnabled, 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user