| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <QWidget> |
| 7 |
|
| 8 |
#include <string> |
| 9 |
#include <unordered_map> |
| 10 |
|
| 11 |
#include "Common/CommonTypes.h" |
| 12 |
#include "Core/ActionReplay.h" |
| 13 |
#include "Core/CheatSearch.h" |
| 14 |
|
| 15 |
namespace Core |
| 16 |
{ |
| 17 |
class System; |
| 18 |
} |
| 19 |
|
| 20 |
class QCheckBox; |
| 21 |
class QComboBox; |
| 22 |
class QLabel; |
| 23 |
class QLineEdit; |
| 24 |
class QPushButton; |
| 25 |
class QTableWidget; |
| 26 |
class QTableWidgetItem; |
| 27 |
|
| 28 |
struct CheatSearchTableUserData |
| 29 |
{ |
| 30 |
std::string m_description; |
| 31 |
}; |
| 32 |
|
| 33 |
class CheatSearchWidget : public QWidget |
| 34 |
{ |
| 35 |
Q_OBJECT |
| 36 |
public: |
| 37 |
explicit CheatSearchWidget(Core::System& system, |
| 38 |
std::unique_ptr<Cheats::CheatSearchSessionBase> session, |
| 39 |
QWidget* parent = nullptr); |
| 40 |
~CheatSearchWidget() override; |
| 41 |
|
| 42 |
enum class UpdateSource |
| 43 |
{ |
| 44 |
User, |
| 45 |
Auto, |
| 46 |
}; |
| 47 |
|
| 48 |
bool UpdateTableAllCurrentValues(UpdateSource source); |
| 49 |
void UpdateTableVisibleCurrentValues(UpdateSource source); |
| 50 |
|
| 51 |
signals: |
| 52 |
void ActionReplayCodeGenerated(const ActionReplay::ARCode& ar_code); |
| 53 |
void RequestWatch(QString name, u32 address); |
| 54 |
void ShowMemory(u32 address); |
| 55 |
|
| 56 |
private: |
| 57 |
void CreateWidgets(); |
| 58 |
void ConnectWidgets(); |
| 59 |
|
| 60 |
void OnNextScanClicked(); |
| 61 |
void OnRefreshClicked(); |
| 62 |
void OnResetClicked(); |
| 63 |
void OnAddressTableItemChanged(QTableWidgetItem* item); |
| 64 |
void OnAddressTableContextMenu(); |
| 65 |
void AddMemoryBreakpoints(std::string_view type); |
| 66 |
void OnValueSourceChanged(); |
| 67 |
void OnDisplayHexCheckboxStateChanged(); |
| 68 |
|
| 69 |
void RefreshCurrentValueTableItem(QTableWidgetItem* current_value_table_item); |
| 70 |
void RefreshGUICurrentValues(size_t begin_index, size_t end_index); |
| 71 |
bool UpdateTableRows(const Core::CPUThreadGuard& guard, size_t begin_index, size_t end_index, |
| 72 |
UpdateSource source); |
| 73 |
void RecreateGUITable(); |
| 74 |
void GenerateARCodes(); |
| 75 |
void WriteValue(); |
| 76 |
int GetVisibleRowsBeginIndex() const; |
| 77 |
int GetVisibleRowsEndIndex() const; |
| 78 |
size_t GetTableRowCount() const; |
| 79 |
const std::vector<const QTableWidgetItem*> GetSelectedAddressTableItems() const; |
| 80 |
|
| 81 |
Core::System& m_system; |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
std::unique_ptr<Cheats::CheatSearchSessionBase> m_last_value_session; |
| 86 |
|
| 87 |
|
| 88 |
std::unordered_map<u32, std::string> m_address_table_current_values; |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
std::unordered_map<u32, CheatSearchTableUserData> m_address_table_user_data; |
| 93 |
|
| 94 |
QComboBox* m_compare_type_dropdown; |
| 95 |
QComboBox* m_value_source_dropdown; |
| 96 |
QLineEdit* m_given_value_text; |
| 97 |
QLabel* m_info_label_1; |
| 98 |
QLabel* m_info_label_2; |
| 99 |
QPushButton* m_next_scan_button; |
| 100 |
QPushButton* m_refresh_values_button; |
| 101 |
QPushButton* m_reset_button; |
| 102 |
QCheckBox* m_parse_values_as_hex_checkbox; |
| 103 |
QCheckBox* m_display_values_in_hex_checkbox; |
| 104 |
QCheckBox* m_autoupdate_current_values; |
| 105 |
QTableWidget* m_address_table; |
| 106 |
}; |