Merge pull request #4428 from lioncash/event
DolphinWX: Move common wxUpdateUIEvent functions to WxEventUtils
This commit is contained in:
commit
e05553acfc
|
@ -240,10 +240,6 @@ private:
|
|||
void OnReloadThemeBitmaps(wxCommandEvent& event);
|
||||
void OnReloadGameList(wxCommandEvent& event);
|
||||
|
||||
void OnEnableMenuItemIfCoreInitialized(wxUpdateUIEvent& event);
|
||||
void OnEnableMenuItemIfCoreUninitialized(wxUpdateUIEvent& event);
|
||||
void OnEnableMenuItemIfCorePaused(wxUpdateUIEvent& event);
|
||||
void OnEnableMenuItemIfCPUCanStep(wxUpdateUIEvent& event);
|
||||
void OnUpdateInterpreterMenuItem(wxUpdateUIEvent& event);
|
||||
|
||||
void OnOpen(wxCommandEvent& event); // File menu
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
#include "DolphinWX/NetPlay/NetWindow.h"
|
||||
#include "DolphinWX/TASInputDlg.h"
|
||||
#include "DolphinWX/WXInputBase.h"
|
||||
#include "DolphinWX/WxEventUtils.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
@ -206,46 +207,42 @@ void CFrame::BindDebuggerMenuBarEvents()
|
|||
|
||||
void CFrame::BindDebuggerMenuBarUpdateEvents()
|
||||
{
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCPUCanStep, this, IDM_STEP);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCPUCanStep, this, IDM_STEPOUT);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCPUCanStep, this, IDM_STEPOVER);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCPUCanStep, IDM_STEP);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCPUCanStep, IDM_STEPOUT);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCPUCanStep, IDM_STEPOVER);
|
||||
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnUpdateInterpreterMenuItem, this, IDM_INTERPRETER);
|
||||
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LS_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LSLXZ_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LSLWZ_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LSLBZX_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LSF_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LSP_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_FP_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_I_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_P_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_SR_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_CLEAR_CODE_CACHE);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_JIT_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_JIT_LS_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_JIT_LSLXZ_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_JIT_LSLWZ_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_JIT_LSLBZX_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_JIT_LSF_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_JIT_LSP_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_JIT_FP_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_JIT_I_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_JIT_P_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_JIT_SR_OFF);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCorePaused, IDM_CLEAR_CODE_CACHE);
|
||||
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_SEARCH_INSTRUCTION);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_CLEAR_SYMBOLS);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_SCAN_FUNCTIONS);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_LOAD_MAP_FILE);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_SAVEMAPFILE);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_LOAD_MAP_FILE_AS);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_SAVE_MAP_FILE_AS);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_LOAD_BAD_MAP_FILE);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this,
|
||||
IDM_SAVE_MAP_FILE_WITH_CODES);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this,
|
||||
IDM_CREATE_SIGNATURE_FILE);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this,
|
||||
IDM_APPEND_SIGNATURE_FILE);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this,
|
||||
IDM_COMBINE_SIGNATURE_FILES);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_RENAME_SYMBOLS);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_USE_SIGNATURE_FILE);
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_PATCH_HLE_FUNCTIONS);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_SEARCH_INSTRUCTION);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_CLEAR_SYMBOLS);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_SCAN_FUNCTIONS);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_LOAD_MAP_FILE);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_SAVEMAPFILE);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_LOAD_MAP_FILE_AS);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_SAVE_MAP_FILE_AS);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_LOAD_BAD_MAP_FILE);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_SAVE_MAP_FILE_WITH_CODES);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_CREATE_SIGNATURE_FILE);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_APPEND_SIGNATURE_FILE);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_COMBINE_SIGNATURE_FILES);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_RENAME_SYMBOLS);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_USE_SIGNATURE_FILE);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_PATCH_HLE_FUNCTIONS);
|
||||
|
||||
Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreUninitialized, this, IDM_JIT_NO_BLOCK_CACHE);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreUninitialized, IDM_JIT_NO_BLOCK_CACHE);
|
||||
}
|
||||
|
||||
wxToolBar* CFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name)
|
||||
|
@ -1065,29 +1062,9 @@ void CFrame::OnReloadGameList(wxCommandEvent& WXUNUSED(event))
|
|||
UpdateGameList();
|
||||
}
|
||||
|
||||
void CFrame::OnEnableMenuItemIfCoreInitialized(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(Core::GetState() != Core::CORE_UNINITIALIZED);
|
||||
}
|
||||
|
||||
void CFrame::OnEnableMenuItemIfCoreUninitialized(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(Core::GetState() == Core::CORE_UNINITIALIZED);
|
||||
}
|
||||
|
||||
void CFrame::OnEnableMenuItemIfCorePaused(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(Core::GetState() == Core::CORE_PAUSE);
|
||||
}
|
||||
|
||||
void CFrame::OnEnableMenuItemIfCPUCanStep(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(Core::GetState() != Core::CORE_UNINITIALIZED && CPU::IsStepping());
|
||||
}
|
||||
|
||||
void CFrame::OnUpdateInterpreterMenuItem(wxUpdateUIEvent& event)
|
||||
{
|
||||
OnEnableMenuItemIfCorePaused(event);
|
||||
WxEventUtils::OnEnableIfCorePaused(event);
|
||||
|
||||
if (GetMenuBar()->FindItem(IDM_INTERPRETER)->IsChecked())
|
||||
return;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include <utility>
|
||||
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/CPU.h"
|
||||
#include "DolphinWX/Globals.h"
|
||||
#include "DolphinWX/WxEventUtils.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
|
||||
wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_TOOLBAR_BITMAPS, wxCommandEvent);
|
||||
|
@ -38,42 +38,20 @@ void MainToolBar::BindEvents()
|
|||
|
||||
void MainToolBar::BindMainButtonEvents()
|
||||
{
|
||||
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCoreNotRunning, this, wxID_OPEN);
|
||||
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCoreNotRunning, this, wxID_REFRESH);
|
||||
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCoreRunningOrPaused, this, IDM_STOP);
|
||||
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCoreRunningOrPaused, this, IDM_TOGGLE_FULLSCREEN);
|
||||
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCoreRunningOrPaused, this, IDM_SCREENSHOT);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning, wxID_OPEN);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning, wxID_REFRESH);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreRunningOrPaused, IDM_STOP);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreRunningOrPaused, IDM_TOGGLE_FULLSCREEN);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreRunningOrPaused, IDM_SCREENSHOT);
|
||||
}
|
||||
|
||||
void MainToolBar::BindDebuggerButtonEvents()
|
||||
{
|
||||
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCPUCanStep, this, IDM_STEP);
|
||||
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCPUCanStep, this, IDM_STEPOVER);
|
||||
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCPUCanStep, this, IDM_STEPOUT);
|
||||
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCPUCanStep, this, IDM_SKIP);
|
||||
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCorePaused, this, IDM_SETPC);
|
||||
}
|
||||
|
||||
void MainToolBar::OnUpdateIfCoreNotRunning(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(!Core::IsRunning());
|
||||
}
|
||||
|
||||
void MainToolBar::OnUpdateIfCorePaused(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(Core::GetState() == Core::CORE_PAUSE);
|
||||
}
|
||||
|
||||
void MainToolBar::OnUpdateIfCoreRunningOrPaused(wxUpdateUIEvent& event)
|
||||
{
|
||||
const auto state = Core::GetState();
|
||||
|
||||
event.Enable(state == Core::CORE_RUN || state == Core::CORE_PAUSE);
|
||||
}
|
||||
|
||||
void MainToolBar::OnUpdateIfCPUCanStep(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(Core::IsRunning() && CPU::IsStepping());
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCPUCanStep, IDM_STEP);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCPUCanStep, IDM_STEPOVER);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCPUCanStep, IDM_STEPOUT);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCPUCanStep, IDM_SKIP);
|
||||
Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCPUCanStep, IDM_SETPC);
|
||||
}
|
||||
|
||||
void MainToolBar::OnReloadBitmaps(wxCommandEvent& WXUNUSED(event))
|
||||
|
|
|
@ -53,11 +53,6 @@ private:
|
|||
void BindMainButtonEvents();
|
||||
void BindDebuggerButtonEvents();
|
||||
|
||||
void OnUpdateIfCoreNotRunning(wxUpdateUIEvent&);
|
||||
void OnUpdateIfCorePaused(wxUpdateUIEvent&);
|
||||
void OnUpdateIfCoreRunningOrPaused(wxUpdateUIEvent&);
|
||||
void OnUpdateIfCPUCanStep(wxUpdateUIEvent&);
|
||||
|
||||
void OnReloadBitmaps(wxCommandEvent&);
|
||||
|
||||
void InitializeBitmaps();
|
||||
|
|
|
@ -6,15 +6,48 @@
|
|||
|
||||
#include <wx/event.h>
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/CPU.h"
|
||||
#include "Core/NetPlayProto.h"
|
||||
|
||||
namespace WxEventUtils
|
||||
{
|
||||
void OnEnableIfCoreInitialized(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(Core::GetState() != Core::CORE_UNINITIALIZED);
|
||||
}
|
||||
|
||||
void OnEnableIfCoreUninitialized(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(Core::GetState() == Core::CORE_UNINITIALIZED);
|
||||
}
|
||||
|
||||
void OnEnableIfCoreRunning(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(Core::IsRunning());
|
||||
}
|
||||
|
||||
void OnEnableIfCoreNotRunning(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(!Core::IsRunning());
|
||||
}
|
||||
|
||||
void OnEnableIfCorePaused(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(Core::GetState() == Core::CORE_PAUSE);
|
||||
}
|
||||
|
||||
void OnEnableIfCoreRunningOrPaused(wxUpdateUIEvent& event)
|
||||
{
|
||||
const auto state = Core::GetState();
|
||||
|
||||
event.Enable(state == Core::CORE_RUN || state == Core::CORE_PAUSE);
|
||||
}
|
||||
|
||||
void OnEnableIfCPUCanStep(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(Core::IsRunning() && CPU::IsStepping());
|
||||
}
|
||||
|
||||
void OnEnableIfNetplayNotRunning(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(!NetPlay::IsNetPlayRunning());
|
||||
|
|
|
@ -12,6 +12,14 @@ class wxUpdateUIEvent;
|
|||
|
||||
namespace WxEventUtils
|
||||
{
|
||||
void OnEnableIfCoreInitialized(wxUpdateUIEvent&);
|
||||
void OnEnableIfCoreUninitialized(wxUpdateUIEvent&);
|
||||
void OnEnableIfCoreRunning(wxUpdateUIEvent&);
|
||||
void OnEnableIfCoreNotRunning(wxUpdateUIEvent&);
|
||||
void OnEnableIfCorePaused(wxUpdateUIEvent&);
|
||||
void OnEnableIfCoreRunningOrPaused(wxUpdateUIEvent&);
|
||||
|
||||
void OnEnableIfCPUCanStep(wxUpdateUIEvent&);
|
||||
|
||||
void OnEnableIfNetplayNotRunning(wxUpdateUIEvent&);
|
||||
} // namespace WxEventUtils
|
||||
|
|
Loading…
Reference in New Issue