Fix Cheat Manager not saving created codes

This commit is contained in:
JosJuice 2015-09-19 17:20:16 +02:00
parent 3f56480903
commit 17edcc4fc7
7 changed files with 13 additions and 12 deletions

View file

@ -933,9 +933,4 @@ bool RunCode(const ARCode &arcode)
return true;
}
std::vector<ARCode>* GetARCodes()
{
return &arCodes;
}
} // namespace ActionReplay

View file

@ -40,5 +40,4 @@ void UpdateActiveList();
void EnableSelfLogging(bool enable);
const std::vector<std::string> &GetSelfLog();
bool IsSelfLogging();
std::vector<ARCode>* GetARCodes();
} // namespace

View file

@ -169,7 +169,7 @@ void CheatSearchTab::OnCreateARCodeClicked(wxCommandEvent&)
const u32 address = m_search_results[idx].address | ((m_search_type_size & ~1) << 24);
CreateCodeDialog arcode_dlg(this, address, ActionReplay::GetARCodes());
CreateCodeDialog arcode_dlg(this, address);
arcode_dlg.SetExtraStyle(arcode_dlg.GetExtraStyle() & ~wxWS_EX_BLOCK_EVENTS);
arcode_dlg.ShowModal();
}

View file

@ -17,10 +17,9 @@
// Fired when an ActionReplay code is created.
wxDEFINE_EVENT(UPDATE_CHEAT_LIST_EVENT, wxCommandEvent);
CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address, std::vector<ActionReplay::ARCode>* _arCodes)
CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address)
: 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));
@ -89,7 +88,7 @@ void CreateCodeDialog::PressOK(wxCommandEvent& ev)
{
CISOProperties isoprops(GameListItem(SConfig::GetInstance().m_LastFilename, std::unordered_map<std::string, std::string>()), this);
// add the code to the isoproperties arcode list
arCodes->push_back(new_cheat);
isoprops.AddARCode(new_cheat);
// save the gameini
isoprops.SaveGameConfig();
isoprops.ActionReplayList_Load(); // loads the new arcodes

View file

@ -17,11 +17,10 @@ wxDECLARE_EVENT(UPDATE_CHEAT_LIST_EVENT, wxCommandEvent);
class CreateCodeDialog final : public wxDialog
{
public:
CreateCodeDialog(wxWindow* const parent, const u32 address, std::vector<ActionReplay::ARCode>* _arCodes);
CreateCodeDialog(wxWindow* const parent, const u32 address);
private:
const u32 m_code_address;
std::vector<ActionReplay::ARCode>* arCodes;
wxTextCtrl* m_textctrl_name;
wxTextCtrl* m_textctrl_code;

View file

@ -1493,6 +1493,11 @@ void CISOProperties::ActionReplayButtonClicked(wxCommandEvent& event)
RemoveCheat->Disable();
}
void CISOProperties::AddARCode(const ActionReplay::ARCode& code)
{
arCodes.emplace_back(code);
}
void CISOProperties::OnChangeBannerLang(wxCommandEvent& event)
{
ChangeBannerDetails(OpenGameListItem.GetLanguages()[event.GetSelection()]);

View file

@ -70,9 +70,13 @@ public:
bool bRefreshList;
// These are only public because of the ugly hack in CreateCodeDialog.cpp
void ActionReplayList_Load();
bool SaveGameConfig();
// This only exists because of the ugly hack in CreateCodeDialog.cpp
void AddARCode(const ActionReplay::ARCode& code);
private:
DECLARE_EVENT_TABLE();