Merge pull request #1518 from lioncash/evt

DolphinWX: Kill off trivial event tables
This commit is contained in:
skidau 2014-11-11 11:55:49 +11:00
commit 71d8165a86
17 changed files with 234 additions and 334 deletions

View File

@ -29,15 +29,12 @@
#include "DolphinWX/ISOProperties.h" #include "DolphinWX/ISOProperties.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
BEGIN_EVENT_TABLE(CARCodeAddEdit, wxDialog)
EVT_BUTTON(wxID_OK, CARCodeAddEdit::SaveCheatData)
EVT_SPIN(ID_ENTRY_SELECT, CARCodeAddEdit::ChangeEntry)
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)
{ {
Bind(wxEVT_BUTTON, &CARCodeAddEdit::SaveCheatData, this);
ActionReplay::ARCode tempEntries; ActionReplay::ARCode tempEntries;
wxString currentName = _("Insert name here.."); wxString currentName = _("Insert name here..");
@ -55,13 +52,16 @@ CARCodeAddEdit::CARCodeAddEdit(int _selection, wxWindow* parent, wxWindowID id,
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);
wxStaticText* EditCheatNameText = new wxStaticText(this, ID_EDITCHEAT_NAME_TEXT, _("Name:")); wxStaticText* EditCheatNameText = new wxStaticText(this, wxID_ANY, _("Name:"));
EditCheatName = new wxTextCtrl(this, ID_EDITCHEAT_NAME, wxEmptyString); EditCheatName = new wxTextCtrl(this, wxID_ANY, wxEmptyString);
EditCheatName->SetValue(currentName); EditCheatName->SetValue(currentName);
EntrySelection = new wxSpinButton(this, ID_ENTRY_SELECT);
EntrySelection = new wxSpinButton(this);
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); EntrySelection->Bind(wxEVT_SPIN, &CARCodeAddEdit::ChangeEntry, this);
EditCheatCode = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, 100), wxTE_MULTILINE);
UpdateTextCtrl(tempEntries); UpdateTextCtrl(tempEntries);
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);

View File

@ -20,33 +20,22 @@ namespace ActionReplay { struct ARCode; }
class CARCodeAddEdit : public wxDialog class CARCodeAddEdit : public wxDialog
{ {
public: public:
CARCodeAddEdit(int _selection, wxWindow* parent, CARCodeAddEdit(int _selection, wxWindow* parent,
wxWindowID id = 1, wxWindowID id = 1,
const wxString& title = _("Edit ActionReplay Code"), const wxString& title = _("Edit ActionReplay Code"),
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);
private: private:
DECLARE_EVENT_TABLE(); wxTextCtrl* EditCheatName;
wxSpinButton* EntrySelection;
wxTextCtrl* EditCheatCode;
wxTextCtrl *EditCheatName; void SaveCheatData(wxCommandEvent& event);
wxSpinButton *EntrySelection; void ChangeEntry(wxSpinEvent& event);
wxTextCtrl *EditCheatCode; void UpdateTextCtrl(ActionReplay::ARCode arCode);
enum
{
ID_EDITCHEAT_NAME_TEXT = 4550,
ID_EDITCHEAT_NAME,
ID_ENTRY_SELECT,
ID_EDITCHEAT_CODE
};
void SaveCheatData(wxCommandEvent& event);
void ChangeEntry(wxSpinEvent& event);
void UpdateTextCtrl(ActionReplay::ARCode arCode);
int selection;
int selection;
}; };

View File

@ -28,20 +28,6 @@
#include "VideoCommon/Debugger.h" #include "VideoCommon/Debugger.h"
#include "VideoCommon/TextureCacheBase.h" #include "VideoCommon/TextureCacheBase.h"
BEGIN_EVENT_TABLE(GFXDebuggerPanel, wxPanel)
EVT_CLOSE(GFXDebuggerPanel::OnClose)
EVT_BUTTON(ID_PAUSE,GFXDebuggerPanel::OnPauseButton)
EVT_BUTTON(ID_PAUSE_AT_NEXT,GFXDebuggerPanel::OnPauseAtNextButton)
EVT_BUTTON(ID_PAUSE_AT_NEXT_FRAME,GFXDebuggerPanel::OnPauseAtNextFrameButton)
EVT_BUTTON(ID_CONT,GFXDebuggerPanel::OnContButton)
EVT_BUTTON(ID_DUMP,GFXDebuggerPanel::OnDumpButton)
EVT_BUTTON(ID_UPDATE_SCREEN,GFXDebuggerPanel::OnUpdateScreenButton)
EVT_BUTTON(ID_CLEAR_SCREEN,GFXDebuggerPanel::OnClearScreenButton)
EVT_BUTTON(ID_CLEAR_TEXTURE_CACHE,GFXDebuggerPanel::OnClearTextureCacheButton)
EVT_BUTTON(ID_CLEAR_VERTEX_SHADER_CACHE,GFXDebuggerPanel::OnClearVertexShaderCacheButton)
EVT_BUTTON(ID_CLEAR_PIXEL_SHADER_CACHE,GFXDebuggerPanel::OnClearPixelShaderCacheButton)
END_EVENT_TABLE()
GFXDebuggerPanel::GFXDebuggerPanel(wxWindow *parent, wxWindowID id, const wxPoint &position, GFXDebuggerPanel::GFXDebuggerPanel(wxWindow *parent, wxWindowID id, const wxPoint &position,
const wxSize& size, long style, const wxString &title) const wxSize& size, long style, const wxString &title)
: wxPanel(parent, id, position, size, style, title) : wxPanel(parent, id, position, size, style, title)
@ -50,6 +36,8 @@ GFXDebuggerPanel::GFXDebuggerPanel(wxWindow *parent, wxWindowID id, const wxPoin
CreateGUIControls(); CreateGUIControls();
Bind(wxEVT_CLOSE_WINDOW, &GFXDebuggerPanel::OnClose, this);
LoadSettings(); LoadSettings();
} }
@ -148,28 +136,46 @@ void GFXDebuggerPanel::CreateGUIControls()
// Basic settings // Basic settings
CenterOnParent(); CenterOnParent();
m_pButtonPause = new wxButton(this, ID_PAUSE, _("Pause"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Pause")); m_pButtonPause = new wxButton(this, wxID_ANY, _("Pause"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Pause"));
m_pButtonPauseAtNext = new wxButton(this, ID_PAUSE_AT_NEXT, _("Pause After"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Pause At Next")); m_pButtonPause->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnPauseButton, this);
m_pButtonPauseAtNextFrame = new wxButton(this, ID_PAUSE_AT_NEXT_FRAME, _("Go to Next Frame"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Next Frame"));
m_pButtonCont = new wxButton(this, ID_CONT, _("Continue"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Continue"));
m_pCount = new wxTextCtrl(this, ID_COUNT, "1", wxDefaultPosition, wxSize(50,25), wxTE_RIGHT, wxDefaultValidator, _("Count")); m_pButtonPauseAtNext = new wxButton(this, wxID_ANY, _("Pause After"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Pause At Next"));
m_pButtonPauseAtNext->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnPauseAtNextButton, this);
m_pPauseAtList = new wxChoice(this, ID_PAUSE_AT_LIST, wxDefaultPosition, wxSize(100,25), 0, nullptr,0,wxDefaultValidator, _("PauseAtList")); m_pButtonPauseAtNextFrame = new wxButton(this, wxID_ANY, _("Go to Next Frame"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Next Frame"));
m_pButtonPauseAtNextFrame->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnPauseAtNextFrameButton, this);
m_pButtonCont = new wxButton(this, wxID_ANY, _("Continue"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Continue"));
m_pButtonCont->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnContButton, this);
m_pCount = new wxTextCtrl(this, wxID_ANY, "1", wxDefaultPosition, wxSize(50,25), wxTE_RIGHT, wxDefaultValidator, _("Count"));
m_pPauseAtList = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(100,25), 0, nullptr,0,wxDefaultValidator, _("PauseAtList"));
for (int i=0; i<numPauseEventMap; i++) for (int i=0; i<numPauseEventMap; i++)
{ {
m_pPauseAtList->Append(pauseEventMap[i].ListStr); m_pPauseAtList->Append(pauseEventMap[i].ListStr);
} }
m_pPauseAtList->SetSelection(0); m_pPauseAtList->SetSelection(0);
m_pButtonDump = new wxButton(this, ID_DUMP, _("Dump"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Dump")); m_pButtonDump = new wxButton(this, wxID_ANY, _("Dump"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Dump"));
m_pButtonUpdateScreen = new wxButton(this, ID_UPDATE_SCREEN, _("Update Screen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Update Screen")); m_pButtonDump->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnDumpButton, this);
m_pButtonClearScreen = new wxButton(this, ID_CLEAR_SCREEN, _("Clear Screen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear Screen"));
m_pButtonClearTextureCache = new wxButton(this, ID_CLEAR_TEXTURE_CACHE, _("Clear Textures"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear Textures"));
m_pButtonClearVertexShaderCache = new wxButton(this, ID_CLEAR_VERTEX_SHADER_CACHE, _("Clear V Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear V Shaders"));
m_pButtonClearPixelShaderCache = new wxButton(this, ID_CLEAR_PIXEL_SHADER_CACHE, _("Clear P Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear P Shaders"));
m_pDumpList = new wxChoice(this, ID_DUMP_LIST, wxDefaultPosition, wxSize(120,25), 0, nullptr, 0 ,wxDefaultValidator, _("DumpList")); m_pButtonUpdateScreen = new wxButton(this, wxID_ANY, _("Update Screen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Update Screen"));
m_pButtonUpdateScreen->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnUpdateScreenButton, this);
m_pButtonClearScreen = new wxButton(this, wxID_ANY, _("Clear Screen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear Screen"));
m_pButtonClearScreen->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnClearScreenButton, this);
m_pButtonClearTextureCache = new wxButton(this, wxID_ANY, _("Clear Textures"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear Textures"));
m_pButtonClearTextureCache->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnClearTextureCacheButton, this);
m_pButtonClearVertexShaderCache = new wxButton(this, wxID_ANY, _("Clear V Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear V Shaders"));
m_pButtonClearVertexShaderCache->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnClearVertexShaderCacheButton, this);
m_pButtonClearPixelShaderCache = new wxButton(this, wxID_ANY, _("Clear P Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear P Shaders"));
m_pButtonClearPixelShaderCache->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnClearPixelShaderCacheButton, this);
m_pDumpList = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(120,25), 0, nullptr, 0 ,wxDefaultValidator, _("DumpList"));
m_pDumpList->Insert(_("Pixel Shader"),0); m_pDumpList->Insert(_("Pixel Shader"),0);
m_pDumpList->Append(_("Vertex Shader")); m_pDumpList->Append(_("Vertex Shader"));
m_pDumpList->Append(_("Pixel Shader Constants")); m_pDumpList->Append(_("Pixel Shader Constants"));

View File

@ -22,7 +22,7 @@ class wxWindow;
class GFXDebuggerPanel : public wxPanel, public GFXDebuggerBase class GFXDebuggerPanel : public wxPanel, public GFXDebuggerBase
{ {
public: public:
GFXDebuggerPanel(wxWindow *parent, GFXDebuggerPanel(wxWindow* parent,
wxWindowID id = wxID_ANY, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@ -46,8 +46,6 @@ public:
void OnContinue() override; void OnContinue() override;
private: private:
DECLARE_EVENT_TABLE();
wxPanel* m_MainPanel; wxPanel* m_MainPanel;
wxButton* m_pButtonPause; wxButton* m_pButtonPause;
@ -64,26 +62,6 @@ private:
wxButton* m_pButtonClearPixelShaderCache; wxButton* m_pButtonClearPixelShaderCache;
wxTextCtrl* m_pCount; wxTextCtrl* m_pCount;
// TODO: Prefix with GFX_
enum
{
ID_MAINPANEL = 3900,
ID_CONT,
ID_PAUSE,
ID_PAUSE_AT_NEXT,
ID_PAUSE_AT_NEXT_FRAME,
ID_PAUSE_AT_LIST,
ID_DUMP,
ID_DUMP_LIST,
ID_UPDATE_SCREEN,
ID_CLEAR_SCREEN,
ID_CLEAR_TEXTURE_CACHE,
ID_CLEAR_VERTEX_SHADER_CACHE,
ID_CLEAR_PIXEL_SHADER_CACHE,
ID_COUNT
};
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void CreateGUIControls(); void CreateGUIControls();

View File

@ -65,25 +65,6 @@ FifoPlayerDlg::FifoPlayerDlg(wxWindow * const parent) :
FifoPlayerDlg::~FifoPlayerDlg() FifoPlayerDlg::~FifoPlayerDlg()
{ {
Unbind(RECORDING_FINISHED_EVENT, &FifoPlayerDlg::OnRecordingFinished, this);
Unbind(FRAME_WRITTEN_EVENT, &FifoPlayerDlg::OnFrameWritten, this);
// Disconnect Events
Unbind(wxEVT_PAINT, &FifoPlayerDlg::OnPaint, this);
m_FrameFromCtrl->Unbind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnFrameFrom, this);
m_FrameToCtrl->Unbind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnFrameTo, this);
m_ObjectFromCtrl->Unbind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnObjectFrom, this);
m_ObjectToCtrl->Unbind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnObjectTo, this);
m_EarlyMemoryUpdates->Unbind(wxEVT_CHECKBOX, &FifoPlayerDlg::OnCheckEarlyMemoryUpdates, this);
m_RecordStop->Unbind(wxEVT_BUTTON, &FifoPlayerDlg::OnRecordStop, this);
m_Save->Unbind(wxEVT_BUTTON, &FifoPlayerDlg::OnSaveFile, this);
m_FramesToRecordCtrl->Unbind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnNumFramesToRecord, this);
m_Close->Unbind(wxEVT_BUTTON, &FifoPlayerDlg::OnCloseClick, this);
m_framesList->Unbind(wxEVT_LISTBOX, &FifoPlayerDlg::OnFrameListSelectionChanged, this);
m_objectsList->Unbind(wxEVT_LISTBOX, &FifoPlayerDlg::OnObjectListSelectionChanged, this);
m_objectCmdList->Unbind(wxEVT_LISTBOX, &FifoPlayerDlg::OnObjectCmdListSelectionChanged, this);
FifoPlayer::GetInstance().SetFrameWrittenCallback(nullptr); FifoPlayer::GetInstance().SetFrameWrittenCallback(nullptr);
sMutex.lock(); sMutex.lock();

View File

@ -319,7 +319,6 @@ EVT_ACTIVATE(CFrame::OnActive)
EVT_CLOSE(CFrame::OnClose) EVT_CLOSE(CFrame::OnClose)
EVT_SIZE(CFrame::OnResize) EVT_SIZE(CFrame::OnResize)
EVT_MOVE(CFrame::OnMove) EVT_MOVE(CFrame::OnMove)
EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, CFrame::OnGameListCtrl_ItemActivated)
EVT_HOST_COMMAND(wxID_ANY, CFrame::OnHostMessage) EVT_HOST_COMMAND(wxID_ANY, CFrame::OnHostMessage)
EVT_AUI_PANE_CLOSE(CFrame::OnPaneClose) EVT_AUI_PANE_CLOSE(CFrame::OnPaneClose)
@ -393,9 +392,10 @@ CFrame::CFrame(wxFrame* parent,
// This panel is the parent for rendering and it holds the gamelistctrl // This panel is the parent for rendering and it holds the gamelistctrl
m_Panel = new wxPanel(this, IDM_MPANEL, wxDefaultPosition, wxDefaultSize, 0); m_Panel = new wxPanel(this, IDM_MPANEL, wxDefaultPosition, wxDefaultSize, 0);
m_GameListCtrl = new CGameListCtrl(m_Panel, LIST_CTRL, m_GameListCtrl = new CGameListCtrl(m_Panel, wxID_ANY,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT); wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT);
m_GameListCtrl->Bind(wxEVT_LIST_ITEM_ACTIVATED, &CFrame::OnGameListCtrl_ItemActivated, this);
wxBoxSizer *sizerPanel = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *sizerPanel = new wxBoxSizer(wxHORIZONTAL);
sizerPanel->Add(m_GameListCtrl, 1, wxEXPAND | wxALL); sizerPanel->Add(m_GameListCtrl, 1, wxEXPAND | wxALL);

View File

@ -184,35 +184,29 @@ static int CompareGameListItems(const GameListItem* iso1, const GameListItem* is
return 0; return 0;
} }
BEGIN_EVENT_TABLE(wxEmuStateTip, wxTipWindow)
EVT_KEY_DOWN(wxEmuStateTip::OnKeyDown)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(CGameListCtrl, wxListCtrl)
EVT_SIZE(CGameListCtrl::OnSize)
EVT_RIGHT_DOWN(CGameListCtrl::OnRightClick)
EVT_LEFT_DOWN(CGameListCtrl::OnLeftClick)
EVT_LIST_KEY_DOWN(LIST_CTRL, CGameListCtrl::OnKeyPress)
EVT_MOTION(CGameListCtrl::OnMouseMotion)
EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, CGameListCtrl::OnColBeginDrag)
EVT_LIST_COL_CLICK(LIST_CTRL, CGameListCtrl::OnColumnClick)
EVT_MENU(IDM_PROPERTIES, CGameListCtrl::OnProperties)
EVT_MENU(IDM_GAMEWIKI, CGameListCtrl::OnWiki)
EVT_MENU(IDM_OPENCONTAININGFOLDER, CGameListCtrl::OnOpenContainingFolder)
EVT_MENU(IDM_OPENSAVEFOLDER, CGameListCtrl::OnOpenSaveFolder)
EVT_MENU(IDM_EXPORTSAVE, CGameListCtrl::OnExportSave)
EVT_MENU(IDM_SETDEFAULTISO, CGameListCtrl::OnSetDefaultISO)
EVT_MENU(IDM_COMPRESSISO, CGameListCtrl::OnCompressISO)
EVT_MENU(IDM_MULTICOMPRESSISO, CGameListCtrl::OnMultiCompressISO)
EVT_MENU(IDM_MULTIDECOMPRESSISO, CGameListCtrl::OnMultiDecompressISO)
EVT_MENU(IDM_DELETEISO, CGameListCtrl::OnDeleteISO)
EVT_MENU(IDM_LIST_CHANGEDISC, CGameListCtrl::OnChangeDisc)
END_EVENT_TABLE()
CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const
wxPoint& pos, const wxSize& size, long style) wxPoint& pos, const wxSize& size, long style)
: wxListCtrl(parent, id, pos, size, style), toolTip(nullptr) : wxListCtrl(parent, id, pos, size, style), toolTip(nullptr)
{ {
Bind(wxEVT_SIZE, &CGameListCtrl::OnSize, this);
Bind(wxEVT_RIGHT_DOWN, &CGameListCtrl::OnRightClick, this);
Bind(wxEVT_LEFT_DOWN, &CGameListCtrl::OnLeftClick, this);
Bind(wxEVT_MOTION, &CGameListCtrl::OnMouseMotion, this);
Bind(wxEVT_LIST_KEY_DOWN, &CGameListCtrl::OnKeyPress, this);
Bind(wxEVT_LIST_COL_BEGIN_DRAG, &CGameListCtrl::OnColBeginDrag, this);
Bind(wxEVT_LIST_COL_CLICK, &CGameListCtrl::OnColumnClick, this);
Bind(wxEVT_MENU, &CGameListCtrl::OnProperties, this, IDM_PROPERTIES);
Bind(wxEVT_MENU, &CGameListCtrl::OnWiki, this, IDM_GAMEWIKI);
Bind(wxEVT_MENU, &CGameListCtrl::OnOpenContainingFolder, this, IDM_OPENCONTAININGFOLDER);
Bind(wxEVT_MENU, &CGameListCtrl::OnOpenSaveFolder, this, IDM_OPENSAVEFOLDER);
Bind(wxEVT_MENU, &CGameListCtrl::OnExportSave, this, IDM_EXPORTSAVE);
Bind(wxEVT_MENU, &CGameListCtrl::OnSetDefaultISO, this, IDM_SETDEFAULTISO);
Bind(wxEVT_MENU, &CGameListCtrl::OnCompressISO, this, IDM_COMPRESSISO);
Bind(wxEVT_MENU, &CGameListCtrl::OnMultiCompressISO, this, IDM_MULTICOMPRESSISO);
Bind(wxEVT_MENU, &CGameListCtrl::OnMultiDecompressISO, this, IDM_MULTIDECOMPRESSISO);
Bind(wxEVT_MENU, &CGameListCtrl::OnDeleteISO, this, IDM_DELETEISO);
Bind(wxEVT_MENU, &CGameListCtrl::OnChangeDisc, this, IDM_LIST_CHANGEDISC);
} }
CGameListCtrl::~CGameListCtrl() CGameListCtrl::~CGameListCtrl()

View File

@ -24,11 +24,13 @@ class wxEmuStateTip : public wxTipWindow
{ {
public: public:
wxEmuStateTip(wxWindow* parent, const wxString& text, wxEmuStateTip** windowPtr) wxEmuStateTip(wxWindow* parent, const wxString& text, wxEmuStateTip** windowPtr)
: wxTipWindow(parent, text, 70, (wxTipWindow**)windowPtr) {} : wxTipWindow(parent, text, 70, (wxTipWindow**)windowPtr)
{
Bind(wxEVT_KEY_DOWN, &wxEmuStateTip::OnKeyDown, this);
}
// wxTipWindow doesn't correctly handle KeyEvents and crashes... we must overload that. // wxTipWindow doesn't correctly handle KeyEvents and crashes... we must overload that.
void OnKeyDown(wxKeyEvent& event) { event.StopPropagation(); Close(); } void OnKeyDown(wxKeyEvent& event) { event.StopPropagation(); Close(); }
private:
DECLARE_EVENT_TABLE()
}; };
class CGameListCtrl : public wxListCtrl class CGameListCtrl : public wxListCtrl
@ -83,8 +85,6 @@ private:
void SetBackgroundColor(); void SetBackgroundColor();
void ScanForISOs(); void ScanForISOs();
DECLARE_EVENT_TABLE()
// events // events
void OnLeftClick(wxMouseEvent& event); void OnLeftClick(wxMouseEvent& event);
void OnRightClick(wxMouseEvent& event); void OnRightClick(wxMouseEvent& event);

View File

@ -281,7 +281,6 @@ enum
IDM_MPANEL, ID_STATUSBAR, IDM_MPANEL, ID_STATUSBAR,
ID_TOOLBAR = 500, ID_TOOLBAR = 500,
LIST_CTRL = 1000
}; };
// custom message macro // custom message macro

View File

@ -27,11 +27,6 @@
#include "DolphinWX/HotkeyDlg.h" #include "DolphinWX/HotkeyDlg.h"
#include "DolphinWX/WXInputBase.h" #include "DolphinWX/WXInputBase.h"
BEGIN_EVENT_TABLE(HotkeyConfigDialog,wxDialog)
EVT_COMMAND_RANGE(0, NUM_HOTKEYS - 1, wxEVT_BUTTON, HotkeyConfigDialog::OnButtonClick)
EVT_TIMER(wxID_ANY, HotkeyConfigDialog::OnButtonTimer)
END_EVENT_TABLE()
HotkeyConfigDialog::HotkeyConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, HotkeyConfigDialog::HotkeyConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &position, const wxSize& size, long style) const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style) : wxDialog(parent, id, title, position, size, style)
@ -39,6 +34,9 @@ HotkeyConfigDialog::HotkeyConfigDialog(wxWindow *parent, wxWindowID id, const wx
{ {
CreateHotkeyGUIControls(); CreateHotkeyGUIControls();
Bind(wxEVT_BUTTON, &HotkeyConfigDialog::OnButtonClick, this, 0, NUM_HOTKEYS - 1);
Bind(wxEVT_TIMER, &HotkeyConfigDialog::OnButtonTimer, this);
g_Pressed = 0; g_Pressed = 0;
g_Modkey = 0; g_Modkey = 0;
ClickedButton = nullptr; ClickedButton = nullptr;

View File

@ -26,35 +26,33 @@ class wxWindow;
class HotkeyConfigDialog : public wxDialog class HotkeyConfigDialog : public wxDialog
{ {
public: public:
HotkeyConfigDialog(wxWindow *parent, HotkeyConfigDialog(wxWindow* parent,
wxWindowID id = 1, wxWindowID id = 1,
const wxString &title = _("Hotkey Configuration"), const wxString &title = _("Hotkey Configuration"),
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 ~HotkeyConfigDialog(); virtual ~HotkeyConfigDialog();
private: private:
DECLARE_EVENT_TABLE(); wxString OldLabel;
wxString OldLabel; wxButton* ClickedButton;
wxButton* m_Button_Hotkeys[NUM_HOTKEYS];
wxButton *ClickedButton; wxTimer m_ButtonMappingTimer;
wxButton *m_Button_Hotkeys[NUM_HOTKEYS];
wxTimer m_ButtonMappingTimer; void OnButtonTimer(wxTimerEvent& WXUNUSED(event)) { DoGetButtons(GetButtonWaitingID); }
void OnButtonClick(wxCommandEvent& event);
void OnKeyDown(wxKeyEvent& event);
void SaveButtonMapping(int Id, int Key, int Modkey);
void CreateHotkeyGUIControls();
void OnButtonTimer(wxTimerEvent& WXUNUSED(event)) { DoGetButtons(GetButtonWaitingID); } void SetButtonText(int id, const wxString &keystr, const wxString &modkeystr = wxString());
void OnButtonClick(wxCommandEvent& event);
void OnKeyDown(wxKeyEvent& event);
void SaveButtonMapping(int Id, int Key, int Modkey);
void CreateHotkeyGUIControls();
void SetButtonText(int id, const wxString &keystr, const wxString &modkeystr = wxString()); void DoGetButtons(int id);
void EndGetButtons();
void DoGetButtons(int id); int GetButtonWaitingID, GetButtonWaitingTimer, g_Pressed, g_Modkey;
void EndGetButtons();
int GetButtonWaitingID, GetButtonWaitingTimer, g_Pressed, g_Modkey;
}; };

View File

@ -41,14 +41,6 @@
// Milliseconds between msgQueue flushes to wxTextCtrl // Milliseconds between msgQueue flushes to wxTextCtrl
#define UPDATETIME 200 #define UPDATETIME 200
BEGIN_EVENT_TABLE(CLogWindow, wxPanel)
EVT_CLOSE(CLogWindow::OnClose)
EVT_BUTTON(IDM_CLEARLOG, CLogWindow::OnClear)
EVT_CHOICE(IDM_FONT, CLogWindow::OnFontChange)
EVT_CHECKBOX(IDM_WRAPLINE, CLogWindow::OnWrapLineCheck)
EVT_TIMER(IDTM_UPDATELOG, CLogWindow::OnLogTimer)
END_EVENT_TABLE()
CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos, CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style, const wxString& name) const wxSize& size, long style, const wxString& name)
: wxPanel(parent, id, pos, size, style, name) : wxPanel(parent, id, pos, size, style, name)
@ -56,11 +48,13 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
, Parent(parent), m_ignoreLogTimer(false), m_LogAccess(true) , Parent(parent), m_ignoreLogTimer(false), m_LogAccess(true)
, m_Log(nullptr), m_cmdline(nullptr), m_FontChoice(nullptr) , m_Log(nullptr), m_cmdline(nullptr), m_FontChoice(nullptr)
{ {
Bind(wxEVT_CLOSE_WINDOW, &CLogWindow::OnClose, this);
m_LogManager = LogManager::GetInstance(); m_LogManager = LogManager::GetInstance();
CreateGUIControls(); CreateGUIControls();
m_LogTimer = new wxTimer(this, IDTM_UPDATELOG); m_LogTimer = new wxTimer(this);
m_LogTimer->Bind(wxEVT_TIMER, &CLogWindow::OnLogTimer, this);
m_LogTimer->Start(UPDATETIME); m_LogTimer->Start(UPDATETIME);
} }
@ -124,7 +118,8 @@ void CLogWindow::CreateGUIControls()
} }
// Font // Font
m_FontChoice = new wxChoice(this, IDM_FONT); m_FontChoice = new wxChoice(this, wxID_ANY);
m_FontChoice->Bind(wxEVT_CHOICE, &CLogWindow::OnFontChange, this);
m_FontChoice->Append(_("Default font")); m_FontChoice->Append(_("Default font"));
m_FontChoice->Append(_("Monospaced font")); m_FontChoice->Append(_("Monospaced font"));
m_FontChoice->Append(_("Selected font")); m_FontChoice->Append(_("Selected font"));
@ -142,27 +137,32 @@ void CLogWindow::CreateGUIControls()
// Word wrap // Word wrap
bool wrap_lines; bool wrap_lines;
options->Get("WrapLines", &wrap_lines, false); options->Get("WrapLines", &wrap_lines, false);
m_WrapLine = new wxCheckBox(this, IDM_WRAPLINE, _("Word Wrap")); m_WrapLine = new wxCheckBox(this, wxID_ANY, _("Word Wrap"));
m_WrapLine->Bind(wxEVT_CHECKBOX, &CLogWindow::OnWrapLineCheck, this);
m_WrapLine->SetValue(wrap_lines); m_WrapLine->SetValue(wrap_lines);
// Log viewer // Log viewer
m_Log = CreateTextCtrl(this, IDM_LOG, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | m_Log = CreateTextCtrl(this, wxID_ANY, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY |
(wrap_lines ? wxTE_WORDWRAP : wxTE_DONTWRAP)); (wrap_lines ? wxTE_WORDWRAP : wxTE_DONTWRAP));
// submit row // submit row
m_cmdline = new wxTextCtrl(this, IDM_SUBMITCMD, wxEmptyString, wxDefaultPosition, wxDefaultSize, m_cmdline = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB); wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
// Clear log button
m_clear_log_btn = new wxButton(this, wxID_ANY, _("Clear"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
m_clear_log_btn->Bind(wxEVT_BUTTON, &CLogWindow::OnClear, this);
// Sizers // Sizers
wxBoxSizer *sTop = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sTop = new wxBoxSizer(wxHORIZONTAL);
sTop->Add(new wxButton(this, IDM_CLEARLOG, _("Clear"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT)); sTop->Add(m_clear_log_btn);
sTop->Add(m_FontChoice, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 3); sTop->Add(m_FontChoice, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 3);
sTop->Add(m_WrapLine, 0, wxALIGN_CENTER_VERTICAL); sTop->Add(m_WrapLine, 0, wxALIGN_CENTER_VERTICAL);
sBottom = new wxBoxSizer(wxVERTICAL); sBottom = new wxBoxSizer(wxVERTICAL);
PopulateBottom(); PopulateBottom();
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL); wxBoxSizer* sMain = new wxBoxSizer(wxVERTICAL);
sMain->Add(sTop, 0, wxEXPAND); sMain->Add(sTop, 0, wxEXPAND);
sMain->Add(sBottom, 1, wxEXPAND); sMain->Add(sBottom, 1, wxEXPAND);
SetSizer(sMain); SetSizer(sMain);
@ -273,9 +273,9 @@ void CLogWindow::OnWrapLineCheck(wxCommandEvent& event)
Text = m_Log->GetValue(); Text = m_Log->GetValue();
m_Log->Destroy(); m_Log->Destroy();
if (event.IsChecked()) if (event.IsChecked())
m_Log = CreateTextCtrl(this, IDM_LOG, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_WORDWRAP); m_Log = CreateTextCtrl(this, wxID_ANY, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_WORDWRAP);
else else
m_Log = CreateTextCtrl(this, IDM_LOG, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP); m_Log = CreateTextCtrl(this, wxID_ANY, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE)); m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE));
m_Log->AppendText(Text); m_Log->AppendText(Text);
PopulateBottom(); PopulateBottom();

View File

@ -28,22 +28,11 @@ class wxTextCtrl;
class wxTimer; class wxTimer;
class wxTimerEvent; class wxTimerEvent;
enum
{
IDM_LOG,
IDM_CLEARLOG,
IDM_TOGGLEALL,
IDM_WRAPLINE,
IDTM_UPDATELOG,
IDM_FONT,
IDM_SUBMITCMD
};
// Uses multiple inheritance - only sane because LogListener is a pure virtual interface. // Uses multiple inheritance - only sane because LogListener is a pure virtual interface.
class CLogWindow : public wxPanel, LogListener class CLogWindow : public wxPanel, LogListener
{ {
public: public:
CLogWindow(CFrame *parent, CLogWindow(CFrame* parent,
wxWindowID id = wxID_ANY, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@ -58,26 +47,26 @@ public:
int x, y, winpos; int x, y, winpos;
private: private:
CFrame *Parent; CFrame* Parent;
wxFont DefaultFont, MonoSpaceFont; wxFont DefaultFont, MonoSpaceFont;
std::vector<wxFont> LogFont; std::vector<wxFont> LogFont;
wxTimer *m_LogTimer; wxTimer* m_LogTimer;
bool m_ignoreLogTimer; bool m_ignoreLogTimer;
LogManager *m_LogManager; LogManager* m_LogManager;
std::queue<std::pair<u8, wxString> > msgQueue; std::queue<std::pair<u8, wxString> > msgQueue;
bool m_writeFile, m_writeWindow, m_writeDebugger, m_LogAccess; bool m_writeFile, m_writeWindow, m_writeDebugger, m_LogAccess;
// Controls // Controls
wxBoxSizer *sBottom; wxBoxSizer* sBottom;
wxTextCtrl *m_Log, *m_cmdline; wxTextCtrl* m_Log;
wxChoice *m_FontChoice; wxTextCtrl* m_cmdline;
wxCheckBox *m_WrapLine; wxChoice* m_FontChoice;
wxCheckBox* m_WrapLine;
wxButton* m_clear_log_btn;
std::mutex m_LogSection; std::mutex m_LogSection;
DECLARE_EVENT_TABLE() wxTextCtrl* CreateTextCtrl(wxPanel* parent, wxWindowID id, long Style);
wxTextCtrl * CreateTextCtrl(wxPanel* parent, wxWindowID id, long Style);
void CreateGUIControls(); void CreateGUIControls();
void PopulateBottom(); void PopulateBottom();
void UnPopulateBottom(); void UnPopulateBottom();

View File

@ -89,12 +89,6 @@ class wxFrame;
IMPLEMENT_APP(DolphinApp) IMPLEMENT_APP(DolphinApp)
BEGIN_EVENT_TABLE(DolphinApp, wxApp)
EVT_TIMER(wxID_ANY, DolphinApp::AfterInit)
EVT_QUERY_END_SESSION(DolphinApp::OnEndSession)
EVT_END_SESSION(DolphinApp::OnEndSession)
END_EVENT_TABLE()
bool wxMsgAlert(const char*, const char*, bool, int); bool wxMsgAlert(const char*, const char*, bool, int);
std::string wxStringTranslator(const char *); std::string wxStringTranslator(const char *);
@ -138,6 +132,9 @@ bool DolphinApp::Initialize(int& c, wxChar **v)
bool DolphinApp::OnInit() bool DolphinApp::OnInit()
{ {
Bind(wxEVT_QUERY_END_SESSION, &DolphinApp::OnEndSession, this);
Bind(wxEVT_END_SESSION, &DolphinApp::OnEndSession, this);
InitLanguageSupport(); InitLanguageSupport();
// Declarations and definitions // Declarations and definitions
@ -309,18 +306,14 @@ bool DolphinApp::OnInit()
y = wxDefaultCoord; y = wxDefaultCoord;
#endif #endif
main_frame = new CFrame((wxFrame*)nullptr, wxID_ANY, main_frame = new CFrame(nullptr, wxID_ANY,
StrToWxStr(scm_rev_str), StrToWxStr(scm_rev_str),
wxPoint(x, y), wxSize(w, h), wxPoint(x, y), wxSize(w, h),
UseDebugger, BatchMode, UseLogger); UseDebugger, BatchMode, UseLogger);
SetTopWindow(main_frame); SetTopWindow(main_frame);
main_frame->SetMinSize(wxSize(400, 300)); main_frame->SetMinSize(wxSize(400, 300));
// Postpone final actions until event handler is running. AfterInit();
// Updating the game list makes use of wxProgressDialog which may
// only be run after OnInit() when the event handler is running.
m_afterinit = new wxTimer(this, wxID_ANY);
m_afterinit->Start(1, wxTIMER_ONE_SHOT);
return true; return true;
} }
@ -329,16 +322,11 @@ void DolphinApp::MacOpenFile(const wxString &fileName)
{ {
FileToLoad = fileName; FileToLoad = fileName;
LoadFile = true; LoadFile = true;
main_frame->BootGame(WxStrToStr(FileToLoad));
if (m_afterinit == nullptr)
main_frame->BootGame(WxStrToStr(FileToLoad));
} }
void DolphinApp::AfterInit(wxTimerEvent& WXUNUSED(event)) void DolphinApp::AfterInit()
{ {
delete m_afterinit;
m_afterinit = nullptr;
if (!BatchMode) if (!BatchMode)
main_frame->UpdateGameList(); main_frame->UpdateGameList();
@ -352,7 +340,7 @@ void DolphinApp::AfterInit(wxTimerEvent& WXUNUSED(event))
} }
else else
{ {
main_frame->BootGame(std::string("")); main_frame->BootGame("");
} }
} }
} }

View File

@ -12,8 +12,6 @@
class CFrame; class CFrame;
class wxLocale; class wxLocale;
class wxTimer;
class wxTimerEvent;
extern CFrame* main_frame; extern CFrame* main_frame;
@ -31,9 +29,6 @@ private:
void InitLanguageSupport(); void InitLanguageSupport();
void MacOpenFile(const wxString &fileName); void MacOpenFile(const wxString &fileName);
DECLARE_EVENT_TABLE()
wxTimer *m_afterinit;
bool BatchMode; bool BatchMode;
bool LoadFile; bool LoadFile;
bool playMovie; bool playMovie;
@ -41,7 +36,7 @@ private:
wxString movieFile; wxString movieFile;
wxLocale *m_locale; wxLocale *m_locale;
void AfterInit(wxTimerEvent& WXUNUSED(event)); void AfterInit();
void OnEndSession(wxCloseEvent& event); void OnEndSession(wxCloseEvent& event);
}; };

View File

@ -28,18 +28,13 @@
#include "DolphinWX/PatchAddEdit.h" #include "DolphinWX/PatchAddEdit.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
BEGIN_EVENT_TABLE(CPatchAddEdit, wxDialog)
EVT_BUTTON(wxID_OK, CPatchAddEdit::SavePatchData)
EVT_BUTTON(ID_ENTRY_ADD, CPatchAddEdit::AddRemoveEntry)
EVT_BUTTON(ID_ENTRY_REMOVE, CPatchAddEdit::AddRemoveEntry)
EVT_SPIN(ID_ENTRY_SELECT, CPatchAddEdit::ChangeEntry)
END_EVENT_TABLE()
CPatchAddEdit::CPatchAddEdit(int _selection, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) CPatchAddEdit::CPatchAddEdit(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); CreateGUIControls(selection);
Bind(wxEVT_BUTTON, &CPatchAddEdit::SavePatchData, this, wxID_OK);
} }
CPatchAddEdit::~CPatchAddEdit() CPatchAddEdit::~CPatchAddEdit()
@ -64,25 +59,35 @@ 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:"));
EditPatchName = new wxTextCtrl(this, ID_EDITPATCH_NAME); wxStaticText* EditPatchNameText = new wxStaticText(this, wxID_ANY, _("Name:"));
EditPatchName = new wxTextCtrl(this, wxID_ANY);
EditPatchName->SetValue(currentName); EditPatchName->SetValue(currentName);
wxStaticText* EditPatchOffsetText = new wxStaticText(this, ID_EDITPATCH_OFFSET_TEXT, _("Offset:"));
EditPatchOffset = new wxTextCtrl(this, ID_EDITPATCH_OFFSET); wxStaticText* EditPatchOffsetText = new wxStaticText(this, wxID_ANY, _("Offset:"));
EditPatchOffset = new wxTextCtrl(this, wxID_ANY);
EditPatchOffset->SetValue(wxString::Format("%08X", tempEntries.at(0).address)); EditPatchOffset->SetValue(wxString::Format("%08X", tempEntries.at(0).address));
EntrySelection = new wxSpinButton(this, ID_ENTRY_SELECT);
EntrySelection = new wxSpinButton(this);
EntrySelection->Bind(wxEVT_SPIN, &CPatchAddEdit::ChangeEntry, this);
EntrySelection->SetRange(0, (int)tempEntries.size()-1); EntrySelection->SetRange(0, (int)tempEntries.size()-1);
EntrySelection->SetValue((int)tempEntries.size()-1); EntrySelection->SetValue((int)tempEntries.size()-1);
wxArrayString wxArrayStringFor_EditPatchType; wxArrayString wxArrayStringFor_EditPatchType;
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
wxArrayStringFor_EditPatchType.Add(StrToWxStr(PatchEngine::PatchTypeStrings[i])); wxArrayStringFor_EditPatchType.Add(StrToWxStr(PatchEngine::PatchTypeStrings[i]));
EditPatchType = new wxRadioBox(this, ID_EDITPATCH_TYPE, _("Type"), wxDefaultPosition, wxDefaultSize, wxArrayStringFor_EditPatchType, 3, wxRA_SPECIFY_COLS); EditPatchType = new wxRadioBox(this, wxID_ANY, _("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:"));
EditPatchValue = new wxTextCtrl(this, ID_EDITPATCH_VALUE); wxStaticText* EditPatchValueText = new wxStaticText(this, wxID_ANY, _("Value:"));
EditPatchValue = new wxTextCtrl(this, wxID_ANY);
EditPatchValue->SetValue(wxString::Format("%0*X", PatchEngine::GetPatchTypeCharLength(tempEntries.at(0).type), tempEntries.at(0).value)); EditPatchValue->SetValue(wxString::Format("%0*X", PatchEngine::GetPatchTypeCharLength(tempEntries.at(0).type), tempEntries.at(0).value));
wxButton *EntryAdd = new wxButton(this, ID_ENTRY_ADD, _("Add"));
EntryRemove = new wxButton(this, ID_ENTRY_REMOVE, _("Remove")); EntryAdd = new wxButton(this, wxID_ANY, _("Add"));
EntryAdd->Bind(wxEVT_BUTTON, &CPatchAddEdit::AddEntry, this);
EntryRemove = new wxButton(this, wxID_ANY, _("Remove"));
EntryRemove->Bind(wxEVT_BUTTON, &CPatchAddEdit::RemoveEntry, this);
if ((int)tempEntries.size() <= 1) if ((int)tempEntries.size() <= 1)
EntryRemove->Disable(); EntryRemove->Disable();
@ -92,6 +97,7 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
sEditPatch->Add(sEditPatchName, 0, wxEXPAND); sEditPatch->Add(sEditPatchName, 0, wxEXPAND);
sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, wxString::Format(_("Entry 1/%d"), (int)tempEntries.size())); sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, wxString::Format(_("Entry 1/%d"), (int)tempEntries.size()));
currentItem = 1; currentItem = 1;
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0); wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
sgEntry->Add(EditPatchType, wxGBPosition(0, 0), wxGBSpan(1, 2), wxEXPAND|wxALL, 5); sgEntry->Add(EditPatchType, wxGBPosition(0, 0), wxGBSpan(1, 2), wxEXPAND|wxALL, 5);
sgEntry->Add(EditPatchOffsetText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sgEntry->Add(EditPatchOffsetText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
@ -100,6 +106,7 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
sgEntry->Add(EditPatchValue, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); sgEntry->Add(EditPatchValue, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sgEntry->Add(EntrySelection, wxGBPosition(0, 2), wxGBSpan(3, 1), wxEXPAND|wxALL, 5); sgEntry->Add(EntrySelection, wxGBPosition(0, 2), wxGBSpan(3, 1), wxEXPAND|wxALL, 5);
sgEntry->AddGrowableCol(1); sgEntry->AddGrowableCol(1);
wxBoxSizer* sEntryAddRemove = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sEntryAddRemove = new wxBoxSizer(wxHORIZONTAL);
sEntryAddRemove->Add(EntryAdd, 0, wxALL, 5); sEntryAddRemove->Add(EntryAdd, 0, wxALL, 5);
sEntryAddRemove->Add(EntryRemove, 0, wxALL, 5); sEntryAddRemove->Add(EntryRemove, 0, wxALL, 5);
@ -146,51 +153,44 @@ void CPatchAddEdit::SavePatchData(wxCommandEvent& event)
event.Skip(); event.Skip();
} }
void CPatchAddEdit::AddRemoveEntry(wxCommandEvent& event) void CPatchAddEdit::AddEntry(wxCommandEvent& event)
{ {
switch (event.GetId()) if (!UpdateTempEntryData(itCurEntry))
return;
PatchEngine::PatchEntry peEmptyEntry(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000);
++itCurEntry;
currentItem++;
itCurEntry = tempEntries.insert(itCurEntry, peEmptyEntry);
EntrySelection->SetRange(EntrySelection->GetMin(), EntrySelection->GetMax() + 1);
UpdateEntryCtrls(*itCurEntry);
EntryRemove->Enable();
EntrySelection->Enable();
}
void CPatchAddEdit::RemoveEntry(wxCommandEvent& event)
{
itCurEntry = tempEntries.erase(itCurEntry);
if (itCurEntry != tempEntries.begin())
{ {
case ID_ENTRY_ADD: --itCurEntry;
{ currentItem--;
if (!UpdateTempEntryData(itCurEntry)) }
break; else
{
EntrySelection->SetValue(EntrySelection->GetValue() - 1);
}
PatchEngine::PatchEntry peEmptyEntry(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000); EntrySelection->SetRange(EntrySelection->GetMin(), EntrySelection->GetMax() - 1);
++itCurEntry; UpdateEntryCtrls(*itCurEntry);
currentItem++;
itCurEntry = tempEntries.insert(itCurEntry, peEmptyEntry);
EntrySelection->SetRange(EntrySelection->GetMin(), EntrySelection->GetMax() + 1); if ((int)tempEntries.size() <= 1)
UpdateEntryCtrls(*itCurEntry); {
EntryRemove->Disable();
EntryRemove->Enable(); EntrySelection->Disable();
EntrySelection->Enable();
}
break;
case ID_ENTRY_REMOVE:
{
itCurEntry = tempEntries.erase(itCurEntry);
if (itCurEntry != tempEntries.begin())
{
--itCurEntry;
currentItem--;
}
else
{
EntrySelection->SetValue(EntrySelection->GetValue() - 1);
}
EntrySelection->SetRange(EntrySelection->GetMin(), EntrySelection->GetMax() - 1);
UpdateEntryCtrls(*itCurEntry);
if ((int)tempEntries.size() <= 1)
{
EntryRemove->Disable();
EntrySelection->Disable();
}
}
break;
} }
} }

View File

@ -24,49 +24,34 @@ class wxWindow;
class CPatchAddEdit : public wxDialog class CPatchAddEdit : public wxDialog
{ {
public: public:
CPatchAddEdit(int _selection, wxWindow* parent, CPatchAddEdit(int _selection, wxWindow* parent,
wxWindowID id = 1, wxWindowID id = 1,
const wxString& title = _("Edit Patch"), const wxString& title = _("Edit Patch"),
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 ~CPatchAddEdit(); virtual ~CPatchAddEdit();
private: private:
DECLARE_EVENT_TABLE(); wxTextCtrl* EditPatchName;
wxTextCtrl* EditPatchOffset;
wxRadioBox* EditPatchType;
wxTextCtrl* EditPatchValue;
wxSpinButton* EntrySelection;
wxButton* EntryAdd;
wxButton* EntryRemove;
wxStaticBoxSizer* sbEntry;
wxTextCtrl *EditPatchName; void CreateGUIControls(int selection);
wxTextCtrl *EditPatchOffset; void ChangeEntry(wxSpinEvent& event);
wxRadioBox *EditPatchType; void SavePatchData(wxCommandEvent& event);
wxTextCtrl *EditPatchValue; void AddEntry(wxCommandEvent& event);
wxSpinButton *EntrySelection; void RemoveEntry(wxCommandEvent& event);
wxButton *EntryRemove; void UpdateEntryCtrls(PatchEngine::PatchEntry pE);
wxStaticBoxSizer* sbEntry; bool UpdateTempEntryData(std::vector<PatchEngine::PatchEntry>::iterator iterEntry);
enum
{
ID_EDITPATCH_NAME_TEXT = 4500,
ID_EDITPATCH_NAME,
ID_EDITPATCH_OFFSET_TEXT,
ID_EDITPATCH_OFFSET,
ID_ENTRY_SELECT,
ID_EDITPATCH_TYPE,
ID_EDITPATCH_VALUE_TEXT,
ID_EDITPATCH_VALUE,
ID_ENTRY_ADD,
ID_ENTRY_REMOVE
};
void CreateGUIControls(int selection);
void ChangeEntry(wxSpinEvent& event);
void SavePatchData(wxCommandEvent& event);
void AddRemoveEntry(wxCommandEvent& event);
void UpdateEntryCtrls(PatchEngine::PatchEntry pE);
bool UpdateTempEntryData(std::vector<PatchEngine::PatchEntry>::iterator iterEntry);
int selection, currentItem;
std::vector<PatchEngine::PatchEntry> tempEntries;
std::vector<PatchEngine::PatchEntry>::iterator itCurEntry;
int selection, currentItem;
std::vector<PatchEngine::PatchEntry> tempEntries;
std::vector<PatchEngine::PatchEntry>::iterator itCurEntry;
}; };