Fix for AR code adding, as per sl1nk3.s's patch in issue 747.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2730 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
564cf2dac1
commit
374861d63d
|
@ -38,7 +38,7 @@ CARCodeAddEdit::~CARCodeAddEdit()
|
||||||
|
|
||||||
void CARCodeAddEdit::CreateGUIControls(int _selection)
|
void CARCodeAddEdit::CreateGUIControls(int _selection)
|
||||||
{
|
{
|
||||||
wxString currentName = wxT("<Insert name here>");
|
wxString currentName = wxT("Insert name here");
|
||||||
|
|
||||||
if (_selection == -1)
|
if (_selection == -1)
|
||||||
{
|
{
|
||||||
|
@ -56,8 +56,8 @@ void CARCodeAddEdit::CreateGUIControls(int _selection)
|
||||||
EditCheatName = new wxTextCtrl(this, ID_EDITCHEAT_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
EditCheatName = new wxTextCtrl(this, ID_EDITCHEAT_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
||||||
EditCheatName->SetValue(currentName);
|
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(1, ((int)arCodes.size()) > 0 ? (int)arCodes.size() : 1);
|
||||||
EntrySelection->SetValue((int)arCodes.size()-1 - _selection);
|
EntrySelection->SetValue((int)(arCodes.size() - _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(tempEntries);
|
UpdateTextCtrl(tempEntries);
|
||||||
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
|
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
|
||||||
|
@ -87,7 +87,7 @@ void CARCodeAddEdit::OnClose(wxCloseEvent& WXUNUSED (event))
|
||||||
|
|
||||||
void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event)
|
void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event)
|
||||||
{
|
{
|
||||||
ActionReplay::ARCode currentCode = arCodes.at((int)arCodes.size()-1 - event.GetPosition());
|
ActionReplay::ARCode currentCode = arCodes.at((int)arCodes.size() - event.GetPosition());
|
||||||
EditCheatName->SetValue(wxString::FromAscii(currentCode.name.c_str()));
|
EditCheatName->SetValue(wxString::FromAscii(currentCode.name.c_str()));
|
||||||
UpdateTextCtrl(currentCode);
|
UpdateTextCtrl(currentCode);
|
||||||
}
|
}
|
||||||
|
@ -97,24 +97,19 @@ void CARCodeAddEdit::SaveCheatData(wxCommandEvent& WXUNUSED (event))
|
||||||
|
|
||||||
std::vector<ActionReplay::AREntry> tempEntries;
|
std::vector<ActionReplay::AREntry> tempEntries;
|
||||||
std::string cheatValues = std::string(EditCheatCode->GetValue().mb_str());
|
std::string cheatValues = std::string(EditCheatCode->GetValue().mb_str());
|
||||||
bool bWhile = true; size_t line = 0;
|
size_t line = 0;
|
||||||
|
|
||||||
while (bWhile)
|
|
||||||
{
|
|
||||||
bWhile = false;
|
|
||||||
u32 addr, value;
|
u32 addr, value;
|
||||||
|
|
||||||
addr = strtol(std::string(cheatValues.substr(line, line+8)).c_str(), NULL, 16); // cmd_addr of ArCode
|
while (cheatValues.length() > (line + 17) && (line != std::string::npos))
|
||||||
value = strtol(std::string(cheatValues.substr(line+9, line+17)).c_str(), NULL, 16); // value of ArCode
|
{
|
||||||
|
// there's no newline, or newline is imcomplete, stop here.
|
||||||
|
|
||||||
|
addr = strtol(std::string(cheatValues.substr(line, line+8)).c_str(), NULL, 16);
|
||||||
|
value = strtol(std::string(cheatValues.substr(line+9, line+17)).c_str(), NULL, 16);
|
||||||
|
|
||||||
tempEntries.push_back(ActionReplay::AREntry(addr, value));
|
tempEntries.push_back(ActionReplay::AREntry(addr, value));
|
||||||
|
|
||||||
line = cheatValues.find("\n", line);
|
line = cheatValues.find('\n', line+1);
|
||||||
|
|
||||||
if (line != std::string::npos && cheatValues.length() > (line+17))
|
|
||||||
bWhile = true; // newline found, if not empty, go on
|
|
||||||
|
|
||||||
line++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selection == -1)
|
if (selection == -1)
|
||||||
|
|
Loading…
Reference in New Issue