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; return true;
} }
std::vector<ARCode>* GetARCodes()
{
return &arCodes;
}
} // namespace ActionReplay } // namespace ActionReplay

View File

@ -40,5 +40,4 @@ void UpdateActiveList();
void EnableSelfLogging(bool enable); void EnableSelfLogging(bool enable);
const std::vector<std::string> &GetSelfLog(); const std::vector<std::string> &GetSelfLog();
bool IsSelfLogging(); bool IsSelfLogging();
std::vector<ARCode>* GetARCodes();
} // namespace } // 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); 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.SetExtraStyle(arcode_dlg.GetExtraStyle() & ~wxWS_EX_BLOCK_EVENTS);
arcode_dlg.ShowModal(); arcode_dlg.ShowModal();
} }

View File

@ -17,10 +17,9 @@
// Fired when an ActionReplay code is created. // Fired when an ActionReplay code is created.
wxDEFINE_EVENT(UPDATE_CHEAT_LIST_EVENT, wxCommandEvent); 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")) : wxDialog(parent, wxID_ANY, _("Create AR Code"))
, m_code_address(address) , m_code_address(address)
, arCodes(_arCodes)
{ {
wxStaticText* const label_name = new wxStaticText(this, wxID_ANY, _("Name: ")); wxStaticText* const label_name = new wxStaticText(this, wxID_ANY, _("Name: "));
m_textctrl_name = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(256, -1)); 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); CISOProperties isoprops(GameListItem(SConfig::GetInstance().m_LastFilename, std::unordered_map<std::string, std::string>()), this);
// add the code to the isoproperties arcode list // add the code to the isoproperties arcode list
arCodes->push_back(new_cheat); isoprops.AddARCode(new_cheat);
// save the gameini // save the gameini
isoprops.SaveGameConfig(); isoprops.SaveGameConfig();
isoprops.ActionReplayList_Load(); // loads the new arcodes 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 class CreateCodeDialog final : public wxDialog
{ {
public: public:
CreateCodeDialog(wxWindow* const parent, const u32 address, std::vector<ActionReplay::ARCode>* _arCodes); CreateCodeDialog(wxWindow* const parent, const u32 address);
private: private:
const u32 m_code_address; const u32 m_code_address;
std::vector<ActionReplay::ARCode>* arCodes;
wxTextCtrl* m_textctrl_name; wxTextCtrl* m_textctrl_name;
wxTextCtrl* m_textctrl_code; wxTextCtrl* m_textctrl_code;

View File

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

View File

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