mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Clarified Patch Add/Edit, added AR Add/Edit by slink3
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2313 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -24,6 +24,8 @@ namespace ActionReplay
|
|||||||
{
|
{
|
||||||
|
|
||||||
struct AREntry {
|
struct AREntry {
|
||||||
|
AREntry() {}
|
||||||
|
AREntry(u32 _addr, u32 _value) : cmd_addr(_addr), value(_value) {}
|
||||||
u32 cmd_addr;
|
u32 cmd_addr;
|
||||||
u32 value;
|
u32 value;
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,7 @@ extern std::vector<ActionReplay::ARCode> arCodes;
|
|||||||
|
|
||||||
BEGIN_EVENT_TABLE(CARCodeAddEdit, wxDialog)
|
BEGIN_EVENT_TABLE(CARCodeAddEdit, wxDialog)
|
||||||
EVT_CLOSE(CARCodeAddEdit::OnClose)
|
EVT_CLOSE(CARCodeAddEdit::OnClose)
|
||||||
|
EVT_BUTTON(wxID_OK, CARCodeAddEdit::SaveCheatData)
|
||||||
EVT_SPIN(ID_ENTRY_SELECT, CARCodeAddEdit::ChangeEntry)
|
EVT_SPIN(ID_ENTRY_SELECT, CARCodeAddEdit::ChangeEntry)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@ -37,18 +38,28 @@ CARCodeAddEdit::~CARCodeAddEdit()
|
|||||||
|
|
||||||
void CARCodeAddEdit::CreateGUIControls(int _selection)
|
void CARCodeAddEdit::CreateGUIControls(int _selection)
|
||||||
{
|
{
|
||||||
ActionReplay::ARCode currentCode = arCodes.at(_selection);
|
wxString currentName = wxT("<Insert name here>");
|
||||||
|
|
||||||
|
if (_selection == -1)
|
||||||
|
{
|
||||||
|
tempEntries.name = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentName = wxString::FromAscii(arCodes.at(_selection).name.c_str());
|
||||||
|
tempEntries = arCodes.at(_selection);
|
||||||
|
}
|
||||||
|
|
||||||
wxBoxSizer* sEditCheat = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* sEditCheat = new wxBoxSizer(wxVERTICAL);
|
||||||
wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, _("Code"));
|
wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, _("Code"));
|
||||||
wxStaticText* EditCheatNameText = new wxStaticText(this, ID_EDITCHEAT_NAME_TEXT, _("Name:"), wxDefaultPosition, wxDefaultSize);
|
wxStaticText* EditCheatNameText = new wxStaticText(this, ID_EDITCHEAT_NAME_TEXT, _("Name:"), wxDefaultPosition, wxDefaultSize);
|
||||||
EditCheatName = new wxTextCtrl(this, ID_EDITCHEAT_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
EditCheatName = new wxTextCtrl(this, ID_EDITCHEAT_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
||||||
EditCheatName->SetValue(wxString::FromAscii(currentCode.name.c_str()));
|
EditCheatName->SetValue(currentName);
|
||||||
EntrySelection = new wxSpinButton(this, ID_ENTRY_SELECT, wxDefaultPosition, wxDefaultSize, wxVERTICAL);
|
EntrySelection = new wxSpinButton(this, ID_ENTRY_SELECT, wxDefaultPosition, wxDefaultSize, wxVERTICAL);
|
||||||
EntrySelection->SetRange(0, (int)arCodes.size()-1);
|
EntrySelection->SetRange(0, (int)arCodes.size()-1);
|
||||||
EntrySelection->SetValue((int)arCodes.size()-1 - _selection);
|
EntrySelection->SetValue((int)arCodes.size()-1 - _selection);
|
||||||
EditCheatCode = new wxTextCtrl(this, ID_EDITCHEAT_CODE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
|
EditCheatCode = new wxTextCtrl(this, ID_EDITCHEAT_CODE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
|
||||||
UpdateTextCtrl(currentCode);
|
UpdateTextCtrl(tempEntries);
|
||||||
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
|
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
|
||||||
sgEntry->AddGrowableCol(1);
|
sgEntry->AddGrowableCol(1);
|
||||||
sgEntry->AddGrowableRow(1);
|
sgEntry->AddGrowableRow(1);
|
||||||
@ -81,6 +92,50 @@ void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event)
|
|||||||
UpdateTextCtrl(currentCode);
|
UpdateTextCtrl(currentCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CARCodeAddEdit::SaveCheatData(wxCommandEvent& WXUNUSED (event))
|
||||||
|
{
|
||||||
|
|
||||||
|
std::vector<ActionReplay::AREntry> tempEntries;
|
||||||
|
std::string cheatValues = std::string(EditCheatCode->GetValue().mb_str());
|
||||||
|
bool bWhile = true; size_t line = 0;
|
||||||
|
|
||||||
|
while (bWhile)
|
||||||
|
{
|
||||||
|
bWhile = false;
|
||||||
|
u32 addr, value;
|
||||||
|
|
||||||
|
addr = strtol(std::string(cheatValues.substr(line, line+8)).c_str(), NULL, 16); // cmd_addr of ArCode
|
||||||
|
value = strtol(std::string(cheatValues.substr(line+9, line+17)).c_str(), NULL, 16); // value of ArCode
|
||||||
|
|
||||||
|
tempEntries.push_back(ActionReplay::AREntry(addr, value));
|
||||||
|
|
||||||
|
line = cheatValues.find("\n", line);
|
||||||
|
|
||||||
|
if (line != std::string::npos && cheatValues.length() > (line+17))
|
||||||
|
bWhile = true; // newline found, if not empty, go on
|
||||||
|
|
||||||
|
line += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selection == -1)
|
||||||
|
{
|
||||||
|
ActionReplay::ARCode newCheat;
|
||||||
|
newCheat.name = std::string(EditCheatName->GetValue().mb_str());
|
||||||
|
newCheat.ops = tempEntries;
|
||||||
|
|
||||||
|
newCheat.active = true;
|
||||||
|
|
||||||
|
arCodes.push_back(newCheat);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
arCodes.at(selection).name = std::string(EditCheatName->GetValue().mb_str());
|
||||||
|
arCodes.at(selection).ops = tempEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
AcceptAndClose();
|
||||||
|
}
|
||||||
|
|
||||||
void CARCodeAddEdit::UpdateTextCtrl(ActionReplay::ARCode arCode)
|
void CARCodeAddEdit::UpdateTextCtrl(ActionReplay::ARCode arCode)
|
||||||
{
|
{
|
||||||
EditCheatCode->Clear();
|
EditCheatCode->Clear();
|
||||||
|
@ -49,10 +49,12 @@ class CARCodeAddEdit : public wxDialog
|
|||||||
|
|
||||||
void CreateGUIControls(int selection);
|
void CreateGUIControls(int selection);
|
||||||
void OnClose(wxCloseEvent& event);
|
void OnClose(wxCloseEvent& event);
|
||||||
|
void SaveCheatData(wxCommandEvent& event);
|
||||||
void ChangeEntry(wxSpinEvent& event);
|
void ChangeEntry(wxSpinEvent& event);
|
||||||
void UpdateTextCtrl(ActionReplay::ARCode arCode);
|
void UpdateTextCtrl(ActionReplay::ARCode arCode);
|
||||||
|
|
||||||
int selection;
|
int selection;
|
||||||
|
ActionReplay::ARCode tempEntries;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // __PATCH_ADDEDIT_h__
|
#endif // __PATCH_ADDEDIT_h__
|
||||||
|
@ -730,7 +730,12 @@ void CISOProperties::ActionReplayButtonClicked(wxCommandEvent& event)
|
|||||||
break;
|
break;
|
||||||
case ID_ADDCHEAT:
|
case ID_ADDCHEAT:
|
||||||
{
|
{
|
||||||
// dialog
|
CARCodeAddEdit dlg(-1, this, 1, _("Add AR Code"));
|
||||||
|
if (dlg.ShowModal() == wxID_OK)
|
||||||
|
{
|
||||||
|
Cheats->Append(wxString::FromAscii(arCodes.back().name.c_str()));
|
||||||
|
Cheats->Check((unsigned int)(arCodes.size() - 1), arCodes.back().active);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ID_REMOVECHEAT:
|
case ID_REMOVECHEAT:
|
||||||
|
@ -82,7 +82,8 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
|
|||||||
sEditPatchName->Add(EditPatchNameText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
sEditPatchName->Add(EditPatchNameText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||||
sEditPatchName->Add(EditPatchName, 1, wxEXPAND|wxALL, 5);
|
sEditPatchName->Add(EditPatchName, 1, wxEXPAND|wxALL, 5);
|
||||||
sEditPatch->Add(sEditPatchName, 0, wxEXPAND);
|
sEditPatch->Add(sEditPatchName, 0, wxEXPAND);
|
||||||
wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, _("Entry"));
|
sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, wxString::Format(wxT("Entry 1/%d"), (int)tempEntries.size()));
|
||||||
|
currentItem = 1;
|
||||||
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
|
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
|
||||||
sgEntry->AddGrowableCol(1);
|
sgEntry->AddGrowableCol(1);
|
||||||
sgEntry->Add(EditPatchType, wxGBPosition(0, 0), wxGBSpan(1, 2), wxEXPAND|wxALL, 5);
|
sgEntry->Add(EditPatchType, wxGBPosition(0, 0), wxGBSpan(1, 2), wxEXPAND|wxALL, 5);
|
||||||
@ -119,6 +120,7 @@ void CPatchAddEdit::ChangeEntry(wxSpinEvent& event)
|
|||||||
SaveEntryData(itCurEntry);
|
SaveEntryData(itCurEntry);
|
||||||
|
|
||||||
itCurEntry = tempEntries.end() - event.GetPosition() - 1;
|
itCurEntry = tempEntries.end() - event.GetPosition() - 1;
|
||||||
|
currentItem = (int)tempEntries.size() - event.GetPosition();
|
||||||
UpdateEntryCtrls(*itCurEntry);
|
UpdateEntryCtrls(*itCurEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,6 +156,7 @@ void CPatchAddEdit::AddRemoveEntry(wxCommandEvent& event)
|
|||||||
|
|
||||||
PatchEngine::PatchEntry peEmptyEntry(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000);
|
PatchEngine::PatchEntry peEmptyEntry(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000);
|
||||||
itCurEntry++;
|
itCurEntry++;
|
||||||
|
currentItem++;
|
||||||
itCurEntry = tempEntries.insert(itCurEntry, peEmptyEntry);
|
itCurEntry = tempEntries.insert(itCurEntry, peEmptyEntry);
|
||||||
|
|
||||||
EntrySelection->SetRange(EntrySelection->GetMin(), EntrySelection->GetMax() + 1);
|
EntrySelection->SetRange(EntrySelection->GetMin(), EntrySelection->GetMax() + 1);
|
||||||
@ -170,6 +173,7 @@ void CPatchAddEdit::AddRemoveEntry(wxCommandEvent& event)
|
|||||||
if (itCurEntry != tempEntries.begin())
|
if (itCurEntry != tempEntries.begin())
|
||||||
{
|
{
|
||||||
itCurEntry--;
|
itCurEntry--;
|
||||||
|
currentItem--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -191,6 +195,8 @@ void CPatchAddEdit::AddRemoveEntry(wxCommandEvent& event)
|
|||||||
|
|
||||||
void CPatchAddEdit::UpdateEntryCtrls(PatchEngine::PatchEntry pE)
|
void CPatchAddEdit::UpdateEntryCtrls(PatchEngine::PatchEntry pE)
|
||||||
{
|
{
|
||||||
|
sbEntry->GetStaticBox()->SetLabel(wxString::Format(wxT("Entry %d/%d"), currentItem,
|
||||||
|
(int)tempEntries.size()));
|
||||||
EditPatchOffset->SetValue(wxString::Format(wxT("%08X"), pE.address));
|
EditPatchOffset->SetValue(wxString::Format(wxT("%08X"), pE.address));
|
||||||
EditPatchType->SetSelection(pE.type);
|
EditPatchType->SetSelection(pE.type);
|
||||||
EditPatchValue->SetValue(wxString::Format(wxT("%08X"), pE.value));
|
EditPatchValue->SetValue(wxString::Format(wxT("%08X"), pE.value));
|
||||||
|
@ -42,6 +42,7 @@ class CPatchAddEdit : public wxDialog
|
|||||||
wxTextCtrl *EditPatchValue;
|
wxTextCtrl *EditPatchValue;
|
||||||
wxSpinButton *EntrySelection;
|
wxSpinButton *EntrySelection;
|
||||||
wxButton *EntryRemove;
|
wxButton *EntryRemove;
|
||||||
|
wxStaticBoxSizer* sbEntry;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ID_EDITPATCH_NAME_TEXT = 4500,
|
ID_EDITPATCH_NAME_TEXT = 4500,
|
||||||
@ -64,7 +65,7 @@ class CPatchAddEdit : public wxDialog
|
|||||||
void UpdateEntryCtrls(PatchEngine::PatchEntry pE);
|
void UpdateEntryCtrls(PatchEngine::PatchEntry pE);
|
||||||
void SaveEntryData(std::vector<PatchEngine::PatchEntry>::iterator iterEntry);
|
void SaveEntryData(std::vector<PatchEngine::PatchEntry>::iterator iterEntry);
|
||||||
|
|
||||||
int selection;
|
int selection, currentItem;
|
||||||
std::vector<PatchEngine::PatchEntry> tempEntries;
|
std::vector<PatchEngine::PatchEntry> tempEntries;
|
||||||
std::vector<PatchEngine::PatchEntry>::iterator itCurEntry;
|
std::vector<PatchEngine::PatchEntry>::iterator itCurEntry;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user