diff options
Diffstat (limited to 'src/yuzu')
24 files changed, 281 insertions, 258 deletions
| diff --git a/src/yuzu/applets/profile_select.cpp b/src/yuzu/applets/profile_select.cpp index 4bc8ee726..dca8835ed 100644 --- a/src/yuzu/applets/profile_select.cpp +++ b/src/yuzu/applets/profile_select.cpp @@ -26,7 +26,7 @@ QString FormatUserEntryText(const QString& username, Common::UUID uuid) {  }  QString GetImagePath(Common::UUID uuid) { -    const auto path = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + +    const auto path = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir) +                        "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg";      return QString::fromStdString(path);  } diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index cb71b8d11..a372190cc 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -13,10 +13,12 @@  #include "input_common/udp/client.h"  #include "yuzu/configuration/config.h" +namespace FS = Common::FS; +  Config::Config(const std::string& config_file, bool is_global) {      // TODO: Don't hardcode the path; let the frontend decide where to put the config files. -    qt_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + config_file; -    FileUtil::CreateFullPath(qt_config_loc); +    qt_config_loc = FS::GetUserPath(FS::UserPath::ConfigDir) + config_file; +    FS::CreateFullPath(qt_config_loc);      qt_config =          std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), QSettings::IniFormat);      global = is_global; @@ -464,41 +466,36 @@ void Config::ReadDataStorageValues() {      qt_config->beginGroup(QStringLiteral("Data Storage"));      Settings::values.use_virtual_sd = ReadSetting(QStringLiteral("use_virtual_sd"), true).toBool(); -    FileUtil::GetUserPath( -        FileUtil::UserPath::NANDDir, -        qt_config -            ->value(QStringLiteral("nand_directory"), -                    QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir))) -            .toString() -            .toStdString()); -    FileUtil::GetUserPath( -        FileUtil::UserPath::SDMCDir, -        qt_config -            ->value(QStringLiteral("sdmc_directory"), -                    QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir))) -            .toString() -            .toStdString()); -    FileUtil::GetUserPath( -        FileUtil::UserPath::LoadDir, -        qt_config -            ->value(QStringLiteral("load_directory"), -                    QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::LoadDir))) -            .toString() -            .toStdString()); -    FileUtil::GetUserPath( -        FileUtil::UserPath::DumpDir, -        qt_config -            ->value(QStringLiteral("dump_directory"), -                    QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::DumpDir))) -            .toString() -            .toStdString()); -    FileUtil::GetUserPath( -        FileUtil::UserPath::CacheDir, -        qt_config -            ->value(QStringLiteral("cache_directory"), -                    QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir))) -            .toString() -            .toStdString()); +    FS::GetUserPath(FS::UserPath::NANDDir, +                    qt_config +                        ->value(QStringLiteral("nand_directory"), +                                QString::fromStdString(FS::GetUserPath(FS::UserPath::NANDDir))) +                        .toString() +                        .toStdString()); +    FS::GetUserPath(FS::UserPath::SDMCDir, +                    qt_config +                        ->value(QStringLiteral("sdmc_directory"), +                                QString::fromStdString(FS::GetUserPath(FS::UserPath::SDMCDir))) +                        .toString() +                        .toStdString()); +    FS::GetUserPath(FS::UserPath::LoadDir, +                    qt_config +                        ->value(QStringLiteral("load_directory"), +                                QString::fromStdString(FS::GetUserPath(FS::UserPath::LoadDir))) +                        .toString() +                        .toStdString()); +    FS::GetUserPath(FS::UserPath::DumpDir, +                    qt_config +                        ->value(QStringLiteral("dump_directory"), +                                QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir))) +                        .toString() +                        .toStdString()); +    FS::GetUserPath(FS::UserPath::CacheDir, +                    qt_config +                        ->value(QStringLiteral("cache_directory"), +                                QString::fromStdString(FS::GetUserPath(FS::UserPath::CacheDir))) +                        .toString() +                        .toStdString());      Settings::values.gamecard_inserted =          ReadSetting(QStringLiteral("gamecard_inserted"), false).toBool();      Settings::values.gamecard_current_game = @@ -677,11 +674,11 @@ void Config::ReadScreenshotValues() {      UISettings::values.enable_screenshot_save_as =          ReadSetting(QStringLiteral("enable_screenshot_save_as"), true).toBool(); -    FileUtil::GetUserPath( -        FileUtil::UserPath::ScreenshotsDir, +    FS::GetUserPath( +        FS::UserPath::ScreenshotsDir,          qt_config -            ->value(QStringLiteral("screenshot_path"), QString::fromStdString(FileUtil::GetUserPath( -                                                           FileUtil::UserPath::ScreenshotsDir))) +            ->value(QStringLiteral("screenshot_path"), +                    QString::fromStdString(FS::GetUserPath(FS::UserPath::ScreenshotsDir)))              .toString()              .toStdString()); @@ -1016,20 +1013,20 @@ void Config::SaveDataStorageValues() {      WriteSetting(QStringLiteral("use_virtual_sd"), Settings::values.use_virtual_sd, true);      WriteSetting(QStringLiteral("nand_directory"), -                 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)), -                 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir))); +                 QString::fromStdString(FS::GetUserPath(FS::UserPath::NANDDir)), +                 QString::fromStdString(FS::GetUserPath(FS::UserPath::NANDDir)));      WriteSetting(QStringLiteral("sdmc_directory"), -                 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)), -                 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir))); +                 QString::fromStdString(FS::GetUserPath(FS::UserPath::SDMCDir)), +                 QString::fromStdString(FS::GetUserPath(FS::UserPath::SDMCDir)));      WriteSetting(QStringLiteral("load_directory"), -                 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::LoadDir)), -                 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::LoadDir))); +                 QString::fromStdString(FS::GetUserPath(FS::UserPath::LoadDir)), +                 QString::fromStdString(FS::GetUserPath(FS::UserPath::LoadDir)));      WriteSetting(QStringLiteral("dump_directory"), -                 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::DumpDir)), -                 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::DumpDir))); +                 QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir)), +                 QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir)));      WriteSetting(QStringLiteral("cache_directory"), -                 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir)), -                 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir))); +                 QString::fromStdString(FS::GetUserPath(FS::UserPath::CacheDir)), +                 QString::fromStdString(FS::GetUserPath(FS::UserPath::CacheDir)));      WriteSetting(QStringLiteral("gamecard_inserted"), Settings::values.gamecard_inserted, false);      WriteSetting(QStringLiteral("gamecard_current_game"), Settings::values.gamecard_current_game,                   false); @@ -1180,7 +1177,7 @@ void Config::SaveScreenshotValues() {      WriteSetting(QStringLiteral("enable_screenshot_save_as"),                   UISettings::values.enable_screenshot_save_as);      WriteSetting(QStringLiteral("screenshot_path"), -                 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ScreenshotsDir))); +                 QString::fromStdString(FS::GetUserPath(FS::UserPath::ScreenshotsDir)));      qt_config->endGroup();  } diff --git a/src/yuzu/configuration/configuration_shared.cpp b/src/yuzu/configuration/configuration_shared.cpp index f9becab6e..18482795c 100644 --- a/src/yuzu/configuration/configuration_shared.cpp +++ b/src/yuzu/configuration/configuration_shared.cpp @@ -72,18 +72,18 @@ void ConfigurationShared::SetPerGameSetting(                                                             ConfigurationShared::USE_GLOBAL_OFFSET);  } -void ConfigurationShared::SetHighlight(QWidget* widget, const std::string& name, bool highlighted) { +void ConfigurationShared::SetHighlight(QWidget* widget, bool highlighted) {      if (highlighted) {          widget->setStyleSheet(QStringLiteral("QWidget#%1 { background-color:rgba(0,203,255,0.5) }") -                                  .arg(QString::fromStdString(name))); +                                  .arg(widget->objectName()));      } else {          widget->setStyleSheet(QStringLiteral("QWidget#%1 { background-color:rgba(0,0,0,0) }") -                                  .arg(QString::fromStdString(name))); +                                  .arg(widget->objectName()));      }      widget->show();  } -void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox, const std::string& name, +void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox,                                               const Settings::Setting<bool>& setting,                                               CheckState& tracker) {      if (setting.UsingGlobal()) { @@ -91,45 +91,39 @@ void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox, const std::str      } else {          tracker = (setting.GetValue() == setting.GetValue(true)) ? CheckState::On : CheckState::Off;      } -    SetHighlight(checkbox, name, tracker != CheckState::Global); -    QObject::connect(checkbox, &QCheckBox::clicked, checkbox, -                     [checkbox, name, setting, &tracker]() { -                         tracker = static_cast<CheckState>((static_cast<int>(tracker) + 1) % -                                                           static_cast<int>(CheckState::Count)); -                         if (tracker == CheckState::Global) { -                             checkbox->setChecked(setting.GetValue(true)); -                         } -                         SetHighlight(checkbox, name, tracker != CheckState::Global); -                     }); +    SetHighlight(checkbox, tracker != CheckState::Global); +    QObject::connect(checkbox, &QCheckBox::clicked, checkbox, [checkbox, setting, &tracker] { +        tracker = static_cast<CheckState>((static_cast<int>(tracker) + 1) % +                                          static_cast<int>(CheckState::Count)); +        if (tracker == CheckState::Global) { +            checkbox->setChecked(setting.GetValue(true)); +        } +        SetHighlight(checkbox, tracker != CheckState::Global); +    });  } -void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox, const std::string& name, -                                             bool global, bool state, bool global_state, -                                             CheckState& tracker) { +void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox, bool global, bool state, +                                             bool global_state, CheckState& tracker) {      if (global) {          tracker = CheckState::Global;      } else {          tracker = (state == global_state) ? CheckState::On : CheckState::Off;      } -    SetHighlight(checkbox, name, tracker != CheckState::Global); -    QObject::connect(checkbox, &QCheckBox::clicked, checkbox, -                     [checkbox, name, global_state, &tracker]() { -                         tracker = static_cast<CheckState>((static_cast<int>(tracker) + 1) % -                                                           static_cast<int>(CheckState::Count)); -                         if (tracker == CheckState::Global) { -                             checkbox->setChecked(global_state); -                         } -                         SetHighlight(checkbox, name, tracker != CheckState::Global); -                     }); +    SetHighlight(checkbox, tracker != CheckState::Global); +    QObject::connect(checkbox, &QCheckBox::clicked, checkbox, [checkbox, global_state, &tracker] { +        tracker = static_cast<CheckState>((static_cast<int>(tracker) + 1) % +                                          static_cast<int>(CheckState::Count)); +        if (tracker == CheckState::Global) { +            checkbox->setChecked(global_state); +        } +        SetHighlight(checkbox, tracker != CheckState::Global); +    });  } -void ConfigurationShared::SetColoredComboBox(QComboBox* combobox, QWidget* target, -                                             const std::string& target_name, int global) { +void ConfigurationShared::SetColoredComboBox(QComboBox* combobox, QWidget* target, int global) {      InsertGlobalItem(combobox, global); -    QObject::connect(combobox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), target, -                     [target, target_name](int index) { -                         ConfigurationShared::SetHighlight(target, target_name, index != 0); -                     }); +    QObject::connect(combobox, qOverload<int>(&QComboBox::activated), target, +                     [target](int index) { SetHighlight(target, index != 0); });  }  void ConfigurationShared::InsertGlobalItem(QComboBox* combobox, int global_index) { diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h index 003148c68..312b9e549 100644 --- a/src/yuzu/configuration/configuration_shared.h +++ b/src/yuzu/configuration/configuration_shared.h @@ -39,13 +39,12 @@ void SetPerGameSetting(QComboBox* combobox,  void SetPerGameSetting(QComboBox* combobox,                         const Settings::Setting<Settings::GPUAccuracy>* setting); -void SetHighlight(QWidget* widget, const std::string& name, bool highlighted); -void SetColoredTristate(QCheckBox* checkbox, const std::string& name, -                        const Settings::Setting<bool>& setting, CheckState& tracker); -void SetColoredTristate(QCheckBox* checkbox, const std::string& name, bool global, bool state, -                        bool global_state, CheckState& tracker); -void SetColoredComboBox(QComboBox* combobox, QWidget* target, const std::string& target_name, -                        int global); +void SetHighlight(QWidget* widget, bool highlighted); +void SetColoredTristate(QCheckBox* checkbox, const Settings::Setting<bool>& setting, +                        CheckState& tracker); +void SetColoredTristate(QCheckBox* checkbox, bool global, bool state, bool global_state, +                        CheckState& tracker); +void SetColoredComboBox(QComboBox* combobox, QWidget* target, int global);  void InsertGlobalItem(QComboBox* combobox, int global_index); diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index fea632531..fa9124ecf 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -59,7 +59,7 @@ void ConfigureAudio::SetConfiguration() {              ui->volume_combo_box->setCurrentIndex(1);              ui->volume_slider->setEnabled(true);          } -        ConfigurationShared::SetHighlight(ui->volume_layout, "volume_layout", +        ConfigurationShared::SetHighlight(ui->volume_layout,                                            !Settings::values.volume.UsingGlobal());      }      SetVolumeIndicatorText(ui->volume_slider->sliderPosition()); @@ -173,14 +173,13 @@ void ConfigureAudio::SetupPerGameUI() {          return;      } -    ConfigurationShared::SetColoredTristate(ui->toggle_audio_stretching, "toggle_audio_stretching", +    ConfigurationShared::SetColoredTristate(ui->toggle_audio_stretching,                                              Settings::values.enable_audio_stretching,                                              enable_audio_stretching); -    connect(ui->volume_combo_box, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), -            this, [this](int index) { -                ui->volume_slider->setEnabled(index == 1); -                ConfigurationShared::SetHighlight(ui->volume_layout, "volume_layout", index == 1); -            }); +    connect(ui->volume_combo_box, qOverload<int>(&QComboBox::activated), this, [this](int index) { +        ui->volume_slider->setEnabled(index == 1); +        ConfigurationShared::SetHighlight(ui->volume_layout, index == 1); +    });      ui->output_sink_combo_box->setVisible(false);      ui->output_sink_label->setVisible(false); diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index d0e71dd60..2bfe2c306 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -19,7 +19,8 @@ ConfigureDebug::ConfigureDebug(QWidget* parent) : QWidget(parent), ui(new Ui::Co      SetConfiguration();      connect(ui->open_log_button, &QPushButton::clicked, []() { -        QString path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::LogDir)); +        const auto path = +            QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::LogDir));          QDesktopServices::openUrl(QUrl::fromLocalFile(path));      });  } diff --git a/src/yuzu/configuration/configure_filesystem.cpp b/src/yuzu/configuration/configure_filesystem.cpp index a089f5733..7ab4a80f7 100644 --- a/src/yuzu/configuration/configure_filesystem.cpp +++ b/src/yuzu/configuration/configure_filesystem.cpp @@ -42,16 +42,16 @@ ConfigureFilesystem::~ConfigureFilesystem() = default;  void ConfigureFilesystem::setConfiguration() {      ui->nand_directory_edit->setText( -        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir))); +        QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)));      ui->sdmc_directory_edit->setText( -        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir))); +        QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)));      ui->gamecard_path_edit->setText(QString::fromStdString(Settings::values.gamecard_path));      ui->dump_path_edit->setText( -        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::DumpDir))); +        QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::DumpDir)));      ui->load_path_edit->setText( -        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::LoadDir))); +        QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::LoadDir)));      ui->cache_directory_edit->setText( -        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir))); +        QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::CacheDir)));      ui->gamecard_inserted->setChecked(Settings::values.gamecard_inserted);      ui->gamecard_current_game->setChecked(Settings::values.gamecard_current_game); @@ -64,14 +64,16 @@ void ConfigureFilesystem::setConfiguration() {  }  void ConfigureFilesystem::applyConfiguration() { -    FileUtil::GetUserPath(FileUtil::UserPath::NANDDir, -                          ui->nand_directory_edit->text().toStdString()); -    FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir, -                          ui->sdmc_directory_edit->text().toStdString()); -    FileUtil::GetUserPath(FileUtil::UserPath::DumpDir, ui->dump_path_edit->text().toStdString()); -    FileUtil::GetUserPath(FileUtil::UserPath::LoadDir, ui->load_path_edit->text().toStdString()); -    FileUtil::GetUserPath(FileUtil::UserPath::CacheDir, -                          ui->cache_directory_edit->text().toStdString()); +    Common::FS::GetUserPath(Common::FS::UserPath::NANDDir, +                            ui->nand_directory_edit->text().toStdString()); +    Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir, +                            ui->sdmc_directory_edit->text().toStdString()); +    Common::FS::GetUserPath(Common::FS::UserPath::DumpDir, +                            ui->dump_path_edit->text().toStdString()); +    Common::FS::GetUserPath(Common::FS::UserPath::LoadDir, +                            ui->load_path_edit->text().toStdString()); +    Common::FS::GetUserPath(Common::FS::UserPath::CacheDir, +                            ui->cache_directory_edit->text().toStdString());      Settings::values.gamecard_path = ui->gamecard_path_edit->text().toStdString();      Settings::values.gamecard_inserted = ui->gamecard_inserted->isChecked(); @@ -121,12 +123,13 @@ void ConfigureFilesystem::SetDirectory(DirectoryTarget target, QLineEdit* edit)  }  void ConfigureFilesystem::ResetMetadata() { -    if (!FileUtil::Exists(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir) + DIR_SEP + -                          "game_list")) { +    if (!Common::FS::Exists(Common::FS::GetUserPath(Common::FS::UserPath::CacheDir) + DIR_SEP + +                            "game_list")) {          QMessageBox::information(this, tr("Reset Metadata Cache"),                                   tr("The metadata cache is already empty.")); -    } else if (FileUtil::DeleteDirRecursively(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir) + -                                              DIR_SEP + "game_list")) { +    } else if (Common::FS::DeleteDirRecursively( +                   Common::FS::GetUserPath(Common::FS::UserPath::CacheDir) + DIR_SEP + +                   "game_list")) {          QMessageBox::information(this, tr("Reset Metadata Cache"),                                   tr("The operation completed successfully."));          UISettings::values.is_game_list_reload_pending.exchange(true); diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index c0dbd9855..830096ea0 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -105,10 +105,10 @@ void ConfigureGeneral::SetupPerGameUI() {      ui->toggle_background_pause->setVisible(false);      ui->toggle_hide_mouse->setVisible(false); -    ConfigurationShared::SetColoredTristate(ui->toggle_frame_limit, "toggle_frame_limit", +    ConfigurationShared::SetColoredTristate(ui->toggle_frame_limit,                                              Settings::values.use_frame_limit, use_frame_limit); -    ConfigurationShared::SetColoredTristate(ui->use_multi_core, "use_multi_core", -                                            Settings::values.use_multi_core, use_multi_core); +    ConfigurationShared::SetColoredTristate(ui->use_multi_core, Settings::values.use_multi_core, +                                            use_multi_core);      connect(ui->toggle_frame_limit, &QCheckBox::clicked, ui->frame_limit, [this]() {          ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked() && diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 3e42531c3..07d818548 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -34,9 +34,8 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent)      connect(ui->api, qOverload<int>(&QComboBox::currentIndexChanged), this, [this] {          UpdateDeviceComboBox();          if (!Settings::configuring_global) { -            ConfigurationShared::SetHighlight(ui->api_layout, "api_layout", -                                              ui->api->currentIndex() != -                                                  ConfigurationShared::USE_GLOBAL_INDEX); +            ConfigurationShared::SetHighlight( +                ui->api_layout, ui->api->currentIndex() != ConfigurationShared::USE_GLOBAL_INDEX);          }      });      connect(ui->device, qOverload<int>(&QComboBox::activated), this, @@ -80,17 +79,16 @@ void ConfigureGraphics::SetConfiguration() {          ui->aspect_ratio_combobox->setCurrentIndex(Settings::values.aspect_ratio.GetValue());      } else {          ConfigurationShared::SetPerGameSetting(ui->api, &Settings::values.renderer_backend); -        ConfigurationShared::SetHighlight(ui->api_layout, "api_layout", +        ConfigurationShared::SetHighlight(ui->api_layout,                                            !Settings::values.renderer_backend.UsingGlobal());          ConfigurationShared::SetPerGameSetting(ui->aspect_ratio_combobox,                                                 &Settings::values.aspect_ratio);          ui->bg_combobox->setCurrentIndex(Settings::values.bg_red.UsingGlobal() ? 0 : 1);          ui->bg_button->setEnabled(!Settings::values.bg_red.UsingGlobal()); -        ConfigurationShared::SetHighlight(ui->ar_label, "ar_label", +        ConfigurationShared::SetHighlight(ui->ar_label,                                            !Settings::values.aspect_ratio.UsingGlobal()); -        ConfigurationShared::SetHighlight(ui->bg_layout, "bg_layout", -                                          !Settings::values.bg_red.UsingGlobal()); +        ConfigurationShared::SetHighlight(ui->bg_layout, !Settings::values.bg_red.UsingGlobal());      }      UpdateBackgroundColorButton(QColor::fromRgbF(Settings::values.bg_red.GetValue(), @@ -248,20 +246,18 @@ void ConfigureGraphics::SetupPerGameUI() {          return;      } -    connect(ui->bg_combobox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, -            [this](int index) { -                ui->bg_button->setEnabled(index == 1); -                ConfigurationShared::SetHighlight(ui->bg_layout, "bg_layout", index == 1); -            }); +    connect(ui->bg_combobox, qOverload<int>(&QComboBox::activated), this, [this](int index) { +        ui->bg_button->setEnabled(index == 1); +        ConfigurationShared::SetHighlight(ui->bg_layout, index == 1); +    }); -    ConfigurationShared::SetColoredTristate(ui->use_disk_shader_cache, "use_disk_shader_cache", -                                            Settings::values.use_disk_shader_cache, -                                            use_disk_shader_cache);      ConfigurationShared::SetColoredTristate( -        ui->use_asynchronous_gpu_emulation, "use_asynchronous_gpu_emulation", -        Settings::values.use_asynchronous_gpu_emulation, use_asynchronous_gpu_emulation); +        ui->use_disk_shader_cache, Settings::values.use_disk_shader_cache, use_disk_shader_cache); +    ConfigurationShared::SetColoredTristate(ui->use_asynchronous_gpu_emulation, +                                            Settings::values.use_asynchronous_gpu_emulation, +                                            use_asynchronous_gpu_emulation); -    ConfigurationShared::SetColoredComboBox(ui->aspect_ratio_combobox, ui->ar_label, "ar_label", +    ConfigurationShared::SetColoredComboBox(ui->aspect_ratio_combobox, ui->ar_label,                                              Settings::values.aspect_ratio.GetValue(true));      ConfigurationShared::InsertGlobalItem(          ui->api, static_cast<int>(Settings::values.renderer_backend.GetValue(true))); diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index c5d1a778c..73f276949 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -41,9 +41,9 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {          ConfigurationShared::SetPerGameSetting(ui->gpu_accuracy, &Settings::values.gpu_accuracy);          ConfigurationShared::SetPerGameSetting(ui->anisotropic_filtering_combobox,                                                 &Settings::values.max_anisotropy); -        ConfigurationShared::SetHighlight(ui->label_gpu_accuracy, "label_gpu_accuracy", +        ConfigurationShared::SetHighlight(ui->label_gpu_accuracy,                                            !Settings::values.gpu_accuracy.UsingGlobal()); -        ConfigurationShared::SetHighlight(ui->af_label, "af_label", +        ConfigurationShared::SetHighlight(ui->af_label,                                            !Settings::values.max_anisotropy.UsingGlobal());      }  } @@ -131,20 +131,18 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {          return;      } -    ConfigurationShared::SetColoredTristate(ui->use_vsync, "use_vsync", Settings::values.use_vsync, -                                            use_vsync); -    ConfigurationShared::SetColoredTristate(ui->use_assembly_shaders, "use_assembly_shaders", -                                            Settings::values.use_assembly_shaders, -                                            use_assembly_shaders); +    ConfigurationShared::SetColoredTristate(ui->use_vsync, Settings::values.use_vsync, use_vsync);      ConfigurationShared::SetColoredTristate( -        ui->use_asynchronous_shaders, "use_asynchronous_shaders", -        Settings::values.use_asynchronous_shaders, use_asynchronous_shaders); -    ConfigurationShared::SetColoredTristate(ui->use_fast_gpu_time, "use_fast_gpu_time", +        ui->use_assembly_shaders, Settings::values.use_assembly_shaders, use_assembly_shaders); +    ConfigurationShared::SetColoredTristate(ui->use_asynchronous_shaders, +                                            Settings::values.use_asynchronous_shaders, +                                            use_asynchronous_shaders); +    ConfigurationShared::SetColoredTristate(ui->use_fast_gpu_time,                                              Settings::values.use_fast_gpu_time, use_fast_gpu_time);      ConfigurationShared::SetColoredComboBox( -        ui->gpu_accuracy, ui->label_gpu_accuracy, "label_gpu_accuracy", +        ui->gpu_accuracy, ui->label_gpu_accuracy,          static_cast<int>(Settings::values.gpu_accuracy.GetValue(true)));      ConfigurationShared::SetColoredComboBox( -        ui->anisotropic_filtering_combobox, ui->af_label, "af_label", +        ui->anisotropic_filtering_combobox, ui->af_label,          static_cast<int>(Settings::values.max_anisotropy.GetValue(true)));  } diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui index a793c803d..846a30586 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.ui +++ b/src/yuzu/configuration/configure_graphics_advanced.ui @@ -92,7 +92,7 @@             <string>Enables asynchronous shader compilation, which may reduce shader stutter. This feature is experimental.</string>            </property>            <property name="text"> -           <string>Use asynchronous shader building (experimental, OpenGL or Assembly shaders only)</string> +           <string>Use asynchronous shader building (experimental)</string>            </property>           </widget>          </item> diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp index 6f7fd4414..cbee51a5e 100644 --- a/src/yuzu/configuration/configure_hotkeys.cpp +++ b/src/yuzu/configuration/configure_hotkeys.cpp @@ -154,7 +154,7 @@ void ConfigureHotkeys::ClearAll() {          const QStandardItem* parent = model->item(r, 0);          for (int r2 = 0; r2 < parent->rowCount(); ++r2) { -            model->item(r, 0)->child(r2, 1)->setText(tr("")); +            model->item(r, 0)->child(r2, 1)->setText(QString{});          }      }  } @@ -186,7 +186,7 @@ void ConfigureHotkeys::PopupContextMenu(const QPoint& menu_location) {              model->setData(selected, default_key_sequence.toString(QKeySequence::NativeText));          }      }); -    connect(clear, &QAction::triggered, [this, selected] { model->setData(selected, tr("")); }); +    connect(clear, &QAction::triggered, [this, selected] { model->setData(selected, QString{}); });      context_menu.exec(ui->hotkey_list->viewport()->mapToGlobal(menu_location));  } diff --git a/src/yuzu/configuration/configure_per_game_addons.cpp b/src/yuzu/configuration/configure_per_game_addons.cpp index 478d5d3a1..793fd8975 100644 --- a/src/yuzu/configuration/configure_per_game_addons.cpp +++ b/src/yuzu/configuration/configure_per_game_addons.cpp @@ -79,8 +79,8 @@ void ConfigurePerGameAddons::ApplyConfiguration() {      std::sort(disabled_addons.begin(), disabled_addons.end());      std::sort(current.begin(), current.end());      if (disabled_addons != current) { -        FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir) + DIR_SEP + -                         "game_list" + DIR_SEP + fmt::format("{:016X}.pv.txt", title_id)); +        Common::FS::Delete(Common::FS::GetUserPath(Common::FS::UserPath::CacheDir) + DIR_SEP + +                           "game_list" + DIR_SEP + fmt::format("{:016X}.pv.txt", title_id));      }      Settings::values.disabled_addons[title_id] = disabled_addons; diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index f53423440..6334c4c50 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp @@ -34,7 +34,7 @@ constexpr std::array<u8, 107> backup_jpeg{  };  QString GetImagePath(Common::UUID uuid) { -    const auto path = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + +    const auto path = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir) +                        "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg";      return QString::fromStdString(path);  } @@ -282,7 +282,7 @@ void ConfigureProfileManager::SetUserImage() {      }      const auto raw_path = QString::fromStdString( -        FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "/system/save/8000000000000010"); +        Common::FS::GetUserPath(Common::FS::UserPath::NANDDir) + "/system/save/8000000000000010");      const QFileInfo raw_info{raw_path};      if (raw_info.exists() && !raw_info.isDir() && !QFile::remove(raw_path)) {          QMessageBox::warning(this, tr("Error deleting file"), diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 0c4daf147..9ad43ed8f 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -90,13 +90,13 @@ void ConfigureSystem::SetConfiguration() {                                                 &Settings::values.time_zone_index);          ConfigurationShared::SetPerGameSetting(ui->combo_sound, &Settings::values.sound_index); -        ConfigurationShared::SetHighlight(ui->label_language, "label_language", +        ConfigurationShared::SetHighlight(ui->label_language,                                            !Settings::values.language_index.UsingGlobal()); -        ConfigurationShared::SetHighlight(ui->label_region, "label_region", +        ConfigurationShared::SetHighlight(ui->label_region,                                            !Settings::values.region_index.UsingGlobal()); -        ConfigurationShared::SetHighlight(ui->label_timezone, "label_timezone", +        ConfigurationShared::SetHighlight(ui->label_timezone,                                            !Settings::values.time_zone_index.UsingGlobal()); -        ConfigurationShared::SetHighlight(ui->label_sound, "label_sound", +        ConfigurationShared::SetHighlight(ui->label_sound,                                            !Settings::values.sound_index.UsingGlobal());      }  } @@ -224,22 +224,20 @@ void ConfigureSystem::SetupPerGameUI() {      }      ConfigurationShared::SetColoredComboBox(ui->combo_language, ui->label_language, -                                            "label_language",                                              Settings::values.language_index.GetValue(true)); -    ConfigurationShared::SetColoredComboBox(ui->combo_region, ui->label_region, "label_region", +    ConfigurationShared::SetColoredComboBox(ui->combo_region, ui->label_region,                                              Settings::values.region_index.GetValue(true));      ConfigurationShared::SetColoredComboBox(ui->combo_time_zone, ui->label_timezone, -                                            "label_timezone",                                              Settings::values.time_zone_index.GetValue(true)); -    ConfigurationShared::SetColoredComboBox(ui->combo_sound, ui->label_sound, "label_sound", +    ConfigurationShared::SetColoredComboBox(ui->combo_sound, ui->label_sound,                                              Settings::values.sound_index.GetValue(true));      ConfigurationShared::SetColoredTristate( -        ui->rng_seed_checkbox, "rng_seed_checkbox", Settings::values.rng_seed.UsingGlobal(), +        ui->rng_seed_checkbox, Settings::values.rng_seed.UsingGlobal(),          Settings::values.rng_seed.GetValue().has_value(),          Settings::values.rng_seed.GetValue(true).has_value(), use_rng_seed);      ConfigurationShared::SetColoredTristate( -        ui->custom_rtc_checkbox, "custom_rtc_checkbox", Settings::values.custom_rtc.UsingGlobal(), +        ui->custom_rtc_checkbox, Settings::values.custom_rtc.UsingGlobal(),          Settings::values.custom_rtc.GetValue().has_value(),          Settings::values.custom_rtc.GetValue(true).has_value(), use_custom_rtc);  } diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp index 2c20b68d0..dbe3f78c8 100644 --- a/src/yuzu/configuration/configure_ui.cpp +++ b/src/yuzu/configuration/configure_ui.cpp @@ -61,9 +61,9 @@ ConfigureUi::ConfigureUi(QWidget* parent) : QWidget(parent), ui(new Ui::Configur      // Set screenshot path to user specification.      connect(ui->screenshot_path_button, &QToolButton::pressed, this, [this] {          const QString& filename = -            QFileDialog::getExistingDirectory( -                this, tr("Select Screenshots Path..."), -                QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ScreenshotsDir))) + +            QFileDialog::getExistingDirectory(this, tr("Select Screenshots Path..."), +                                              QString::fromStdString(Common::FS::GetUserPath( +                                                  Common::FS::UserPath::ScreenshotsDir))) +              QDir::separator();          if (!filename.isEmpty()) {              ui->screenshot_path_edit->setText(filename); @@ -82,8 +82,8 @@ void ConfigureUi::ApplyConfiguration() {      UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt();      UISettings::values.enable_screenshot_save_as = ui->enable_screenshot_save_as->isChecked(); -    FileUtil::GetUserPath(FileUtil::UserPath::ScreenshotsDir, -                          ui->screenshot_path_edit->text().toStdString()); +    Common::FS::GetUserPath(Common::FS::UserPath::ScreenshotsDir, +                            ui->screenshot_path_edit->text().toStdString());      Settings::Apply();  } @@ -101,7 +101,7 @@ void ConfigureUi::SetConfiguration() {      ui->enable_screenshot_save_as->setChecked(UISettings::values.enable_screenshot_save_as);      ui->screenshot_path_edit->setText( -        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ScreenshotsDir))); +        QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::ScreenshotsDir)));  }  void ConfigureUi::changeEvent(QEvent* event) { diff --git a/src/yuzu/debugger/profiler.cpp b/src/yuzu/debugger/profiler.cpp index 53049ffd6..0e26f765b 100644 --- a/src/yuzu/debugger/profiler.cpp +++ b/src/yuzu/debugger/profiler.cpp @@ -109,8 +109,7 @@ MicroProfileWidget::MicroProfileWidget(QWidget* parent) : QWidget(parent) {      MicroProfileSetDisplayMode(1); // Timers screen      MicroProfileInitUI(); -    connect(&update_timer, &QTimer::timeout, this, -            static_cast<void (MicroProfileWidget::*)()>(&MicroProfileWidget::update)); +    connect(&update_timer, &QTimer::timeout, this, qOverload<>(&MicroProfileWidget::update));  }  void MicroProfileWidget::paintEvent(QPaintEvent* ev) { diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 62acc3720..6a71d9644 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -406,7 +406,7 @@ bool GameList::isEmpty() const {               type == GameListItemType::SysNandDir)) {              item_model->invisibleRootItem()->removeRow(child->row());              i--; -        }; +        }      }      return !item_model->invisibleRootItem()->hasChildren();  } @@ -502,10 +502,10 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, std::string pat      navigate_to_gamedb_entry->setVisible(it != compatibility_list.end() && program_id != 0);      connect(open_save_location, &QAction::triggered, [this, program_id, path]() { -        emit OpenFolderRequested(GameListOpenTarget::SaveData, path); +        emit OpenFolderRequested(program_id, GameListOpenTarget::SaveData, path);      });      connect(open_mod_location, &QAction::triggered, [this, program_id, path]() { -        emit OpenFolderRequested(GameListOpenTarget::ModData, path); +        emit OpenFolderRequested(program_id, GameListOpenTarget::ModData, path);      });      connect(open_transferable_shader_cache, &QAction::triggered,              [this, program_id]() { emit OpenTransferableShaderCacheRequested(program_id); }); diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h index 483835cce..78e2ba169 100644 --- a/src/yuzu/game_list.h +++ b/src/yuzu/game_list.h @@ -84,7 +84,8 @@ public:  signals:      void GameChosen(QString game_path);      void ShouldCancelWorker(); -    void OpenFolderRequested(GameListOpenTarget target, const std::string& game_path); +    void OpenFolderRequested(u64 program_id, GameListOpenTarget target, +                             const std::string& game_path);      void OpenTransferableShaderCacheRequested(u64 program_id);      void RemoveInstalledEntryRequested(u64 program_id, InstalledEntryType type);      void RemoveFileRequested(u64 program_id, GameListRemoveTarget target); diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 643ca6491..e0ce45fd9 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp @@ -39,12 +39,12 @@ QString GetGameListCachedObject(const std::string& filename, const std::string&          return generator();      } -    const auto path = FileUtil::GetUserPath(FileUtil::UserPath::CacheDir) + DIR_SEP + "game_list" + -                      DIR_SEP + filename + '.' + ext; +    const auto path = Common::FS::GetUserPath(Common::FS::UserPath::CacheDir) + DIR_SEP + +                      "game_list" + DIR_SEP + filename + '.' + ext; -    FileUtil::CreateFullPath(path); +    Common::FS::CreateFullPath(path); -    if (!FileUtil::Exists(path)) { +    if (!Common::FS::Exists(path)) {          const auto str = generator();          QFile file{QString::fromStdString(path)}; @@ -70,14 +70,14 @@ std::pair<std::vector<u8>, std::string> GetGameListCachedObject(          return generator();      } -    const auto path1 = FileUtil::GetUserPath(FileUtil::UserPath::CacheDir) + DIR_SEP + "game_list" + -                       DIR_SEP + filename + ".jpeg"; -    const auto path2 = FileUtil::GetUserPath(FileUtil::UserPath::CacheDir) + DIR_SEP + "game_list" + -                       DIR_SEP + filename + ".appname.txt"; +    const auto path1 = Common::FS::GetUserPath(Common::FS::UserPath::CacheDir) + DIR_SEP + +                       "game_list" + DIR_SEP + filename + ".jpeg"; +    const auto path2 = Common::FS::GetUserPath(Common::FS::UserPath::CacheDir) + DIR_SEP + +                       "game_list" + DIR_SEP + filename + ".appname.txt"; -    FileUtil::CreateFullPath(path1); +    Common::FS::CreateFullPath(path1); -    if (!FileUtil::Exists(path1) || !FileUtil::Exists(path2)) { +    if (!Common::FS::Exists(path1) || !Common::FS::Exists(path2)) {          const auto [icon, nacp] = generator();          QFile file1{QString::fromStdString(path1)}; @@ -208,7 +208,7 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::stri                               file_type_string, program_id),          new GameListItemCompat(compatibility),          new GameListItem(file_type_string), -        new GameListItemSize(FileUtil::GetSize(path)), +        new GameListItemSize(Common::FS::GetSize(path)),      };      if (UISettings::values.show_add_ons) { @@ -289,7 +289,7 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa          }          const std::string physical_name = directory + DIR_SEP + virtual_name; -        const bool is_dir = FileUtil::IsDirectory(physical_name); +        const bool is_dir = Common::FS::IsDirectory(physical_name);          if (!is_dir &&              (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) {              const auto file = vfs->OpenFile(physical_name, FileSys::Mode::Read); @@ -345,7 +345,7 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa          return true;      }; -    FileUtil::ForeachDirectoryEntry(nullptr, dir_path, callback); +    Common::FS::ForeachDirectoryEntry(nullptr, dir_path, callback);  }  void GameListWorker::run() { @@ -374,7 +374,7 @@ void GameListWorker::run() {              ScanFileSystem(ScanTarget::PopulateGameList, game_dir.path.toStdString(),                             game_dir.deep_scan ? 256 : 0, game_list_dir);          } -    }; +    }      emit Finished(watch_list);  } diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 592993c36..c6b7e2c00 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -177,8 +177,8 @@ static void InitializeLogging() {      log_filter.ParseFilterString(Settings::values.log_filter);      Log::SetGlobalFilter(log_filter); -    const std::string& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir); -    FileUtil::CreateFullPath(log_dir); +    const std::string& log_dir = Common::FS::GetUserPath(Common::FS::UserPath::LogDir); +    Common::FS::CreateFullPath(log_dir);      Log::AddBackend(std::make_unique<Log::FileBackend>(log_dir + LOG_FILE));  #ifdef _WIN32      Log::AddBackend(std::make_unique<Log::DebuggerBackend>()); @@ -894,6 +894,8 @@ void GMainWindow::ConnectMenuEvents() {      connect(ui.action_Open_FAQ, &QAction::triggered, this, &GMainWindow::OnOpenFAQ);      connect(ui.action_Restart, &QAction::triggered, this, [this] { BootGame(QString(game_path)); });      connect(ui.action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure); +    connect(ui.action_Configure_Current_Game, &QAction::triggered, this, +            &GMainWindow::OnConfigurePerGame);      // View      connect(ui.action_Single_Window_Mode, &QAction::triggered, this, @@ -1121,7 +1123,7 @@ void GMainWindow::BootGame(const QString& filename) {          title_name = metadata.first->GetApplicationName();      }      if (res != Loader::ResultStatus::Success || title_name.empty()) { -        title_name = FileUtil::GetFilename(filename.toStdString()); +        title_name = Common::FS::GetFilename(filename.toStdString());      }      LOG_INFO(Frontend, "Booting game: {:016X} | {} | {}", title_id, title_name, title_version);      UpdateWindowTitle(title_name, title_version); @@ -1167,6 +1169,7 @@ void GMainWindow::ShutdownGame() {      ui.action_Pause->setEnabled(false);      ui.action_Stop->setEnabled(false);      ui.action_Restart->setEnabled(false); +    ui.action_Configure_Current_Game->setEnabled(false);      ui.action_Report_Compatibility->setEnabled(false);      ui.action_Load_Amiibo->setEnabled(false);      ui.action_Capture_Screenshot->setEnabled(false); @@ -1239,27 +1242,36 @@ void GMainWindow::OnGameListLoadFile(QString game_path) {      BootGame(game_path);  } -void GMainWindow::OnGameListOpenFolder(GameListOpenTarget target, const std::string& game_path) { +void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target, +                                       const std::string& game_path) {      std::string path;      QString open_target; -    const auto v_file = Core::GetGameFileFromPath(vfs, game_path); -    const auto loader = Loader::GetLoader(v_file); -    FileSys::NACP control{}; -    u64 program_id{}; +    const auto [user_save_size, device_save_size] = [this, &program_id, &game_path] { +        FileSys::PatchManager pm{program_id}; +        const auto control = pm.GetControlMetadata().first; +        if (control != nullptr) { +            return std::make_pair(control->GetDefaultNormalSaveSize(), +                                  control->GetDeviceSaveDataSize()); +        } else { +            const auto file = Core::GetGameFileFromPath(vfs, game_path); +            const auto loader = Loader::GetLoader(file); -    loader->ReadControlData(control); -    loader->ReadProgramId(program_id); +            FileSys::NACP nacp{}; +            loader->ReadControlData(nacp); +            return std::make_pair(nacp.GetDefaultNormalSaveSize(), nacp.GetDeviceSaveDataSize()); +        } +    }(); -    const bool has_user_save{control.GetDefaultNormalSaveSize() > 0}; -    const bool has_device_save{control.GetDeviceSaveDataSize() > 0}; +    const bool has_user_save{user_save_size > 0}; +    const bool has_device_save{device_save_size > 0};      ASSERT_MSG(has_user_save != has_device_save, "Game uses both user and device savedata?");      switch (target) {      case GameListOpenTarget::SaveData: {          open_target = tr("Save Data"); -        const std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); +        const std::string nand_dir = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir);          if (has_user_save) {              // User save data @@ -1294,16 +1306,16 @@ void GMainWindow::OnGameListOpenFolder(GameListOpenTarget target, const std::str                                    FileSys::SaveDataType::SaveData, program_id, {}, 0);          } -        if (!FileUtil::Exists(path)) { -            FileUtil::CreateFullPath(path); -            FileUtil::CreateDir(path); +        if (!Common::FS::Exists(path)) { +            Common::FS::CreateFullPath(path); +            Common::FS::CreateDir(path);          }          break;      }      case GameListOpenTarget::ModData: {          open_target = tr("Mod Data"); -        const auto load_dir = FileUtil::GetUserPath(FileUtil::UserPath::LoadDir); +        const auto load_dir = Common::FS::GetUserPath(Common::FS::UserPath::LoadDir);          path = fmt::format("{}{:016X}", load_dir, program_id);          break;      } @@ -1325,7 +1337,7 @@ void GMainWindow::OnGameListOpenFolder(GameListOpenTarget target, const std::str  void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) {      const QString shader_dir = -        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir)); +        QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir));      const QString transferable_shader_cache_folder_path =          shader_dir + QStringLiteral("opengl") + QDir::separator() + QStringLiteral("transferable");      const QString transferable_shader_cache_file_path = @@ -1428,8 +1440,8 @@ void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryT          RemoveAddOnContent(program_id, entry_type);          break;      } -    FileUtil::DeleteDirRecursively(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir) + DIR_SEP + -                                   "game_list"); +    Common::FS::DeleteDirRecursively(Common::FS::GetUserPath(Common::FS::UserPath::CacheDir) + +                                     DIR_SEP + "game_list");      game_list->PopulateAsync(UISettings::values.game_dirs);  } @@ -1519,7 +1531,7 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ  void GMainWindow::RemoveTransferableShaderCache(u64 program_id) {      const QString shader_dir = -        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir)); +        QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir));      const QString transferable_shader_cache_folder_path =          shader_dir + QStringLiteral("opengl") + QDir::separator() + QStringLiteral("transferable");      const QString transferable_shader_cache_file_path = @@ -1543,7 +1555,7 @@ void GMainWindow::RemoveTransferableShaderCache(u64 program_id) {  void GMainWindow::RemoveCustomConfiguration(u64 program_id) {      const QString config_dir = -        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir)); +        QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::ConfigDir));      const QString custom_config_file_path =          config_dir + QString::fromStdString(fmt::format("{:016X}.ini", program_id)); @@ -1590,7 +1602,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa      }      const auto path = fmt::format( -        "{}{:016X}/romfs", FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), *romfs_title_id); +        "{}{:016X}/romfs", Common::FS::GetUserPath(Common::FS::UserPath::DumpDir), *romfs_title_id);      FileSys::VirtualFile romfs; @@ -1670,13 +1682,13 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id,  void GMainWindow::OnGameListOpenDirectory(const QString& directory) {      QString path;      if (directory == QStringLiteral("SDMC")) { -        path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir) + +        path = QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir) +                                        "Nintendo/Contents/registered");      } else if (directory == QStringLiteral("UserNAND")) { -        path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + +        path = QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::NANDDir) +                                        "user/Contents/registered");      } else if (directory == QStringLiteral("SysNAND")) { -        path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + +        path = QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::NANDDir) +                                        "system/Contents/registered");      } else {          path = directory; @@ -1690,8 +1702,10 @@ void GMainWindow::OnGameListOpenDirectory(const QString& directory) {  void GMainWindow::OnGameListAddDirectory() {      const QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory")); -    if (dir_path.isEmpty()) +    if (dir_path.isEmpty()) {          return; +    } +      UISettings::GameDir game_dir{dir_path, false, true};      if (!UISettings::values.game_dirs.contains(game_dir)) {          UISettings::values.game_dirs.append(game_dir); @@ -1718,26 +1732,7 @@ void GMainWindow::OnGameListOpenPerGameProperties(const std::string& file) {          return;      } -    ConfigurePerGame dialog(this, title_id); -    dialog.LoadFromFile(v_file); -    auto result = dialog.exec(); -    if (result == QDialog::Accepted) { -        dialog.ApplyConfiguration(); - -        const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false); -        if (reload) { -            game_list->PopulateAsync(UISettings::values.game_dirs); -        } - -        // Do not cause the global config to write local settings into the config file -        Settings::RestoreGlobalState(); - -        if (!Core::System::GetInstance().IsPoweredOn()) { -            config->Save(); -        } -    } else { -        Settings::RestoreGlobalState(); -    } +    OpenPerGameConfiguration(title_id, file);  }  void GMainWindow::OnMenuLoadFile() { @@ -1882,8 +1877,8 @@ void GMainWindow::OnMenuInstallToNAND() {                                  : tr("%n file(s) failed to install\n", "", failed_files.size()));      QMessageBox::information(this, tr("Install Results"), install_results); -    FileUtil::DeleteDirRecursively(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir) + DIR_SEP + -                                   "game_list"); +    Common::FS::DeleteDirRecursively(Common::FS::GetUserPath(Common::FS::UserPath::CacheDir) + +                                     DIR_SEP + "game_list");      game_list->PopulateAsync(UISettings::values.game_dirs);      ui.action_Install_File_NAND->setEnabled(true);  } @@ -2066,6 +2061,7 @@ void GMainWindow::OnStartGame() {      ui.action_Pause->setEnabled(true);      ui.action_Stop->setEnabled(true);      ui.action_Restart->setEnabled(true); +    ui.action_Configure_Current_Game->setEnabled(true);      ui.action_Report_Compatibility->setEnabled(true);      discord_rpc->Update(); @@ -2255,6 +2251,36 @@ void GMainWindow::OnConfigure() {      UpdateStatusButtons();  } +void GMainWindow::OnConfigurePerGame() { +    const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); +    OpenPerGameConfiguration(title_id, game_path.toStdString()); +} + +void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file_name) { +    const auto v_file = Core::GetGameFileFromPath(vfs, file_name); + +    ConfigurePerGame dialog(this, title_id); +    dialog.LoadFromFile(v_file); +    auto result = dialog.exec(); +    if (result == QDialog::Accepted) { +        dialog.ApplyConfiguration(); + +        const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false); +        if (reload) { +            game_list->PopulateAsync(UISettings::values.game_dirs); +        } + +        // Do not cause the global config to write local settings into the config file +        Settings::RestoreGlobalState(); + +        if (!Core::System::GetInstance().IsPoweredOn()) { +            config->Save(); +        } +    } else { +        Settings::RestoreGlobalState(); +    } +} +  void GMainWindow::OnLoadAmiibo() {      const QString extensions{QStringLiteral("*.bin")};      const QString file_filter = tr("Amiibo File (%1);; All Files (*.*)").arg(extensions); @@ -2302,7 +2328,7 @@ void GMainWindow::LoadAmiibo(const QString& filename) {  void GMainWindow::OnOpenYuzuFolder() {      QDesktopServices::openUrl(QUrl::fromLocalFile( -        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::UserDir)))); +        QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::UserDir))));  }  void GMainWindow::OnAbout() { @@ -2324,7 +2350,7 @@ void GMainWindow::OnCaptureScreenshot() {      const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID();      const auto screenshot_path = -        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ScreenshotsDir)); +        QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::ScreenshotsDir));      const auto date =          QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd_hh-mm-ss-zzz"));      QString filename = QStringLiteral("%1%2_%3.png") @@ -2527,18 +2553,18 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) {          if (res == QMessageBox::Cancel)              return; -        FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::KeysDir) + -                         "prod.keys_autogenerated"); -        FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::KeysDir) + -                         "console.keys_autogenerated"); -        FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::KeysDir) + -                         "title.keys_autogenerated"); +        Common::FS::Delete(Common::FS::GetUserPath(Common::FS::UserPath::KeysDir) + +                           "prod.keys_autogenerated"); +        Common::FS::Delete(Common::FS::GetUserPath(Common::FS::UserPath::KeysDir) + +                           "console.keys_autogenerated"); +        Common::FS::Delete(Common::FS::GetUserPath(Common::FS::UserPath::KeysDir) + +                           "title.keys_autogenerated");      }      Core::Crypto::KeyManager& keys = Core::Crypto::KeyManager::Instance();      if (keys.BaseDeriveNecessary()) {          Core::Crypto::PartitionDataManager pdm{vfs->OpenDirectory( -            FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir), FileSys::Mode::Read)}; +            Common::FS::GetUserPath(Common::FS::UserPath::SysDataDir), FileSys::Mode::Read)};          const auto function = [this, &keys, &pdm] {              keys.PopulateFromPartitionData(pdm); @@ -2870,7 +2896,7 @@ int main(int argc, char* argv[]) {      // If you start a bundle (binary) on OSX without the Terminal, the working directory is "/".      // But since we require the working directory to be the executable path for the location of      // the user folder in the Qt Frontend, we need to cd into that working directory -    const std::string bin_path = FileUtil::GetBundleDirectory() + DIR_SEP + ".."; +    const std::string bin_path = Common::FS::GetBundleDirectory() + DIR_SEP + "..";      chdir(bin_path.c_str());  #endif diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 73a44a3bf..01f9131e5 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -198,7 +198,8 @@ private slots:      void OnOpenFAQ();      /// Called whenever a user selects a game in the game list widget.      void OnGameListLoadFile(QString game_path); -    void OnGameListOpenFolder(GameListOpenTarget target, const std::string& game_path); +    void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target, +                              const std::string& game_path);      void OnTransferableShaderCacheOpenFile(u64 program_id);      void OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryType type);      void OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target); @@ -216,6 +217,7 @@ private slots:      void OnMenuInstallToNAND();      void OnMenuRecentFile();      void OnConfigure(); +    void OnConfigurePerGame();      void OnLoadAmiibo();      void OnOpenYuzuFolder();      void OnAbout(); @@ -249,6 +251,7 @@ private:      void ShowMouseCursor();      void OpenURL(const QUrl& url);      void LoadTranslation(); +    void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);      Ui::MainWindow ui; diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui index c3a1d715e..87ea985d8 100644 --- a/src/yuzu/main.ui +++ b/src/yuzu/main.ui @@ -81,6 +81,7 @@      <addaction name="action_Restart"/>      <addaction name="separator"/>      <addaction name="action_Configure"/> +    <addaction name="action_Configure_Current_Game"/>     </widget>     <widget class="QMenu" name="menu_View">      <property name="title"> @@ -287,6 +288,14 @@      <string>Capture Screenshot</string>     </property>    </action> +  <action name="action_Configure_Current_Game"> +   <property name="enabled"> +    <bool>false</bool> +   </property> +   <property name="text"> +    <string>Configure Current Game..</string> +   </property> +  </action>   </widget>   <resources/>   <connections/> diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index bbfeafc55..2d2e82f15 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -29,14 +29,14 @@ extern const Themes themes;  struct GameDir {      QString path; -    bool deep_scan; -    bool expanded; +    bool deep_scan = false; +    bool expanded = false;      bool operator==(const GameDir& rhs) const {          return path == rhs.path; -    }; +    }      bool operator!=(const GameDir& rhs) const {          return !operator==(rhs); -    }; +    }  };  struct Values { | 
