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 // Data Storage
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);
Settings::values.load_dir = sdl2_config->GetString(
"Data Storage", "load_directory", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir));
Settings::values.nand_dir = sdl2_config->GetString( Settings::values.nand_dir = sdl2_config->GetString(
"Data Storage", "nand_directory", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)); "Data Storage", "nand_directory", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
Settings::values.sdmc_dir = sdl2_config->GetString( Settings::values.sdmc_dir = sdl2_config->GetString(
"Data Storage", "sdmc_directory", FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)); "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 // 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);

View File

@ -250,6 +250,10 @@ volume =
# 1 (default): Yes, 0: No # 1 (default): Yes, 0: No
use_virtual_sd = 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. # 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 =
@ -258,6 +262,10 @@ sdmc_directory =
# empty (default) will use the user_path # empty (default) will use the user_path
nand_directory = nand_directory =
# The path of the Shaders directory.
# empty (default) will use the user_path
shaders_directory =
[System] [System]
# The system model that Citra will try to emulate # The system model that Citra will try to emulate
# 0: Old 3DS, 1: New 3DS (default) # 0: Old 3DS, 1: New 3DS (default)

View File

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

View File

@ -15,6 +15,21 @@ ConfigureStorage::ConfigureStorage(QWidget* parent)
ui->setupUi(this); ui->setupUi(this);
SetConfiguration(); 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, []() { connect(ui->open_nand_dir, &QPushButton::clicked, []() {
QString path = QString::fromStdString(Settings::values.nand_dir); QString path = QString::fromStdString(Settings::values.nand_dir);
QDesktopServices::openUrl(QUrl::fromLocalFile(path)); 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]() { connect(ui->toggle_virtual_sd, &QCheckBox::clicked, this, [this]() {
ApplyConfiguration(); ApplyConfiguration();
SetConfiguration(); SetConfiguration();
@ -54,6 +84,11 @@ ConfigureStorage::ConfigureStorage(QWidget* parent)
ConfigureStorage::~ConfigureStorage() = default; ConfigureStorage::~ConfigureStorage() = default;
void ConfigureStorage::SetConfiguration() { 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); ui->nand_group->setVisible(Settings::values.use_virtual_sd);
QString nand_path = QString::fromStdString(Settings::values.nand_dir); QString nand_path = QString::fromStdString(Settings::values.nand_dir);
ui->nand_dir_path->setText(nand_path); ui->nand_dir_path->setText(nand_path);
@ -64,6 +99,11 @@ void ConfigureStorage::SetConfiguration() {
ui->sdmc_dir_path->setText(sdmc_path); ui->sdmc_dir_path->setText(sdmc_path);
ui->open_sdmc_dir->setEnabled(!Settings::values.sdmc_dir.empty()); 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->toggle_virtual_sd->setChecked(Settings::values.use_virtual_sd);
ui->storage_group->setEnabled(!Core::System::GetInstance().IsPoweredOn()); ui->storage_group->setEnabled(!Core::System::GetInstance().IsPoweredOn());

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>681</width> <width>681</width>
<height>375</height> <height>431</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -34,7 +34,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="nand_group"> <widget class="QGroupBox" name="load_group">
<property name="title"> <property name="title">
<string/> <string/>
</property> </property>
@ -44,19 +44,19 @@
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>NAND Directory</string> <string>Load Directory</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="nand_dir_path"> <widget class="QLineEdit" name="load_dir_path">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="open_nand_dir"> <widget class="QPushButton" name="open_load_dir">
<property name="text"> <property name="text">
<string>Open</string> <string>Open</string>
</property> </property>
@ -86,6 +86,71 @@
</property> </property>
</spacer> </spacer>
</item> </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> <item>
<widget class="QPushButton" name="change_nand_dir"> <widget class="QPushButton" name="change_nand_dir">
<property name="text"> <property name="text">
@ -103,11 +168,11 @@
<property name="title"> <property name="title">
<string/> <string/>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_5">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>SDMC Directory</string> <string>SDMC Directory</string>
</property> </property>
@ -132,14 +197,14 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>NOTE: this does not move the contents of the previous directory to the new one</string> <string>NOTE: this does not move the contents of the previous directory to the new one</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_4"> <spacer name="horizontalSpacer_5">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -163,6 +228,71 @@
</layout> </layout>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
</item> </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::LogDir, user_path + LOG_DIR DIR_SEP);
g_paths.emplace(UserPath::CheatsDir, user_path + CHEATS_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::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::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); 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_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_LoadDir", values.load_dir);
log_setting("DataStorage_SdmcDir", values.sdmc_dir); log_setting("DataStorage_SdmcDir", values.sdmc_dir);
log_setting("DataStorage_NandDir", values.nand_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_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);

View File

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