diff --git a/src/citra/config.cpp b/src/citra/config.cpp
index bcb97372b..477318ac0 100644
--- a/src/citra/config.cpp
+++ b/src/citra/config.cpp
@@ -203,14 +203,15 @@ void Config::ReadValues() {
Settings::values.use_virtual_sd =
sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
- const std::string default_nand_dir = FileUtil::GetDefaultUserPath(FileUtil::UserPath::NANDDir);
- FileUtil::UpdateUserPath(
- FileUtil::UserPath::NANDDir,
- sdl2_config->GetString("Data Storage", "nand_directory", default_nand_dir));
- const std::string default_sdmc_dir = FileUtil::GetDefaultUserPath(FileUtil::UserPath::SDMCDir);
- FileUtil::UpdateUserPath(
- FileUtil::UserPath::SDMCDir,
- sdl2_config->GetString("Data Storage", "sdmc_directory", default_sdmc_dir));
+ Settings::values.use_custom_storage =
+ sdl2_config->GetBoolean("Data Storage", "use_custom_storage", false);
+
+ if (Settings::values.use_custom_storage) {
+ FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir,
+ sdl2_config->GetString("Data Storage", "nand_directory", ""));
+ FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir,
+ sdl2_config->GetString("Data Storage", "sdmc_directory", ""));
+ }
// System
Settings::values.is_new_3ds = sdl2_config->GetBoolean("System", "is_new_3ds", true);
diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h
index 55d8da8f5..568ff43be 100644
--- a/src/citra/default_ini.h
+++ b/src/citra/default_ini.h
@@ -250,6 +250,10 @@ volume =
# 1 (default): Yes, 0: No
use_virtual_sd =
+# Whether to use custom storage locations
+# 1: Yes, 0 (default): No
+use_custom_storage =
+
# The path of the virtual SD card directory.
# empty (default) will use the user_path
sdmc_directory =
diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp
index f48609849..b4dcd4759 100644
--- a/src/citra_qt/configuration/config.cpp
+++ b/src/citra_qt/configuration/config.cpp
@@ -304,21 +304,17 @@ void Config::ReadDataStorageValues() {
Settings::values.use_virtual_sd = ReadSetting(QStringLiteral("use_virtual_sd"), true).toBool();
+ Settings::values.use_custom_storage =
+ ReadSetting(QStringLiteral("use_custom_storage"), false).toBool();
const std::string nand_dir =
- ReadSetting(
- QStringLiteral("nand_directory"),
- QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::NANDDir)))
- .toString()
- .toStdString();
+ ReadSetting(QStringLiteral("nand_directory"), QStringLiteral("")).toString().toStdString();
const std::string sdmc_dir =
- ReadSetting(
- QStringLiteral("sdmc_directory"),
- QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::SDMCDir)))
- .toString()
- .toStdString();
+ ReadSetting(QStringLiteral("sdmc_directory"), QStringLiteral("")).toString().toStdString();
- FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir, nand_dir);
- FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir, sdmc_dir);
+ if (Settings::values.use_custom_storage) {
+ FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir, nand_dir);
+ FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir, sdmc_dir);
+ }
qt_config->endGroup();
}
@@ -869,12 +865,13 @@ void Config::SaveDataStorageValues() {
qt_config->beginGroup(QStringLiteral("Data Storage"));
WriteSetting(QStringLiteral("use_virtual_sd"), Settings::values.use_virtual_sd, true);
+ WriteSetting(QStringLiteral("use_custom_storage"), Settings::values.use_custom_storage, false);
WriteSetting(QStringLiteral("nand_directory"),
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)),
- QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::NANDDir)));
+ QStringLiteral(""));
WriteSetting(QStringLiteral("sdmc_directory"),
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)),
- QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::SDMCDir)));
+ QStringLiteral(""));
qt_config->endGroup();
}
diff --git a/src/citra_qt/configuration/configure_storage.cpp b/src/citra_qt/configuration/configure_storage.cpp
index dcc414630..043254350 100644
--- a/src/citra_qt/configuration/configure_storage.cpp
+++ b/src/citra_qt/configuration/configure_storage.cpp
@@ -51,28 +51,42 @@ ConfigureStorage::ConfigureStorage(QWidget* parent)
ApplyConfiguration();
SetConfiguration();
});
+ connect(ui->toggle_custom_storage, &QCheckBox::clicked, this, [this]() {
+ ApplyConfiguration();
+ SetConfiguration();
+ });
}
ConfigureStorage::~ConfigureStorage() = default;
void ConfigureStorage::SetConfiguration() {
- ui->nand_group->setVisible(Settings::values.use_virtual_sd);
+ ui->nand_group->setVisible(Settings::values.use_custom_storage);
QString nand_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
ui->nand_dir_path->setText(nand_path);
ui->open_nand_dir->setEnabled(!nand_path.isEmpty());
- ui->sdmc_group->setVisible(Settings::values.use_virtual_sd);
+ ui->sdmc_group->setVisible(Settings::values.use_virtual_sd &&
+ Settings::values.use_custom_storage);
QString sdmc_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir));
ui->sdmc_dir_path->setText(sdmc_path);
ui->open_sdmc_dir->setEnabled(!sdmc_path.isEmpty());
ui->toggle_virtual_sd->setChecked(Settings::values.use_virtual_sd);
+ ui->toggle_custom_storage->setChecked(Settings::values.use_custom_storage);
ui->storage_group->setEnabled(!Core::System::GetInstance().IsPoweredOn());
}
void ConfigureStorage::ApplyConfiguration() {
Settings::values.use_virtual_sd = ui->toggle_virtual_sd->isChecked();
+ Settings::values.use_custom_storage = ui->toggle_custom_storage->isChecked();
+
+ if (!Settings::values.use_custom_storage) {
+ FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir,
+ GetDefaultUserPath(FileUtil::UserPath::NANDDir));
+ FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir,
+ GetDefaultUserPath(FileUtil::UserPath::SDMCDir));
+ }
}
void ConfigureStorage::RetranslateUI() {
diff --git a/src/citra_qt/configuration/configure_storage.ui b/src/citra_qt/configuration/configure_storage.ui
index 5571d200f..75c5a8a3f 100644
--- a/src/citra_qt/configuration/configure_storage.ui
+++ b/src/citra_qt/configuration/configure_storage.ui
@@ -34,131 +34,147 @@
-
-
+
-
+ Custom Storage
-
+
-
-
-
-
-
-
- NAND Directory
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- Open
-
-
-
-
+
+
+ Use Custom Storage
+
+
-
-
-
-
-
-
- NOTE: This does not move the contents of the previous directory to the new one.
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Change
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
- SDMC Directory
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- Open
-
-
-
-
+
+
+
+
+
+ -
+
+
-
+
+
+ NAND Directory
+
+
+
+ -
+
+
+ false
+
+
+
+ -
+
+
+ Open
+
+
+
+
+
+ -
+
+
-
+
+
+ NOTE: This does not move the contents of the previous directory to the new one.
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Change
+
+
+
+
+
+
+
-
-
-
-
-
-
- NOTE: This does not move the contents of the previous directory to the new one.
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Change
-
-
-
-
+
+
+
+
+
+ -
+
+
-
+
+
+ SDMC Directory
+
+
+
+ -
+
+
+ false
+
+
+
+ -
+
+
+ Open
+
+
+
+
+
+ -
+
+
-
+
+
+ NOTE: This does not move the contents of the previous directory to the new one.
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Change
+
+
+
+
+
+
+
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 436d94406..53071b524 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -774,6 +774,9 @@ const std::string& GetDefaultUserPath(UserPath path) {
}
const void UpdateUserPath(UserPath path, const std::string& filename) {
+ if (filename.empty()) {
+ return;
+ }
if (!FileUtil::IsDirectory(filename)) {
LOG_ERROR(Common_Filesystem, "Path is not a directory. UserPath: {} filename: {}", path,
filename);
diff --git a/src/core/settings.cpp b/src/core/settings.cpp
index c5c1b6155..3a26e7217 100644
--- a/src/core/settings.cpp
+++ b/src/core/settings.cpp
@@ -120,8 +120,11 @@ void LogSettings() {
log_setting("Camera_OuterLeftConfig", values.camera_config[OuterLeftCamera]);
log_setting("Camera_OuterLeftFlip", values.camera_flip[OuterLeftCamera]);
log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd);
- log_setting("DataStorage_SdmcDir", FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir));
- log_setting("DataStorage_NandDir", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
+ log_setting("DataStorage_UseCustomStorage", values.use_custom_storage);
+ if (values.use_custom_storage) {
+ log_setting("DataStorage_SdmcDir", FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir));
+ log_setting("DataStorage_NandDir", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
+ }
log_setting("System_IsNew3ds", values.is_new_3ds);
log_setting("System_RegionValue", values.region_value);
log_setting("Debugging_UseGdbstub", values.use_gdbstub);
diff --git a/src/core/settings.h b/src/core/settings.h
index 98614deae..b7d35e070 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -155,6 +155,7 @@ struct Values {
// Data Storage
bool use_virtual_sd;
+ bool use_custom_storage;
// System
int region_value;