From 25b072ff2ba6839b300b05a45ce76e94d84ded32 Mon Sep 17 00:00:00 2001 From: EmptyChaos Date: Tue, 19 Apr 2016 21:19:31 +0000 Subject: 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. --- Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 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 364dfbad41..d53136987a 100644 --- a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp +++ b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp @@ -14,9 +14,6 @@ #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, wxID_ANY, _("Create AR Code")) , m_code_address(address) @@ -80,24 +77,21 @@ void CreateCodeDialog::PressOK(wxCommandEvent& ev) // create the new code ActionReplay::ARCode new_cheat; new_cheat.active = false; + new_cheat.user_defined = true; new_cheat.name = WxStrToStr(code_name); - const ActionReplay::AREntry new_entry(m_code_address, code_value); - new_cheat.ops.push_back(new_entry); + new_cheat.ops.emplace_back(ActionReplay::AREntry(m_code_address, code_value)); + ActionReplay::AddCode(new_cheat); // pretty hacky - add the code to the gameini + // FIXME: The save logic should be ActionReplay since it mirrors the parser { - CISOProperties isoprops(GameListItem(SConfig::GetInstance().m_LastFilename, std::unordered_map()), this); + CISOProperties isoprops(GameListItem(SConfig::GetInstance().m_LastFilename, {}), this); // add the code to the isoproperties arcode list isoprops.AddARCode(new_cheat); // save the gameini isoprops.SaveGameConfig(); - isoprops.ActionReplayList_Load(); // loads the new arcodes - //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 6ab1b2747714179783d0a2946acc9408eef2d950 Mon Sep 17 00:00:00 2001 From: EmptyChaos Date: Fri, 22 Apr 2016 10:42:16 +0000 Subject: ActionReplay: UI Consistency and Cleanup Cleanup code style. Move ActionReplay code->INI saving into ActionReplay namespace. Threadsafety Cleanup: ActionReplay is accessed from the Host, Emu and CPU Threads so the internal storage needs to be protected by a lock to prevent vectors/strings being deleted/moved while in use by the CPU Thread. UI Consistency: Make ARCodes behave like Gecko Codes - only apply changes when Apply is pressed. Save changes to INI from CheatsWindow. ISOProperties/CheatsWindow now synchronize with each other. --- Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 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 d53136987a..34b6baac82 100644 --- a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp +++ b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp @@ -12,6 +12,7 @@ #include "Core/ConfigManager.h" #include "DolphinWX/ISOProperties.h" #include "DolphinWX/WxUtils.h" +#include "DolphinWX/Cheats/CheatsWindow.h" #include "DolphinWX/Cheats/CreateCodeDialog.h" CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address) @@ -70,27 +71,16 @@ void CreateCodeDialog::PressOK(wxCommandEvent& ev) 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.user_defined = true; new_cheat.name = WxStrToStr(code_name); new_cheat.ops.emplace_back(ActionReplay::AREntry(m_code_address, code_value)); - ActionReplay::AddCode(new_cheat); - // pretty hacky - add the code to the gameini - // FIXME: The save logic should be ActionReplay since it mirrors the parser - { - CISOProperties isoprops(GameListItem(SConfig::GetInstance().m_LastFilename, {}), this); - // add the code to the isoproperties arcode list - isoprops.AddARCode(new_cheat); - // save the gameini - isoprops.SaveGameConfig(); - } + wxCommandEvent add_event(DOLPHIN_EVT_ADD_NEW_ACTION_REPLAY_CODE, GetId()); + add_event.SetClientData(&new_cheat); + GetParent()->GetEventHandler()->ProcessEvent(add_event); Close(); } -- cgit v1.2.3