From f0769233e675ae754176f6b516c0f8584bd8b4cf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 18 Oct 2014 17:32:50 -0400 Subject: DolphinWX: Split cheat window components into their own source files --- Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp | 109 ++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp (limited to 'Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp') diff --git a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp new file mode 100644 index 0000000000..b266e9d7ab --- /dev/null +++ b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp @@ -0,0 +1,109 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Core/ActionReplay.h" +#include "Core/ConfigManager.h" +#include "DolphinWX/ISOProperties.h" +#include "DolphinWX/WxUtils.h" +#include "DolphinWX/Cheats/CreateCodeDialog.h" + +CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address) + : wxDialog(parent, -1, _("Create AR Code")) + , m_code_address(address) +{ + wxStaticText* const label_name = new wxStaticText(this, -1, _("Name: ")); + m_textctrl_name = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxSize(256,-1)); + + wxStaticText* const label_code = new wxStaticText(this, -1, _("Code: ")); + m_textctrl_code = new wxTextCtrl(this, -1, wxString::Format("0x%08x", address)); + m_textctrl_code->Disable(); + + wxStaticText* const label_value = new wxStaticText(this, -1, _("Value: ")); + m_textctrl_value = new wxTextCtrl(this, -1, "0"); + + m_checkbox_use_hex = new wxCheckBox(this, -1, _("Use Hex")); + m_checkbox_use_hex->SetValue(true); + + wxBoxSizer* const sizer_value_label = new wxBoxSizer(wxHORIZONTAL); + sizer_value_label->Add(label_value, 0, wxRIGHT, 5); + sizer_value_label->Add(m_checkbox_use_hex); + + // main sizer + wxBoxSizer* const sizer_main = new wxBoxSizer(wxVERTICAL); + sizer_main->Add(label_name, 0, wxALL, 5); + sizer_main->Add(m_textctrl_name, 0, wxALL, 5); + sizer_main->Add(label_code, 0, wxALL, 5); + sizer_main->Add(m_textctrl_code, 0, wxALL, 5); + sizer_main->Add(sizer_value_label, 0, wxALL, 5); + sizer_main->Add(m_textctrl_value, 0, wxALL, 5); + sizer_main->Add(CreateButtonSizer(wxOK | wxCANCEL | wxNO_DEFAULT), 0, wxALL, 5); + + Bind(wxEVT_BUTTON, &CreateCodeDialog::PressOK, this, wxID_OK); + Bind(wxEVT_BUTTON, &CreateCodeDialog::PressCancel, this, wxID_CANCEL); + Bind(wxEVT_CLOSE_WINDOW, &CreateCodeDialog::OnEvent_Close, this); + + SetSizerAndFit(sizer_main); + SetFocus(); +} + +void CreateCodeDialog::PressOK(wxCommandEvent& ev) +{ + const wxString code_name = m_textctrl_name->GetValue(); + if (code_name.empty()) + { + WxUtils::ShowErrorDialog(_("You must enter a name.")); + return; + } + + long code_value; + int base = m_checkbox_use_hex->IsChecked() ? 16 : 10; + if (!m_textctrl_value->GetValue().ToLong(&code_value, base)) + { + WxUtils::ShowErrorDialog(_("Invalid value.")); + return; + } + + //wxString full_code = textctrl_code->GetValue(); + //full_code += ' '; + //full_code += wxString::Format("0x%08x", code_value); + + // create the new code + ActionReplay::ARCode new_cheat; + new_cheat.active = false; + new_cheat.name = WxStrToStr(code_name); + const ActionReplay::AREntry new_entry(m_code_address, code_value); + new_cheat.ops.push_back(new_entry); + + // pretty hacky - add the code to the gameini + { + CISOProperties isoprops(SConfig::GetInstance().m_LastFilename, this); + // add the code to the isoproperties arcode list + arCodes.push_back(new_cheat); + // save the gameini + isoprops.SaveGameConfig(); + isoprops.ActionReplayList_Load(); // loads the new arcodes + //ActionReplay::UpdateActiveList(); + } + + Close(); +} + +void CreateCodeDialog::PressCancel(wxCommandEvent& ev) +{ + Close(); +} + +void CreateCodeDialog::OnEvent_Close(wxCloseEvent& ev) +{ + Destroy(); +} -- cgit v1.2.3 From e7939a6b4422e55844642d9382ad1aac7e952f6d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 18 Oct 2014 21:28:36 -0400 Subject: DolphinWX: Reimplement cheat listbox updating, but without a global Just use event handling. --- Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp') diff --git a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp index b266e9d7ab..aa4c0edbcc 100644 --- a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp +++ b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp @@ -17,6 +17,9 @@ #include "DolphinWX/WxUtils.h" #include "DolphinWX/Cheats/CreateCodeDialog.h" +// Fired when an ActionReplay code is created. +wxDEFINE_EVENT(UPDATE_CHEAT_LIST_EVENT, wxCommandEvent); + CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address) : wxDialog(parent, -1, _("Create AR Code")) , m_code_address(address) @@ -95,6 +98,9 @@ void CreateCodeDialog::PressOK(wxCommandEvent& ev) //ActionReplay::UpdateActiveList(); } + // Propagate back to the parent frame to update the cheat list. + GetEventHandler()->AddPendingEvent(wxCommandEvent(UPDATE_CHEAT_LIST_EVENT)); + Close(); } -- cgit v1.2.3 From 10bfbebc780fb3693741a72f258a5da2c3daffa1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 1 Dec 2014 22:56:18 -0500 Subject: DolphinWX: Specify wxID_ANY where -1 is used in controls --- Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp') diff --git a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp index aa4c0edbcc..d5188e34f6 100644 --- a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp +++ b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp @@ -21,20 +21,20 @@ wxDEFINE_EVENT(UPDATE_CHEAT_LIST_EVENT, wxCommandEvent); CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address) - : wxDialog(parent, -1, _("Create AR Code")) + : wxDialog(parent, wxID_ANY, _("Create AR Code")) , m_code_address(address) { - wxStaticText* const label_name = new wxStaticText(this, -1, _("Name: ")); - m_textctrl_name = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxSize(256,-1)); + wxStaticText* const label_name = new wxStaticText(this, wxID_ANY, _("Name: ")); + m_textctrl_name = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(256, -1)); - wxStaticText* const label_code = new wxStaticText(this, -1, _("Code: ")); - m_textctrl_code = new wxTextCtrl(this, -1, wxString::Format("0x%08x", address)); + wxStaticText* const label_code = new wxStaticText(this, wxID_ANY, _("Code: ")); + m_textctrl_code = new wxTextCtrl(this, wxID_ANY, wxString::Format("0x%08x", address)); m_textctrl_code->Disable(); - wxStaticText* const label_value = new wxStaticText(this, -1, _("Value: ")); - m_textctrl_value = new wxTextCtrl(this, -1, "0"); + wxStaticText* const label_value = new wxStaticText(this, wxID_ANY, _("Value: ")); + m_textctrl_value = new wxTextCtrl(this, wxID_ANY, "0"); - m_checkbox_use_hex = new wxCheckBox(this, -1, _("Use Hex")); + m_checkbox_use_hex = new wxCheckBox(this, wxID_ANY, _("Use Hex")); m_checkbox_use_hex->SetValue(true); wxBoxSizer* const sizer_value_label = new wxBoxSizer(wxHORIZONTAL); -- cgit v1.2.3 From 2df8190e1ad88e6051cd709641ab2b42a3d251e0 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Tue, 24 Feb 2015 18:32:17 -0500 Subject: Make iso properties non modal. --- Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp') diff --git a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp index d5188e34f6..c9766cd2ce 100644 --- a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp +++ b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp @@ -20,9 +20,10 @@ // Fired when an ActionReplay code is created. wxDEFINE_EVENT(UPDATE_CHEAT_LIST_EVENT, wxCommandEvent); -CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address) +CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address, const std::vector& _arCodes) : wxDialog(parent, wxID_ANY, _("Create AR Code")) , m_code_address(address) + , arCodes(_arCodes) { wxStaticText* const label_name = new wxStaticText(this, wxID_ANY, _("Name: ")); m_textctrl_name = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(256, -1)); -- cgit v1.2.3 From 4a41ab17155e4103ea7844b6e6aa3c434dbb7e63 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 6 Mar 2015 12:26:40 +0100 Subject: Fix 4.0-5689 regression (AR codes, patches) CreateCodeTab, ARCodeAddEdit and PatchAddEdit need to be able to modify arCodes/onFrame. --- Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp') diff --git a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp index c9766cd2ce..4ba0926ab3 100644 --- a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp +++ b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp @@ -20,7 +20,7 @@ // Fired when an ActionReplay code is created. wxDEFINE_EVENT(UPDATE_CHEAT_LIST_EVENT, wxCommandEvent); -CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address, const std::vector& _arCodes) +CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address, std::vector* _arCodes) : wxDialog(parent, wxID_ANY, _("Create AR Code")) , m_code_address(address) , arCodes(_arCodes) @@ -92,7 +92,7 @@ void CreateCodeDialog::PressOK(wxCommandEvent& ev) { CISOProperties isoprops(SConfig::GetInstance().m_LastFilename, this); // add the code to the isoproperties arcode list - arCodes.push_back(new_cheat); + arCodes->push_back(new_cheat); // save the gameini isoprops.SaveGameConfig(); isoprops.ActionReplayList_Load(); // loads the new arcodes -- cgit v1.2.3 From a7e9aea7972c0a0af6fc7e9c4126ccda43118a0f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 8 May 2015 10:04:40 -0400 Subject: DolphinWX: Remove unnecessary includes --- Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp') diff --git a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp index 4ba0926ab3..a1545daac8 100644 --- a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp +++ b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp @@ -4,12 +4,9 @@ #include #include -#include #include #include -#include #include -#include #include "Core/ActionReplay.h" #include "Core/ConfigManager.h" -- cgit v1.2.3 From cefcb0ace9d363b3679b4e93bcc9ec05f1e5f4f8 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Mon, 18 May 2015 01:08:10 +0200 Subject: Update license headers to GPLv2+ --- Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp') diff --git a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp index a1545daac8..5239a1817a 100644 --- a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp +++ b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp @@ -1,5 +1,5 @@ // Copyright 2014 Dolphin Emulator Project -// Licensed under GPLv2 +// Licensed under GPLv2+ // Refer to the license.txt file included. #include -- cgit v1.2.3