Skip to content

Instantly share code, notes, and snippets.

@AdmiralCurtiss
Created July 11, 2021 20:18
Show Gist options
  • Save AdmiralCurtiss/15327767a3a3237b2df70853d57a30b6 to your computer and use it in GitHub Desktop.
Save AdmiralCurtiss/15327767a3a3237b2df70853d57a30b6 to your computer and use it in GitHub Desktop.
diff --git b/Source/Core/DolphinQt/CheatSearchWidget.cpp a/Source/Core/DolphinQt/CheatSearchWidget.cpp
index f644c786ff..7ec10779fd 100644
--- b/Source/Core/DolphinQt/CheatSearchWidget.cpp
+++ a/Source/Core/DolphinQt/CheatSearchWidget.cpp
@@ -45,6 +45,7 @@ constexpr int ADDRESS_TABLE_COLUMN_INDEX_DESCRIPTION = 0;
constexpr int ADDRESS_TABLE_COLUMN_INDEX_ADDRESS = 1;
constexpr int ADDRESS_TABLE_COLUMN_INDEX_LAST_VALUE = 2;
constexpr int ADDRESS_TABLE_COLUMN_INDEX_CURRENT_VALUE = 3;
+constexpr int ADDRESS_TABLE_COLUMN_INDEX_FREEZE_CHECKBOX = 4;
constexpr int AR_SET_BYTE_CMD = 0x00;
constexpr int AR_SET_SHORT_CMD = 0x02;
@@ -404,6 +405,20 @@ void CheatSearchWidget::OnAddressTableItemChanged(QTableWidgetItem* item)
m_address_table_user_data[address].m_description = item->text().toStdString();
break;
}
+ case ADDRESS_TABLE_COLUMN_INDEX_FREEZE_CHECKBOX:
+ {
+ auto& user_data = m_address_table_user_data[address];
+ user_data.m_frozen = item->checkState() == Qt::Checked;
+ PowerPC::debug_interface.UnsetPatch(address);
+ u32 index = item->data(ADDRESS_TABLE_RESULT_INDEX_ROLE).toUInt();
+ if (user_data.m_frozen && m_results && index < m_results->size())
+ {
+ auto sv = (*m_results)[index].GetAsSearchValue();
+ if (sv)
+ PowerPC::debug_interface.SetPatch(address, Cheats::GetValueAsByteVector(*sv));
+ }
+ break;
+ }
default:
break;
}
@@ -582,9 +597,9 @@ void CheatSearchWidget::UpdateGuiTable()
const QSignalBlocker blocker(m_address_table);
m_address_table->clear();
- m_address_table->setColumnCount(4);
- m_address_table->setHorizontalHeaderLabels(
- {tr("Description"), tr("Address"), tr("Last Value"), tr("Current Value")});
+ m_address_table->setColumnCount(5);
+ m_address_table->setHorizontalHeaderLabels({tr("Description"), tr("Address"), tr("Last Value"),
+ tr("Current Value"), tr("Freeze Value")});
const size_t result_count = m_results ? m_results->size() : 0;
const bool too_many_results = result_count > TABLE_MAX_ROWS;
@@ -629,5 +644,13 @@ void CheatSearchWidget::UpdateGuiTable()
current_value_item->setData(ADDRESS_TABLE_ADDRESS_ROLE, address);
current_value_item->setData(ADDRESS_TABLE_RESULT_INDEX_ROLE, static_cast<u32>(i));
m_address_table->setItem(i, ADDRESS_TABLE_COLUMN_INDEX_CURRENT_VALUE, current_value_item);
+
+ auto* freeze_item = new QTableWidgetItem();
+ freeze_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
+ freeze_item->setCheckState(has_user_data && user_data_it->second.m_frozen ? Qt::Checked :
+ Qt::Unchecked);
+ freeze_item->setData(ADDRESS_TABLE_ADDRESS_ROLE, address);
+ freeze_item->setData(ADDRESS_TABLE_RESULT_INDEX_ROLE, static_cast<u32>(i));
+ m_address_table->setItem(i, ADDRESS_TABLE_COLUMN_INDEX_FREEZE_CHECKBOX, freeze_item);
}
}
diff --git b/Source/Core/DolphinQt/CheatSearchWidget.h a/Source/Core/DolphinQt/CheatSearchWidget.h
index 99c6221c6b..b1b66c08cd 100644
--- b/Source/Core/DolphinQt/CheatSearchWidget.h
+++ a/Source/Core/DolphinQt/CheatSearchWidget.h
@@ -29,6 +29,7 @@ class QTableWidgetItem;
struct CheatSearchTableUserData
{
std::string m_description;
+ bool m_frozen = false;
};
class CheatSearchWidget : public QWidget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment