mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-28 10:02:31 -06:00
Gate use of custom directories behind a variable (#6157)
previous changes had forced every single user to use custom directories for NAND and SDMC. Those paths were saved to the config file and would interact badly with portable builds.
This commit is contained in:
parent
67c4b87184
commit
9626bdf385
8 changed files with 183 additions and 144 deletions
|
@ -203,14 +203,15 @@ void Config::ReadValues() {
|
||||||
Settings::values.use_virtual_sd =
|
Settings::values.use_virtual_sd =
|
||||||
sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
|
sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
|
||||||
|
|
||||||
const std::string default_nand_dir = FileUtil::GetDefaultUserPath(FileUtil::UserPath::NANDDir);
|
Settings::values.use_custom_storage =
|
||||||
FileUtil::UpdateUserPath(
|
sdl2_config->GetBoolean("Data Storage", "use_custom_storage", false);
|
||||||
FileUtil::UserPath::NANDDir,
|
|
||||||
sdl2_config->GetString("Data Storage", "nand_directory", default_nand_dir));
|
if (Settings::values.use_custom_storage) {
|
||||||
const std::string default_sdmc_dir = FileUtil::GetDefaultUserPath(FileUtil::UserPath::SDMCDir);
|
FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir,
|
||||||
FileUtil::UpdateUserPath(
|
sdl2_config->GetString("Data Storage", "nand_directory", ""));
|
||||||
FileUtil::UserPath::SDMCDir,
|
FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir,
|
||||||
sdl2_config->GetString("Data Storage", "sdmc_directory", default_sdmc_dir));
|
sdl2_config->GetString("Data Storage", "sdmc_directory", ""));
|
||||||
|
}
|
||||||
|
|
||||||
// System
|
// System
|
||||||
Settings::values.is_new_3ds = sdl2_config->GetBoolean("System", "is_new_3ds", true);
|
Settings::values.is_new_3ds = sdl2_config->GetBoolean("System", "is_new_3ds", true);
|
||||||
|
|
|
@ -250,6 +250,10 @@ volume =
|
||||||
# 1 (default): Yes, 0: No
|
# 1 (default): Yes, 0: No
|
||||||
use_virtual_sd =
|
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.
|
# The path of the virtual SD card directory.
|
||||||
# empty (default) will use the user_path
|
# empty (default) will use the user_path
|
||||||
sdmc_directory =
|
sdmc_directory =
|
||||||
|
|
|
@ -304,21 +304,17 @@ void Config::ReadDataStorageValues() {
|
||||||
|
|
||||||
Settings::values.use_virtual_sd = ReadSetting(QStringLiteral("use_virtual_sd"), true).toBool();
|
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 =
|
const std::string nand_dir =
|
||||||
ReadSetting(
|
ReadSetting(QStringLiteral("nand_directory"), QStringLiteral("")).toString().toStdString();
|
||||||
QStringLiteral("nand_directory"),
|
|
||||||
QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::NANDDir)))
|
|
||||||
.toString()
|
|
||||||
.toStdString();
|
|
||||||
const std::string sdmc_dir =
|
const std::string sdmc_dir =
|
||||||
ReadSetting(
|
ReadSetting(QStringLiteral("sdmc_directory"), QStringLiteral("")).toString().toStdString();
|
||||||
QStringLiteral("sdmc_directory"),
|
|
||||||
QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::SDMCDir)))
|
|
||||||
.toString()
|
|
||||||
.toStdString();
|
|
||||||
|
|
||||||
|
if (Settings::values.use_custom_storage) {
|
||||||
FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir, nand_dir);
|
FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir, nand_dir);
|
||||||
FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir, sdmc_dir);
|
FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir, sdmc_dir);
|
||||||
|
}
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
}
|
}
|
||||||
|
@ -869,12 +865,13 @@ void Config::SaveDataStorageValues() {
|
||||||
qt_config->beginGroup(QStringLiteral("Data Storage"));
|
qt_config->beginGroup(QStringLiteral("Data Storage"));
|
||||||
|
|
||||||
WriteSetting(QStringLiteral("use_virtual_sd"), Settings::values.use_virtual_sd, true);
|
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"),
|
WriteSetting(QStringLiteral("nand_directory"),
|
||||||
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)),
|
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)),
|
||||||
QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::NANDDir)));
|
QStringLiteral(""));
|
||||||
WriteSetting(QStringLiteral("sdmc_directory"),
|
WriteSetting(QStringLiteral("sdmc_directory"),
|
||||||
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)),
|
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)),
|
||||||
QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::SDMCDir)));
|
QStringLiteral(""));
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,28 +51,42 @@ ConfigureStorage::ConfigureStorage(QWidget* parent)
|
||||||
ApplyConfiguration();
|
ApplyConfiguration();
|
||||||
SetConfiguration();
|
SetConfiguration();
|
||||||
});
|
});
|
||||||
|
connect(ui->toggle_custom_storage, &QCheckBox::clicked, this, [this]() {
|
||||||
|
ApplyConfiguration();
|
||||||
|
SetConfiguration();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigureStorage::~ConfigureStorage() = default;
|
ConfigureStorage::~ConfigureStorage() = default;
|
||||||
|
|
||||||
void ConfigureStorage::SetConfiguration() {
|
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));
|
QString nand_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
|
||||||
ui->nand_dir_path->setText(nand_path);
|
ui->nand_dir_path->setText(nand_path);
|
||||||
ui->open_nand_dir->setEnabled(!nand_path.isEmpty());
|
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));
|
QString sdmc_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir));
|
||||||
ui->sdmc_dir_path->setText(sdmc_path);
|
ui->sdmc_dir_path->setText(sdmc_path);
|
||||||
ui->open_sdmc_dir->setEnabled(!sdmc_path.isEmpty());
|
ui->open_sdmc_dir->setEnabled(!sdmc_path.isEmpty());
|
||||||
|
|
||||||
ui->toggle_virtual_sd->setChecked(Settings::values.use_virtual_sd);
|
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());
|
ui->storage_group->setEnabled(!Core::System::GetInstance().IsPoweredOn());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureStorage::ApplyConfiguration() {
|
void ConfigureStorage::ApplyConfiguration() {
|
||||||
Settings::values.use_virtual_sd = ui->toggle_virtual_sd->isChecked();
|
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() {
|
void ConfigureStorage::RetranslateUI() {
|
||||||
|
|
|
@ -33,6 +33,19 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="custom_storage_group">
|
||||||
|
<property name="title">
|
||||||
|
<string>Custom Storage</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="toggle_custom_storage">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use Custom Storage</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="nand_group">
|
<widget class="QGroupBox" name="nand_group">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -167,6 +180,9 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
|
|
|
@ -774,6 +774,9 @@ const std::string& GetDefaultUserPath(UserPath path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const void UpdateUserPath(UserPath path, const std::string& filename) {
|
const void UpdateUserPath(UserPath path, const std::string& filename) {
|
||||||
|
if (filename.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!FileUtil::IsDirectory(filename)) {
|
if (!FileUtil::IsDirectory(filename)) {
|
||||||
LOG_ERROR(Common_Filesystem, "Path is not a directory. UserPath: {} filename: {}", path,
|
LOG_ERROR(Common_Filesystem, "Path is not a directory. UserPath: {} filename: {}", path,
|
||||||
filename);
|
filename);
|
||||||
|
|
|
@ -120,8 +120,11 @@ void LogSettings() {
|
||||||
log_setting("Camera_OuterLeftConfig", values.camera_config[OuterLeftCamera]);
|
log_setting("Camera_OuterLeftConfig", values.camera_config[OuterLeftCamera]);
|
||||||
log_setting("Camera_OuterLeftFlip", values.camera_flip[OuterLeftCamera]);
|
log_setting("Camera_OuterLeftFlip", values.camera_flip[OuterLeftCamera]);
|
||||||
log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd);
|
log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd);
|
||||||
|
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_SdmcDir", FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir));
|
||||||
log_setting("DataStorage_NandDir", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
|
log_setting("DataStorage_NandDir", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
|
||||||
|
}
|
||||||
log_setting("System_IsNew3ds", values.is_new_3ds);
|
log_setting("System_IsNew3ds", values.is_new_3ds);
|
||||||
log_setting("System_RegionValue", values.region_value);
|
log_setting("System_RegionValue", values.region_value);
|
||||||
log_setting("Debugging_UseGdbstub", values.use_gdbstub);
|
log_setting("Debugging_UseGdbstub", values.use_gdbstub);
|
||||||
|
|
|
@ -155,6 +155,7 @@ struct Values {
|
||||||
|
|
||||||
// Data Storage
|
// Data Storage
|
||||||
bool use_virtual_sd;
|
bool use_virtual_sd;
|
||||||
|
bool use_custom_storage;
|
||||||
|
|
||||||
// System
|
// System
|
||||||
int region_value;
|
int region_value;
|
||||||
|
|
Loading…
Reference in a new issue