summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorShawn Hoffman <godisgovernment@gmail.com>2008-12-01 20:55:45 +0000
committerShawn Hoffman <godisgovernment@gmail.com>2008-12-01 20:55:45 +0000
commit9a7a02fe636a3f74c5d9c79e297b79ea709dae8a (patch)
tree0ff5e86500961a707a23434db29d0b2831d7f428 /Source/Core
parent751124bb68ba86cc853526ff63b96d4fd1258c31 (diff)
bugfixes for patches and isoproperties (and starting on edit/add patches)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1370 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/Src/PatchEngine.cpp4
-rw-r--r--Source/Core/DolphinWX/Src/ISOProperties.cpp88
-rw-r--r--Source/Core/DolphinWX/Src/ISOProperties.h14
3 files changed, 100 insertions, 6 deletions
diff --git a/Source/Core/Core/Src/PatchEngine.cpp b/Source/Core/Core/Src/PatchEngine.cpp
index c436f42a33..9f2b691c45 100644
--- a/Source/Core/Core/Src/PatchEngine.cpp
+++ b/Source/Core/Core/Src/PatchEngine.cpp
@@ -70,6 +70,10 @@ void LoadPatchSection(const char *section, std::vector<Patch> &patches, IniFile
continue;
}
+ std::string::size_type loc = line.find_first_of('=', 0);
+ if (loc != std::string::npos)
+ line.at(loc) = ':';
+
std::vector<std::string> items;
SplitString(line, ":", items);
if (items.size() >= 3) {
diff --git a/Source/Core/DolphinWX/Src/ISOProperties.cpp b/Source/Core/DolphinWX/Src/ISOProperties.cpp
index 2071e441bc..6275dc3008 100644
--- a/Source/Core/DolphinWX/Src/ISOProperties.cpp
+++ b/Source/Core/DolphinWX/Src/ISOProperties.cpp
@@ -598,12 +598,18 @@ void CISOProperties::ListSelectionChanged(wxCommandEvent& event)
switch (event.GetId())
{
case ID_PATCHES_LIST:
- EditPatch->Enable();
- RemovePatch->Enable();
+ if (Patches->GetSelection() != wxNOT_FOUND)
+ {
+ EditPatch->Enable();
+ RemovePatch->Enable();
+ }
break;
case ID_CHEATS_LIST:
- EditCheat->Enable();
- RemoveCheat->Enable();
+ if (Cheats->GetSelection() != wxNOT_FOUND)
+ {
+ EditCheat->Enable();
+ RemoveCheat->Enable();
+ }
break;
}
}
@@ -611,6 +617,7 @@ void CISOProperties::ListSelectionChanged(wxCommandEvent& event)
void CISOProperties::PatchList_Load()
{
onFrame.clear();
+ Patches->Clear();
PatchEngine::LoadPatchSection("OnFrame", onFrame, GameIni);
u32 index = 0;
@@ -643,15 +650,83 @@ 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)
{
switch (event.GetId())
{
case ID_EDITPATCH:
- // dialog
+ {
+ int selection = Patches->GetSelection();
+ std::string currentName = onFrame.at(selection).name;
+ std::vector<PatchEngine::PatchEntry> 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;
+ }
+ }
break;
case ID_ADDPATCH:
- // dialog
+ {
+ // dialog;
+ }
break;
case ID_REMOVEPATCH:
onFrame.erase(onFrame.begin() + Patches->GetSelection());
@@ -669,6 +744,7 @@ void CISOProperties::PatchButtonClicked(wxCommandEvent& event)
void CISOProperties::ActionReplayList_Load()
{
ARCodes.clear();
+ Cheats->Clear();
std::vector<std::string> lines;
if (!GameIni.GetLines("ActionReplay", lines))
diff --git a/Source/Core/DolphinWX/Src/ISOProperties.h b/Source/Core/DolphinWX/Src/ISOProperties.h
index 418b487730..1bbf5a8c4b 100644
--- a/Source/Core/DolphinWX/Src/ISOProperties.h
+++ b/Source/Core/DolphinWX/Src/ISOProperties.h
@@ -86,6 +86,10 @@ 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;
@@ -155,6 +159,15 @@ 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,
@@ -200,6 +213,7 @@ 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);