summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorLeo Lam <leolino.lam@gmail.com>2017-10-11 11:51:49 +0200
committerGitHub <noreply@github.com>2017-10-11 11:51:49 +0200
commit1fb9e793ac3cac16757c3cda3a4298bfff0daa3a (patch)
tree187c308029db4097851f64f964d1f4d4ca41e420 /Source
parent408bc36b8b4e1620e52bcee8adb3ddcb10504f69 (diff)
parent3c515608570ff5983ef6c9beceb7cd37ef8f94e0 (diff)
Merge pull request #6104 from CyberShadow/pull-20171006-091319
CheatSearchTab: Add UI for manually adding an address
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinWX/Cheats/CheatSearchTab.cpp48
-rw-r--r--Source/Core/DolphinWX/Cheats/CheatSearchTab.h4
2 files changed, 52 insertions, 0 deletions
diff --git a/Source/Core/DolphinWX/Cheats/CheatSearchTab.cpp b/Source/Core/DolphinWX/Cheats/CheatSearchTab.cpp
index 6b106c248d..0fe5e03946 100644
--- a/Source/Core/DolphinWX/Cheats/CheatSearchTab.cpp
+++ b/Source/Core/DolphinWX/Cheats/CheatSearchTab.cpp
@@ -121,6 +121,28 @@ CheatSearchTab::CheatSearchTab(wxWindow* const parent) : wxPanel(parent)
sizer_cheat_search_filter->Add(m_search_type, 0, wxLEFT | wxRIGHT, space5);
sizer_cheat_search_filter->AddSpacer(space5);
+ // manual address textbox
+ m_textctrl_address = new wxTextCtrl(this, wxID_ANY, "0x00000000");
+ m_textctrl_address->SetMinSize(WxUtils::GetTextWidgetMinSize(m_textctrl_value_x, "0x00000000"));
+ m_textctrl_address->SetToolTip(
+ // Gecko / ActionReplay codes do not use a 0x prefix, but the cheat search UI does
+ _("An address to add manually. "
+ "The 0x prefix is optional - all addresses are always in hexadecimal."));
+
+ m_btn_add_address = new wxButton(this, wxID_ANY, _("Add"));
+ m_btn_add_address->SetToolTip(_("Add the specified address manually."));
+ m_btn_add_address->Bind(wxEVT_BUTTON, &CheatSearchTab::OnAddAddressClicked, this);
+
+ wxBoxSizer* box_address = new wxBoxSizer(wxHORIZONTAL);
+ box_address->Add(m_textctrl_address, 0, wxEXPAND);
+ box_address->Add(m_btn_add_address, 1, wxLEFT, space5);
+
+ wxStaticBoxSizer* const sizer_cheat_add_address =
+ new wxStaticBoxSizer(wxVERTICAL, this, _("Add address"));
+ sizer_cheat_add_address->AddSpacer(space5);
+ sizer_cheat_add_address->Add(box_address, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
+ sizer_cheat_add_address->AddSpacer(space5);
+
// button sizer
wxBoxSizer* boxButtons = new wxBoxSizer(wxHORIZONTAL);
boxButtons->Add(m_btn_init_scan, 1);
@@ -130,6 +152,7 @@ CheatSearchTab::CheatSearchTab(wxWindow* const parent) : wxPanel(parent)
wxBoxSizer* const sizer_right = new wxBoxSizer(wxVERTICAL);
sizer_right->Add(m_data_sizes, 0, wxEXPAND);
sizer_right->Add(sizer_cheat_search_filter, 0, wxEXPAND | wxTOP, space5);
+ sizer_right->Add(sizer_cheat_add_address, 0, wxEXPAND | wxTOP, space5);
sizer_right->AddStretchSpacer(1);
sizer_right->Add(m_label_scan_disabled, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, space5);
sizer_right->Add(boxButtons, 0, wxEXPAND | wxTOP, space5);
@@ -207,6 +230,31 @@ void CheatSearchTab::OnNextScanClicked(wxCommandEvent&)
UpdateCheatSearchResultsList();
}
+void CheatSearchTab::OnAddAddressClicked(wxCommandEvent&)
+{
+ unsigned long parsed_address = 0;
+ wxString address = m_textctrl_address->GetValue();
+
+ if (!address.ToULong(&parsed_address, address.StartsWith("0x") ? 0 : 16))
+ {
+ WxUtils::ShowErrorDialog(_("You must enter a valid hexadecimal value."));
+ return;
+ }
+
+ if (parsed_address > Memory::RAM_SIZE - sizeof(double))
+ {
+ WxUtils::ShowErrorDialog(wxString::Format(_("Address too large (greater than RAM size).\n"
+ "Did you mean to strip the cheat opcode (0x%08X)?"),
+ parsed_address & Memory::RAM_MASK));
+ return;
+ }
+
+ CheatSearchResult result;
+ result.address = parsed_address;
+ m_search_results.push_back(result);
+ UpdateCheatSearchResultsList();
+}
+
void CheatSearchTab::OnCreateARCodeClicked(wxCommandEvent&)
{
long idx = m_lview_search_results->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
diff --git a/Source/Core/DolphinWX/Cheats/CheatSearchTab.h b/Source/Core/DolphinWX/Cheats/CheatSearchTab.h
index d62a86659c..cd962a7934 100644
--- a/Source/Core/DolphinWX/Cheats/CheatSearchTab.h
+++ b/Source/Core/DolphinWX/Cheats/CheatSearchTab.h
@@ -42,6 +42,7 @@ private:
bool ParseUserEnteredValue(u32* out) const;
u32 SwapValue(u32 value) const;
+ void OnAddAddressClicked(wxCommandEvent&);
void OnNewScanClicked(wxCommandEvent&);
void OnNextScanClicked(wxCommandEvent&);
void OnCreateARCodeClicked(wxCommandEvent&);
@@ -58,6 +59,9 @@ private:
wxStaticText* m_label_results_count;
wxTextCtrl* m_textctrl_value_x;
+ wxTextCtrl* m_textctrl_address;
+ wxButton* m_btn_add_address;
+
wxButton* m_btn_create_code;
wxButton* m_btn_init_scan;
wxButton* m_btn_next_scan;