diff options
| author | EmptyChaos <EmptyChaos@users.noreply.github.com> | 2016-04-19 21:19:31 +0000 |
|---|---|---|
| committer | EmptyChaos <EmptyChaos@users.noreply.github.com> | 2016-05-29 23:33:24 +1000 |
| commit | 25b072ff2ba6839b300b05a45ce76e94d84ded32 (patch) | |
| tree | 2c17f26fac961a5a5b0d69501c72bd09ca69325d /Source/Core/DolphinWX/Cheats/CheatsWindow.cpp | |
| parent | 0fa9233c1acb91c89f1cecad1340621e375dc083 (diff) | |
ActionReplay: Fix ISOProperties corrupting active code set
ISOProperties loads codes using ActionReplay::LoadCodes which actually applies
the codes to the global state. If a game is running then that games receives
all the codes (and ACTIVE status) from the second game being shown in
ISOProperties which is not desirable.
Diffstat (limited to 'Source/Core/DolphinWX/Cheats/CheatsWindow.cpp')
| -rw-r--r-- | Source/Core/DolphinWX/Cheats/CheatsWindow.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/Source/Core/DolphinWX/Cheats/CheatsWindow.cpp b/Source/Core/DolphinWX/Cheats/CheatsWindow.cpp index 49a58504a5..83089b58c8 100644 --- a/Source/Core/DolphinWX/Cheats/CheatsWindow.cpp +++ b/Source/Core/DolphinWX/Cheats/CheatsWindow.cpp @@ -6,6 +6,7 @@ #include <cstddef> #include <cstdio> #include <cstring> +#include <functional> #include <string> #include <vector> #include <wx/button.h> @@ -38,12 +39,19 @@ #include "DolphinWX/Cheats/CreateCodeDialog.h" #include "DolphinWX/Cheats/GeckoCodeDiag.h" +namespace +{ +wxDEFINE_EVENT(DOLPHIN_EVT_UPDATE_CHEAT_LIST, wxThreadEvent); +} + wxCheatsWindow::wxCheatsWindow(wxWindow* const parent) : wxDialog(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | wxDIALOG_NO_PARENT) { // Create the GUI controls Init_ChildControls(); + m_ar_callback_token = ActionReplay::RegisterCodeChangeCallback(std::bind(&wxCheatsWindow::OnActionReplayModified, this)); + // load codes UpdateGUI(); @@ -54,6 +62,7 @@ wxCheatsWindow::wxCheatsWindow(wxWindow* const parent) wxCheatsWindow::~wxCheatsWindow() { + ActionReplay::UnregisterCodeChangeCallback(m_ar_callback_token); main_frame->g_CheatsWindow = nullptr; } @@ -126,7 +135,7 @@ void wxCheatsWindow::Init_ChildControls() button_cancel->Bind(wxEVT_BUTTON, &wxCheatsWindow::OnEvent_ButtonClose_Press, this); Bind(wxEVT_CLOSE_WINDOW, &wxCheatsWindow::OnEvent_Close, this); - Bind(UPDATE_CHEAT_LIST_EVENT, &wxCheatsWindow::OnEvent_CheatsList_Update, this); + Bind(DOLPHIN_EVT_UPDATE_CHEAT_LIST, &wxCheatsWindow::OnEvent_CheatsList_Update, this); wxStdDialogButtonSizer* const sButtons = new wxStdDialogButtonSizer(); sButtons->AddButton(m_button_apply); @@ -232,24 +241,30 @@ void wxCheatsWindow::OnEvent_CheatsList_ItemToggled(wxCommandEvent& WXUNUSED(eve { if ((int)code_index.uiIndex == index) { + m_ar_ignore_callback = true; ActionReplay::SetARCode_IsActive(m_checklistbox_cheats_list->IsChecked(index), code_index.index); } } } -void wxCheatsWindow::OnEvent_CheatsList_Update(wxCommandEvent& event) +void wxCheatsWindow::OnEvent_CheatsList_Update(wxThreadEvent&) { + if (m_ar_ignore_callback) + { + m_ar_ignore_callback = false; + return; + } Load_ARCodes(); } -void wxCheatsWindow::OnEvent_ApplyChanges_Press(wxCommandEvent& ev) +void wxCheatsWindow::OnActionReplayModified() { - // Apply AR Code changes - for (const ARCodeIndex& code_index : m_index_list) - { - ActionReplay::SetARCode_IsActive(m_checklistbox_cheats_list->IsChecked(code_index.uiIndex), code_index.index); - } + // NOTE: This is an arbitrary thread context + GetEventHandler()->QueueEvent(new wxThreadEvent(DOLPHIN_EVT_UPDATE_CHEAT_LIST)); +} +void wxCheatsWindow::OnEvent_ApplyChanges_Press(wxCommandEvent& ev) +{ // Apply Gecko Code changes Gecko::SetActiveCodes(m_geckocode_panel->GetCodes()); @@ -265,11 +280,15 @@ void wxCheatsWindow::OnEvent_ApplyChanges_Press(wxCommandEvent& ev) void wxCheatsWindow::OnEvent_ButtonUpdateLog_Press(wxCommandEvent& WXUNUSED(event)) { + wxBeginBusyCursor(); + m_textctrl_log->Freeze(); m_textctrl_log->Clear(); for (const std::string& text : ActionReplay::GetSelfLog()) { m_textctrl_log->AppendText(StrToWxStr(text)); } + m_textctrl_log->Thaw(); + wxEndBusyCursor(); } void wxCheatsWindow::OnEvent_CheckBoxEnableLogging_StateChange(wxCommandEvent& WXUNUSED(event)) |
