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.
This commit is contained in:
EmptyChaos
2016-04-19 21:19:31 +00:00
parent 0fa9233c1a
commit 25b072ff2b
9 changed files with 124 additions and 45 deletions

View File

@ -95,6 +95,7 @@ BEGIN_EVENT_TABLE(CISOProperties, wxDialog)
EVT_MENU(IDM_EXTRACTDOL, CISOProperties::OnExtractDataFromHeader)
EVT_MENU(IDM_CHECKINTEGRITY, CISOProperties::CheckPartitionIntegrity)
EVT_CHOICE(ID_LANG, CISOProperties::OnChangeBannerLang)
EVT_CHECKLISTBOX(ID_CHEATS_LIST, CISOProperties::OnActionReplayCodeChecked)
END_EVENT_TABLE()
CISOProperties::CISOProperties(const GameListItem& game_list_item, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
@ -1314,6 +1315,11 @@ void CISOProperties::ListSelectionChanged(wxCommandEvent& event)
}
}
void CISOProperties::OnActionReplayCodeChecked(wxCommandEvent& event)
{
arCodes[event.GetSelection()].active = Cheats->IsChecked(event.GetSelection());
}
void CISOProperties::PatchList_Load()
{
onFrame.clear();
@ -1399,9 +1405,8 @@ void CISOProperties::PatchButtonClicked(wxCommandEvent& event)
void CISOProperties::ActionReplayList_Load()
{
arCodes.clear();
Cheats->Clear();
ActionReplay::LoadCodes(arCodes, GameIniDefault, GameIniLocal);
arCodes = ActionReplay::LoadCodes(GameIniDefault, GameIniLocal);
u32 index = 0;
for (const ActionReplay::ARCode& arCode : arCodes)
@ -1422,8 +1427,7 @@ void CISOProperties::ActionReplayList_Save()
u32 cheats_chkbox_count = Cheats->GetCount();
for (const ActionReplay::ARCode& code : arCodes)
{
// Check the index against the count because of the hacky way codes are added from the "Cheat Search" dialog
if ((index < cheats_chkbox_count) && Cheats->IsChecked(index))
if (code.active)
enabledLines.push_back("$" + code.name);
// Do not save default cheats.