diff --git a/Source/Core/DolphinWX/DolphinWX.vcproj b/Source/Core/DolphinWX/DolphinWX.vcproj index d005b9448c..ce9e849fd3 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcproj +++ b/Source/Core/DolphinWX/DolphinWX.vcproj @@ -850,6 +850,14 @@ RelativePath=".\src\MemcardManager.h" > + + + + ops; u32 uiIndex; }; - std::vector ARCodes; + BEGIN_EVENT_TABLE(CISOProperties, wxDialog) EVT_CLOSE(CISOProperties::OnClose) EVT_BUTTON(ID_CLOSE, CISOProperties::OnCloseClick) @@ -650,77 +651,16 @@ void CISOProperties::PatchList_Save() lines.clear(); } - -void CISOProperties::ChangeEditPatchEntry(wxSpinEvent& event) -{ - PatchEngine::PatchEntry pE = onFrame.at(Patches->GetSelection()).entries.at(event.GetPosition()); - EditPatchOffset->SetValue(wxString::Format(_("%08X"), pE.address)); - EditPatchType->SetSelection(pE.type); - EditPatchValue->SetValue(wxString::Format(_("%08X"), pE.value)); -} - void CISOProperties::PatchButtonClicked(wxCommandEvent& event) { + int selection = Patches->GetSelection(); + switch (event.GetId()) { case ID_EDITPATCH: { - int selection = Patches->GetSelection(); - std::string currentName = onFrame.at(selection).name; - std::vector currentEntries = onFrame.at(selection).entries; - wxDialog* dEditPatch = new wxDialog(this, IDD_EDITPATCH, wxString::Format(_("Edit Patch: %s"), currentName.c_str()), wxDefaultPosition, wxSize(300, -1)); - - wxBoxSizer* sEditPatch = new wxBoxSizer(wxVERTICAL); - wxStaticText* EditPatchNameText = new wxStaticText(dEditPatch, ID_EDITPATCH_NAME_TEXT, _("Name:"), wxDefaultPosition, wxDefaultSize); - EditPatchName = new wxTextCtrl(dEditPatch, ID_EDITPATCH_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); - EditPatchName->SetValue(wxString::FromAscii(currentName.c_str())); - wxStaticText* EditPatchOffsetText = new wxStaticText(dEditPatch, ID_EDITPATCH_OFFSET_TEXT, _("Offset:"), wxDefaultPosition, wxDefaultSize); - EditPatchOffset = new wxTextCtrl(dEditPatch, ID_EDITPATCH_OFFSET, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); - EditPatchOffset->SetValue(wxString::Format(_("%08X"), currentEntries.at(0).address)); - wxSpinButton* EntrySelection = new wxSpinButton(dEditPatch, ID_ENTRY_SELECT, wxDefaultPosition, wxDefaultSize, wxVERTICAL); - EntrySelection->SetRange(0, currentEntries.size()); - wxArrayString wxArrayStringFor_EditPatchType; - for (int i = 0; i < 3; ++i) - wxArrayStringFor_EditPatchType.Add(wxString::FromAscii(PatchEngine::PatchTypeStrings[i])); - EditPatchType = new wxRadioBox(dEditPatch, ID_EDITPATCH_TYPE, _("Type"), wxDefaultPosition, wxDefaultSize, wxArrayStringFor_EditPatchType, 3, wxRA_SPECIFY_COLS, wxDefaultValidator); - EditPatchType->SetSelection((int)currentEntries.at(0).type); - wxStaticText* EditPatchValueText = new wxStaticText(dEditPatch, ID_EDITPATCH_VALUE_TEXT, _("Value:"), wxDefaultPosition, wxDefaultSize); - EditPatchValue = new wxTextCtrl(dEditPatch, ID_EDITPATCH_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); - EditPatchValue->SetValue(wxString::Format(_("%08X"), currentEntries.at(0).value)); - wxBoxSizer* sEditPatchName = new wxBoxSizer(wxHORIZONTAL); - sEditPatchName->Add(EditPatchNameText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - sEditPatchName->Add(EditPatchName, 1, wxEXPAND|wxALL, 5); - sEditPatch->Add(sEditPatchName, 0, wxEXPAND); - wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, dEditPatch, _("Entry")); - wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0); - sgEntry->AddGrowableCol(1); - sgEntry->Add(EditPatchOffsetText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); - sgEntry->Add(EditPatchOffset, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); - sgEntry->Add(EntrySelection, wxGBPosition(0, 2), wxGBSpan(3, 1), wxEXPAND|wxALL, 5); - sgEntry->Add(EditPatchType, wxGBPosition(1, 0), wxGBSpan(1, 2), wxEXPAND|wxALL, 5); - sgEntry->Add(EditPatchValueText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); - sgEntry->Add(EditPatchValue, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); - sbEntry->Add(sgEntry, 0, wxEXPAND); - sEditPatch->Add(sbEntry, 0, wxEXPAND|wxALL, 5); - wxBoxSizer* sEditPatchButtons = new wxBoxSizer(wxHORIZONTAL); - wxButton* bOK = new wxButton(dEditPatch, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - wxButton* bCancel = new wxButton(dEditPatch, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - sEditPatchButtons->Add(0, 0, 1, wxEXPAND, 5); - sEditPatchButtons->Add(bOK, 0, wxALL, 5); - sEditPatchButtons->Add(bCancel, 0, wxALL, 5); - sEditPatch->Add(sEditPatchButtons, 0, wxEXPAND, 5); - dEditPatch->SetSizer(sEditPatch); - sEditPatch->Layout(); - if (dEditPatch->ShowModal() == wxID_OK) - { - onFrame.at(selection).name = std::string(EditPatchName->GetValue().mb_str()); - unsigned long value; - if (EditPatchOffset->GetValue().ToULong(&value, 16)) - onFrame.at(selection).entries.at(0).address = value; - onFrame.at(selection).entries.at(0).type = (PatchEngine::PatchType)EditPatchType->GetSelection(); - if (EditPatchValue->GetValue().ToULong(&value, 16)) - onFrame.at(selection).entries.at(0).value = value; - } + CPatchAddEdit dlg(selection, this); + dlg.ShowModal(); } break; case ID_ADDPATCH: diff --git a/Source/Core/DolphinWX/Src/ISOProperties.h b/Source/Core/DolphinWX/Src/ISOProperties.h index 1bbf5a8c4b..5ec026718a 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.h +++ b/Source/Core/DolphinWX/Src/ISOProperties.h @@ -31,6 +31,7 @@ #include "Filesystem.h" #include "IniFile.h" +#include "PatchEngine.h" #undef ISOPROPERTIES_STYLE #define ISOPROPERTIES_STYLE wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxCLOSE_BOX @@ -86,10 +87,6 @@ class CISOProperties : public wxDialog wxArrayString arrayStringFor_Patches; wxCheckListBox *Patches; wxButton *EditPatch; - wxTextCtrl *EditPatchName; - wxTextCtrl *EditPatchOffset; - wxRadioBox *EditPatchType; - wxTextCtrl *EditPatchValue; wxButton *AddPatch; wxButton *RemovePatch; wxArrayString arrayStringFor_Cheats; @@ -159,15 +156,6 @@ class CISOProperties : public wxDialog ID_EMUSTATE, ID_PATCHES_LIST, ID_EDITPATCH, - IDD_EDITPATCH, - ID_EDITPATCH_NAME_TEXT, - ID_EDITPATCH_NAME, - ID_EDITPATCH_OFFSET_TEXT, - ID_EDITPATCH_OFFSET, - ID_ENTRY_SELECT, - ID_EDITPATCH_TYPE, - ID_EDITPATCH_VALUE_TEXT, - ID_EDITPATCH_VALUE, ID_ADDPATCH, ID_REMOVEPATCH, ID_CHEATS_LIST, @@ -213,7 +201,6 @@ class CISOProperties : public wxDialog void OnEditConfig(wxCommandEvent& event); void ListSelectionChanged(wxCommandEvent& event); void PatchButtonClicked(wxCommandEvent& event); - void ChangeEditPatchEntry(wxSpinEvent& event); void ActionReplayButtonClicked(wxCommandEvent& event); void RightClickOnBanner(wxMouseEvent& event); void OnBannerImageSave(wxCommandEvent& event); @@ -225,12 +212,13 @@ class CISOProperties : public wxDialog std::vector Our_Files; typedef std::vector::iterator fileIter; - IniFile GameIni; - std::string GameIniFile; - void CreateDirectoryTree(wxTreeItemId& parent,fileIter& begin, fileIter& end, fileIter& iterPos, char *directory); + + IniFile GameIni; + std::string GameIniFile; + void LoadGameConfig(); bool SaveGameConfig(); void PatchList_Load(); diff --git a/Source/Core/DolphinWX/Src/PatchAddEdit.cpp b/Source/Core/DolphinWX/Src/PatchAddEdit.cpp new file mode 100644 index 0000000000..41e44c4e11 --- /dev/null +++ b/Source/Core/DolphinWX/Src/PatchAddEdit.cpp @@ -0,0 +1,109 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "PatchAddEdit.h" + +extern std::vector onFrame; + +BEGIN_EVENT_TABLE(CPatchAddEdit, wxDialog) + EVT_CLOSE(CPatchAddEdit::OnClose) + EVT_SPIN(ID_ENTRY_SELECT, CPatchAddEdit::ChangeEntry) +END_EVENT_TABLE() + +CPatchAddEdit::CPatchAddEdit(int _selection, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) + : wxDialog(parent, id, title, position, size, style) +{ + selection = _selection; + CreateGUIControls(selection); +} + +CPatchAddEdit::~CPatchAddEdit() +{ +} + +void CPatchAddEdit::CreateGUIControls(int selection) +{ + std::string currentName = onFrame.at(selection).name; + std::vector currentEntries = onFrame.at(selection).entries; + + wxBoxSizer* sEditPatch = new wxBoxSizer(wxVERTICAL); + wxStaticText* EditPatchNameText = new wxStaticText(this, ID_EDITPATCH_NAME_TEXT, _("Name:"), wxDefaultPosition, wxDefaultSize); + EditPatchName = new wxTextCtrl(this, ID_EDITPATCH_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); + EditPatchName->SetValue(wxString::FromAscii(currentName.c_str())); + wxStaticText* EditPatchOffsetText = new wxStaticText(this, ID_EDITPATCH_OFFSET_TEXT, _("Offset:"), wxDefaultPosition, wxDefaultSize); + EditPatchOffset = new wxTextCtrl(this, ID_EDITPATCH_OFFSET, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); + EditPatchOffset->SetValue(wxString::Format(wxT("%08X"), currentEntries.at(0).address)); + EntrySelection = new wxSpinButton(this, ID_ENTRY_SELECT, wxDefaultPosition, wxDefaultSize, wxVERTICAL); + EntrySelection->SetRange(0, (int)currentEntries.size()-1); + wxArrayString wxArrayStringFor_EditPatchType; + for (int i = 0; i < 3; ++i) + wxArrayStringFor_EditPatchType.Add(wxString::FromAscii(PatchEngine::PatchTypeStrings[i])); + EditPatchType = new wxRadioBox(this, ID_EDITPATCH_TYPE, _("Type"), wxDefaultPosition, wxDefaultSize, wxArrayStringFor_EditPatchType, 3, wxRA_SPECIFY_COLS, wxDefaultValidator); + EditPatchType->SetSelection((int)currentEntries.at(0).type); + wxStaticText* EditPatchValueText = new wxStaticText(this, ID_EDITPATCH_VALUE_TEXT, _("Value:"), wxDefaultPosition, wxDefaultSize); + EditPatchValue = new wxTextCtrl(this, ID_EDITPATCH_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); + EditPatchValue->SetValue(wxString::Format(wxT("%08X"), currentEntries.at(0).value)); + + wxBoxSizer* sEditPatchName = new wxBoxSizer(wxHORIZONTAL); + sEditPatchName->Add(EditPatchNameText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + sEditPatchName->Add(EditPatchName, 1, wxEXPAND|wxALL, 5); + sEditPatch->Add(sEditPatchName, 0, wxEXPAND); + wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, _("Entry")); + wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0); + sgEntry->AddGrowableCol(1); + sgEntry->Add(EditPatchType, wxGBPosition(0, 0), wxGBSpan(1, 2), wxEXPAND|wxALL, 5); + sgEntry->Add(EditPatchOffsetText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); + sgEntry->Add(EditPatchOffset, wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); + sgEntry->Add(EditPatchValueText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); + sgEntry->Add(EditPatchValue, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); + sgEntry->Add(EntrySelection, wxGBPosition(0, 2), wxGBSpan(3, 1), wxEXPAND|wxALL, 5); + sbEntry->Add(sgEntry, 0, wxEXPAND); + sEditPatch->Add(sbEntry, 0, wxEXPAND|wxALL, 5); + wxBoxSizer* sEditPatchButtons = new wxBoxSizer(wxHORIZONTAL); + wxButton* bOK = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + wxButton* bCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + sEditPatchButtons->Add(0, 0, 1, wxEXPAND, 5); + sEditPatchButtons->Add(bOK, 0, wxALL, 5); + sEditPatchButtons->Add(bCancel, 0, wxALL, 5); + sEditPatch->Add(sEditPatchButtons, 0, wxEXPAND, 5); + this->SetSizer(sEditPatch); + sEditPatch->Layout(); + + /*if (this->ShowModal() == wxID_OK) + { + onFrame.at(selection).name = std::string(EditPatchName->GetValue().mb_str()); + unsigned long value; + if (EditPatchOffset->GetValue().ToULong(&value, 16)) + onFrame.at(selection).entries.at(0).address = value; + onFrame.at(selection).entries.at(0).type = (PatchEngine::PatchType)EditPatchType->GetSelection(); + if (EditPatchValue->GetValue().ToULong(&value, 16)) + onFrame.at(selection).entries.at(0).value = value; + }*/ +} + +void CPatchAddEdit::OnClose(wxCloseEvent& WXUNUSED (event)) +{ + Destroy(); +} + +void CPatchAddEdit::ChangeEntry(wxSpinEvent& event) +{ + PatchEngine::PatchEntry pE = onFrame.at(selection).entries.at(event.GetPosition()); + EditPatchOffset->SetValue(wxString::Format(wxT("%08X"), pE.address)); + EditPatchType->SetSelection(pE.type); + EditPatchValue->SetValue(wxString::Format(wxT("%08X"), pE.value)); +} diff --git a/Source/Core/DolphinWX/Src/PatchAddEdit.h b/Source/Core/DolphinWX/Src/PatchAddEdit.h new file mode 100644 index 0000000000..11a4001f50 --- /dev/null +++ b/Source/Core/DolphinWX/Src/PatchAddEdit.h @@ -0,0 +1,58 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef __PATCH_ADDEDIT_h__ +#define __PATCH_ADDEDIT_h__ + +#include +#include +#include "ISOProperties.h" + +class CPatchAddEdit : public wxDialog +{ + public: + CPatchAddEdit(int _selection, wxWindow* parent, wxWindowID id = 1, const wxString& title = wxT("Edit Patch"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(300, -1), long style = wxDEFAULT_DIALOG_STYLE); + virtual ~CPatchAddEdit(); + + private: + DECLARE_EVENT_TABLE(); + + wxTextCtrl *EditPatchName; + wxTextCtrl *EditPatchOffset; + wxRadioBox *EditPatchType; + wxTextCtrl *EditPatchValue; + wxSpinButton *EntrySelection; + + enum { + ID_EDITPATCH_NAME_TEXT = 4500, + ID_EDITPATCH_NAME, + ID_EDITPATCH_OFFSET_TEXT, + ID_EDITPATCH_OFFSET, + ID_ENTRY_SELECT, + ID_EDITPATCH_TYPE, + ID_EDITPATCH_VALUE_TEXT, + ID_EDITPATCH_VALUE + }; + + void CreateGUIControls(int selection); + void OnClose(wxCloseEvent& event); + void ChangeEntry(wxSpinEvent& event); + + int selection; + +}; +#endif // __PATCH_ADDEDIT_h__