CheatsSettings/PatchSettings: Add toggle for showing All CRCs

This used to be off by default, but was changed to show found patches/cheats for all CRCs for a game serial. However, this also clutters and shows cheats for CRCs that may not be applicable without a way to hide them.

This puts this setting behind a toggle to choose if this should be enabled/disabled so the user has choice. Still defaults to enabled to keep current behavior.
This commit is contained in:
Dan McCarthy 2023-12-31 18:23:27 -06:00 committed by refractionpcsx2
parent 44e2837efb
commit 6b12ca5b39
7 changed files with 39 additions and 7 deletions

View File

@ -23,6 +23,7 @@ GameCheatSettingsWidget::GameCheatSettingsWidget(SettingsWindow* dialog, QWidget
SettingsInterface* sif = m_dialog->getSettingsInterface(); SettingsInterface* sif = m_dialog->getSettingsInterface();
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableCheats, "EmuCore", "EnableCheats", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableCheats, "EmuCore", "EnableCheats", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.allCRCsCheckbox, "EmuCore", "ShowCheatsForAllCRCs", false);
updateListEnabled(); updateListEnabled();
connect(m_ui.enableCheats, &QCheckBox::stateChanged, this, &GameCheatSettingsWidget::updateListEnabled); connect(m_ui.enableCheats, &QCheckBox::stateChanged, this, &GameCheatSettingsWidget::updateListEnabled);
@ -31,6 +32,7 @@ GameCheatSettingsWidget::GameCheatSettingsWidget(SettingsWindow* dialog, QWidget
connect(m_ui.reloadCheats, &QPushButton::clicked, this, &GameCheatSettingsWidget::onReloadClicked); connect(m_ui.reloadCheats, &QPushButton::clicked, this, &GameCheatSettingsWidget::onReloadClicked);
connect(m_ui.enableAll, &QPushButton::clicked, this, [this]() { setStateForAll(true); }); connect(m_ui.enableAll, &QPushButton::clicked, this, [this]() { setStateForAll(true); });
connect(m_ui.disableAll, &QPushButton::clicked, this, [this]() { setStateForAll(false); }); connect(m_ui.disableAll, &QPushButton::clicked, this, [this]() { setStateForAll(false); });
connect(m_ui.allCRCsCheckbox, &QCheckBox::stateChanged, this, &GameCheatSettingsWidget::onReloadClicked);
} }
GameCheatSettingsWidget::~GameCheatSettingsWidget() = default; GameCheatSettingsWidget::~GameCheatSettingsWidget() = default;
@ -78,6 +80,7 @@ void GameCheatSettingsWidget::updateListEnabled()
m_ui.enableAll->setEnabled(cheats_enabled); m_ui.enableAll->setEnabled(cheats_enabled);
m_ui.disableAll->setEnabled(cheats_enabled); m_ui.disableAll->setEnabled(cheats_enabled);
m_ui.reloadCheats->setEnabled(cheats_enabled); m_ui.reloadCheats->setEnabled(cheats_enabled);
m_ui.allCRCsCheckbox->setEnabled(cheats_enabled);
} }
void GameCheatSettingsWidget::disableAllCheats() void GameCheatSettingsWidget::disableAllCheats()
@ -145,7 +148,8 @@ void GameCheatSettingsWidget::setStateRecursively(QTreeWidgetItem* parent, bool
void GameCheatSettingsWidget::reloadList() void GameCheatSettingsWidget::reloadList()
{ {
u32 num_unlabelled_codes = 0; u32 num_unlabelled_codes = 0;
m_patches = Patch::GetPatchInfo(m_dialog->getSerial(), m_dialog->getDiscCRC(), true, &num_unlabelled_codes); bool showAllCRCS = m_ui.allCRCsCheckbox->isChecked();
m_patches = Patch::GetPatchInfo(m_dialog->getSerial(), m_dialog->getDiscCRC(), true, showAllCRCS, & num_unlabelled_codes);
m_enabled_patches = m_enabled_patches =
m_dialog->getSettingsInterface()->GetStringList(Patch::CHEATS_CONFIG_SECTION, Patch::PATCH_ENABLE_CONFIG_KEY); m_dialog->getSettingsInterface()->GetStringList(Patch::CHEATS_CONFIG_SECTION, Patch::PATCH_ENABLE_CONFIG_KEY);

View File

@ -84,6 +84,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="allCRCsCheckbox">
<property name="text">
<string>All CRCs</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">

View File

@ -5,6 +5,7 @@
#include "QtHost.h" #include "QtHost.h"
#include "QtUtils.h" #include "QtUtils.h"
#include "Settings/GamePatchSettingsWidget.h" #include "Settings/GamePatchSettingsWidget.h"
#include "SettingWidgetBinder.h"
#include "Settings/SettingsWindow.h" #include "Settings/SettingsWindow.h"
#include "pcsx2/GameList.h" #include "pcsx2/GameList.h"
@ -57,6 +58,9 @@ GamePatchSettingsWidget::GamePatchSettingsWidget(SettingsWindow* dialog, QWidget
setUnlabeledPatchesWarningVisibility(false); setUnlabeledPatchesWarningVisibility(false);
connect(m_ui.reload, &QPushButton::clicked, this, &GamePatchSettingsWidget::onReloadClicked); connect(m_ui.reload, &QPushButton::clicked, this, &GamePatchSettingsWidget::onReloadClicked);
connect(m_ui.allCRCsCheckbox, &QCheckBox::stateChanged, this, &GamePatchSettingsWidget::onReloadClicked);
SettingsInterface* sif = m_dialog->getSettingsInterface();
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.allCRCsCheckbox, "EmuCore", "ShowPatchesForAllCRCs", false);
reloadList(); reloadList();
} }
@ -82,7 +86,8 @@ void GamePatchSettingsWidget::reloadList()
{ {
// Patches shouldn't have any unlabelled patch groups, because they're new. // Patches shouldn't have any unlabelled patch groups, because they're new.
u32 number_of_unlabeled_patches = 0; u32 number_of_unlabeled_patches = 0;
std::vector<Patch::PatchInfo> patches = Patch::GetPatchInfo(m_dialog->getSerial(), m_dialog->getDiscCRC(), false, &number_of_unlabeled_patches); bool showAllCRCS = m_ui.allCRCsCheckbox->isChecked();
std::vector<Patch::PatchInfo> patches = Patch::GetPatchInfo(m_dialog->getSerial(), m_dialog->getDiscCRC(), false, showAllCRCS, &number_of_unlabeled_patches);
std::vector<std::string> enabled_list = std::vector<std::string> enabled_list =
m_dialog->getSettingsInterface()->GetStringList(Patch::PATCHES_CONFIG_SECTION, Patch::PATCH_ENABLE_CONFIG_KEY); m_dialog->getSettingsInterface()->GetStringList(Patch::PATCHES_CONFIG_SECTION, Patch::PATCH_ENABLE_CONFIG_KEY);

View File

@ -52,6 +52,19 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="allCRCsCheckbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>All CRCs</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">

View File

@ -2414,9 +2414,9 @@ void FullscreenUI::PopulatePatchesAndCheatsList(const std::string_view& serial,
std::sort(list.begin(), list.end(), [](const Patch::PatchInfo& lhs, const Patch::PatchInfo& rhs) { return lhs.name < rhs.name; }); std::sort(list.begin(), list.end(), [](const Patch::PatchInfo& lhs, const Patch::PatchInfo& rhs) { return lhs.name < rhs.name; });
}; };
s_game_patch_list = Patch::GetPatchInfo(serial, crc, false, nullptr); s_game_patch_list = Patch::GetPatchInfo(serial, crc, false, true, nullptr);
sort_patches(s_game_patch_list); sort_patches(s_game_patch_list);
s_game_cheats_list = Patch::GetPatchInfo(serial, crc, true, &s_game_cheat_unlabelled_count); s_game_cheats_list = Patch::GetPatchInfo(serial, crc, true, true, &s_game_cheat_unlabelled_count);
sort_patches(s_game_cheats_list); sort_patches(s_game_cheats_list);
pxAssert(s_game_settings_interface); pxAssert(s_game_settings_interface);

View File

@ -518,14 +518,14 @@ std::string_view Patch::PatchInfo::GetNameParentPart() const
return ret; return ret;
} }
Patch::PatchInfoList Patch::GetPatchInfo(const std::string_view& serial, u32 crc, bool cheats, u32* num_unlabelled_patches) Patch::PatchInfoList Patch::GetPatchInfo(const std::string_view& serial, u32 crc, bool cheats, bool showAllCRCS, u32* num_unlabelled_patches)
{ {
PatchInfoList ret; PatchInfoList ret;
if (num_unlabelled_patches) if (num_unlabelled_patches)
*num_unlabelled_patches = 0; *num_unlabelled_patches = 0;
EnumeratePnachFiles(serial, crc, cheats, true, EnumeratePnachFiles(serial, crc, cheats, showAllCRCS,
[&ret, num_unlabelled_patches](const std::string& filename, const std::string& pnach_data) { [&ret, num_unlabelled_patches](const std::string& filename, const std::string& pnach_data) {
ExtractPatchInfo(&ret, pnach_data, num_unlabelled_patches); ExtractPatchInfo(&ret, pnach_data, num_unlabelled_patches);
}); });

View File

@ -81,7 +81,7 @@ namespace Patch
extern const char* CHEATS_CONFIG_SECTION; extern const char* CHEATS_CONFIG_SECTION;
extern const char* PATCH_ENABLE_CONFIG_KEY; extern const char* PATCH_ENABLE_CONFIG_KEY;
extern PatchInfoList GetPatchInfo(const std::string_view& serial, u32 crc, bool cheats, u32* num_unlabelled_patches); extern PatchInfoList GetPatchInfo(const std::string_view& serial, u32 crc, bool cheats, bool showAllCRCS, u32* num_unlabelled_patches);
/// Returns the path to a new cheat/patch pnach for the specified serial and CRC. /// Returns the path to a new cheat/patch pnach for the specified serial and CRC.
extern std::string GetPnachFilename(const std::string_view& serial, u32 crc, bool cheats); extern std::string GetPnachFilename(const std::string_view& serial, u32 crc, bool cheats);