2013-04-18 03:43:35 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <climits>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/chartype.h>
|
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/checklst.h>
|
|
|
|
#include <wx/choice.h>
|
|
|
|
#include <wx/defs.h>
|
|
|
|
#include <wx/dialog.h>
|
|
|
|
#include <wx/event.h>
|
|
|
|
#include <wx/gdicmn.h>
|
|
|
|
#include <wx/listbox.h>
|
2014-07-25 01:46:46 +00:00
|
|
|
#include <wx/msgdlg.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/notebook.h>
|
|
|
|
#include <wx/panel.h>
|
|
|
|
#include <wx/radiobut.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/statbox.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
#include <wx/toplevel.h>
|
|
|
|
#include <wx/translation.h>
|
|
|
|
#include <wx/validate.h>
|
|
|
|
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/IniFile.h"
|
2014-07-08 20:19:34 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/ActionReplay.h"
|
|
|
|
#include "Core/ConfigManager.h"
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "Core/Core.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Core/CoreParameter.h"
|
|
|
|
#include "Core/GeckoCode.h"
|
|
|
|
#include "Core/GeckoCodeConfig.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/HW/Memmap.h"
|
|
|
|
#include "DolphinWX/CheatsWindow.h"
|
|
|
|
#include "DolphinWX/Frame.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "DolphinWX/GeckoCodeDiag.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/ISOProperties.h"
|
2014-07-08 14:49:33 +00:00
|
|
|
#include "DolphinWX/Main.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
|
|
|
|
2014-02-22 22:36:30 +00:00
|
|
|
class wxWindow;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
#define MAX_CHEAT_SEARCH_RESULTS_DISPLAY 256
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
// meh
|
|
|
|
static wxCheatsWindow *g_cheat_window;
|
|
|
|
|
|
|
|
wxCheatsWindow::wxCheatsWindow(wxWindow* const parent)
|
2013-09-23 02:48:50 +00:00
|
|
|
: wxDialog(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxDIALOG_NO_PARENT)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2010-07-18 04:13:16 +00:00
|
|
|
::g_cheat_window = this;
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
// Create the GUI controls
|
|
|
|
Init_ChildControls();
|
|
|
|
|
2013-05-04 17:27:39 +00:00
|
|
|
// load codes
|
|
|
|
UpdateGUI();
|
2010-07-22 01:48:48 +00:00
|
|
|
|
2012-12-04 01:58:25 +00:00
|
|
|
SetSize(wxSize(-1, 600));
|
2010-07-18 04:13:16 +00:00
|
|
|
Center();
|
2008-12-08 05:30:24 +00:00
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
2011-02-27 02:27:43 +00:00
|
|
|
wxCheatsWindow::~wxCheatsWindow()
|
|
|
|
{
|
2014-03-09 20:14:26 +00:00
|
|
|
main_frame->g_CheatsWindow = nullptr;
|
|
|
|
::g_cheat_window = nullptr;
|
2011-02-27 02:27:43 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void wxCheatsWindow::Init_ChildControls()
|
|
|
|
{
|
2010-07-18 04:13:16 +00:00
|
|
|
wxPanel* const panel = new wxPanel(this);
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
// Main Notebook
|
2014-03-06 04:02:34 +00:00
|
|
|
m_Notebook_Main = new wxNotebook(panel, wxID_ANY);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
// --- Tabs ---
|
|
|
|
// $ Cheats List Tab
|
2014-03-06 04:02:34 +00:00
|
|
|
m_Tab_Cheats = new wxPanel(m_Notebook_Main, wxID_ANY);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-07-18 04:13:16 +00:00
|
|
|
m_CheckListBox_CheatsList = new wxCheckListBox(m_Tab_Cheats, wxID_ANY, wxDefaultPosition, wxSize(300, 0), m_CheatStringList, wxLB_HSCROLL, wxDefaultValidator);
|
2014-05-17 16:49:00 +00:00
|
|
|
m_CheckListBox_CheatsList->Bind(wxEVT_LISTBOX, &wxCheatsWindow::OnEvent_CheatsList_ItemSelected, this);
|
|
|
|
m_CheckListBox_CheatsList->Bind(wxEVT_CHECKLISTBOX, &wxCheatsWindow::OnEvent_CheatsList_ItemToggled, this);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_Label_Codename = new wxStaticText(m_Tab_Cheats, wxID_ANY, _("Name: "));
|
|
|
|
m_GroupBox_Info = new wxStaticBox(m_Tab_Cheats, wxID_ANY, _("Code Info"));
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_Label_NumCodes = new wxStaticText(m_Tab_Cheats, wxID_ANY, _("Number Of Codes: "));
|
2014-03-09 20:14:26 +00:00
|
|
|
m_ListBox_CodesList = new wxListBox(m_Tab_Cheats, wxID_ANY, wxDefaultPosition, wxSize(120, 150), 0, nullptr, wxLB_HSCROLL);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-07-18 04:13:16 +00:00
|
|
|
wxStaticBoxSizer* sGroupBoxInfo = new wxStaticBoxSizer(m_GroupBox_Info, wxVERTICAL);
|
|
|
|
sGroupBoxInfo->Add(m_Label_Codename, 0, wxALL, 5);
|
|
|
|
sGroupBoxInfo->Add(m_Label_NumCodes, 0, wxALL, 5);
|
|
|
|
sGroupBoxInfo->Add(m_ListBox_CodesList, 1, wxALL, 5);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-07-18 04:13:16 +00:00
|
|
|
wxBoxSizer* sizer_tab_cheats = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
sizer_tab_cheats->Add(m_CheckListBox_CheatsList, 1, wxEXPAND | wxTOP | wxBOTTOM | wxLEFT, 10);
|
2010-07-22 01:48:48 +00:00
|
|
|
sizer_tab_cheats->Add(sGroupBoxInfo, 0, wxALIGN_LEFT | wxEXPAND | wxALL, 5);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2013-10-29 05:23:17 +00:00
|
|
|
m_Tab_Cheats->SetSizerAndFit(sizer_tab_cheats);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-07-18 04:13:16 +00:00
|
|
|
// $ Cheat Search Tab
|
|
|
|
wxPanel* const tab_cheat_search = new CheatSearchTab(m_Notebook_Main);
|
2008-12-12 06:44:02 +00:00
|
|
|
|
2010-07-18 04:13:16 +00:00
|
|
|
// $ Log Tab
|
2014-03-06 04:02:34 +00:00
|
|
|
m_Tab_Log = new wxPanel(m_Notebook_Main, wxID_ANY);
|
2008-12-12 06:44:02 +00:00
|
|
|
|
2011-01-05 04:35:46 +00:00
|
|
|
wxButton* const button_updatelog = new wxButton(m_Tab_Log, wxID_ANY, _("Update"));
|
2014-05-17 16:49:00 +00:00
|
|
|
button_updatelog->Bind(wxEVT_BUTTON, &wxCheatsWindow::OnEvent_ButtonUpdateLog_Press, this);
|
2008-12-12 06:44:02 +00:00
|
|
|
|
2011-01-05 04:35:46 +00:00
|
|
|
m_CheckBox_LogAR = new wxCheckBox(m_Tab_Log, wxID_ANY, _("Enable AR Logging"));
|
2014-05-17 16:49:00 +00:00
|
|
|
m_CheckBox_LogAR->Bind(wxEVT_CHECKBOX, &wxCheatsWindow::OnEvent_CheckBoxEnableLogging_StateChange, this);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
m_CheckBox_LogAR->SetValue(ActionReplay::IsSelfLogging());
|
2014-05-17 17:17:28 +00:00
|
|
|
m_TextCtrl_Log = new wxTextCtrl(m_Tab_Log, wxID_ANY, "", wxDefaultPosition, wxSize(100, -1), wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
wxBoxSizer *HStrip1 = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
HStrip1->Add(m_CheckBox_LogAR, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
|
|
|
|
HStrip1->Add(button_updatelog, 0, wxALL, 5);
|
|
|
|
|
|
|
|
wxBoxSizer *sTabLog = new wxBoxSizer(wxVERTICAL);
|
|
|
|
sTabLog->Add(HStrip1, 0, wxALL, 5);
|
|
|
|
sTabLog->Add(m_TextCtrl_Log, 1, wxALL|wxEXPAND, 5);
|
|
|
|
|
|
|
|
m_Tab_Log->SetSizerAndFit(sTabLog);
|
2008-12-12 06:44:02 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
// Add Tabs to Notebook
|
2011-01-05 04:35:46 +00:00
|
|
|
m_Notebook_Main->AddPage(m_Tab_Cheats, _("AR Codes"));
|
2010-07-22 01:48:48 +00:00
|
|
|
m_geckocode_panel = new Gecko::CodeConfigPanel(m_Notebook_Main);
|
2011-01-05 04:35:46 +00:00
|
|
|
m_Notebook_Main->AddPage(m_geckocode_panel, _("Gecko Codes"));
|
|
|
|
m_Notebook_Main->AddPage(tab_cheat_search, _("Cheat Search"));
|
|
|
|
m_Notebook_Main->AddPage(m_Tab_Log, _("Logging"));
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
// Button Strip
|
2014-03-06 04:02:34 +00:00
|
|
|
button_apply = new wxButton(panel, wxID_APPLY, _("Apply"));
|
2014-05-17 16:49:00 +00:00
|
|
|
button_apply->Bind(wxEVT_BUTTON, &wxCheatsWindow::OnEvent_ApplyChanges_Press, this);
|
2014-03-06 04:02:34 +00:00
|
|
|
wxButton* const button_cancel = new wxButton(panel, wxID_CANCEL, _("Cancel"));
|
2014-05-17 16:49:00 +00:00
|
|
|
button_cancel->Bind(wxEVT_BUTTON, &wxCheatsWindow::OnEvent_ButtonClose_Press, this);
|
2011-06-17 09:19:13 +00:00
|
|
|
|
2013-01-13 18:07:45 +00:00
|
|
|
Bind(wxEVT_CLOSE_WINDOW, &wxCheatsWindow::OnEvent_Close, this);
|
2011-06-17 09:19:13 +00:00
|
|
|
|
2011-06-03 12:26:32 +00:00
|
|
|
wxStdDialogButtonSizer* const sButtons = new wxStdDialogButtonSizer();
|
|
|
|
sButtons->AddButton(button_apply);
|
|
|
|
sButtons->AddButton(button_cancel);
|
|
|
|
sButtons->Realize();
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-07-18 04:13:16 +00:00
|
|
|
wxBoxSizer* const sMain = new wxBoxSizer(wxVERTICAL);
|
2008-12-08 05:30:24 +00:00
|
|
|
sMain->Add(m_Notebook_Main, 1, wxEXPAND|wxALL, 5);
|
2010-07-18 04:13:16 +00:00
|
|
|
sMain->Add(sButtons, 0, wxRIGHT | wxBOTTOM | wxALIGN_RIGHT, 5);
|
|
|
|
panel->SetSizerAndFit(sMain);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-07-18 04:13:16 +00:00
|
|
|
wxBoxSizer* const frame_szr = new wxBoxSizer(wxVERTICAL);
|
|
|
|
frame_szr->Add(panel, 1, wxEXPAND);
|
|
|
|
SetSizerAndFit(frame_szr);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
CheatSearchTab::CheatSearchTab(wxWindow* const parent)
|
2014-03-06 04:02:34 +00:00
|
|
|
: wxPanel(parent, -1)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2010-07-22 05:28:24 +00:00
|
|
|
// first scan button
|
2011-01-05 04:35:46 +00:00
|
|
|
btnInitScan = new wxButton(this, -1, _("New Scan"));
|
2014-05-17 16:49:00 +00:00
|
|
|
btnInitScan->Bind(wxEVT_BUTTON, &CheatSearchTab::StartNewSearch, this);
|
2010-07-22 05:28:24 +00:00
|
|
|
|
|
|
|
// next scan button
|
2011-01-05 04:35:46 +00:00
|
|
|
btnNextScan = new wxButton(this, -1, _("Next Scan"));
|
2014-05-17 16:49:00 +00:00
|
|
|
btnNextScan->Bind(wxEVT_BUTTON, &CheatSearchTab::FilterCheatSearchResults, this);
|
2010-07-22 05:28:24 +00:00
|
|
|
btnNextScan->Disable();
|
|
|
|
|
|
|
|
// data size radio buttons
|
2011-01-15 02:30:36 +00:00
|
|
|
size_radiobtn.rad_8 = new wxRadioButton(this, -1, _("8 bit"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
|
|
|
|
size_radiobtn.rad_16 = new wxRadioButton(this, -1, _("16 bit"));
|
|
|
|
size_radiobtn.rad_32 = new wxRadioButton(this, -1, _("32 bit"));
|
2010-07-18 04:13:16 +00:00
|
|
|
size_radiobtn.rad_8->SetValue(true);
|
|
|
|
|
2010-07-22 05:28:24 +00:00
|
|
|
// data sizes groupbox
|
2011-01-05 04:35:46 +00:00
|
|
|
wxStaticBoxSizer* const sizer_cheat_new_search = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Data Size"));
|
2010-07-22 05:28:24 +00:00
|
|
|
sizer_cheat_new_search->Add(size_radiobtn.rad_8, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 5);
|
|
|
|
sizer_cheat_new_search->Add(size_radiobtn.rad_16, 0, wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 5);
|
|
|
|
sizer_cheat_new_search->Add(size_radiobtn.rad_32, 0, wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 5);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2010-07-22 05:28:24 +00:00
|
|
|
// result controls
|
2014-03-06 04:02:34 +00:00
|
|
|
lbox_search_results = new wxListBox(this, -1);
|
2011-01-05 04:35:46 +00:00
|
|
|
label_results_count = new wxStaticText(this, -1, _("Count:"));
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2010-07-22 05:28:24 +00:00
|
|
|
// create AR code button
|
2011-01-05 04:35:46 +00:00
|
|
|
wxButton* const button_cheat_search_copy_address = new wxButton(this, -1, _("Create AR Code"));
|
2014-05-17 16:49:00 +00:00
|
|
|
button_cheat_search_copy_address->Bind(wxEVT_BUTTON, &CheatSearchTab::CreateARCode, this);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2010-07-22 05:28:24 +00:00
|
|
|
// results groupbox
|
2011-01-05 04:35:46 +00:00
|
|
|
wxStaticBoxSizer* const sizer_cheat_search_results = new wxStaticBoxSizer(wxVERTICAL, this, _("Results"));
|
2010-07-18 04:13:16 +00:00
|
|
|
sizer_cheat_search_results->Add(label_results_count, 0, wxALIGN_LEFT | wxALL, 5);
|
|
|
|
sizer_cheat_search_results->Add(lbox_search_results, 1, wxEXPAND | wxALL, 5);
|
|
|
|
sizer_cheat_search_results->Add(button_cheat_search_copy_address, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5);
|
|
|
|
|
2010-07-22 05:28:24 +00:00
|
|
|
// Search value radio buttons
|
2011-01-05 04:35:46 +00:00
|
|
|
value_x_radiobtn.rad_oldvalue = new wxRadioButton(this, -1, _("Previous Value"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
|
2014-05-17 17:17:28 +00:00
|
|
|
value_x_radiobtn.rad_uservalue = new wxRadioButton(this, -1, "");
|
2010-07-18 04:13:16 +00:00
|
|
|
value_x_radiobtn.rad_oldvalue->SetValue(true);
|
|
|
|
|
2010-07-22 05:28:24 +00:00
|
|
|
// search value textbox
|
2014-05-17 17:17:28 +00:00
|
|
|
textctrl_value_x = new wxTextCtrl(this, -1, "0x0", wxDefaultPosition, wxSize(96,-1));
|
2013-01-13 08:28:12 +00:00
|
|
|
textctrl_value_x->Bind(wxEVT_SET_FOCUS, &CheatSearchTab::ApplyFocus, this);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
wxBoxSizer* const sizer_cheat_filter_text = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
sizer_cheat_filter_text->Add(value_x_radiobtn.rad_uservalue, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
|
|
|
|
sizer_cheat_filter_text->Add(textctrl_value_x, 1, wxALIGN_CENTER_VERTICAL, 5);
|
|
|
|
|
2010-07-22 05:28:24 +00:00
|
|
|
// value groupbox
|
2011-01-05 04:35:46 +00:00
|
|
|
wxStaticBoxSizer* const sizer_cheat_search_filter_x = new wxStaticBoxSizer(wxVERTICAL, this, _("Value"));
|
2010-07-18 04:13:16 +00:00
|
|
|
sizer_cheat_search_filter_x->Add(value_x_radiobtn.rad_oldvalue, 0, wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
2010-07-22 05:28:24 +00:00
|
|
|
sizer_cheat_search_filter_x->Add(sizer_cheat_filter_text, 0, wxALL | wxEXPAND, 5);
|
|
|
|
|
|
|
|
// filter types in the compare dropdown
|
|
|
|
static const wxString searches[] = {
|
2011-01-05 04:35:46 +00:00
|
|
|
_("Unknown"),
|
|
|
|
_("Not Equal"),
|
|
|
|
_("Equal"),
|
|
|
|
_("Greater Than"),
|
|
|
|
_("Less Than"),
|
2010-07-22 05:28:24 +00:00
|
|
|
// TODO: Implement between search.
|
2011-01-05 04:35:46 +00:00
|
|
|
//_("Between"),
|
2010-07-22 05:28:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
search_type = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, sizeof(searches)/sizeof(*searches), searches);
|
|
|
|
search_type->Select(0);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2011-01-05 04:35:46 +00:00
|
|
|
wxStaticBoxSizer* const sizer_cheat_search_filter = new wxStaticBoxSizer(wxVERTICAL, this, _("Search Filter"));
|
2010-07-22 05:28:24 +00:00
|
|
|
sizer_cheat_search_filter->Add(sizer_cheat_search_filter_x, 0, wxALL | wxEXPAND, 5);
|
|
|
|
sizer_cheat_search_filter->Add(search_type, 0, wxALL, 5);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
// left sizer
|
|
|
|
wxBoxSizer* const sizer_left = new wxBoxSizer(wxVERTICAL);
|
|
|
|
sizer_left->Add(sizer_cheat_search_results, 1, wxEXPAND, 5);
|
|
|
|
|
2010-07-22 05:28:24 +00:00
|
|
|
// button sizer
|
|
|
|
wxBoxSizer* boxButtons = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
boxButtons->Add(btnInitScan, 1, wxRIGHT, 5);
|
|
|
|
boxButtons->Add(btnNextScan, 1);
|
|
|
|
|
2010-07-18 04:13:16 +00:00
|
|
|
// right sizer
|
|
|
|
wxBoxSizer* const sizer_right = new wxBoxSizer(wxVERTICAL);
|
2010-07-22 05:28:24 +00:00
|
|
|
sizer_right->Add(sizer_cheat_new_search, 0, wxBOTTOM, 5);
|
2010-07-18 04:13:16 +00:00
|
|
|
sizer_right->Add(sizer_cheat_search_filter, 0, wxEXPAND | wxBOTTOM, 5);
|
|
|
|
sizer_right->AddStretchSpacer(1);
|
2010-07-22 05:28:24 +00:00
|
|
|
sizer_right->Add(boxButtons, 0, wxTOP | wxEXPAND, 5);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
// main sizer
|
|
|
|
wxBoxSizer* const sizer_main = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
sizer_main->Add(sizer_left, 1, wxEXPAND | wxALL, 5);
|
|
|
|
sizer_main->Add(sizer_right, 0, wxEXPAND | wxALL, 5);
|
|
|
|
|
|
|
|
SetSizerAndFit(sizer_main);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2011-06-17 09:19:13 +00:00
|
|
|
void wxCheatsWindow::OnEvent_ButtonClose_Press(wxCommandEvent& WXUNUSED (event))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-06-17 09:19:13 +00:00
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxCheatsWindow::OnEvent_Close(wxCloseEvent& ev)
|
|
|
|
{
|
|
|
|
Destroy();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2013-05-04 17:27:39 +00:00
|
|
|
// load codes for a new ISO ID
|
|
|
|
void wxCheatsWindow::UpdateGUI()
|
|
|
|
{
|
|
|
|
// load code
|
2014-09-09 04:24:49 +00:00
|
|
|
m_gameini_default = SConfig::GetInstance().m_LocalCoreStartupParameter.LoadDefaultGameIni();
|
|
|
|
m_gameini_local = SConfig::GetInstance().m_LocalCoreStartupParameter.LoadLocalGameIni();
|
|
|
|
m_gameini_local_path = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIniLocal;
|
2013-05-04 17:27:39 +00:00
|
|
|
Load_ARCodes();
|
|
|
|
Load_GeckoCodes();
|
|
|
|
|
|
|
|
// enable controls
|
|
|
|
button_apply->Enable(Core::IsRunning());
|
|
|
|
|
2013-09-23 02:48:50 +00:00
|
|
|
wxString title = _("Cheats Manager");
|
|
|
|
|
2013-05-04 17:27:39 +00:00
|
|
|
// write the ISO name in the title
|
|
|
|
if (Core::IsRunning())
|
2014-09-09 04:24:49 +00:00
|
|
|
SetTitle(title + ": " + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + " - " + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strName);
|
2013-05-04 17:27:39 +00:00
|
|
|
else
|
|
|
|
SetTitle(title);
|
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void wxCheatsWindow::Load_ARCodes()
|
|
|
|
{
|
2010-07-18 04:13:16 +00:00
|
|
|
using namespace ActionReplay;
|
|
|
|
|
|
|
|
m_CheckListBox_CheatsList->Clear();
|
|
|
|
|
2013-05-04 17:27:39 +00:00
|
|
|
if (!Core::IsRunning())
|
|
|
|
return;
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
indexList.clear();
|
2008-12-17 04:14:24 +00:00
|
|
|
size_t size = GetCodeListSize();
|
2008-12-08 05:30:24 +00:00
|
|
|
for (size_t i = 0; i < size; i++)
|
|
|
|
{
|
2008-12-17 04:14:24 +00:00
|
|
|
ARCode code = GetARCode(i);
|
2008-12-08 05:30:24 +00:00
|
|
|
ARCodeIndex ind;
|
2013-02-28 04:37:38 +00:00
|
|
|
u32 index = m_CheckListBox_CheatsList->Append(StrToWxStr(code.name));
|
2008-12-08 05:30:24 +00:00
|
|
|
m_CheckListBox_CheatsList->Check(index, code.active);
|
|
|
|
ind.index = i;
|
|
|
|
ind.uiIndex = index;
|
|
|
|
indexList.push_back(ind);
|
|
|
|
}
|
|
|
|
}
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2013-05-04 17:27:39 +00:00
|
|
|
void wxCheatsWindow::Load_GeckoCodes()
|
|
|
|
{
|
2014-09-09 04:24:49 +00:00
|
|
|
m_geckocode_panel->LoadCodes(m_gameini_default, m_gameini_local, SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID(), true);
|
2013-05-04 17:27:39 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void wxCheatsWindow::OnEvent_CheatsList_ItemSelected(wxCommandEvent& WXUNUSED (event))
|
|
|
|
{
|
2010-07-18 04:13:16 +00:00
|
|
|
using namespace ActionReplay;
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
int index = m_CheckListBox_CheatsList->GetSelection();
|
|
|
|
for (size_t i = 0; i < indexList.size(); i++)
|
|
|
|
{
|
|
|
|
if ((int)indexList[i].uiIndex == index)
|
|
|
|
{
|
2008-12-17 04:14:24 +00:00
|
|
|
ARCode code = GetARCode(i);
|
2013-02-28 04:37:38 +00:00
|
|
|
m_Label_Codename->SetLabel(_("Name: ") + StrToWxStr(code.name));
|
2014-07-08 20:19:34 +00:00
|
|
|
|
|
|
|
std::string numcodes = StringFromFormat("Number of Codes: %lu", (unsigned long)code.ops.size());
|
2013-02-28 04:37:38 +00:00
|
|
|
m_Label_NumCodes->SetLabel(StrToWxStr(numcodes));
|
2008-12-08 05:30:24 +00:00
|
|
|
m_ListBox_CodesList->Clear();
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2014-03-03 05:25:15 +00:00
|
|
|
for (const AREntry& entry : code.ops)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2014-07-08 20:19:34 +00:00
|
|
|
std::string ops = StringFromFormat("%08x %08x", entry.cmd_addr, entry.value);
|
2013-02-28 04:37:38 +00:00
|
|
|
m_ListBox_CodesList->Append(StrToWxStr(ops));
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void wxCheatsWindow::OnEvent_CheatsList_ItemToggled(wxCommandEvent& WXUNUSED (event))
|
|
|
|
{
|
|
|
|
int index = m_CheckListBox_CheatsList->GetSelection();
|
2014-03-03 05:25:15 +00:00
|
|
|
for (const ARCodeIndex& code_index : indexList)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2014-03-03 05:25:15 +00:00
|
|
|
if ((int)code_index.uiIndex == index)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2014-03-03 05:25:15 +00:00
|
|
|
ActionReplay::SetARCode_IsActive(m_CheckListBox_CheatsList->IsChecked(index), code_index.index);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2011-06-03 12:26:32 +00:00
|
|
|
void wxCheatsWindow::OnEvent_ApplyChanges_Press(wxCommandEvent& ev)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2013-04-19 13:21:45 +00:00
|
|
|
// Apply AR Code changes
|
2014-03-03 05:25:15 +00:00
|
|
|
for (const ARCodeIndex& code_index : indexList)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2014-03-03 05:25:15 +00:00
|
|
|
ActionReplay::SetARCode_IsActive(m_CheckListBox_CheatsList->IsChecked(code_index.uiIndex), code_index.index);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2010-07-22 01:48:48 +00:00
|
|
|
|
|
|
|
// Apply Gecko Code changes
|
|
|
|
Gecko::SetActiveCodes(m_geckocode_panel->GetCodes());
|
|
|
|
|
2013-04-08 05:16:50 +00:00
|
|
|
// Save gameini, with changed gecko codes
|
2013-09-07 21:02:49 +00:00
|
|
|
if (m_gameini_local_path.size())
|
2010-07-22 01:48:48 +00:00
|
|
|
{
|
2013-09-07 21:02:49 +00:00
|
|
|
Gecko::SaveCodes(m_gameini_local, m_geckocode_panel->GetCodes());
|
|
|
|
m_gameini_local.Save(m_gameini_local_path);
|
2010-07-22 01:48:48 +00:00
|
|
|
}
|
2011-06-03 12:26:32 +00:00
|
|
|
|
|
|
|
ev.Skip();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2008-12-12 06:44:02 +00:00
|
|
|
|
|
|
|
void wxCheatsWindow::OnEvent_ButtonUpdateLog_Press(wxCommandEvent& WXUNUSED (event))
|
|
|
|
{
|
|
|
|
m_TextCtrl_Log->Clear();
|
2014-03-03 05:25:15 +00:00
|
|
|
for (const std::string& text : ActionReplay::GetSelfLog())
|
2008-12-12 06:44:02 +00:00
|
|
|
{
|
2014-03-03 05:25:15 +00:00
|
|
|
m_TextCtrl_Log->AppendText(StrToWxStr(text));
|
2008-12-12 06:44:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxCheatsWindow::OnEvent_CheckBoxEnableLogging_StateChange(wxCommandEvent& WXUNUSED (event))
|
|
|
|
{
|
2010-07-18 04:13:16 +00:00
|
|
|
ActionReplay::EnableSelfLogging(m_CheckBox_LogAR->IsChecked());
|
|
|
|
}
|
|
|
|
|
|
|
|
void CheatSearchTab::StartNewSearch(wxCommandEvent& WXUNUSED (event))
|
|
|
|
{
|
|
|
|
const u8* const memptr = Memory::GetPointer(0);
|
2014-03-09 20:14:26 +00:00
|
|
|
if (nullptr == memptr)
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
2014-07-25 01:46:46 +00:00
|
|
|
WxUtils::ShowErrorDialog(_("A game is not currently running."));
|
2011-06-13 15:47:02 +00:00
|
|
|
return;
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
2011-06-13 15:47:02 +00:00
|
|
|
|
|
|
|
// Determine the user-selected data size for this search.
|
|
|
|
search_type_size =
|
|
|
|
size_radiobtn.rad_8->GetValue() +
|
|
|
|
(size_radiobtn.rad_16->GetValue() << 1) +
|
|
|
|
(size_radiobtn.rad_32->GetValue() << 2);
|
|
|
|
|
|
|
|
// Set up the search results efficiently to prevent automatic re-allocations.
|
|
|
|
search_results.clear();
|
|
|
|
search_results.reserve(Memory::RAM_SIZE / search_type_size);
|
|
|
|
|
|
|
|
// Enable the "Next Scan" button.
|
|
|
|
btnNextScan->Enable();
|
|
|
|
|
|
|
|
CheatSearchResult r;
|
|
|
|
// can I assume cheatable values will be aligned like this?
|
|
|
|
for (u32 addr = 0; addr != Memory::RAM_SIZE; addr += search_type_size)
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
2011-06-13 15:47:02 +00:00
|
|
|
r.address = addr;
|
|
|
|
memcpy(&r.old_value, memptr + addr, search_type_size);
|
|
|
|
search_results.push_back(r);
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UpdateCheatSearchResultsList();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CheatSearchTab::FilterCheatSearchResults(wxCommandEvent&)
|
|
|
|
{
|
|
|
|
const u8* const memptr = Memory::GetPointer(0);
|
2014-03-09 20:14:26 +00:00
|
|
|
if (nullptr == memptr)
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
2014-07-25 01:46:46 +00:00
|
|
|
WxUtils::ShowErrorDialog(_("A game is not currently running."));
|
2011-06-13 15:47:02 +00:00
|
|
|
return;
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
|
|
|
|
2011-06-13 15:47:02 +00:00
|
|
|
// Set up the sub-search results efficiently to prevent automatic re-allocations.
|
|
|
|
std::vector<CheatSearchResult> filtered_results;
|
|
|
|
filtered_results.reserve(search_results.size());
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
|
2013-04-08 05:16:50 +00:00
|
|
|
// Determine the selected filter
|
2011-06-13 15:47:02 +00:00
|
|
|
// 1 : equal
|
|
|
|
// 2 : greater-than
|
|
|
|
// 4 : less-than
|
|
|
|
|
|
|
|
const int filters[] = {7, 6, 1, 2, 4};
|
|
|
|
int filter_mask = filters[search_type->GetSelection()];
|
|
|
|
|
2014-02-17 04:51:41 +00:00
|
|
|
if (value_x_radiobtn.rad_oldvalue->GetValue()) // using old value comparison
|
2011-06-13 15:47:02 +00:00
|
|
|
{
|
2014-03-03 05:25:15 +00:00
|
|
|
for (CheatSearchResult& result : search_results)
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
2011-06-13 15:47:02 +00:00
|
|
|
// with big endian, can just use memcmp for ><= comparison
|
2014-03-03 05:25:15 +00:00
|
|
|
int cmp_result = memcmp(memptr + result.address, &result.old_value, search_type_size);
|
2011-06-13 15:47:02 +00:00
|
|
|
if (cmp_result < 0)
|
|
|
|
cmp_result = 4;
|
|
|
|
else
|
|
|
|
cmp_result = cmp_result ? 2 : 1;
|
|
|
|
|
|
|
|
if (cmp_result & filter_mask)
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
2014-03-03 05:25:15 +00:00
|
|
|
memcpy(&result.old_value, memptr + result.address, search_type_size);
|
|
|
|
filtered_results.push_back(result);
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
|
|
|
}
|
2011-06-13 15:47:02 +00:00
|
|
|
}
|
2014-02-17 04:51:41 +00:00
|
|
|
else // using user entered x value comparison
|
2011-06-13 15:47:02 +00:00
|
|
|
{
|
|
|
|
u32 user_x_val;
|
|
|
|
|
|
|
|
// parse the user entered x value
|
|
|
|
if (filter_mask != 7) // don't need the value for the "None" filter
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
2011-06-13 15:47:02 +00:00
|
|
|
unsigned long parsed_x_val = 0;
|
2012-05-26 05:45:58 +00:00
|
|
|
wxString x_val = textctrl_value_x->GetValue();
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2011-06-13 15:47:02 +00:00
|
|
|
if (!x_val.ToULong(&parsed_x_val, 0))
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
2014-07-25 01:46:46 +00:00
|
|
|
WxUtils::ShowErrorDialog(_("You must enter a valid decimal, hexadecimal or octal value."));
|
2011-06-13 15:47:02 +00:00
|
|
|
return;
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
|
|
|
|
2011-06-13 15:47:02 +00:00
|
|
|
user_x_val = (u32)parsed_x_val;
|
|
|
|
|
|
|
|
// #ifdef LIL_ENDIAN :p
|
|
|
|
switch (search_type_size)
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
2011-06-13 15:47:02 +00:00
|
|
|
case 1 :
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
*(u16*)&user_x_val = Common::swap16((u8*)&user_x_val);
|
|
|
|
break;
|
|
|
|
case 4 :
|
|
|
|
user_x_val = Common::swap32(user_x_val);
|
|
|
|
break;
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
2011-06-13 15:47:02 +00:00
|
|
|
// #elseif BIG_ENDIAN
|
|
|
|
// would have to move <u32 vals (8/16bit) to start of the user_x_val for the comparisons i use below
|
|
|
|
// #endif
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 05:25:15 +00:00
|
|
|
for (CheatSearchResult& result : search_results)
|
2011-06-13 15:47:02 +00:00
|
|
|
{
|
|
|
|
// with big endian, can just use memcmp for ><= comparison
|
2014-03-03 05:25:15 +00:00
|
|
|
int cmp_result = memcmp(memptr + result.address, &user_x_val, search_type_size);
|
2011-06-13 15:47:02 +00:00
|
|
|
if (cmp_result < 0)
|
|
|
|
cmp_result = 4;
|
|
|
|
else if (cmp_result)
|
|
|
|
cmp_result = 2;
|
|
|
|
else
|
|
|
|
cmp_result = 1;
|
|
|
|
|
|
|
|
if (cmp_result & filter_mask)
|
|
|
|
{
|
2014-03-03 05:25:15 +00:00
|
|
|
memcpy(&result.old_value, memptr + result.address, search_type_size);
|
|
|
|
filtered_results.push_back(result);
|
2011-06-13 15:47:02 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
2011-06-13 15:47:02 +00:00
|
|
|
|
|
|
|
search_results.swap(filtered_results);
|
|
|
|
|
|
|
|
UpdateCheatSearchResultsList();
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
|
|
|
|
2013-01-13 08:28:12 +00:00
|
|
|
void CheatSearchTab::ApplyFocus(wxEvent& ev)
|
2010-07-22 05:28:24 +00:00
|
|
|
{
|
2014-07-11 00:39:26 +00:00
|
|
|
ev.Skip();
|
2010-07-22 05:28:24 +00:00
|
|
|
value_x_radiobtn.rad_uservalue->SetValue(true);
|
|
|
|
}
|
|
|
|
|
2010-07-18 04:13:16 +00:00
|
|
|
void CheatSearchTab::UpdateCheatSearchResultsList()
|
|
|
|
{
|
|
|
|
lbox_search_results->Clear();
|
|
|
|
|
2014-05-17 17:17:28 +00:00
|
|
|
wxString count_label = _("Count:") + wxString::Format(" %lu",
|
2011-02-06 01:56:45 +00:00
|
|
|
(unsigned long)search_results.size());
|
2010-07-18 04:13:16 +00:00
|
|
|
if (search_results.size() > MAX_CHEAT_SEARCH_RESULTS_DISPLAY)
|
|
|
|
{
|
2011-01-05 04:35:46 +00:00
|
|
|
count_label += _(" (too many to display)");
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-11 05:55:00 +00:00
|
|
|
for (const CheatSearchResult& result : search_results)
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
2014-03-11 05:55:00 +00:00
|
|
|
u32 display_value = result.old_value;
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
// #ifdef LIL_ENDIAN :p
|
|
|
|
switch (search_type_size)
|
|
|
|
{
|
|
|
|
case 1 :
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
*(u16*)&display_value = Common::swap16((u8*)&display_value);
|
|
|
|
break;
|
|
|
|
case 4 :
|
|
|
|
display_value = Common::swap32(display_value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// #elseif BIG_ENDIAN
|
|
|
|
// need to do some stuff in here (for 8 and 16bit) for bigendian
|
|
|
|
// #endif
|
2014-05-17 17:17:28 +00:00
|
|
|
std::string rowfmt = StringFromFormat("0x%%08x 0x%%0%ux %%u/%%i", search_type_size*2);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
lbox_search_results->Append(
|
2014-05-17 17:17:28 +00:00
|
|
|
wxString::Format(rowfmt.c_str(), result.address, display_value, display_value, display_value));
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
label_results_count->SetLabel(count_label);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CheatSearchTab::CreateARCode(wxCommandEvent&)
|
|
|
|
{
|
|
|
|
const int sel = lbox_search_results->GetSelection();
|
|
|
|
if (sel >= 0)
|
|
|
|
{
|
|
|
|
const u32 address = search_results[sel].address | ((search_type_size & ~1) << 24);
|
|
|
|
|
2011-03-17 04:26:01 +00:00
|
|
|
CreateCodeDialog arcode_dlg(this, address);
|
|
|
|
arcode_dlg.ShowModal();
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address)
|
2014-03-06 04:02:34 +00:00
|
|
|
: wxDialog(parent, -1, _("Create AR Code"))
|
2010-07-18 04:13:16 +00:00
|
|
|
, code_address(address)
|
|
|
|
{
|
2011-03-17 04:26:01 +00:00
|
|
|
wxStaticText* const label_name = new wxStaticText(this, -1, _("Name: "));
|
|
|
|
textctrl_name = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxSize(256,-1));
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2011-03-17 04:26:01 +00:00
|
|
|
wxStaticText* const label_code = new wxStaticText(this, -1, _("Code: "));
|
2014-05-17 17:17:28 +00:00
|
|
|
textctrl_code = new wxTextCtrl(this, -1, wxString::Format("0x%08x", address));
|
2010-07-18 04:13:16 +00:00
|
|
|
textctrl_code->Disable();
|
|
|
|
|
2011-03-17 04:26:01 +00:00
|
|
|
wxStaticText* const label_value = new wxStaticText(this, -1, _("Value: "));
|
2014-05-17 17:17:28 +00:00
|
|
|
textctrl_value = new wxTextCtrl(this, -1, "0");
|
2010-07-18 04:13:16 +00:00
|
|
|
|
2011-03-17 04:26:01 +00:00
|
|
|
checkbox_use_hex = new wxCheckBox(this, -1, _("Use Hex"));
|
2010-07-18 04:13:16 +00:00
|
|
|
checkbox_use_hex->SetValue(true);
|
|
|
|
|
|
|
|
wxBoxSizer* const sizer_value_label = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
sizer_value_label->Add(label_value, 0, wxRIGHT, 5);
|
2011-03-17 04:26:01 +00:00
|
|
|
sizer_value_label->Add(checkbox_use_hex);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
// main sizer
|
2011-03-17 04:26:01 +00:00
|
|
|
wxBoxSizer* const sizer_main = new wxBoxSizer(wxVERTICAL);
|
|
|
|
sizer_main->Add(label_name, 0, wxALL, 5);
|
|
|
|
sizer_main->Add(textctrl_name, 0, wxALL, 5);
|
|
|
|
sizer_main->Add(label_code, 0, wxALL, 5);
|
|
|
|
sizer_main->Add(textctrl_code, 0, wxALL, 5);
|
|
|
|
sizer_main->Add(sizer_value_label, 0, wxALL, 5);
|
|
|
|
sizer_main->Add(textctrl_value, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
sizer_main->Add(CreateButtonSizer(wxOK | wxCANCEL | wxNO_DEFAULT), 0, wxALL, 5);
|
2011-06-17 09:19:13 +00:00
|
|
|
|
2014-05-17 16:49:00 +00:00
|
|
|
Bind(wxEVT_BUTTON, &CreateCodeDialog::PressOK, this, wxID_OK);
|
|
|
|
Bind(wxEVT_BUTTON, &CreateCodeDialog::PressCancel, this, wxID_CANCEL);
|
2013-01-13 18:07:45 +00:00
|
|
|
Bind(wxEVT_CLOSE_WINDOW, &CreateCodeDialog::OnEvent_Close, this);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
SetSizerAndFit(sizer_main);
|
2011-03-17 04:26:01 +00:00
|
|
|
SetFocus();
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
|
|
|
|
2011-06-03 12:26:32 +00:00
|
|
|
void CreateCodeDialog::PressOK(wxCommandEvent& ev)
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
|
|
|
const wxString code_name = textctrl_name->GetValue();
|
|
|
|
if (code_name.empty())
|
|
|
|
{
|
2014-07-25 01:46:46 +00:00
|
|
|
WxUtils::ShowErrorDialog(_("You must enter a name."));
|
2010-07-18 04:13:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
long code_value;
|
2014-03-03 03:11:42 +00:00
|
|
|
int base = checkbox_use_hex->IsChecked() ? 16 : 10;
|
|
|
|
if (!textctrl_value->GetValue().ToLong(&code_value, base))
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
2014-07-25 01:46:46 +00:00
|
|
|
WxUtils::ShowErrorDialog(_("Invalid value."));
|
2010-07-18 04:13:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//wxString full_code = textctrl_code->GetValue();
|
2014-05-17 17:17:28 +00:00
|
|
|
//full_code += ' ';
|
|
|
|
//full_code += wxString::Format("0x%08x", code_value);
|
2010-07-18 04:13:16 +00:00
|
|
|
|
|
|
|
// create the new code
|
|
|
|
ActionReplay::ARCode new_cheat;
|
|
|
|
new_cheat.active = false;
|
2013-02-28 04:37:38 +00:00
|
|
|
new_cheat.name = WxStrToStr(code_name);
|
2010-07-18 04:13:16 +00:00
|
|
|
const ActionReplay::AREntry new_entry(code_address, code_value);
|
|
|
|
new_cheat.ops.push_back(new_entry);
|
|
|
|
|
|
|
|
// pretty hacky - add the code to the gameini
|
|
|
|
{
|
|
|
|
CISOProperties isoprops(SConfig::GetInstance().m_LastFilename, this);
|
|
|
|
// add the code to the isoproperties arcode list
|
|
|
|
arCodes.push_back(new_cheat);
|
|
|
|
// save the gameini
|
|
|
|
isoprops.SaveGameConfig();
|
2014-02-17 04:51:41 +00:00
|
|
|
isoprops.ActionReplayList_Load(); // loads the new arcodes
|
2010-07-18 04:13:16 +00:00
|
|
|
//ActionReplay::UpdateActiveList();
|
|
|
|
}
|
|
|
|
|
|
|
|
// refresh arcode list in other tab
|
|
|
|
::g_cheat_window->Load_ARCodes();
|
|
|
|
|
2011-06-17 09:19:13 +00:00
|
|
|
Close();
|
2010-07-18 04:13:16 +00:00
|
|
|
}
|
|
|
|
|
2011-06-03 12:26:32 +00:00
|
|
|
void CreateCodeDialog::PressCancel(wxCommandEvent& ev)
|
2010-07-18 04:13:16 +00:00
|
|
|
{
|
2011-06-17 09:19:13 +00:00
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateCodeDialog::OnEvent_Close(wxCloseEvent& ev)
|
|
|
|
{
|
|
|
|
Destroy();
|
2008-12-13 19:49:19 +00:00
|
|
|
}
|