mirror of https://github.com/RPCS3/rpcs3.git
patch_manager: warning for incompatible patches (#8535)
* patch_manager: warning for incompatible patches This will open a warning dialog whenever the patch manager is opened and incompatible patches are detected. * Apply suggestions from code review Co-authored-by: Bird Egop <sampletext32@bk.ru> Co-authored-by: Bird Egop <sampletext32@bk.ru>
This commit is contained in:
parent
bd14429f20
commit
55e907385b
|
@ -6,8 +6,6 @@
|
||||||
|
|
||||||
LOG_CHANNEL(patch_log);
|
LOG_CHANNEL(patch_log);
|
||||||
|
|
||||||
static const std::string patch_engine_version = "1.2";
|
|
||||||
|
|
||||||
namespace config_key
|
namespace config_key
|
||||||
{
|
{
|
||||||
static const std::string enable_legacy_patches = "Enable Legacy Patches";
|
static const std::string enable_legacy_patches = "Enable Legacy Patches";
|
||||||
|
@ -84,6 +82,11 @@ std::string patch_engine::get_patch_config_path()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string patch_engine::get_patches_path()
|
||||||
|
{
|
||||||
|
return fs::get_config_dir() + "patches/";
|
||||||
|
}
|
||||||
|
|
||||||
std::string patch_engine::get_imported_patch_path()
|
std::string patch_engine::get_imported_patch_path()
|
||||||
{
|
{
|
||||||
return fs::get_config_dir() + "patches/imported_patch.yml";
|
return fs::get_config_dir() + "patches/imported_patch.yml";
|
||||||
|
|
|
@ -20,6 +20,8 @@ namespace patch_key
|
||||||
static const std::string version = "Version";
|
static const std::string version = "Version";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const std::string patch_engine_version = "1.2";
|
||||||
|
|
||||||
enum class patch_type
|
enum class patch_type
|
||||||
{
|
{
|
||||||
invalid,
|
invalid,
|
||||||
|
@ -90,6 +92,9 @@ public:
|
||||||
// Returns the directory in which patch_config.yml is located
|
// Returns the directory in which patch_config.yml is located
|
||||||
static std::string get_patch_config_path();
|
static std::string get_patch_config_path();
|
||||||
|
|
||||||
|
// Returns the directory in which patches are located
|
||||||
|
static std::string get_patches_path();
|
||||||
|
|
||||||
// Returns the filepath for the imported_patch.yml
|
// Returns the filepath for the imported_patch.yml
|
||||||
static std::string get_imported_patch_path();
|
static std::string get_imported_patch_path();
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "ui_patch_manager_dialog.h"
|
#include "ui_patch_manager_dialog.h"
|
||||||
#include "patch_manager_dialog.h"
|
#include "patch_manager_dialog.h"
|
||||||
|
@ -100,7 +101,7 @@ int patch_manager_dialog::exec()
|
||||||
|
|
||||||
void patch_manager_dialog::refresh(bool restore_layout)
|
void patch_manager_dialog::refresh(bool restore_layout)
|
||||||
{
|
{
|
||||||
load_patches();
|
load_patches(restore_layout);
|
||||||
populate_tree();
|
populate_tree();
|
||||||
filter_patches(ui->patch_filter->text());
|
filter_patches(ui->patch_filter->text());
|
||||||
|
|
||||||
|
@ -120,13 +121,13 @@ void patch_manager_dialog::refresh(bool restore_layout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void patch_manager_dialog::load_patches()
|
void patch_manager_dialog::load_patches(bool show_error)
|
||||||
{
|
{
|
||||||
m_map.clear();
|
m_map.clear();
|
||||||
|
|
||||||
// NOTE: Make sure these paths are loaded in the same order as they are applied on boot
|
// NOTE: Make sure these paths are loaded in the same order as they are applied on boot
|
||||||
|
|
||||||
const std::string patches_path = fs::get_config_dir() + "patches/";
|
const std::string patches_path = patch_engine::get_patches_path();
|
||||||
const QStringList filters = QStringList() << "*_patch.yml";
|
const QStringList filters = QStringList() << "*_patch.yml";
|
||||||
|
|
||||||
QStringList path_list;
|
QStringList path_list;
|
||||||
|
@ -135,9 +136,25 @@ void patch_manager_dialog::load_patches()
|
||||||
path_list << QDir(QString::fromStdString(patches_path)).entryList(filters);
|
path_list << QDir(QString::fromStdString(patches_path)).entryList(filters);
|
||||||
path_list.removeDuplicates(); // make sure to load patch.yml and imported_patch.yml only once
|
path_list.removeDuplicates(); // make sure to load patch.yml and imported_patch.yml only once
|
||||||
|
|
||||||
|
bool has_errors = false;
|
||||||
|
|
||||||
for (const auto& path : path_list)
|
for (const auto& path : path_list)
|
||||||
{
|
{
|
||||||
patch_engine::load(m_map, patches_path + path.toStdString());
|
if (!patch_engine::load(m_map, patches_path + path.toStdString()))
|
||||||
|
{
|
||||||
|
has_errors = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (show_error && has_errors)
|
||||||
|
{
|
||||||
|
// Open a warning dialog after the patch manager was opened
|
||||||
|
QTimer::singleShot(100, [this, patches_path]()
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, tr("Incompatible patches detected"),
|
||||||
|
tr("Some of your patches are not compatible with the current version of RPCS3's Patch Manager.\n\nMake sure that all the patches located in \"%0\" contain the proper formatting that is required for the Patch Manager Version %1.")
|
||||||
|
.arg(QString::fromStdString(patches_path)).arg(QString::fromStdString(patch_engine_version)));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ private Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void refresh(bool restore_layout = false);
|
void refresh(bool restore_layout = false);
|
||||||
void load_patches();
|
void load_patches(bool show_error);
|
||||||
void populate_tree();
|
void populate_tree();
|
||||||
void save_config();
|
void save_config();
|
||||||
void update_patch_info(const gui_patch_info& info);
|
void update_patch_info(const gui_patch_info& info);
|
||||||
|
|
Loading…
Reference in New Issue