Merge pull request #2555 from CookiePLMonster/cheat-list-fixes

Cheat list fixes
This commit is contained in:
Connor McLaughlin 2021-09-01 15:08:52 +10:00 committed by GitHub
commit 81ec359229
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 6 deletions

View file

@ -179,6 +179,8 @@ void CheatManagerDialog::connectUi()
connect(m_ui.watchTable, &QTableWidget::currentItemChanged, this, &CheatManagerDialog::watchCurrentItemChanged); connect(m_ui.watchTable, &QTableWidget::currentItemChanged, this, &CheatManagerDialog::watchCurrentItemChanged);
connect(m_ui.scanTable, &QTableWidget::itemChanged, this, &CheatManagerDialog::scanItemChanged); connect(m_ui.scanTable, &QTableWidget::itemChanged, this, &CheatManagerDialog::scanItemChanged);
connect(m_ui.watchTable, &QTableWidget::itemChanged, this, &CheatManagerDialog::watchItemChanged); connect(m_ui.watchTable, &QTableWidget::itemChanged, this, &CheatManagerDialog::watchItemChanged);
connect(QtHostInterface::GetInstance(), &QtHostInterface::cheatEnabled, this, &CheatManagerDialog::setCheatCheckState);
} }
void CheatManagerDialog::showEvent(QShowEvent* event) void CheatManagerDialog::showEvent(QShowEvent* event)
@ -488,12 +490,7 @@ void CheatManagerDialog::activateCheat(u32 index)
} }
const bool new_enabled = !cc.enabled; const bool new_enabled = !cc.enabled;
QTreeWidgetItem* item = getItemForCheatIndex(index); setCheatCheckState(index, new_enabled);
if (item)
{
QSignalBlocker sb(m_ui.cheatList);
item->setCheckState(0, new_enabled ? Qt::Checked : Qt::Unchecked);
}
QtHostInterface::GetInstance()->executeOnEmulationThread([index, new_enabled]() { QtHostInterface::GetInstance()->executeOnEmulationThread([index, new_enabled]() {
System::GetCheatList()->SetCodeEnabled(index, new_enabled); System::GetCheatList()->SetCodeEnabled(index, new_enabled);
@ -501,6 +498,16 @@ void CheatManagerDialog::activateCheat(u32 index)
}); });
} }
void CheatManagerDialog::setCheatCheckState(u32 index, bool checked)
{
QTreeWidgetItem* item = getItemForCheatIndex(index);
if (item)
{
QSignalBlocker sb(m_ui.cheatList);
item->setCheckState(0, checked ? Qt::Checked : Qt::Unchecked);
}
}
void CheatManagerDialog::newCategoryClicked() void CheatManagerDialog::newCategoryClicked()
{ {
QString group_name = QInputDialog::getText(this, tr("Add Group"), tr("Group Name:")); QString group_name = QInputDialog::getText(this, tr("Add Group"), tr("Group Name:"));

View file

@ -31,6 +31,7 @@ private Q_SLOTS:
void cheatListItemActivated(QTreeWidgetItem* item); void cheatListItemActivated(QTreeWidgetItem* item);
void cheatListItemChanged(QTreeWidgetItem* item, int column); void cheatListItemChanged(QTreeWidgetItem* item, int column);
void activateCheat(u32 index); void activateCheat(u32 index);
void setCheatCheckState(u32 index, bool checked);
void newCategoryClicked(); void newCategoryClicked();
void addCodeClicked(); void addCodeClicked();
void editCodeClicked(); void editCodeClicked();

View file

@ -1279,6 +1279,7 @@ void QtHostInterface::setCheatEnabled(quint32 index, bool enabled)
} }
SetCheatCodeState(index, enabled, g_settings.auto_load_cheats); SetCheatCodeState(index, enabled, g_settings.auto_load_cheats);
emit cheatEnabled(index, enabled);
} }
void QtHostInterface::applyCheat(quint32 index) void QtHostInterface::applyCheat(quint32 index)

View file

@ -148,6 +148,7 @@ Q_SIGNALS:
void inputProfileLoaded(); void inputProfileLoaded();
void mouseModeRequested(bool relative, bool hide_cursor); void mouseModeRequested(bool relative, bool hide_cursor);
void achievementsLoaded(quint32 id, const QString& game_info_string, quint32 total, quint32 points); void achievementsLoaded(quint32 id, const QString& game_info_string, quint32 total, quint32 points);
void cheatEnabled(quint32 index, bool enabled);
public Q_SLOTS: public Q_SLOTS:
void setDefaultSettings(); void setDefaultSettings();

View file

@ -3891,6 +3891,8 @@ void CommonHostInterface::SetCheatCodeState(u32 index, bool enabled, bool save_t
return; return;
cc.enabled = enabled; cc.enabled = enabled;
if (!enabled)
cc.ApplyOnDisable();
if (enabled) if (enabled)
{ {