diff --git a/Utilities/bin_patch.cpp b/Utilities/bin_patch.cpp index 7c405c33bb..95070eae5a 100644 --- a/Utilities/bin_patch.cpp +++ b/Utilities/bin_patch.cpp @@ -4,6 +4,8 @@ LOG_CHANNEL(patch_log); +static const std::string yml_key_enable_legacy_patches = "Enable Legacy Patches"; + template <> void fmt_class_string::format(std::string& out, u64 arg) { @@ -87,7 +89,8 @@ void patch_engine::load(patch_map& patches_map, const std::string& path) } // Load patch config to determine which patches are enabled - patch_config_map patch_config = load_config(); + bool enable_legacy_patches; + patch_config_map patch_config = load_config(enable_legacy_patches); static const std::string target_version = "1.0"; std::string version; @@ -122,7 +125,7 @@ void patch_engine::load(patch_map& patches_map, const std::string& path) { struct patch_info info{}; info.hash = main_key; - info.enabled = true; + info.enabled = enable_legacy_patches; info.is_legacy = true; read_patch_node(info, pair.second, root); @@ -463,7 +466,7 @@ std::size_t patch_engine::apply_patch(const std::string& name, u8* dst, u32 file return applied_total; } -void patch_engine::save_config(const patch_map& patches_map) +void patch_engine::save_config(const patch_map& patches_map, bool enable_legacy_patches) { const std::string path = get_patch_config_path(); patch_log.notice("Saving patch config file %s", path); @@ -478,6 +481,10 @@ void patch_engine::save_config(const patch_map& patches_map) YAML::Emitter out; out << YAML::BeginMap; + // Save "Enable Legacy Patches" + out << yml_key_enable_legacy_patches << enable_legacy_patches; + + // Save 'enabled' state per hash and description patch_config_map config_map; for (const auto& [hash, title_info] : patches_map) @@ -511,8 +518,10 @@ void patch_engine::save_config(const patch_map& patches_map) file.write(out.c_str(), out.size()); } -patch_engine::patch_config_map patch_engine::load_config() +patch_engine::patch_config_map patch_engine::load_config(bool& enable_legacy_patches) { + enable_legacy_patches = true; // Default to true + patch_config_map config_map; const std::string path = get_patch_config_path(); @@ -528,6 +537,13 @@ patch_engine::patch_config_map patch_engine::load_config() return config_map; } + // Try to load "Enable Legacy Patches" (default to true) + if (auto enable_legacy_node = root[yml_key_enable_legacy_patches]) + { + enable_legacy_patches = enable_legacy_node.as(true); + root.remove(yml_key_enable_legacy_patches); // Remove the node in order to skip it in the next part + } + for (auto pair : root) { auto& hash = pair.first.Scalar(); diff --git a/Utilities/bin_patch.h b/Utilities/bin_patch.h index 92a7dab34d..c3588f563c 100644 --- a/Utilities/bin_patch.h +++ b/Utilities/bin_patch.h @@ -94,10 +94,10 @@ public: static void add_patch_data(YAML::Node node, patch_info& info, u32 modifier, const YAML::Node& root); // Save to patch_config.yml - static void save_config(const patch_map& patches_map); + static void save_config(const patch_map& patches_map, bool enable_legacy_patches); // Load patch_config.yml - static patch_config_map load_config(); + static patch_config_map load_config(bool& enable_legacy_patches); // Load from file and append to member patches map void append_global_patches(); diff --git a/rpcs3/rpcs3qt/emu_settings.cpp b/rpcs3/rpcs3qt/emu_settings.cpp index 530494ee85..afef6996fe 100644 --- a/rpcs3/rpcs3qt/emu_settings.cpp +++ b/rpcs3/rpcs3qt/emu_settings.cpp @@ -262,7 +262,7 @@ void emu_settings::EnhanceCheckBox(QCheckBox* checkbox, emu_settings_type type) m_broken_types.insert(type); } - connect(checkbox, &QCheckBox::stateChanged, [=, this](int val) + connect(checkbox, &QCheckBox::stateChanged, [type, this](int val) { const std::string str = val != 0 ? "true" : "false"; SetSetting(type, str); @@ -303,7 +303,7 @@ void emu_settings::EnhanceSlider(QSlider* slider, emu_settings_type type) slider->setRange(min, max); slider->setValue(val); - connect(slider, &QSlider::valueChanged, [=, this](int value) + connect(slider, &QSlider::valueChanged, [type, this](int value) { SetSetting(type, sstr(value)); }); @@ -404,7 +404,7 @@ void emu_settings::EnhanceLineEdit(QLineEdit* edit, emu_settings_type type) const std::string set_text = GetSetting(type); edit->setText(qstr(set_text)); - connect(edit, &QLineEdit::textChanged, [=, this](const QString &text) + connect(edit, &QLineEdit::textChanged, [type, this](const QString &text) { SetSetting(type, sstr(text)); }); diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.cpp b/rpcs3/rpcs3qt/patch_manager_dialog.cpp index d0f52b536c..21899e2f8c 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/patch_manager_dialog.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "ui_patch_manager_dialog.h" #include "patch_manager_dialog.h" @@ -39,6 +40,10 @@ patch_manager_dialog::patch_manager_dialog(QWidget* parent) ui->setupUi(this); setModal(true); + // Load config for special settings + patch_engine::load_config(m_legacy_patches_enabled); + ui->cb_enable_legacy_patches->setChecked(m_legacy_patches_enabled); + load_patches(); populate_tree(); @@ -50,6 +55,7 @@ patch_manager_dialog::patch_manager_dialog(QWidget* parent) connect(ui->patch_tree, &QTreeWidget::customContextMenuRequested, this, &patch_manager_dialog::on_custom_context_menu_requested); connect(ui->pb_expand_all, &QAbstractButton::clicked, ui->patch_tree, &QTreeWidget::expandAll); connect(ui->pb_collapse_all, &QAbstractButton::clicked, ui->patch_tree, &QTreeWidget::collapseAll); + connect(ui->cb_enable_legacy_patches, &QCheckBox::stateChanged, this, &patch_manager_dialog::on_legacy_patches_enabled); connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close); connect(ui->buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton* button) { @@ -195,7 +201,7 @@ void patch_manager_dialog::populate_tree() void patch_manager_dialog::save() { - patch_engine::save_config(m_map); + patch_engine::save_config(m_map, m_legacy_patches_enabled); } void patch_manager_dialog::filter_patches(const QString& term) @@ -342,3 +348,8 @@ void patch_manager_dialog::on_custom_context_menu_requested(const QPoint &pos) menu->exec(ui->patch_tree->viewport()->mapToGlobal(pos)); } + +void patch_manager_dialog::on_legacy_patches_enabled(int state) +{ + m_legacy_patches_enabled = state == Qt::CheckState::Checked; +} diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.h b/rpcs3/rpcs3qt/patch_manager_dialog.h index 7edeae4b42..86e940d089 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.h +++ b/rpcs3/rpcs3qt/patch_manager_dialog.h @@ -23,6 +23,7 @@ private Q_SLOTS: void on_item_selected(QTreeWidgetItem *current, QTreeWidgetItem *previous); void on_item_changed(QTreeWidgetItem *item, int column); void on_custom_context_menu_requested(const QPoint& pos); + void on_legacy_patches_enabled(int state); private: void load_patches(); @@ -32,6 +33,7 @@ private: void update_patch_info(const patch_engine::patch_info& info); patch_engine::patch_map m_map; + bool m_legacy_patches_enabled = false; Ui::patch_manager_dialog *ui; }; diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.ui b/rpcs3/rpcs3qt/patch_manager_dialog.ui index 0a9e3044b7..3302e5cae1 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.ui +++ b/rpcs3/rpcs3qt/patch_manager_dialog.ui @@ -36,6 +36,13 @@ + + + + Enable Legacy Patches + + +