Finish making dialogs close when escape is pressed. Fixes issue 4265. At least I think I got them all.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7365 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2011-03-17 04:26:01 +00:00
parent cab5fdb44b
commit e4141c331e
15 changed files with 110 additions and 227 deletions

View File

@ -21,39 +21,28 @@
extern std::vector<ActionReplay::ARCode> arCodes; extern std::vector<ActionReplay::ARCode> arCodes;
BEGIN_EVENT_TABLE(CARCodeAddEdit, wxDialog) BEGIN_EVENT_TABLE(CARCodeAddEdit, wxDialog)
EVT_CLOSE(CARCodeAddEdit::OnClose)
EVT_BUTTON(wxID_OK, CARCodeAddEdit::SaveCheatData) 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()
CARCodeAddEdit::CARCodeAddEdit(int _selection, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) CARCodeAddEdit::CARCodeAddEdit(int _selection, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style) : wxDialog(parent, id, title, position, size, style)
{ , selection(_selection)
selection = _selection;
CreateGUIControls(selection);
}
CARCodeAddEdit::~CARCodeAddEdit()
{
}
void CARCodeAddEdit::CreateGUIControls(int _selection)
{ {
ActionReplay::ARCode tempEntries; ActionReplay::ARCode tempEntries;
wxString currentName = _("Insert name here.."); wxString currentName = _("Insert name here..");
if (_selection == -1) if (selection == -1)
{ {
tempEntries.name = ""; tempEntries.name = "";
} }
else else
{ {
currentName = wxString(arCodes.at(_selection).name.c_str(), *wxConvCurrent); currentName = wxString(arCodes.at(selection).name.c_str(), *wxConvCurrent);
tempEntries = arCodes.at(_selection); tempEntries = arCodes.at(selection);
} }
wxBoxSizer* sEditCheat = new wxBoxSizer(wxVERTICAL); wxBoxSizer* sEditCheat = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* sEditCheatButtons = new wxBoxSizer(wxHORIZONTAL);
wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, _("Cheat Code")); wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, _("Cheat Code"));
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0); wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
@ -62,11 +51,9 @@ void CARCodeAddEdit::CreateGUIControls(int _selection)
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(1, ((int)arCodes.size()) > 0 ? (int)arCodes.size() : 1); EntrySelection->SetRange(1, ((int)arCodes.size()) > 0 ? (int)arCodes.size() : 1);
EntrySelection->SetValue((int)(arCodes.size() - _selection)); EntrySelection->SetValue((int)(arCodes.size() - selection));
EditCheatCode = new wxTextCtrl(this, ID_EDITCHEAT_CODE, wxEmptyString, wxDefaultPosition, wxSize(300, 100), wxTE_MULTILINE); EditCheatCode = new wxTextCtrl(this, ID_EDITCHEAT_CODE, wxEmptyString, wxDefaultPosition, wxSize(300, 100), wxTE_MULTILINE);
UpdateTextCtrl(tempEntries); UpdateTextCtrl(tempEntries);
wxButton* bOK = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
wxButton* bCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
sgEntry->Add(EditCheatNameText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER|wxALL, 5); sgEntry->Add(EditCheatNameText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER|wxALL, 5);
sgEntry->Add(EditCheatName, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); sgEntry->Add(EditCheatName, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
@ -76,19 +63,11 @@ void CARCodeAddEdit::CreateGUIControls(int _selection)
sgEntry->AddGrowableRow(1); sgEntry->AddGrowableRow(1);
sbEntry->Add(sgEntry, 1, wxEXPAND|wxALL); sbEntry->Add(sgEntry, 1, wxEXPAND|wxALL);
sEditCheatButtons->AddStretchSpacer();
sEditCheatButtons->Add(bOK, 0, wxALL, 5);
sEditCheatButtons->Add(bCancel, 0, wxALL, 5);
sEditCheat->Add(sbEntry, 1, wxEXPAND|wxALL, 5); sEditCheat->Add(sbEntry, 1, wxEXPAND|wxALL, 5);
sEditCheat->Add(sEditCheatButtons, 0, wxEXPAND, 5); sEditCheat->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxALL, 5);
SetSizerAndFit(sEditCheat); SetSizerAndFit(sEditCheat);
} SetFocus();
void CARCodeAddEdit::OnClose(wxCloseEvent& WXUNUSED (event))
{
Destroy();
} }
void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event) void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event)

View File

@ -31,7 +31,6 @@ class CARCodeAddEdit : public wxDialog
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE); long style = wxDEFAULT_DIALOG_STYLE);
virtual ~CARCodeAddEdit();
private: private:
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
@ -47,8 +46,6 @@ class CARCodeAddEdit : public wxDialog
ID_EDITCHEAT_CODE ID_EDITCHEAT_CODE
}; };
void CreateGUIControls(int selection);
void OnClose(wxCloseEvent& event);
void SaveCheatData(wxCommandEvent& event); void SaveCheatData(wxCommandEvent& event);
void ChangeEntry(wxSpinEvent& event); void ChangeEntry(wxSpinEvent& event);
void UpdateTextCtrl(ActionReplay::ARCode arCode); void UpdateTextCtrl(ActionReplay::ARCode arCode);

View File

@ -537,8 +537,8 @@ void CheatSearchTab::CreateARCode(wxCommandEvent&)
{ {
const u32 address = search_results[sel].address | ((search_type_size & ~1) << 24); const u32 address = search_results[sel].address | ((search_type_size & ~1) << 24);
CreateCodeDialog* const arcode_dlg = new CreateCodeDialog(this, address); CreateCodeDialog arcode_dlg(this, address);
arcode_dlg->ShowModal(); arcode_dlg.ShowModal();
} }
} }
@ -546,52 +546,45 @@ CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address)
: wxDialog(parent, -1, _("Create AR Code"), wxDefaultPosition) : wxDialog(parent, -1, _("Create AR Code"), wxDefaultPosition)
, code_address(address) , code_address(address)
{ {
wxPanel* const panel = new wxPanel(this); wxStaticText* const label_name = new wxStaticText(this, -1, _("Name: "));
textctrl_name = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxSize(256,-1));
wxStaticText* const label_name = new wxStaticText(panel, -1, _("Name: ")); wxStaticText* const label_code = new wxStaticText(this, -1, _("Code: "));
textctrl_name = new wxTextCtrl(panel, -1, wxEmptyString, wxDefaultPosition, wxSize(256,-1)); textctrl_code = new wxTextCtrl(this, -1, wxString::Format(wxT("0x%08x"), address));
wxStaticText* const label_code = new wxStaticText(panel, -1, _("Code: "));
textctrl_code = new wxTextCtrl(panel, -1, wxString::Format(wxT("0x%08x"), address));
textctrl_code->Disable(); textctrl_code->Disable();
wxStaticText* const label_value = new wxStaticText(panel, -1, _("Value: ")); wxStaticText* const label_value = new wxStaticText(this, -1, _("Value: "));
textctrl_value = new wxTextCtrl(panel, -1, wxT("0")); textctrl_value = new wxTextCtrl(this, -1, wxT("0"));
checkbox_use_hex = new wxCheckBox(panel, -1, _("Use Hex")); checkbox_use_hex = new wxCheckBox(this, -1, _("Use Hex"));
checkbox_use_hex->SetValue(true); checkbox_use_hex->SetValue(true);
wxBoxSizer* const sizer_value_label = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const sizer_value_label = new wxBoxSizer(wxHORIZONTAL);
sizer_value_label->Add(label_value, 0, wxRIGHT, 5); sizer_value_label->Add(label_value, 0, wxRIGHT, 5);
sizer_value_label->Add(checkbox_use_hex, 0, 0, 0); sizer_value_label->Add(checkbox_use_hex);
wxButton* const btn_ok = new wxButton(panel, -1, _("OK")); wxButton* const btn_ok = new wxButton(this, wxID_OK, _("OK"));
_connect_macro_(btn_ok, CreateCodeDialog::PressOK, wxEVT_COMMAND_BUTTON_CLICKED, this); _connect_macro_(btn_ok, CreateCodeDialog::PressOK, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxButton* const btn_cancel = new wxButton(panel, -1, _("Cancel")); wxButton* const btn_cancel = new wxButton(this, wxID_CANCEL, _("Cancel"));
_connect_macro_(btn_cancel, CreateCodeDialog::PressCancel, wxEVT_COMMAND_BUTTON_CLICKED, this); _connect_macro_(btn_cancel, CreateCodeDialog::PressCancel, wxEVT_COMMAND_BUTTON_CLICKED, this);
// button sizer // button sizer
wxBoxSizer* const sizer_buttons = new wxBoxSizer(wxHORIZONTAL); wxSizer* const sizer_buttons = CreateButtonSizer(wxNO_DEFAULT);
sizer_buttons->Add(btn_ok, 0, wxRIGHT, 5); sizer_buttons->Add(btn_ok, 0, wxRIGHT, 5);
sizer_buttons->Add(btn_cancel, 0, 0, 0); sizer_buttons->Add(btn_cancel);
// main sizer // main sizer
wxBoxSizer* const sizer_panel = new wxBoxSizer(wxVERTICAL); wxBoxSizer* const sizer_main = new wxBoxSizer(wxVERTICAL);
sizer_panel->Add(label_name, 0, wxALL, 5); sizer_main->Add(label_name, 0, wxALL, 5);
sizer_panel->Add(textctrl_name, 0, wxALL, 5); sizer_main->Add(textctrl_name, 0, wxALL, 5);
sizer_panel->Add(label_code, 0, wxALL, 5); sizer_main->Add(label_code, 0, wxALL, 5);
sizer_panel->Add(textctrl_code, 0, wxALL, 5); sizer_main->Add(textctrl_code, 0, wxALL, 5);
sizer_panel->Add(sizer_value_label, 0, wxALL, 5); sizer_main->Add(sizer_value_label, 0, wxALL, 5);
sizer_panel->Add(textctrl_value, 0, wxALL, 5); sizer_main->Add(textctrl_value, 0, wxALL, 5);
sizer_panel->Add(sizer_buttons, 0, wxALL | wxALIGN_RIGHT, 5); sizer_main->Add(sizer_buttons, 0, wxALL | wxALIGN_RIGHT, 5);
panel->SetSizerAndFit(sizer_panel);
// panel sizer
wxBoxSizer* const sizer_main = new wxBoxSizer(wxHORIZONTAL);
sizer_main->Add(panel, 1, wxEXPAND, 5);
SetSizerAndFit(sizer_main); SetSizerAndFit(sizer_main);
SetFocus();
} }
void CreateCodeDialog::PressOK(wxCommandEvent&) void CreateCodeDialog::PressOK(wxCommandEvent&)

View File

@ -21,9 +21,7 @@
#include "BreakpointWindow.h" #include "BreakpointWindow.h"
BEGIN_EVENT_TABLE(BreakPointDlg, wxDialog) BEGIN_EVENT_TABLE(BreakPointDlg, wxDialog)
EVT_CLOSE(BreakPointDlg::OnClose)
EVT_BUTTON(wxID_OK, BreakPointDlg::OnOK) EVT_BUTTON(wxID_OK, BreakPointDlg::OnOK)
EVT_BUTTON(wxID_CANCEL, BreakPointDlg::OnCancel)
END_EVENT_TABLE() END_EVENT_TABLE()
BreakPointDlg::BreakPointDlg(CBreakPointWindow *_Parent) BreakPointDlg::BreakPointDlg(CBreakPointWindow *_Parent)
@ -31,30 +29,16 @@ BreakPointDlg::BreakPointDlg(CBreakPointWindow *_Parent)
, Parent(_Parent) , Parent(_Parent)
{ {
m_pEditAddress = new wxTextCtrl(this, wxID_ANY, wxT("80000000")); m_pEditAddress = new wxTextCtrl(this, wxID_ANY, wxT("80000000"));
wxButton *m_pButtonOK = new wxButton(this, wxID_OK, wxT("OK"));
wxButton *m_pButtonCancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"));
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
sButtons->AddStretchSpacer();
sButtons->Add(m_pButtonCancel, 0);
sButtons->Add(m_pButtonOK, 0);
wxBoxSizer *sMainSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *sMainSizer = new wxBoxSizer(wxVERTICAL);
sMainSizer->Add(m_pEditAddress, 0, wxEXPAND | wxALL, 5); sMainSizer->Add(m_pEditAddress, 0, wxEXPAND | wxALL, 5);
sMainSizer->Add(sButtons, 0, wxALL, 5); sMainSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALL, 5);
SetSizer(sMainSizer); SetSizerAndFit(sMainSizer);
Layout(); SetFocus();
Fit();
} }
void BreakPointDlg::OnClose(wxCloseEvent& WXUNUSED(event)) void BreakPointDlg::OnOK(wxCommandEvent& event)
{
EndModal(wxID_CLOSE);
Destroy();
}
void BreakPointDlg::OnOK(wxCommandEvent& WXUNUSED(event))
{ {
wxString AddressString = m_pEditAddress->GetLineText(0); wxString AddressString = m_pEditAddress->GetLineText(0);
u32 Address = 0; u32 Address = 0;
@ -66,9 +50,6 @@ void BreakPointDlg::OnOK(wxCommandEvent& WXUNUSED(event))
} }
else else
PanicAlert("The address %s is invalid.", (const char *)AddressString.ToUTF8()); PanicAlert("The address %s is invalid.", (const char *)AddressString.ToUTF8());
}
void BreakPointDlg::OnCancel(wxCommandEvent& WXUNUSED(event)) event.Skip();
{
Close();
} }

View File

@ -29,13 +29,10 @@ public:
BreakPointDlg(CBreakPointWindow *_Parent); BreakPointDlg(CBreakPointWindow *_Parent);
private: private:
CBreakPointWindow *Parent; CBreakPointWindow *Parent;
wxTextCtrl *m_pEditAddress; wxTextCtrl *m_pEditAddress;
void OnClose(wxCloseEvent& WXUNUSED(event)); void OnOK(wxCommandEvent& event);
void OnCancel(wxCommandEvent& WXUNUSED(event));
void OnOK(wxCommandEvent& WXUNUSED(event));
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
}; };

View File

@ -69,7 +69,7 @@ void GFXDebuggerPanel::OnClose(wxCloseEvent& event)
// save the window position when we hide the window // save the window position when we hide the window
SaveSettings(); SaveSettings();
event.Skip(); // This means wxDialog's Destroy is used event.Skip();
} }
void GFXDebuggerPanel::SaveSettings() const void GFXDebuggerPanel::SaveSettings() const

View File

@ -23,10 +23,8 @@
#define TEXT_BOX(text) new wxStaticText(this, wxID_ANY, wxT(text), wxDefaultPosition, wxDefaultSize) #define TEXT_BOX(text) new wxStaticText(this, wxID_ANY, wxT(text), wxDefaultPosition, wxDefaultSize)
BEGIN_EVENT_TABLE(MemoryCheckDlg,wxDialog) BEGIN_EVENT_TABLE(MemoryCheckDlg, wxDialog)
EVT_CLOSE(MemoryCheckDlg::OnClose)
EVT_BUTTON(wxID_OK, MemoryCheckDlg::OnOK) EVT_BUTTON(wxID_OK, MemoryCheckDlg::OnOK)
EVT_BUTTON(wxID_CANCEL, MemoryCheckDlg::OnCancel)
END_EVENT_TABLE() END_EVENT_TABLE()
MemoryCheckDlg::MemoryCheckDlg(CBreakPointWindow *parent) MemoryCheckDlg::MemoryCheckDlg(CBreakPointWindow *parent)
@ -57,11 +55,6 @@ MemoryCheckDlg::MemoryCheckDlg(CBreakPointWindow *parent)
sFlags->Add(m_log_flag); sFlags->Add(m_log_flag);
sFlags->Add(m_break_flag); sFlags->Add(m_break_flag);
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
sButtons->AddStretchSpacer();
sButtons->Add(new wxButton(this, wxID_CANCEL, _("Cancel")));
sButtons->Add(new wxButton(this, wxID_OK, wxT("OK")));
wxBoxSizer *sControls = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *sControls = new wxBoxSizer(wxHORIZONTAL);
sControls->Add(sAddressRangeBox, 0, wxEXPAND); sControls->Add(sAddressRangeBox, 0, wxEXPAND);
sControls->Add(sActionBox, 0, wxEXPAND); sControls->Add(sActionBox, 0, wxEXPAND);
@ -69,20 +62,13 @@ MemoryCheckDlg::MemoryCheckDlg(CBreakPointWindow *parent)
wxBoxSizer *sMainSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *sMainSizer = new wxBoxSizer(wxVERTICAL);
sMainSizer->Add(sControls, 0, wxEXPAND | wxALL, 5); sMainSizer->Add(sControls, 0, wxEXPAND | wxALL, 5);
sMainSizer->Add(sButtons, 0, wxEXPAND | wxALL, 5); sMainSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
SetSizer(sMainSizer); SetSizerAndFit(sMainSizer);
Layout(); SetFocus();
Fit();
} }
void MemoryCheckDlg::OnClose(wxCloseEvent& WXUNUSED(event)) void MemoryCheckDlg::OnOK(wxCommandEvent& event)
{
EndModal(wxID_CLOSE);
Destroy();
}
void MemoryCheckDlg::OnOK(wxCommandEvent& WXUNUSED(event))
{ {
wxString StartAddressString = m_pEditStartAddress->GetLineText(0); wxString StartAddressString = m_pEditStartAddress->GetLineText(0);
wxString EndAddressString = m_pEditEndAddress->GetLineText(0); wxString EndAddressString = m_pEditEndAddress->GetLineText(0);
@ -115,9 +101,6 @@ void MemoryCheckDlg::OnOK(wxCommandEvent& WXUNUSED(event))
m_parent->NotifyUpdate(); m_parent->NotifyUpdate();
Close(); Close();
} }
}
void MemoryCheckDlg::OnCancel(wxCommandEvent& WXUNUSED(event)) event.Skip();
{
Close();
} }

View File

@ -36,9 +36,7 @@ class MemoryCheckDlg : public wxDialog
wxTextCtrl* m_pEditEndAddress; wxTextCtrl* m_pEditEndAddress;
wxTextCtrl* m_pEditStartAddress; wxTextCtrl* m_pEditStartAddress;
void OnClose(wxCloseEvent& WXUNUSED(event)); void OnOK(wxCommandEvent& event);
void OnOK(wxCommandEvent& WXUNUSED(event));
void OnCancel(wxCommandEvent& WXUNUSED(event));
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
}; };

View File

@ -72,8 +72,6 @@ wxBitmap wxBitmapFromMemoryRGBA(const unsigned char* data, int width, int height
} }
BEGIN_EVENT_TABLE(CMemcardManager, wxDialog) BEGIN_EVENT_TABLE(CMemcardManager, wxDialog)
EVT_CLOSE(CMemcardManager::OnClose)
EVT_BUTTON(ID_COPYFROM_A,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_COPYFROM_A,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_COPYFROM_B,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_COPYFROM_B,CMemcardManager::CopyDeleteClick)
EVT_BUTTON(ID_DELETE_A,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_DELETE_A,CMemcardManager::CopyDeleteClick)
@ -186,6 +184,8 @@ void CMemcardManager::CreateGUIControls()
const wxChar* ARROW[2] = {_T("<-"), _T("->")}; const wxChar* ARROW[2] = {_T("<-"), _T("->")};
m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, _("Convert to GCI")); m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, _("Convert to GCI"));
wxStaticBoxSizer *sMemcard[2];
for (int slot = SLOT_A; slot <= SLOT_B; slot++) for (int slot = SLOT_A; slot <= SLOT_B; slot++)
{ {
@ -204,11 +204,11 @@ void CMemcardManager::CreateGUIControls()
t_Status[slot] = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition,wxDefaultSize, 0, wxEmptyString); t_Status[slot] = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition,wxDefaultSize, 0, wxEmptyString);
sPages[slot] = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer * const sPages = new wxBoxSizer(wxHORIZONTAL);
sPages[slot]->Add(m_PrevPage[slot], 0, wxEXPAND|wxALL, 1); sPages->Add(m_PrevPage[slot], 0, wxEXPAND|wxALL, 1);
sPages[slot]->Add(t_Status[slot],0, wxEXPAND|wxALL, 5); sPages->Add(t_Status[slot],0, wxEXPAND|wxALL, 5);
sPages[slot]->Add(0, 0, 1, wxEXPAND|wxALL, 0); sPages->Add(0, 0, 1, wxEXPAND|wxALL, 0);
sPages[slot]->Add(m_NextPage[slot], 0, wxEXPAND|wxALL, 1); sPages->Add(m_NextPage[slot], 0, wxEXPAND|wxALL, 1);
m_MemcardPath[slot] = new wxFilePickerCtrl(this, ID_MEMCARDPATH_A + slot, m_MemcardPath[slot] = new wxFilePickerCtrl(this, ID_MEMCARDPATH_A + slot,
wxString::From8BitData(File::GetUserPath(D_GCUSER_IDX).c_str()), _("Choose a memory card:"), wxString::From8BitData(File::GetUserPath(D_GCUSER_IDX).c_str()), _("Choose a memory card:"),
@ -222,10 +222,10 @@ void CMemcardManager::CreateGUIControls()
sMemcard[slot] = new wxStaticBoxSizer(wxVERTICAL, this, _("Memory Card") + wxString::Format(wxT(" %c"), 'A' + slot)); sMemcard[slot] = new wxStaticBoxSizer(wxVERTICAL, this, _("Memory Card") + wxString::Format(wxT(" %c"), 'A' + slot));
sMemcard[slot]->Add(m_MemcardPath[slot], 0, wxEXPAND|wxALL, 5); sMemcard[slot]->Add(m_MemcardPath[slot], 0, wxEXPAND|wxALL, 5);
sMemcard[slot]->Add(m_MemcardList[slot], 1, wxEXPAND|wxALL, 5); sMemcard[slot]->Add(m_MemcardList[slot], 1, wxEXPAND|wxALL, 5);
sMemcard[slot]->Add(sPages[slot], 0, wxEXPAND|wxALL, 1); sMemcard[slot]->Add(sPages, 0, wxEXPAND|wxALL, 1);
} }
sButtons = new wxBoxSizer(wxVERTICAL); wxBoxSizer * const sButtons = new wxBoxSizer(wxVERTICAL);
sButtons->AddStretchSpacer(2); sButtons->AddStretchSpacer(2);
sButtons->Add(m_CopyFrom[SLOT_B], 0, wxEXPAND, 5); sButtons->Add(m_CopyFrom[SLOT_B], 0, wxEXPAND, 5);
sButtons->Add(m_CopyFrom[SLOT_A], 0, wxEXPAND, 5); sButtons->Add(m_CopyFrom[SLOT_A], 0, wxEXPAND, 5);
@ -240,17 +240,18 @@ void CMemcardManager::CreateGUIControls()
sButtons->AddStretchSpacer(1); sButtons->AddStretchSpacer(1);
sButtons->Add(m_Delete[SLOT_A], 0, wxEXPAND, 5); sButtons->Add(m_Delete[SLOT_A], 0, wxEXPAND, 5);
sButtons->Add(m_Delete[SLOT_B], 0, wxEXPAND, 5); sButtons->Add(m_Delete[SLOT_B], 0, wxEXPAND, 5);
sButtons->AddStretchSpacer(1); sButtons->AddStretchSpacer();
sButtons->Add(new wxButton(this, wxID_OK, _("Close")), 0, wxEXPAND, 5);
sButtons->AddStretchSpacer();
sMain = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer * const sMain = new wxBoxSizer(wxHORIZONTAL);
sMain->Add(sMemcard[SLOT_A], 1, wxEXPAND|wxALL, 5); sMain->Add(sMemcard[SLOT_A], 1, wxEXPAND|wxALL, 5);
sMain->Add(sButtons, 0, wxEXPAND, 0); sMain->Add(sButtons, 0, wxEXPAND, 0);
sMain->Add(sMemcard[SLOT_B], 1, wxEXPAND|wxALL, 5); sMain->Add(sMemcard[SLOT_B], 1, wxEXPAND|wxALL, 5);
this->SetSizer(sMain); SetSizerAndFit(sMain);
sMain->SetSizeHints(this);
Fit();
Center(); Center();
SetFocus();
for (int i = SLOT_A; i <= SLOT_B; i++) for (int i = SLOT_A; i <= SLOT_B; i++)
{ {
@ -268,11 +269,6 @@ void CMemcardManager::CreateGUIControls()
} }
} }
void CMemcardManager::OnClose(wxCloseEvent& WXUNUSED (event))
{
EndModal(wxID_OK);
}
void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event) void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event)
{ {
ChangePath(event.GetId() - ID_MEMCARDPATH_A); ChangePath(event.GetId() - ID_MEMCARDPATH_A);

View File

@ -58,9 +58,6 @@ class CMemcardManager : public wxDialog
IniFile MemcardManagerIni; IniFile MemcardManagerIni;
IniFile::Section* iniMemcardSection; IniFile::Section* iniMemcardSection;
wxBoxSizer *sMain,
*sButtons,
*sPages[2];
wxButton *m_CopyFrom[2], wxButton *m_CopyFrom[2],
*m_SaveImport[2], *m_SaveImport[2],
*m_SaveExport[2], *m_SaveExport[2],
@ -69,7 +66,6 @@ class CMemcardManager : public wxDialog
*m_PrevPage[2], *m_PrevPage[2],
*m_ConvertToGci; *m_ConvertToGci;
wxFilePickerCtrl *m_MemcardPath[2]; wxFilePickerCtrl *m_MemcardPath[2];
wxStaticBoxSizer *sMemcard[2];
wxStaticText *t_Status[2]; wxStaticText *t_Status[2];
enum enum
@ -124,7 +120,6 @@ class CMemcardManager : public wxDialog
GCMemcard *memoryCard[2]; GCMemcard *memoryCard[2];
void CreateGUIControls(); void CreateGUIControls();
void OnClose(wxCloseEvent& event);
void CopyDeleteClick(wxCommandEvent& event); void CopyDeleteClick(wxCommandEvent& event);
bool ReloadMemcard(const char *fileName, int card); bool ReloadMemcard(const char *fileName, int card);
void OnMenuChange(wxCommandEvent& event); void OnMenuChange(wxCommandEvent& event);

View File

@ -538,9 +538,8 @@ void NetPlayDiag::OnConfigPads(wxCommandEvent&)
if (false == ((NetPlayServer*)netplay_ptr)->GetPadMapping(pid, mapping)) if (false == ((NetPlayServer*)netplay_ptr)->GetPadMapping(pid, mapping))
return; return;
PadMapDiag* const pmd = new PadMapDiag(this, mapping); PadMapDiag pmd(this, mapping);
pmd->ShowModal(); pmd.ShowModal();
pmd->Destroy();
if (false == ((NetPlayServer*)netplay_ptr)->SetPadMapping(pid, mapping)) if (false == ((NetPlayServer*)netplay_ptr)->SetPadMapping(pid, mapping))
PanicAlertT("Could not set pads. The player left or the game is currently running!\n" PanicAlertT("Could not set pads. The player left or the game is currently running!\n"
@ -551,9 +550,7 @@ ChangeGameDiag::ChangeGameDiag(wxWindow* const parent, const CGameListCtrl* cons
: wxDialog(parent, wxID_ANY, _("Change Game"), wxDefaultPosition, wxDefaultSize) : wxDialog(parent, wxID_ANY, _("Change Game"), wxDefaultPosition, wxDefaultSize)
, m_game_name(game_name) , m_game_name(game_name)
{ {
wxPanel* const panel = new wxPanel(this); m_game_lbox = new wxListBox(this, wxID_ANY);
m_game_lbox = new wxListBox(panel, wxID_ANY);
_connect_macro_(m_game_lbox, ChangeGameDiag::OnPick, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, this); _connect_macro_(m_game_lbox, ChangeGameDiag::OnPick, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, this);
// fill list with games // fill list with games
@ -562,44 +559,39 @@ ChangeGameDiag::ChangeGameDiag(wxWindow* const parent, const CGameListCtrl* cons
while (std::getline(ss,game)) while (std::getline(ss,game))
m_game_lbox->Append(wxString(game.c_str(), *wxConvCurrent)); m_game_lbox->Append(wxString(game.c_str(), *wxConvCurrent));
wxButton* const ok_btn = new wxButton(panel, wxID_ANY, _("Change")); wxButton* const ok_btn = new wxButton(this, wxID_OK, _("Change"));
_connect_macro_(ok_btn, ChangeGameDiag::OnPick, wxEVT_COMMAND_BUTTON_CLICKED, this); _connect_macro_(ok_btn, ChangeGameDiag::OnPick, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL); wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
szr->Add(m_game_lbox, 1, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 5); szr->Add(m_game_lbox, 1, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 5);
szr->Add(ok_btn, 0, wxALL | wxALIGN_RIGHT, 5); szr->Add(ok_btn, 0, wxALL | wxALIGN_RIGHT, 5);
panel->SetSizerAndFit(szr); SetSizerAndFit(szr);
SetFocus();
wxBoxSizer* const dlg_szr = new wxBoxSizer(wxVERTICAL);
dlg_szr->Add(panel, 1, wxEXPAND);
SetSizerAndFit(dlg_szr);
} }
void ChangeGameDiag::OnPick(wxCommandEvent&) void ChangeGameDiag::OnPick(wxCommandEvent& event)
{ {
// return the selected game name // return the selected game name
m_game_name = m_game_lbox->GetStringSelection(); m_game_name = m_game_lbox->GetStringSelection();
Destroy(); EndModal(wxID_OK);
} }
PadMapDiag::PadMapDiag(wxWindow* const parent, int map[]) PadMapDiag::PadMapDiag(wxWindow* const parent, int map[])
: wxDialog(parent, wxID_ANY, _("Configure Pads"), wxDefaultPosition, wxDefaultSize) : wxDialog(parent, wxID_ANY, _("Configure Pads"), wxDefaultPosition, wxDefaultSize)
, m_mapping(map) , m_mapping(map)
{ {
wxPanel* const panel = new wxPanel(this);
wxBoxSizer* const h_szr = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const h_szr = new wxBoxSizer(wxHORIZONTAL);
h_szr->AddSpacer(20); h_szr->AddSpacer(20);
// labels // labels
wxBoxSizer* const label_szr = new wxBoxSizer(wxVERTICAL); wxBoxSizer* const label_szr = new wxBoxSizer(wxVERTICAL);
label_szr->Add(new wxStaticText(panel,wxID_ANY, _("Local")), 0, wxALIGN_TOP); label_szr->Add(new wxStaticText(this, wxID_ANY, _("Local")), 0, wxALIGN_TOP);
label_szr->AddStretchSpacer(1); label_szr->AddStretchSpacer(1);
label_szr->Add(new wxStaticText(panel,wxID_ANY, _("In-Game")), 0, wxALIGN_BOTTOM); label_szr->Add(new wxStaticText(this, wxID_ANY, _("In-Game")), 0, wxALIGN_BOTTOM);
h_szr->Add(label_szr, 1, wxTOP | wxBOTTOM | wxEXPAND, 20); h_szr->Add(label_szr, 1, wxTOP | wxEXPAND, 20);
// set up choices // set up choices
wxString pad_names[5]; wxString pad_names[5];
@ -610,25 +602,27 @@ PadMapDiag::PadMapDiag(wxWindow* const parent, int map[])
for (unsigned int i=0; i<4; ++i) for (unsigned int i=0; i<4; ++i)
{ {
wxChoice* const pad_cbox = m_map_cbox[i] wxChoice* const pad_cbox = m_map_cbox[i]
= new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 5, pad_names); = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 5, pad_names);
pad_cbox->Select(m_mapping[i] + 1); pad_cbox->Select(m_mapping[i] + 1);
_connect_macro_(pad_cbox, PadMapDiag::OnAdjust, wxEVT_COMMAND_CHOICE_SELECTED, this); _connect_macro_(pad_cbox, PadMapDiag::OnAdjust, wxEVT_COMMAND_CHOICE_SELECTED, this);
wxBoxSizer* const v_szr = new wxBoxSizer(wxVERTICAL); wxBoxSizer* const v_szr = new wxBoxSizer(wxVERTICAL);
v_szr->Add(new wxStaticText(panel,wxID_ANY, pad_names[i + 1]), 1, wxALIGN_CENTER_HORIZONTAL); v_szr->Add(new wxStaticText(this,wxID_ANY, pad_names[i + 1]), 1, wxALIGN_CENTER_HORIZONTAL);
v_szr->Add(pad_cbox, 1); v_szr->Add(pad_cbox, 1);
h_szr->Add(v_szr, 1, wxTOP | wxBOTTOM | wxEXPAND, 20); h_szr->Add(v_szr, 1, wxTOP | wxEXPAND, 20);
} }
h_szr->AddSpacer(20); h_szr->AddSpacer(20);
panel->SetSizerAndFit(h_szr); wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
main_szr->Add(h_szr);
wxBoxSizer* const dlg_szr = new wxBoxSizer(wxVERTICAL); main_szr->AddSpacer(5);
dlg_szr->Add(panel, 1, wxEXPAND); main_szr->Add(CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT, 20);
SetSizerAndFit(dlg_szr); main_szr->AddSpacer(5);
SetSizerAndFit(main_szr);
SetFocus();
} }
void PadMapDiag::OnAdjust(wxCommandEvent& event) void PadMapDiag::OnAdjust(wxCommandEvent& event)

View File

@ -22,7 +22,6 @@ extern PHackData PHack_Data;
BEGIN_EVENT_TABLE(CPHackSettings, wxDialog) BEGIN_EVENT_TABLE(CPHackSettings, wxDialog)
EVT_CHOICE(ID_PHACK_CHOICE, CPHackSettings::SetRefresh) EVT_CHOICE(ID_PHACK_CHOICE, CPHackSettings::SetRefresh)
EVT_CLOSE(CPHackSettings::OnClose)
EVT_BUTTON(wxID_OK, CPHackSettings::SavePHackData) EVT_BUTTON(wxID_OK, CPHackSettings::SavePHackData)
END_EVENT_TABLE() END_EVENT_TABLE()
@ -45,20 +44,20 @@ CPHackSettings::~CPHackSettings()
void CPHackSettings::CreateGUIControls() void CPHackSettings::CreateGUIControls()
{ {
PHackChoiceText = new wxStaticText(this, ID_PHACK_CHOICE_TEXT, _("Presets: "), wxDefaultPosition, wxDefaultSize); wxStaticText *PHackChoiceText = new wxStaticText(this, wxID_ANY, _("Presets: "));
PHackChoice = new wxChoice(this, ID_PHACK_CHOICE, wxDefaultPosition, wxDefaultSize, wxArrayString(0, wxString("", *wxConvCurrent)), 0, wxDefaultValidator); PHackChoice = new wxChoice(this, ID_PHACK_CHOICE, wxDefaultPosition, wxDefaultSize, wxArrayString(0, wxString("", *wxConvCurrent)));
PHackChoice->SetToolTip(_("Load preset values from hack patterns available.")); PHackChoice->SetToolTip(_("Load preset values from hack patterns available."));
PHackZNearText = new wxStaticText(this, ID_PHACK_ZNEAR_TEXT, _("zNear Correction: "), wxDefaultPosition, wxDefaultSize); wxStaticText *PHackZNearText = new wxStaticText(this, wxID_ANY, _("zNear Correction: "));
PHackZNear = new wxTextCtrl(this, ID_PHACK_ZNEAR, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); PHackZNear = new wxTextCtrl(this, ID_PHACK_ZNEAR);
PHackZNear->SetToolTip(_("Adds the specified value to zNear Parameter.\nTwo ways to express the floating point values.\nExample: entering '\'200'\' or '\'0.0002'\' directly, it produces equal effects, the acquired value will be '\'0.0002'\'.\nValues: (0->+/-Integer) or (0->+/-FP[6 digits of precision])\n\nNOTE: Check LogWindow/Console for the acquired values.")); PHackZNear->SetToolTip(_("Adds the specified value to zNear Parameter.\nTwo ways to express the floating point values.\nExample: entering '\'200'\' or '\'0.0002'\' directly, it produces equal effects, the acquired value will be '\'0.0002'\'.\nValues: (0->+/-Integer) or (0->+/-FP[6 digits of precision])\n\nNOTE: Check LogWindow/Console for the acquired values."));
PHackSZNear = new wxCheckBox(this, ID_PHACK_SZNEAR, _("(-)+zNear"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE, wxDefaultValidator); PHackSZNear = new wxCheckBox(this, ID_PHACK_SZNEAR, _("(-)+zNear"));
PHackSZNear->SetToolTip(_("Changes sign to zNear Parameter (after correction)")); PHackSZNear->SetToolTip(_("Changes sign to zNear Parameter (after correction)"));
PHackZFarText = new wxStaticText(this, ID_PHACK_ZFAR_TEXT, _("zFar Correction: "), wxDefaultPosition, wxDefaultSize); wxStaticText *PHackZFarText = new wxStaticText(this, wxID_ANY, _("zFar Correction: "));
PHackZFar = new wxTextCtrl(this, ID_PHACK_ZFAR, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); PHackZFar = new wxTextCtrl(this, ID_PHACK_ZFAR);
PHackZFar->SetToolTip(_("Adds the specified value to zFar Parameter.\nTwo ways to express the floating point values.\nExample: entering '\'200'\' or '\'0.0002'\' directly, it produces equal effects, the acquired value will be '\'0.0002'\'.\nValues: (0->+/-Integer) or (0->+/-FP[6 digits of precision])\n\nNOTE: Check LogWindow/Console for the acquired values.")); PHackZFar->SetToolTip(_("Adds the specified value to zFar Parameter.\nTwo ways to express the floating point values.\nExample: entering '\'200'\' or '\'0.0002'\' directly, it produces equal effects, the acquired value will be '\'0.0002'\'.\nValues: (0->+/-Integer) or (0->+/-FP[6 digits of precision])\n\nNOTE: Check LogWindow/Console for the acquired values."));
PHackSZFar = new wxCheckBox(this, ID_PHACK_SZFAR, _("(-)+zFar"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE, wxDefaultValidator); PHackSZFar = new wxCheckBox(this, ID_PHACK_SZFAR, _("(-)+zFar"));
PHackSZFar->SetToolTip(_("Changes sign to zFar Parameter (after correction)")); PHackSZFar->SetToolTip(_("Changes sign to zFar Parameter (after correction)"));
PHackExP = new wxCheckBox(this, ID_PHACK_EXP, _("Extra Parameter"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE, wxDefaultValidator); PHackExP = new wxCheckBox(this, ID_PHACK_EXP, _("Extra Parameter"));
PHackExP->SetToolTip(_("Extra Parameter useful in '\'Metroid: Other M'\' only.")); PHackExP->SetToolTip(_("Extra Parameter useful in '\'Metroid: Other M'\' only."));
wxStaticBoxSizer *sbPHackSettings = new wxStaticBoxSizer(wxVERTICAL, this, _("Parameters")); wxStaticBoxSizer *sbPHackSettings = new wxStaticBoxSizer(wxVERTICAL, this, _("Parameters"));
@ -72,20 +71,14 @@ void CPHackSettings::CreateGUIControls()
szrPHackSettings->Add(PHackSZFar, 0, wxEXPAND|wxLEFT, 5); szrPHackSettings->Add(PHackSZFar, 0, wxEXPAND|wxLEFT, 5);
szrPHackSettings->Add(PHackExP, 0, wxEXPAND|wxTOP|wxBOTTOM, 5); szrPHackSettings->Add(PHackExP, 0, wxEXPAND|wxTOP|wxBOTTOM, 5);
wxBoxSizer* sPHackButtons = 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);
sPHackButtons->Add(0, 0, 1, wxEXPAND, 5);
sPHackButtons->Add(bOK, 0, wxALL, 5);
sPHackButtons->Add(bCancel, 0, wxALL, 5);
wxBoxSizer* sPHack = new wxBoxSizer(wxVERTICAL); wxBoxSizer* sPHack = new wxBoxSizer(wxVERTICAL);
sPHack->Add(PHackChoiceText, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5); sPHack->Add(PHackChoiceText, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5);
sPHack->Add(PHackChoice, 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 5); sPHack->Add(PHackChoice, 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 5);
sPHack->Add(sbPHackSettings, 0, wxEXPAND|wxALL, 5); sPHack->Add(sbPHackSettings, 0, wxEXPAND|wxALL, 5);
sPHack->Add(sPHackButtons, 0, wxEXPAND, 5); sPHack->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 5);
SetSizerAndFit(sPHack); SetSizerAndFit(sPHack);
SetFocus();
} }
void CPHackSettings::LoadPHackData() void CPHackSettings::LoadPHackData()
@ -141,12 +134,7 @@ void CPHackSettings::SetRefresh(wxCommandEvent& event)
} }
} }
void CPHackSettings::OnClose(wxCloseEvent& WXUNUSED (event)) void CPHackSettings::SavePHackData(wxCommandEvent& event)
{
Destroy();
}
void CPHackSettings::SavePHackData(wxCommandEvent& WXUNUSED (event))
{ {
PHack_Data.PHackSZNear = PHackSZNear->GetValue(); PHack_Data.PHackSZNear = PHackSZNear->GetValue();
PHack_Data.PHackSZFar = PHackSZFar->GetValue(); PHack_Data.PHackSZFar = PHackSZFar->GetValue();
@ -156,4 +144,5 @@ void CPHackSettings::SavePHackData(wxCommandEvent& WXUNUSED (event))
PHack_Data.PHZFar = PHackZFar->GetValue().char_str(); PHack_Data.PHZFar = PHackZFar->GetValue().char_str();
AcceptAndClose(); AcceptAndClose();
event.Skip();
} }

View File

@ -40,20 +40,14 @@ class CPHackSettings : public wxDialog
wxCheckBox *PHackSZNear; wxCheckBox *PHackSZNear;
wxCheckBox *PHackSZFar; wxCheckBox *PHackSZFar;
wxCheckBox *PHackExP; wxCheckBox *PHackExP;
wxStaticText *PHackChoiceText;
wxStaticText *PHackZNearText;
wxStaticText *PHackZFarText;
wxTextCtrl *PHackZNear; wxTextCtrl *PHackZNear;
wxTextCtrl *PHackZFar; wxTextCtrl *PHackZFar;
enum { enum {
ID_PHACK_CHOICE_TEXT = 1000, ID_PHACK_CHOICE = 1000,
ID_PHACK_CHOICE,
ID_PHACK_SZNEAR, ID_PHACK_SZNEAR,
ID_PHACK_SZFAR, ID_PHACK_SZFAR,
ID_PHACK_ZNEAR_TEXT,
ID_PHACK_ZNEAR, ID_PHACK_ZNEAR,
ID_PHACK_ZFAR_TEXT,
ID_PHACK_ZFAR, ID_PHACK_ZFAR,
ID_PHACK_EXP ID_PHACK_EXP
}; };
@ -63,7 +57,6 @@ class CPHackSettings : public wxDialog
void SetRefresh(wxCommandEvent& event); void SetRefresh(wxCommandEvent& event);
void CreateGUIControls(); void CreateGUIControls();
void OnClose(wxCloseEvent& event);
void SavePHackData(wxCommandEvent& event); void SavePHackData(wxCommandEvent& event);
void LoadPHackData(); void LoadPHackData();
}; };

View File

@ -20,7 +20,6 @@
extern std::vector<PatchEngine::Patch> onFrame; extern std::vector<PatchEngine::Patch> onFrame;
BEGIN_EVENT_TABLE(CPatchAddEdit, wxDialog) BEGIN_EVENT_TABLE(CPatchAddEdit, wxDialog)
EVT_CLOSE(CPatchAddEdit::OnClose)
EVT_BUTTON(wxID_OK, CPatchAddEdit::SavePatchData) EVT_BUTTON(wxID_OK, CPatchAddEdit::SavePatchData)
EVT_BUTTON(ID_ENTRY_ADD, CPatchAddEdit::AddRemoveEntry) EVT_BUTTON(ID_ENTRY_ADD, CPatchAddEdit::AddRemoveEntry)
EVT_BUTTON(ID_ENTRY_REMOVE, CPatchAddEdit::AddRemoveEntry) EVT_BUTTON(ID_ENTRY_REMOVE, CPatchAddEdit::AddRemoveEntry)
@ -56,11 +55,11 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
itCurEntry = tempEntries.begin(); itCurEntry = tempEntries.begin();
wxBoxSizer* sEditPatch = new wxBoxSizer(wxVERTICAL); wxBoxSizer* sEditPatch = new wxBoxSizer(wxVERTICAL);
wxStaticText* EditPatchNameText = new wxStaticText(this, ID_EDITPATCH_NAME_TEXT, _("Name:"), wxDefaultPosition, wxDefaultSize); wxStaticText* EditPatchNameText = new wxStaticText(this, ID_EDITPATCH_NAME_TEXT, _("Name:"));
EditPatchName = new wxTextCtrl(this, ID_EDITPATCH_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); EditPatchName = new wxTextCtrl(this, ID_EDITPATCH_NAME);
EditPatchName->SetValue(currentName); EditPatchName->SetValue(currentName);
wxStaticText* EditPatchOffsetText = new wxStaticText(this, ID_EDITPATCH_OFFSET_TEXT, _("Offset:"), wxDefaultPosition, wxDefaultSize); wxStaticText* EditPatchOffsetText = new wxStaticText(this, ID_EDITPATCH_OFFSET_TEXT, _("Offset:"));
EditPatchOffset = new wxTextCtrl(this, ID_EDITPATCH_OFFSET, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); EditPatchOffset = new wxTextCtrl(this, ID_EDITPATCH_OFFSET);
EditPatchOffset->SetValue(wxString::Format(wxT("%08X"), tempEntries.at(0).address)); EditPatchOffset->SetValue(wxString::Format(wxT("%08X"), tempEntries.at(0).address));
EntrySelection = new wxSpinButton(this, ID_ENTRY_SELECT, wxDefaultPosition, wxDefaultSize, wxVERTICAL); EntrySelection = new wxSpinButton(this, ID_ENTRY_SELECT, wxDefaultPosition, wxDefaultSize, wxVERTICAL);
EntrySelection->SetRange(0, (int)tempEntries.size()-1); EntrySelection->SetRange(0, (int)tempEntries.size()-1);
@ -68,13 +67,13 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
wxArrayString wxArrayStringFor_EditPatchType; wxArrayString wxArrayStringFor_EditPatchType;
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
wxArrayStringFor_EditPatchType.Add(wxString::FromAscii(PatchEngine::PatchTypeStrings[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 = new wxRadioBox(this, ID_EDITPATCH_TYPE, _("Type"), wxDefaultPosition, wxDefaultSize, wxArrayStringFor_EditPatchType, 3, wxRA_SPECIFY_COLS);
EditPatchType->SetSelection((int)tempEntries.at(0).type); EditPatchType->SetSelection((int)tempEntries.at(0).type);
wxStaticText* EditPatchValueText = new wxStaticText(this, ID_EDITPATCH_VALUE_TEXT, _("Value:"), wxDefaultPosition, wxDefaultSize); wxStaticText* EditPatchValueText = new wxStaticText(this, ID_EDITPATCH_VALUE_TEXT, _("Value:"));
EditPatchValue = new wxTextCtrl(this, ID_EDITPATCH_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); EditPatchValue = new wxTextCtrl(this, ID_EDITPATCH_VALUE);
EditPatchValue->SetValue(wxString::Format(wxT("%08X"), tempEntries.at(0).value)); EditPatchValue->SetValue(wxString::Format(wxT("%08X"), tempEntries.at(0).value));
wxButton *EntryAdd = new wxButton(this, ID_ENTRY_ADD, _("Add"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); wxButton *EntryAdd = new wxButton(this, ID_ENTRY_ADD, _("Add"));
EntryRemove = new wxButton(this, ID_ENTRY_REMOVE, _("Remove"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); EntryRemove = new wxButton(this, ID_ENTRY_REMOVE, _("Remove"));
if ((int)tempEntries.size() <= 1) if ((int)tempEntries.size() <= 1)
EntryRemove->Disable(); EntryRemove->Disable();
@ -97,22 +96,11 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
sEntryAddRemove->Add(EntryRemove, 0, wxALL, 5); sEntryAddRemove->Add(EntryRemove, 0, wxALL, 5);
sbEntry->Add(sgEntry, 0, wxEXPAND); sbEntry->Add(sgEntry, 0, wxEXPAND);
sbEntry->Add(sEntryAddRemove, 0, wxEXPAND); sbEntry->Add(sEntryAddRemove, 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();
Fit();
}
void CPatchAddEdit::OnClose(wxCloseEvent& WXUNUSED (event)) sEditPatch->Add(sbEntry, 0, wxEXPAND|wxALL, 5);
{ sEditPatch->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 5);
Destroy(); SetSizerAndFit(sEditPatch);
SetFocus();
} }
void CPatchAddEdit::ChangeEntry(wxSpinEvent& event) void CPatchAddEdit::ChangeEntry(wxSpinEvent& event)
@ -124,7 +112,7 @@ void CPatchAddEdit::ChangeEntry(wxSpinEvent& event)
UpdateEntryCtrls(*itCurEntry); UpdateEntryCtrls(*itCurEntry);
} }
void CPatchAddEdit::SavePatchData(wxCommandEvent& WXUNUSED (event)) void CPatchAddEdit::SavePatchData(wxCommandEvent& event)
{ {
SaveEntryData(itCurEntry); SaveEntryData(itCurEntry);
@ -144,6 +132,7 @@ void CPatchAddEdit::SavePatchData(wxCommandEvent& WXUNUSED (event))
} }
AcceptAndClose(); AcceptAndClose();
event.Skip();
} }
void CPatchAddEdit::AddRemoveEntry(wxCommandEvent& event) void CPatchAddEdit::AddRemoveEntry(wxCommandEvent& event)

View File

@ -58,7 +58,6 @@ class CPatchAddEdit : public wxDialog
}; };
void CreateGUIControls(int selection); void CreateGUIControls(int selection);
void OnClose(wxCloseEvent& event);
void ChangeEntry(wxSpinEvent& event); void ChangeEntry(wxSpinEvent& event);
void SavePatchData(wxCommandEvent& event); void SavePatchData(wxCommandEvent& event);
void AddRemoveEntry(wxCommandEvent& event); void AddRemoveEntry(wxCommandEvent& event);