add capability to change load and shaders directories in Citra filesystem

This commit is contained in:
Nicholas Keane 2021-06-17 13:14:40 -04:00
parent 842031a2eb
commit 21db20d041
8 changed files with 218 additions and 13 deletions

View File

@ -201,10 +201,14 @@ void Config::ReadValues() {
// Data Storage
Settings::values.use_virtual_sd =
sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
Settings::values.load_dir = sdl2_config->GetString(
"Data Storage", "load_directory", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir));
Settings::values.nand_dir = sdl2_config->GetString(
"Data Storage", "nand_directory", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
Settings::values.sdmc_dir = sdl2_config->GetString(
"Data Storage", "sdmc_directory", FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir));
Settings::values.shaders_dir = sdl2_config->GetString(
"Data Storage", "shaders_directory", FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir));
// System
Settings::values.is_new_3ds = sdl2_config->GetBoolean("System", "is_new_3ds", true);

View File

@ -250,6 +250,10 @@ volume =
# 1 (default): Yes, 0: No
use_virtual_sd =
# The path of the Load directory (for mods and textures).
# empty (default) will use the user_path
load_directory =
# The path of the virtual SD card directory.
# empty (default) will use the user_path
sdmc_directory =
@ -258,6 +262,10 @@ sdmc_directory =
# empty (default) will use the user_path
nand_directory =
# The path of the Shaders directory.
# empty (default) will use the user_path
shaders_directory =
[System]
# The system model that Citra will try to emulate
# 0: Old 3DS, 1: New 3DS (default)

View File

@ -302,6 +302,11 @@ void Config::ReadDataStorageValues() {
qt_config->beginGroup(QStringLiteral("Data Storage"));
Settings::values.use_virtual_sd = ReadSetting(QStringLiteral("use_virtual_sd"), true).toBool();
std::string load_dir = FileUtil::GetUserPath(FileUtil::UserPath::LoadDir);
Settings::values.load_dir =
ReadSetting(QStringLiteral("load_directory"), QString::fromStdString(load_dir))
.toString()
.toStdString();
std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
Settings::values.nand_dir =
ReadSetting(QStringLiteral("nand_directory"), QString::fromStdString(nand_dir))
@ -312,6 +317,11 @@ void Config::ReadDataStorageValues() {
ReadSetting(QStringLiteral("sdmc_directory"), QString::fromStdString(sdmc_dir))
.toString()
.toStdString();
std::string shader_dir = FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir);
Settings::values.shaders_dir =
ReadSetting(QStringLiteral("shaders_directory"), QString::fromStdString(shader_dir))
.toString()
.toStdString();
qt_config->endGroup();
}
@ -862,13 +872,18 @@ void Config::SaveDataStorageValues() {
qt_config->beginGroup(QStringLiteral("Data Storage"));
WriteSetting(QStringLiteral("use_virtual_sd"), Settings::values.use_virtual_sd, true);
WriteSetting(QStringLiteral("load_directory"),
QString::fromStdString(Settings::values.load_dir),
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::LoadDir)));
WriteSetting(QStringLiteral("nand_directory"),
QString::fromStdString(Settings::values.nand_dir),
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)));
WriteSetting(QStringLiteral("sdmc_directory"),
QString::fromStdString(Settings::values.sdmc_dir),
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)));
WriteSetting(QStringLiteral("shaders_directory"),
QString::fromStdString(Settings::values.shaders_dir),
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir)));
qt_config->endGroup();
}

View File

@ -15,6 +15,21 @@ ConfigureStorage::ConfigureStorage(QWidget* parent)
ui->setupUi(this);
SetConfiguration();
connect(ui->open_load_dir, &QPushButton::clicked, []() {
QString path = QString::fromStdString(Settings::values.load_dir);
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
});
connect(ui->change_load_dir, &QPushButton::clicked, this, [this]() {
const QString dir_path = QFileDialog::getExistingDirectory(
this, tr("Select Load Directory"), QString::fromStdString(Settings::values.load_dir),
QFileDialog::ShowDirsOnly);
if (!dir_path.isEmpty()) {
Settings::values.load_dir = dir_path.toStdString();
SetConfiguration();
}
});
connect(ui->open_nand_dir, &QPushButton::clicked, []() {
QString path = QString::fromStdString(Settings::values.nand_dir);
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
@ -45,6 +60,21 @@ ConfigureStorage::ConfigureStorage(QWidget* parent)
}
});
connect(ui->open_shaders_dir, &QPushButton::clicked, []() {
QString path = QString::fromStdString(Settings::values.shaders_dir);
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
});
connect(ui->change_shaders_dir, &QPushButton::clicked, this, [this]() {
const QString dir_path = QFileDialog::getExistingDirectory(
this, tr("Select Shaders Directory"), QString::fromStdString(Settings::values.shaders_dir),
QFileDialog::ShowDirsOnly);
if (!dir_path.isEmpty()) {
Settings::values.shaders_dir = dir_path.toStdString();
SetConfiguration();
}
});
connect(ui->toggle_virtual_sd, &QCheckBox::clicked, this, [this]() {
ApplyConfiguration();
SetConfiguration();
@ -54,6 +84,11 @@ ConfigureStorage::ConfigureStorage(QWidget* parent)
ConfigureStorage::~ConfigureStorage() = default;
void ConfigureStorage::SetConfiguration() {
ui->load_group->setVisible(Settings::values.use_virtual_sd);
QString load_path = QString::fromStdString(Settings::values.load_dir);
ui->load_dir_path->setText(load_path);
ui->open_load_dir->setEnabled(!Settings::values.load_path.empty());
ui->nand_group->setVisible(Settings::values.use_virtual_sd);
QString nand_path = QString::fromStdString(Settings::values.nand_dir);
ui->nand_dir_path->setText(nand_path);
@ -64,6 +99,11 @@ void ConfigureStorage::SetConfiguration() {
ui->sdmc_dir_path->setText(sdmc_path);
ui->open_sdmc_dir->setEnabled(!Settings::values.sdmc_dir.empty());
ui->shaders_group->setVisible(Settings::values.use_virtual_sd);
QString shaders_path = QString::fromStdString(Settings::values.shaders_dir);
ui->shaders_dir_path->setText(shaders_path);
ui->open_shaders_dir->setEnabled(!Settings::values.shaders_path.empty());
ui->toggle_virtual_sd->setChecked(Settings::values.use_virtual_sd);
ui->storage_group->setEnabled(!Core::System::GetInstance().IsPoweredOn());

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>681</width>
<height>375</height>
<height>431</height>
</rect>
</property>
<property name="windowTitle">
@ -34,7 +34,7 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="nand_group">
<widget class="QGroupBox" name="load_group">
<property name="title">
<string/>
</property>
@ -44,19 +44,19 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>NAND Directory</string>
<string>Load Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="nand_dir_path">
<widget class="QLineEdit" name="load_dir_path">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="open_nand_dir">
<widget class="QPushButton" name="open_load_dir">
<property name="text">
<string>Open</string>
</property>
@ -86,6 +86,71 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="change_load_dir">
<property name="text">
<string>Change</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="nand_group">
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>NAND Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="nand_dir_path">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="open_nand_dir">
<property name="text">
<string>Open</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>NOTE: this does not move the contents of the previous directory to the new one</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="change_nand_dir">
<property name="text">
@ -103,11 +168,11 @@
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>SDMC Directory</string>
</property>
@ -132,14 +197,14 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label_6">
<property name="text">
<string>NOTE: this does not move the contents of the previous directory to the new one</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -163,6 +228,71 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="shaders_group">
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Shaders Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="shaders_dir_path">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="open_shaders_dir">
<property name="text">
<string>Open</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>NOTE: this does not move the contents of the previous directory to the new one</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="change_shaders_dir">
<property name="text">
<string>Change</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -729,9 +729,13 @@ void SetUserPath(const std::string& path) {
g_paths.emplace(UserPath::LogDir, user_path + LOG_DIR DIR_SEP);
g_paths.emplace(UserPath::CheatsDir, user_path + CHEATS_DIR DIR_SEP);
g_paths.emplace(UserPath::DLLDir, user_path + DLL_DIR DIR_SEP);
g_paths.emplace(UserPath::ShaderDir, user_path + SHADER_DIR DIR_SEP);
g_paths.emplace(UserPath::ShaderDir, !Settings::values.shaders_dir.empty()
? Settings::values.shaders_dir
: user_path + SHADER_DIR DIR_SEP);
g_paths.emplace(UserPath::DumpDir, user_path + DUMP_DIR DIR_SEP);
g_paths.emplace(UserPath::LoadDir, user_path + LOAD_DIR DIR_SEP);
g_paths.emplace(UserPath::LoadDir, !Settings::values.load_dir.empty()
? Settings::values.load_dir
: user_path + LOAD_DIR DIR_SEP);
g_paths.emplace(UserPath::StatesDir, user_path + STATES_DIR DIR_SEP);
}

View File

@ -118,8 +118,10 @@ 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_LoadDir", values.load_dir);
log_setting("DataStorage_SdmcDir", values.sdmc_dir);
log_setting("DataStorage_NandDir", values.nand_dir);
log_setting("DataStorage_ShadersDir", values.shaders_dir);
log_setting("System_IsNew3ds", values.is_new_3ds);
log_setting("System_RegionValue", values.region_value);
log_setting("Debugging_UseGdbstub", values.use_gdbstub);

View File

@ -140,8 +140,10 @@ struct Values {
// Data Storage
bool use_virtual_sd;
std::string load_dir;
std::string nand_dir;
std::string sdmc_dir;
std::string shaders_dir;
// System
int region_value;