Merge pull request #2171 from JosJuice/nonmodal-regression

Fix 4.0-5689 regression (AR codes, patches)
This commit is contained in:
Dolphin Bot 2015-03-11 08:15:02 +01:00
commit 647cd3c8e0
10 changed files with 34 additions and 34 deletions

View File

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

View File

@ -36,5 +36,5 @@ 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(); std::vector<ARCode>* GetARCodes();
} // namespace } // namespace

View File

@ -8,7 +8,6 @@
#include <vector> #include <vector>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Core/PatchEngine.h"
class IniFile; class IniFile;

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm>
#include <cstddef> #include <cstddef>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
@ -28,7 +29,7 @@
#include "DolphinWX/ARCodeAddEdit.h" #include "DolphinWX/ARCodeAddEdit.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
CARCodeAddEdit::CARCodeAddEdit(int _selection, const std::vector<ActionReplay::ARCode>& _arCodes, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) CARCodeAddEdit::CARCodeAddEdit(int _selection, std::vector<ActionReplay::ARCode>* _arCodes, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style) : wxDialog(parent, id, title, position, size, style)
, arCodes(_arCodes) , arCodes(_arCodes)
, selection(_selection) , selection(_selection)
@ -36,7 +37,7 @@ CARCodeAddEdit::CARCodeAddEdit(int _selection, const std::vector<ActionReplay::A
Bind(wxEVT_BUTTON, &CARCodeAddEdit::SaveCheatData, this, wxID_OK); Bind(wxEVT_BUTTON, &CARCodeAddEdit::SaveCheatData, this, wxID_OK);
ActionReplay::ARCode tempEntries; ActionReplay::ARCode tempEntries;
wxString currentName = _("Insert name here.."); wxString currentName = _("Insert name here...");
if (selection == wxNOT_FOUND) if (selection == wxNOT_FOUND)
{ {
@ -44,8 +45,8 @@ CARCodeAddEdit::CARCodeAddEdit(int _selection, const std::vector<ActionReplay::A
} }
else else
{ {
currentName = StrToWxStr(arCodes.at(selection).name); currentName = StrToWxStr(arCodes->at(selection).name);
tempEntries = arCodes.at(selection); tempEntries = arCodes->at(selection);
} }
wxBoxSizer* sEditCheat = new wxBoxSizer(wxVERTICAL); wxBoxSizer* sEditCheat = new wxBoxSizer(wxVERTICAL);
@ -57,8 +58,8 @@ CARCodeAddEdit::CARCodeAddEdit(int _selection, const std::vector<ActionReplay::A
EditCheatName->SetValue(currentName); EditCheatName->SetValue(currentName);
EntrySelection = new wxSpinButton(this); EntrySelection = new wxSpinButton(this);
EntrySelection->SetRange(1, ((int)arCodes.size()) > 0 ? (int)arCodes.size() : 1); EntrySelection->SetRange(1, std::max((int)arCodes->size(), 1));
EntrySelection->SetValue((int)(arCodes.size() - selection)); EntrySelection->SetValue((int)(arCodes->size() - selection));
EntrySelection->Bind(wxEVT_SPIN, &CARCodeAddEdit::ChangeEntry, this); EntrySelection->Bind(wxEVT_SPIN, &CARCodeAddEdit::ChangeEntry, this);
EditCheatCode = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, 100), wxTE_MULTILINE); EditCheatCode = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, 100), wxTE_MULTILINE);
@ -81,7 +82,7 @@ CARCodeAddEdit::CARCodeAddEdit(int _selection, const std::vector<ActionReplay::A
void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event) void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event)
{ {
ActionReplay::ARCode currentCode = arCodes.at((int)arCodes.size() - event.GetPosition()); ActionReplay::ARCode currentCode = arCodes->at((int)arCodes->size() - event.GetPosition());
EditCheatName->SetValue(StrToWxStr(currentCode.name)); EditCheatName->SetValue(StrToWxStr(currentCode.name));
UpdateTextCtrl(currentCode); UpdateTextCtrl(currentCode);
} }
@ -161,13 +162,13 @@ void CARCodeAddEdit::SaveCheatData(wxCommandEvent& WXUNUSED(event))
newCheat.ops = decryptedLines; newCheat.ops = decryptedLines;
newCheat.active = true; newCheat.active = true;
arCodes.push_back(newCheat); arCodes->push_back(newCheat);
} }
else else
{ {
// Update the currently-selected AR cheat code. // Update the currently-selected AR cheat code.
arCodes.at(selection).name = WxStrToStr(EditCheatName->GetValue()); arCodes->at(selection).name = WxStrToStr(EditCheatName->GetValue());
arCodes.at(selection).ops = decryptedLines; arCodes->at(selection).ops = decryptedLines;
} }
AcceptAndClose(); AcceptAndClose();

View File

@ -21,7 +21,7 @@ namespace ActionReplay { struct ARCode; }
class CARCodeAddEdit : public wxDialog class CARCodeAddEdit : public wxDialog
{ {
public: public:
CARCodeAddEdit(int _selection, const std::vector<ActionReplay::ARCode>& _arCodes, CARCodeAddEdit(int _selection, std::vector<ActionReplay::ARCode>* _arCodes,
wxWindow* parent, wxWindow* parent,
wxWindowID id = wxID_ANY, wxWindowID id = wxID_ANY,
const wxString& title = _("Edit ActionReplay Code"), const wxString& title = _("Edit ActionReplay Code"),
@ -34,7 +34,7 @@ private:
wxSpinButton* EntrySelection; wxSpinButton* EntrySelection;
wxTextCtrl* EditCheatCode; wxTextCtrl* EditCheatCode;
std::vector<ActionReplay::ARCode> arCodes; std::vector<ActionReplay::ARCode>* arCodes;
void SaveCheatData(wxCommandEvent& event); void SaveCheatData(wxCommandEvent& event);
void ChangeEntry(wxSpinEvent& event); void ChangeEntry(wxSpinEvent& event);

View File

@ -20,7 +20,7 @@
// 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, const std::vector<ActionReplay::ARCode>& _arCodes) CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address, std::vector<ActionReplay::ARCode>* _arCodes)
: wxDialog(parent, wxID_ANY, _("Create AR Code")) : wxDialog(parent, wxID_ANY, _("Create AR Code"))
, m_code_address(address) , m_code_address(address)
, arCodes(_arCodes) , arCodes(_arCodes)
@ -92,7 +92,7 @@ void CreateCodeDialog::PressOK(wxCommandEvent& ev)
{ {
CISOProperties isoprops(SConfig::GetInstance().m_LastFilename, this); CISOProperties isoprops(SConfig::GetInstance().m_LastFilename, this);
// add the code to the isoproperties arcode list // add the code to the isoproperties arcode list
arCodes.push_back(new_cheat); arCodes->push_back(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

@ -19,11 +19,11 @@ 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, const std::vector<ActionReplay::ARCode>& _arCodes); CreateCodeDialog(wxWindow* const parent, const u32 address, std::vector<ActionReplay::ARCode>* _arCodes);
private: private:
const u32 m_code_address; const u32 m_code_address;
std::vector<ActionReplay::ARCode> arCodes; std::vector<ActionReplay::ARCode>* arCodes;
wxTextCtrl* m_textctrl_name; wxTextCtrl* m_textctrl_name;
wxTextCtrl* m_textctrl_code; wxTextCtrl* m_textctrl_code;

View File

@ -1388,13 +1388,13 @@ void CISOProperties::PatchButtonClicked(wxCommandEvent& event)
{ {
case ID_EDITPATCH: case ID_EDITPATCH:
{ {
CPatchAddEdit dlg(selection, onFrame, this); CPatchAddEdit dlg(selection, &onFrame, this);
dlg.ShowModal(); dlg.ShowModal();
} }
break; break;
case ID_ADDPATCH: case ID_ADDPATCH:
{ {
CPatchAddEdit dlg(-1, onFrame, this, 1, _("Add Patch")); CPatchAddEdit dlg(-1, &onFrame, this, 1, _("Add Patch"));
if (dlg.ShowModal() == wxID_OK) if (dlg.ShowModal() == wxID_OK)
{ {
Patches->Append(StrToWxStr(onFrame.back().name)); Patches->Append(StrToWxStr(onFrame.back().name));
@ -1468,13 +1468,13 @@ void CISOProperties::ActionReplayButtonClicked(wxCommandEvent& event)
{ {
case ID_EDITCHEAT: case ID_EDITCHEAT:
{ {
CARCodeAddEdit dlg(selection, arCodes, this); CARCodeAddEdit dlg(selection, &arCodes, this);
dlg.ShowModal(); dlg.ShowModal();
} }
break; break;
case ID_ADDCHEAT: case ID_ADDCHEAT:
{ {
CARCodeAddEdit dlg(-1, arCodes, this, 1, _("Add ActionReplay Code")); CARCodeAddEdit dlg(-1, &arCodes, this, 1, _("Add ActionReplay Code"));
if (dlg.ShowModal() == wxID_OK) if (dlg.ShowModal() == wxID_OK)
{ {
Cheats->Append(StrToWxStr(arCodes.back().name)); Cheats->Append(StrToWxStr(arCodes.back().name));

View File

@ -28,12 +28,12 @@
#include "DolphinWX/PatchAddEdit.h" #include "DolphinWX/PatchAddEdit.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
CPatchAddEdit::CPatchAddEdit(int _selection, const std::vector<PatchEngine::Patch>& _onFrame, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) CPatchAddEdit::CPatchAddEdit(int _selection, std::vector<PatchEngine::Patch>* _onFrame, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style) : wxDialog(parent, id, title, position, size, style)
, onFrame(_onFrame)
, selection(_selection)
{ {
selection = _selection;
CreateGUIControls(selection); CreateGUIControls(selection);
onFrame = _onFrame;
Bind(wxEVT_BUTTON, &CPatchAddEdit::SavePatchData, this, wxID_OK); Bind(wxEVT_BUTTON, &CPatchAddEdit::SavePatchData, this, wxID_OK);
} }
@ -53,8 +53,8 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
} }
else else
{ {
currentName = StrToWxStr(onFrame.at(_selection).name); currentName = StrToWxStr(onFrame->at(_selection).name);
tempEntries = onFrame.at(_selection).entries; tempEntries = onFrame->at(_selection).entries;
} }
itCurEntry = tempEntries.begin(); itCurEntry = tempEntries.begin();
@ -142,12 +142,12 @@ void CPatchAddEdit::SavePatchData(wxCommandEvent& event)
newPatch.entries = tempEntries; newPatch.entries = tempEntries;
newPatch.active = true; newPatch.active = true;
onFrame.push_back(newPatch); onFrame->push_back(newPatch);
} }
else else
{ {
onFrame.at(selection).name = WxStrToStr(EditPatchName->GetValue()); onFrame->at(selection).name = WxStrToStr(EditPatchName->GetValue());
onFrame.at(selection).entries = tempEntries; onFrame->at(selection).entries = tempEntries;
} }
AcceptAndClose(); AcceptAndClose();

View File

@ -25,7 +25,7 @@ class wxWindow;
class CPatchAddEdit : public wxDialog class CPatchAddEdit : public wxDialog
{ {
public: public:
CPatchAddEdit(int _selection, const std::vector<PatchEngine::Patch>& _onFrame, CPatchAddEdit(int _selection, std::vector<PatchEngine::Patch>* _onFrame,
wxWindow* parent, wxWindow* parent,
wxWindowID id = wxID_ANY, wxWindowID id = wxID_ANY,
const wxString& title = _("Edit Patch"), const wxString& title = _("Edit Patch"),
@ -43,7 +43,7 @@ private:
wxButton* EntryAdd; wxButton* EntryAdd;
wxButton* EntryRemove; wxButton* EntryRemove;
wxStaticBoxSizer* sbEntry; wxStaticBoxSizer* sbEntry;
std::vector<PatchEngine::Patch> onFrame; std::vector<PatchEngine::Patch>* onFrame;
void CreateGUIControls(int selection); void CreateGUIControls(int selection);
void ChangeEntry(wxSpinEvent& event); void ChangeEntry(wxSpinEvent& event);