From 38128b2c27665711d1d27b843e8656b9e890f1e8 Mon Sep 17 00:00:00 2001 From: ElBread3 <92335081+ElBread3@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:33:52 -0500 Subject: [PATCH] add config option --- src/common/config.cpp | 11 +++++++++++ src/common/config.h | 2 ++ src/core/file_sys/fs.cpp | 3 ++- src/emulator.cpp | 7 ++++--- src/qt_gui/game_info.h | 3 ++- src/qt_gui/gui_context_menus.h | 9 ++++++++- src/qt_gui/main_window.cpp | 8 ++++---- src/qt_gui/settings_dialog.cpp | 7 +++++++ src/qt_gui/settings_dialog.ui | 7 +++++++ 9 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 37e51c6554..2508669200 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -60,6 +60,7 @@ static bool vkMarkers = false; static bool vkCrashDiagnostic = false; static s16 cursorState = HideCursorState::Idle; static int cursorHideTimeout = 5; // 5 seconds (default) +static bool separateupdatefolder = false; // Gui std::vector settings_install_dirs = {}; @@ -207,6 +208,10 @@ bool vkCrashDiagnosticEnabled() { return vkCrashDiagnostic; } +bool getSeparateUpdateEnabled() { + return separateupdatefolder; +} + void setGpuId(s32 selectedGpuId) { gpuId = selectedGpuId; } @@ -319,6 +324,10 @@ void setSpecialPadClass(int type) { specialPadClass = type; } +void setSeparateUpdateEnabled(bool use) { + separateupdatefolder = use; +} + void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) { main_window_geometry_x = x; main_window_geometry_y = y; @@ -473,6 +482,7 @@ void load(const std::filesystem::path& path) { } isShowSplash = toml::find_or(general, "showSplash", true); isAutoUpdate = toml::find_or(general, "autoUpdate", false); + separateupdatefolder = toml::find_or(general, "separateUpdateEnabled", false); } if (data.contains("Input")) { @@ -592,6 +602,7 @@ void save(const std::filesystem::path& path) { data["General"]["updateChannel"] = updateChannel; data["General"]["showSplash"] = isShowSplash; data["General"]["autoUpdate"] = isAutoUpdate; + data["General"]["separateUpdateEnabled"] = separateupdatefolder; data["Input"]["cursorState"] = cursorState; data["Input"]["cursorHideTimeout"] = cursorHideTimeout; data["Input"]["backButtonBehavior"] = backButtonBehavior; diff --git a/src/common/config.h b/src/common/config.h index 8e799b55da..00276f657a 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -19,6 +19,7 @@ bool isFullscreenMode(); bool getPlayBGM(); int getBGMvolume(); bool getEnableDiscordRPC(); +bool getSeparateUpdateEnabled(); std::string getLogFilter(); std::string getLogType(); @@ -62,6 +63,7 @@ void setLanguage(u32 language); void setNeoMode(bool enable); void setUserName(const std::string& type); void setUpdateChannel(const std::string& type); +void setSeparateUpdateEnabled(bool use); void setCursorState(s16 cursorState); void setCursorHideTimeout(int newcursorHideTimeout); diff --git a/src/core/file_sys/fs.cpp b/src/core/file_sys/fs.cpp index 9fc44234e1..3c91426ccd 100644 --- a/src/core/file_sys/fs.cpp +++ b/src/core/file_sys/fs.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include "common/config.h" #include "common/string_util.h" #include "core/file_sys/fs.h" @@ -56,7 +57,7 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view guest_directory, b std::filesystem::path host_path = mount->host_path / rel_path; std::filesystem::path patch_path = mount->host_path.string() + "-UPDATE"; - if (std::filesystem::exists(patch_path / rel_path)) { + if (std::filesystem::exists(patch_path / rel_path) && Config::getSeparateUpdateEnabled()) { host_path = patch_path / rel_path; } diff --git a/src/emulator.cpp b/src/emulator.cpp index 4dccb1747a..04375caf2c 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -115,9 +115,10 @@ void Emulator::Run(const std::filesystem::path& file) { u32 fw_version; std::filesystem::path game_patch_folder = file.parent_path().concat("-UPDATE"); - std::filesystem::path sce_sys_folder = std::filesystem::exists(game_patch_folder / "sce_sys") - ? game_patch_folder / "sce_sys" - : file.parent_path() / "sce_sys"; + bool use_game_patch = std::filesystem::exists(game_patch_folder / "sce_sys") && + Config::getSeparateUpdateEnabled(); + std::filesystem::path sce_sys_folder = + use_game_patch ? game_patch_folder / "sce_sys" : file.parent_path() / "sce_sys"; if (std::filesystem::is_directory(sce_sys_folder)) { for (const auto& entry : std::filesystem::directory_iterator(sce_sys_folder)) { if (entry.path().filename() == "param.sfo") { diff --git a/src/qt_gui/game_info.h b/src/qt_gui/game_info.h index 640b25e49f..abe8a2e9ae 100644 --- a/src/qt_gui/game_info.h +++ b/src/qt_gui/game_info.h @@ -28,7 +28,8 @@ class GameInfoClass : public QObject { std::filesystem::path sce_folder_path = filePath / "sce_sys" / "param.sfo"; std::filesystem::path game_update_path = std::filesystem::path(filePath.string() + "-UPDATE"); - if (std::filesystem::exists(game_update_path / "sce_sys" / "param.sfo")) { + if (std::filesystem::exists(game_update_path / "sce_sys" / "param.sfo") && + Config::getSeparateUpdateEnabled()) { sce_folder_path = game_update_path / "sce_sys" / "param.sfo"; } diff --git a/src/qt_gui/gui_context_menus.h b/src/qt_gui/gui_context_menus.h index 0c312cf24e..9a9edbd444 100644 --- a/src/qt_gui/gui_context_menus.h +++ b/src/qt_gui/gui_context_menus.h @@ -295,7 +295,14 @@ class GuiContextMenus : public QObject { Common::FS::PathToQString(game_update_path, m_games[itemID].path.concat("-UPDATE")); QString message_type = tr("Game"); if (selected == deleteUpdate) { - if (!std::filesystem::exists(m_games[itemID].path.concat("-UPDATE"))) { + if (!Config::getSeparateUpdateEnabled()) { + QMessageBox::critical( + nullptr, tr("Error"), + QString(tr("This feature requires the 'Enable Separate Update Folder' " + "config option " + "to work. If you want to use this feature, please enable it."))); + error = true; + } else if (!std::filesystem::exists(m_games[itemID].path.concat("-UPDATE"))) { QMessageBox::critical(nullptr, tr("Error"), QString(tr("This game has no update to delete!"))); error = true; diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index f38f6902c6..270b0882e6 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -678,10 +678,10 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int auto game_install_dir = ids.getSelectedDirectory(); auto game_folder_path = game_install_dir / pkg.GetTitleID(); QString pkgType = QString::fromStdString(pkg.GetPkgFlags()); - auto game_update_path = - pkgType.contains("Patch") - ? Config::getGameInstallDir() / (std::string(pkg.GetTitleID()) + "-UPDATE") - : game_folder_path; + bool use_game_update = pkgType.contains("Patch") && Config::getSeparateUpdateEnabled(); + auto game_update_path = use_game_update ? Config::getGameInstallDir() / + (std::string(pkg.GetTitleID()) + "-UPDATE") + : game_folder_path; if (!std::filesystem::exists(game_update_path)) { std::filesystem::create_directory(game_update_path); } diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index 1cc5a85e46..d1f525e9af 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -132,6 +132,9 @@ SettingsDialog::SettingsDialog(std::span physical_devices, QWidge connect(ui->ps4proCheckBox, &QCheckBox::stateChanged, this, [](int val) { Config::setNeoMode(val); }); + connect(ui->separateUpdatesCheckBox, &QCheckBox::stateChanged, this, + [](int val) { Config::setSeparateUpdateEnabled(val); }); + connect(ui->logTypeComboBox, &QComboBox::currentTextChanged, this, [](const QString& text) { Config::setLogType(text.toStdString()); }); @@ -284,6 +287,7 @@ SettingsDialog::SettingsDialog(std::span physical_devices, QWidge ui->fullscreenCheckBox->installEventFilter(this); ui->showSplashCheckBox->installEventFilter(this); ui->ps4proCheckBox->installEventFilter(this); + ui->separateUpdatesCheckBox->installEventFilter(this); ui->userName->installEventFilter(this); ui->logTypeGroupBox->installEventFilter(this); ui->logFilter->installEventFilter(this); @@ -343,6 +347,7 @@ void SettingsDialog::LoadValuesFromConfig() { ui->logTypeComboBox->setCurrentText(QString::fromStdString(Config::getLogType())); ui->logFilterLineEdit->setText(QString::fromStdString(Config::getLogFilter())); ui->userNameLineEdit->setText(QString::fromStdString(Config::getUserName())); + ui->separateUpdatesCheckBox->setChecked(Config::getSeparateUpdateEnabled()); ui->debugDump->setChecked(Config::debugDump()); ui->vkValidationCheckBox->setChecked(Config::vkValidationEnabled()); @@ -433,6 +438,8 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) { text = tr("showSplashCheckBox"); } else if (elementName == "ps4proCheckBox") { text = tr("ps4proCheckBox"); + } else if (elementName == "separateUpdatesCheckBox") { + text = tr("separateUpdatesCheckBox"); } else if (elementName == "userName") { text = tr("userName"); } else if (elementName == "logTypeGroupBox") { diff --git a/src/qt_gui/settings_dialog.ui b/src/qt_gui/settings_dialog.ui index 9743e51bd9..07ce4fc39a 100644 --- a/src/qt_gui/settings_dialog.ui +++ b/src/qt_gui/settings_dialog.ui @@ -134,6 +134,13 @@ + + + + Enable Separate Update Folder + + +