Disable memory patches in hardcore mode

Memory patches would be an easy way to manipulate the memory needed to calculate achievement logic, so they must be disabled. Riivolution patches that do not affect memory are allowed, as they will be hashed with the game file.
This commit is contained in:
LillyJadeKatrin
2023-11-15 12:03:21 -05:00
parent cb2fa9a1f2
commit 1a19a92943
12 changed files with 103 additions and 10 deletions

View File

@ -14,6 +14,7 @@
#include "Core/ConfigManager.h"
#include "Core/PatchEngine.h"
#include "DolphinQt/Config/HardcoreWarningWidget.h"
#include "DolphinQt/Config/NewPatchDialog.h"
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
@ -40,23 +41,38 @@ PatchesWidget::PatchesWidget(const UICommon::GameFile& game)
void PatchesWidget::CreateWidgets()
{
#ifdef USE_RETRO_ACHIEVEMENTS
m_hc_warning = new HardcoreWarningWidget(this);
#endif // USE_RETRO_ACHIEVEMENTS
m_list = new QListWidget;
m_add_button = new QPushButton(tr("&Add..."));
m_edit_button = new QPushButton();
m_remove_button = new QPushButton(tr("&Remove"));
auto* layout = new QGridLayout;
auto* grid_layout = new QGridLayout;
layout->addWidget(m_list, 0, 0, 1, -1);
layout->addWidget(m_add_button, 1, 0);
layout->addWidget(m_edit_button, 1, 2);
layout->addWidget(m_remove_button, 1, 1);
grid_layout->addWidget(m_list, 0, 0, 1, -1);
grid_layout->addWidget(m_add_button, 1, 0);
grid_layout->addWidget(m_edit_button, 1, 2);
grid_layout->addWidget(m_remove_button, 1, 1);
auto* layout = new QVBoxLayout;
#ifdef USE_RETRO_ACHIEVEMENTS
layout->addWidget(m_hc_warning);
#endif // USE_RETRO_ACHIEVEMENTS
layout->addLayout(grid_layout);
setLayout(layout);
}
void PatchesWidget::ConnectWidgets()
{
#ifdef USE_RETRO_ACHIEVEMENTS
connect(m_hc_warning, &HardcoreWarningWidget::OpenAchievementSettings, this,
&PatchesWidget::OpenAchievementSettings);
#endif // USE_RETRO_ACHIEVEMENTS
connect(m_list, &QListWidget::itemSelectionChanged, this, &PatchesWidget::UpdateActions);
connect(m_list, &QListWidget::itemChanged, this, &PatchesWidget::OnItemChanged);
connect(m_remove_button, &QPushButton::clicked, this, &PatchesWidget::OnRemove);

View File

@ -9,12 +9,11 @@
#include <QWidget>
#include "Common/CommonTypes.h"
#include "Core/PatchEngine.h"
namespace PatchEngine
{
struct Patch;
}
#ifdef USE_RETRO_ACHIEVEMENTS
class HardcoreWarningWidget;
#endif // USE_RETRO_ACHIEVEMENTS
class QListWidget;
class QListWidgetItem;
class QPushButton;
@ -26,9 +25,15 @@ class GameFile;
class PatchesWidget : public QWidget
{
Q_OBJECT
public:
explicit PatchesWidget(const UICommon::GameFile& game);
#ifdef USE_RETRO_ACHIEVEMENTS
signals:
void OpenAchievementSettings();
#endif // USE_RETRO_ACHIEVEMENTS
private:
void CreateWidgets();
void ConnectWidgets();
@ -41,6 +46,9 @@ private:
void OnRemove();
void OnEdit();
#ifdef USE_RETRO_ACHIEVEMENTS
HardcoreWarningWidget* m_hc_warning;
#endif // USE_RETRO_ACHIEVEMENTS
QListWidget* m_list;
QPushButton* m_add_button;
QPushButton* m_edit_button;

View File

@ -51,6 +51,10 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& ga
&PropertiesDialog::OpenGeneralSettings);
connect(ar, &ARCodeWidget::OpenGeneralSettings, this, &PropertiesDialog::OpenGeneralSettings);
#ifdef USE_RETRO_ACHIEVEMENTS
connect(patches, &PatchesWidget::OpenAchievementSettings, this,
&PropertiesDialog::OpenAchievementSettings);
#endif // USE_RETRO_ACHIEVEMENTS
connect(graphics_mod_list, &GraphicsModListWidget::OpenGraphicsSettings, this,
&PropertiesDialog::OpenGraphicsSettings);

View File

@ -19,4 +19,7 @@ public:
signals:
void OpenGeneralSettings();
void OpenGraphicsSettings();
#ifdef USE_RETRO_ACHIEVEMENTS
void OpenAchievementSettings();
#endif // USE_RETRO_ACHIEVEMENTS
};