diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index ba5b076938..69db78b201 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -61,6 +61,7 @@ set(GUI_SRCS SoftwareVideoConfigDialog.cpp TASInputDlg.cpp VideoConfigDiag.cpp + WxEventUtils.cpp WXInputBase.cpp WxUtils.cpp) diff --git a/Source/Core/DolphinWX/Config/AdvancedConfigPane.cpp b/Source/Core/DolphinWX/Config/AdvancedConfigPane.cpp index 406e76785f..732b770ce6 100644 --- a/Source/Core/DolphinWX/Config/AdvancedConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/AdvancedConfigPane.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "DolphinWX/Config/AdvancedConfigPane.h" + #include #include @@ -14,14 +16,14 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" -#include "DolphinWX/Config/AdvancedConfigPane.h" #include "DolphinWX/DolphinSlider.h" +#include "DolphinWX/WxEventUtils.h" AdvancedConfigPane::AdvancedConfigPane(wxWindow* parent, wxWindowID id) : wxPanel(parent, id) { InitializeGUI(); LoadGUIValues(); - RefreshGUI(); + BindEvents(); } void AdvancedConfigPane::InitializeGUI() @@ -31,22 +33,10 @@ void AdvancedConfigPane::InitializeGUI() new DolphinSlider(this, wxID_ANY, 100, 0, 150, wxDefaultPosition, FromDIP(wxSize(200, -1))); m_clock_override_text = new wxStaticText(this, wxID_ANY, ""); - m_clock_override_checkbox->Bind(wxEVT_CHECKBOX, - &AdvancedConfigPane::OnClockOverrideCheckBoxChanged, this); - m_clock_override_slider->Bind(wxEVT_SLIDER, &AdvancedConfigPane::OnClockOverrideSliderChanged, - this); - m_custom_rtc_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Custom RTC")); m_custom_rtc_date_picker = new wxDatePickerCtrl(this, wxID_ANY); m_custom_rtc_time_picker = new wxTimePickerCtrl(this, wxID_ANY); - m_custom_rtc_checkbox->Bind(wxEVT_CHECKBOX, &AdvancedConfigPane::OnCustomRTCCheckBoxChanged, - this); - m_custom_rtc_date_picker->Bind(wxEVT_DATE_CHANGED, &AdvancedConfigPane::OnCustomRTCDateChanged, - this); - m_custom_rtc_time_picker->Bind(wxEVT_TIME_CHANGED, &AdvancedConfigPane::OnCustomRTCTimeChanged, - this); - wxStaticText* const clock_override_description = new wxStaticText(this, wxID_ANY, _("Higher values can make variable-framerate games " "run at a higher framerate, at the expense of CPU. " @@ -122,6 +112,33 @@ void AdvancedConfigPane::LoadGUIValues() LoadCustomRTC(); } +void AdvancedConfigPane::BindEvents() +{ + m_clock_override_checkbox->Bind(wxEVT_CHECKBOX, + &AdvancedConfigPane::OnClockOverrideCheckBoxChanged, this); + m_clock_override_checkbox->Bind(wxEVT_UPDATE_UI, &AdvancedConfigPane::OnUpdateCPUClockControls, + this); + + m_clock_override_slider->Bind(wxEVT_SLIDER, &AdvancedConfigPane::OnClockOverrideSliderChanged, + this); + m_clock_override_slider->Bind(wxEVT_UPDATE_UI, &AdvancedConfigPane::OnUpdateCPUClockControls, + this); + + m_custom_rtc_checkbox->Bind(wxEVT_CHECKBOX, &AdvancedConfigPane::OnCustomRTCCheckBoxChanged, + this); + m_custom_rtc_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_custom_rtc_date_picker->Bind(wxEVT_DATE_CHANGED, &AdvancedConfigPane::OnCustomRTCDateChanged, + this); + m_custom_rtc_date_picker->Bind(wxEVT_UPDATE_UI, &AdvancedConfigPane::OnUpdateRTCDateTimeEntries, + this); + + m_custom_rtc_time_picker->Bind(wxEVT_TIME_CHANGED, &AdvancedConfigPane::OnCustomRTCTimeChanged, + this); + m_custom_rtc_time_picker->Bind(wxEVT_UPDATE_UI, &AdvancedConfigPane::OnUpdateRTCDateTimeEntries, + this); +} + void AdvancedConfigPane::OnClockOverrideCheckBoxChanged(wxCommandEvent& event) { SConfig::GetInstance().m_OCEnable = m_clock_override_checkbox->IsChecked(); @@ -188,17 +205,6 @@ void AdvancedConfigPane::LoadCustomRTC() // Limit dates to a valid range (Jan 1/2000 to Dec 31/2099) m_custom_rtc_date_picker->SetRange(wxDateTime(1, wxDateTime::Jan, 2000), wxDateTime(31, wxDateTime::Dec, 2099)); - if (Core::IsRunning()) - { - m_custom_rtc_checkbox->Enable(false); - m_custom_rtc_date_picker->Enable(false); - m_custom_rtc_time_picker->Enable(false); - } - else - { - m_custom_rtc_date_picker->Enable(custom_rtc_enabled); - m_custom_rtc_time_picker->Enable(custom_rtc_enabled); - } } void AdvancedConfigPane::UpdateCustomRTC(time_t date, time_t time) @@ -209,19 +215,18 @@ void AdvancedConfigPane::UpdateCustomRTC(time_t date, time_t time) m_custom_rtc_time_picker->SetValue(custom_rtc); } -void AdvancedConfigPane::RefreshGUI() +void AdvancedConfigPane::OnUpdateCPUClockControls(wxUpdateUIEvent& event) { - // Don't allow users to edit the RTC while the game is running - if (Core::IsRunning()) + if (!Core::IsRunning()) { - m_custom_rtc_checkbox->Disable(); - m_custom_rtc_date_picker->Disable(); - m_custom_rtc_time_picker->Disable(); - } - // Allow users to edit CPU clock speed in game, but not while needing determinism - if (Core::IsRunning() && Core::g_want_determinism) - { - m_clock_override_checkbox->Disable(); - m_clock_override_slider->Disable(); + event.Enable(true); + return; } + + event.Enable(!Core::g_want_determinism); +} + +void AdvancedConfigPane::OnUpdateRTCDateTimeEntries(wxUpdateUIEvent& event) +{ + event.Enable(!Core::IsRunning() && m_custom_rtc_checkbox->IsChecked()); } diff --git a/Source/Core/DolphinWX/Config/AdvancedConfigPane.h b/Source/Core/DolphinWX/Config/AdvancedConfigPane.h index 09ae33aea2..ffd0f14d0e 100644 --- a/Source/Core/DolphinWX/Config/AdvancedConfigPane.h +++ b/Source/Core/DolphinWX/Config/AdvancedConfigPane.h @@ -23,7 +23,10 @@ public: private: void InitializeGUI(); void LoadGUIValues(); - void RefreshGUI(); + void BindEvents(); + + void OnUpdateCPUClockControls(wxUpdateUIEvent&); + void OnUpdateRTCDateTimeEntries(wxUpdateUIEvent&); void OnClockOverrideCheckBoxChanged(wxCommandEvent&); void OnClockOverrideSliderChanged(wxCommandEvent&); diff --git a/Source/Core/DolphinWX/Config/AudioConfigPane.cpp b/Source/Core/DolphinWX/Config/AudioConfigPane.cpp index 84d1b86360..6a49499fe0 100644 --- a/Source/Core/DolphinWX/Config/AudioConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/AudioConfigPane.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "DolphinWX/Config/AudioConfigPane.h" + #include #include @@ -16,15 +18,15 @@ #include "Common/Common.h" #include "Core/ConfigManager.h" #include "Core/Core.h" -#include "DolphinWX/Config/AudioConfigPane.h" #include "DolphinWX/DolphinSlider.h" +#include "DolphinWX/WxEventUtils.h" #include "DolphinWX/WxUtils.h" AudioConfigPane::AudioConfigPane(wxWindow* parent, wxWindowID id) : wxPanel(parent, id) { InitializeGUI(); LoadGUIValues(); - RefreshGUI(); + BindEvents(); } void AudioConfigPane::InitializeGUI() @@ -46,13 +48,6 @@ void AudioConfigPane::InitializeGUI() new wxSpinCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 30); m_audio_latency_label = new wxStaticText(this, wxID_ANY, _("Latency:")); - m_dsp_engine_radiobox->Bind(wxEVT_RADIOBOX, &AudioConfigPane::OnDSPEngineRadioBoxChanged, this); - m_dpl2_decoder_checkbox->Bind(wxEVT_CHECKBOX, &AudioConfigPane::OnDPL2DecoderCheckBoxChanged, - this); - m_volume_slider->Bind(wxEVT_SLIDER, &AudioConfigPane::OnVolumeSliderChanged, this); - m_audio_backend_choice->Bind(wxEVT_CHOICE, &AudioConfigPane::OnAudioBackendChanged, this); - m_audio_latency_spinctrl->Bind(wxEVT_SPINCTRL, &AudioConfigPane::OnLatencySpinCtrlChanged, this); - m_audio_backend_choice->SetToolTip( _("Changing this will have no effect while the emulator is running.")); m_audio_latency_spinctrl->SetToolTip(_("Sets the latency (in ms). Higher values may reduce audio " @@ -139,15 +134,22 @@ void AudioConfigPane::ToggleBackendSpecificControls(const std::string& backend) m_volume_text->Enable(supports_volume_changes); } -void AudioConfigPane::RefreshGUI() +void AudioConfigPane::BindEvents() { - if (Core::IsRunning()) - { - m_audio_latency_spinctrl->Disable(); - m_audio_backend_choice->Disable(); - m_dpl2_decoder_checkbox->Disable(); - m_dsp_engine_radiobox->Disable(); - } + m_dsp_engine_radiobox->Bind(wxEVT_RADIOBOX, &AudioConfigPane::OnDSPEngineRadioBoxChanged, this); + m_dsp_engine_radiobox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_dpl2_decoder_checkbox->Bind(wxEVT_CHECKBOX, &AudioConfigPane::OnDPL2DecoderCheckBoxChanged, + this); + m_dpl2_decoder_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_volume_slider->Bind(wxEVT_SLIDER, &AudioConfigPane::OnVolumeSliderChanged, this); + + m_audio_backend_choice->Bind(wxEVT_CHOICE, &AudioConfigPane::OnAudioBackendChanged, this); + m_audio_backend_choice->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_audio_latency_spinctrl->Bind(wxEVT_SPINCTRL, &AudioConfigPane::OnLatencySpinCtrlChanged, this); + m_audio_latency_spinctrl->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); } void AudioConfigPane::OnDSPEngineRadioBoxChanged(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/Config/AudioConfigPane.h b/Source/Core/DolphinWX/Config/AudioConfigPane.h index cb5415d577..0c5db837e6 100644 --- a/Source/Core/DolphinWX/Config/AudioConfigPane.h +++ b/Source/Core/DolphinWX/Config/AudioConfigPane.h @@ -23,7 +23,7 @@ public: private: void InitializeGUI(); void LoadGUIValues(); - void RefreshGUI(); + void BindEvents(); void PopulateBackendChoiceBox(); void ToggleBackendSpecificControls(const std::string& backend); diff --git a/Source/Core/DolphinWX/Config/GameCubeConfigPane.cpp b/Source/Core/DolphinWX/Config/GameCubeConfigPane.cpp index 06892a26bb..fd127fdc90 100644 --- a/Source/Core/DolphinWX/Config/GameCubeConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/GameCubeConfigPane.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "DolphinWX/Config/GameCubeConfigPane.h" + #include #include @@ -22,7 +24,7 @@ #include "Core/HW/GCMemcard.h" #include "Core/NetPlayProto.h" #include "DolphinWX/Config/ConfigMain.h" -#include "DolphinWX/Config/GameCubeConfigPane.h" +#include "DolphinWX/WxEventUtils.h" #include "DolphinWX/WxUtils.h" #define DEV_NONE_STR _trans("") @@ -39,7 +41,7 @@ GameCubeConfigPane::GameCubeConfigPane(wxWindow* parent, wxWindowID id) : wxPane { InitializeGUI(); LoadGUIValues(); - RefreshGUI(); + BindEvents(); } void GameCubeConfigPane::InitializeGUI() @@ -54,17 +56,13 @@ void GameCubeConfigPane::InitializeGUI() m_system_lang_choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_ipl_language_strings); m_system_lang_choice->SetToolTip(_("Sets the GameCube system language.")); - m_system_lang_choice->Bind(wxEVT_CHOICE, &GameCubeConfigPane::OnSystemLanguageChange, this); m_override_lang_checkbox = new wxCheckBox(this, wxID_ANY, _("Override Language on NTSC Games")); m_override_lang_checkbox->SetToolTip(_( "Lets the system language be set to values that games were not designed for. This can allow " "the use of extra translations for a few games, but can also lead to text display issues.")); - m_override_lang_checkbox->Bind(wxEVT_CHECKBOX, - &GameCubeConfigPane::OnOverrideLanguageCheckBoxChanged, this); m_skip_bios_checkbox = new wxCheckBox(this, wxID_ANY, _("Skip BIOS")); - m_skip_bios_checkbox->Bind(wxEVT_CHECKBOX, &GameCubeConfigPane::OnSkipBiosCheckBoxChanged, this); if (!File::Exists(File::GetUserPath(D_GCUSER_IDX) + DIR_SEP + USA_DIR + DIR_SEP GC_IPL) && !File::Exists(File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + USA_DIR + DIR_SEP GC_IPL) && @@ -85,20 +83,15 @@ void GameCubeConfigPane::InitializeGUI() }; m_exi_devices[0] = new wxChoice(this, wxID_ANY); - m_exi_devices[0]->Bind(wxEVT_CHOICE, &GameCubeConfigPane::OnSlotAChanged, this); m_exi_devices[1] = new wxChoice(this, wxID_ANY); - m_exi_devices[1]->Bind(wxEVT_CHOICE, &GameCubeConfigPane::OnSlotBChanged, this); m_exi_devices[2] = new wxChoice(this, wxID_ANY); - m_exi_devices[2]->Bind(wxEVT_CHOICE, &GameCubeConfigPane::OnSP1Changed, this); m_exi_devices[2]->SetToolTip( _("Serial Port 1 - This is the port which devices such as the net adapter use.")); m_memcard_path[0] = new wxButton(this, wxID_ANY, "...", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); - m_memcard_path[0]->Bind(wxEVT_BUTTON, &GameCubeConfigPane::OnSlotAButtonClick, this); m_memcard_path[1] = new wxButton(this, wxID_ANY, "...", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); - m_memcard_path[1]->Bind(wxEVT_BUTTON, &GameCubeConfigPane::OnSlotBButtonClick, this); const int space5 = FromDIP(5); const int space10 = FromDIP(10); @@ -131,9 +124,6 @@ void GameCubeConfigPane::InitializeGUI() if (i < 2) gamecube_EXIDev_sizer->Add(m_memcard_path[i], wxGBPosition(i, 2), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); - - if (NetPlay::IsNetPlayRunning()) - m_exi_devices[i]->Disable(); } sbGamecubeDeviceSettings->AddSpacer(space5); sbGamecubeDeviceSettings->Add(gamecube_EXIDev_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); @@ -218,14 +208,27 @@ void GameCubeConfigPane::LoadGUIValues() } } -void GameCubeConfigPane::RefreshGUI() +void GameCubeConfigPane::BindEvents() { - if (Core::IsRunning()) - { - m_system_lang_choice->Disable(); - m_override_lang_checkbox->Disable(); - m_skip_bios_checkbox->Disable(); - } + m_system_lang_choice->Bind(wxEVT_CHOICE, &GameCubeConfigPane::OnSystemLanguageChange, this); + m_system_lang_choice->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_override_lang_checkbox->Bind(wxEVT_CHECKBOX, + &GameCubeConfigPane::OnOverrideLanguageCheckBoxChanged, this); + m_override_lang_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_skip_bios_checkbox->Bind(wxEVT_CHECKBOX, &GameCubeConfigPane::OnSkipBiosCheckBoxChanged, this); + m_skip_bios_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_exi_devices[0]->Bind(wxEVT_CHOICE, &GameCubeConfigPane::OnSlotAChanged, this); + m_exi_devices[0]->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfNetplayNotRunning); + m_exi_devices[1]->Bind(wxEVT_CHOICE, &GameCubeConfigPane::OnSlotBChanged, this); + m_exi_devices[1]->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfNetplayNotRunning); + m_exi_devices[2]->Bind(wxEVT_CHOICE, &GameCubeConfigPane::OnSP1Changed, this); + m_exi_devices[2]->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfNetplayNotRunning); + + m_memcard_path[0]->Bind(wxEVT_BUTTON, &GameCubeConfigPane::OnSlotAButtonClick, this); + m_memcard_path[1]->Bind(wxEVT_BUTTON, &GameCubeConfigPane::OnSlotBButtonClick, this); } void GameCubeConfigPane::OnSystemLanguageChange(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/Config/GameCubeConfigPane.h b/Source/Core/DolphinWX/Config/GameCubeConfigPane.h index cf8c8a2f7b..85ecec9b83 100644 --- a/Source/Core/DolphinWX/Config/GameCubeConfigPane.h +++ b/Source/Core/DolphinWX/Config/GameCubeConfigPane.h @@ -22,7 +22,7 @@ public: private: void InitializeGUI(); void LoadGUIValues(); - void RefreshGUI(); + void BindEvents(); void OnSystemLanguageChange(wxCommandEvent&); void OnOverrideLanguageCheckBoxChanged(wxCommandEvent&); diff --git a/Source/Core/DolphinWX/Config/GeneralConfigPane.cpp b/Source/Core/DolphinWX/Config/GeneralConfigPane.cpp index 86cbe7e84b..11323b0401 100644 --- a/Source/Core/DolphinWX/Config/GeneralConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/GeneralConfigPane.cpp @@ -18,6 +18,7 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/PowerPC/PowerPC.h" +#include "DolphinWX/WxEventUtils.h" GeneralConfigPane::GeneralConfigPane(wxWindow* parent, wxWindowID id) : wxPanel(parent, id) { @@ -34,7 +35,7 @@ GeneralConfigPane::GeneralConfigPane(wxWindow* parent, wxWindowID id) : wxPanel( InitializeGUI(); LoadGUIValues(); - RefreshGUI(); + BindEvents(); } void GeneralConfigPane::InitializeGUI() @@ -86,15 +87,6 @@ void GeneralConfigPane::InitializeGUI() "that raising or lowering the emulation speed will also raise " "or lower the audio pitch to prevent audio from stuttering.")); - m_dual_core_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnDualCoreCheckBoxChanged, this); - m_cheats_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnCheatCheckBoxChanged, this); - m_force_ntscj_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnForceNTSCJCheckBoxChanged, - this); - m_analytics_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnAnalyticsCheckBoxChanged, this); - m_analytics_new_id->Bind(wxEVT_BUTTON, &GeneralConfigPane::OnAnalyticsNewIdButtonClick, this); - m_throttler_choice->Bind(wxEVT_CHOICE, &GeneralConfigPane::OnThrottlerChoiceChanged, this); - m_cpu_engine_radiobox->Bind(wxEVT_RADIOBOX, &GeneralConfigPane::OnCPUEngineRadioBoxChanged, this); - const int space5 = FromDIP(5); wxBoxSizer* const throttler_sizer = new wxBoxSizer(wxHORIZONTAL); @@ -161,15 +153,26 @@ void GeneralConfigPane::LoadGUIValues() } } -void GeneralConfigPane::RefreshGUI() +void GeneralConfigPane::BindEvents() { - if (Core::IsRunning()) - { - m_dual_core_checkbox->Disable(); - m_cheats_checkbox->Disable(); - m_force_ntscj_checkbox->Disable(); - m_cpu_engine_radiobox->Disable(); - } + m_dual_core_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnDualCoreCheckBoxChanged, this); + m_dual_core_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_cheats_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnCheatCheckBoxChanged, this); + m_cheats_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_force_ntscj_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnForceNTSCJCheckBoxChanged, + this); + m_force_ntscj_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_analytics_checkbox->Bind(wxEVT_CHECKBOX, &GeneralConfigPane::OnAnalyticsCheckBoxChanged, this); + + m_analytics_new_id->Bind(wxEVT_BUTTON, &GeneralConfigPane::OnAnalyticsNewIdButtonClick, this); + + m_throttler_choice->Bind(wxEVT_CHOICE, &GeneralConfigPane::OnThrottlerChoiceChanged, this); + + m_cpu_engine_radiobox->Bind(wxEVT_RADIOBOX, &GeneralConfigPane::OnCPUEngineRadioBoxChanged, this); + m_cpu_engine_radiobox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); } void GeneralConfigPane::OnDualCoreCheckBoxChanged(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/Config/GeneralConfigPane.h b/Source/Core/DolphinWX/Config/GeneralConfigPane.h index e34565b86a..d3dce0b8cf 100644 --- a/Source/Core/DolphinWX/Config/GeneralConfigPane.h +++ b/Source/Core/DolphinWX/Config/GeneralConfigPane.h @@ -27,7 +27,7 @@ private: std::vector m_cpu_cores; void InitializeGUI(); void LoadGUIValues(); - void RefreshGUI(); + void BindEvents(); void OnDualCoreCheckBoxChanged(wxCommandEvent&); void OnCheatCheckBoxChanged(wxCommandEvent&); diff --git a/Source/Core/DolphinWX/Config/PathConfigPane.cpp b/Source/Core/DolphinWX/Config/PathConfigPane.cpp index a6e33b52f7..acd56b7747 100644 --- a/Source/Core/DolphinWX/Config/PathConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/PathConfigPane.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "DolphinWX/Config/PathConfigPane.h" + #include #include @@ -18,16 +20,16 @@ #include "Core/Core.h" #include "DiscIO/NANDContentLoader.h" #include "DolphinWX/Config/ConfigMain.h" -#include "DolphinWX/Config/PathConfigPane.h" #include "DolphinWX/Frame.h" #include "DolphinWX/Main.h" +#include "DolphinWX/WxEventUtils.h" #include "DolphinWX/WxUtils.h" PathConfigPane::PathConfigPane(wxWindow* panel, wxWindowID id) : wxPanel(panel, id) { InitializeGUI(); LoadGUIValues(); - RefreshGUI(); + BindEvents(); } void PathConfigPane::InitializeGUI() @@ -62,21 +64,6 @@ void PathConfigPane::InitializeGUI() this, wxID_ANY, wxEmptyString, _("Choose an SD Card file:"), wxFileSelectorDefaultWildcardStr, wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL | wxDIRP_SMALL); - m_iso_paths_listbox->Bind(wxEVT_LISTBOX, &PathConfigPane::OnISOPathSelectionChanged, this); - m_recursive_iso_paths_checkbox->Bind(wxEVT_CHECKBOX, - &PathConfigPane::OnRecursiveISOCheckBoxChanged, this); - m_add_iso_path_button->Bind(wxEVT_BUTTON, &PathConfigPane::OnAddISOPath, this); - m_remove_iso_path_button->Bind(wxEVT_BUTTON, &PathConfigPane::OnRemoveISOPath, this); - m_default_iso_filepicker->Bind(wxEVT_FILEPICKER_CHANGED, &PathConfigPane::OnDefaultISOChanged, - this); - m_dvd_root_dirpicker->Bind(wxEVT_DIRPICKER_CHANGED, &PathConfigPane::OnDVDRootChanged, this); - m_apploader_path_filepicker->Bind(wxEVT_FILEPICKER_CHANGED, - &PathConfigPane::OnApploaderPathChanged, this); - m_nand_root_dirpicker->Bind(wxEVT_DIRPICKER_CHANGED, &PathConfigPane::OnNANDRootChanged, this); - m_dump_path_dirpicker->Bind(wxEVT_DIRPICKER_CHANGED, &PathConfigPane::OnDumpPathChanged, this); - m_wii_sdcard_filepicker->Bind(wxEVT_FILEPICKER_CHANGED, &PathConfigPane::OnSdCardPathChanged, - this); - const int space5 = FromDIP(5); wxBoxSizer* const iso_button_sizer = new wxBoxSizer(wxHORIZONTAL); @@ -141,10 +128,24 @@ void PathConfigPane::LoadGUIValues() m_iso_paths_listbox->Append(StrToWxStr(folder)); } -void PathConfigPane::RefreshGUI() +void PathConfigPane::BindEvents() { - if (Core::IsRunning()) - Disable(); + m_iso_paths_listbox->Bind(wxEVT_LISTBOX, &PathConfigPane::OnISOPathSelectionChanged, this); + m_recursive_iso_paths_checkbox->Bind(wxEVT_CHECKBOX, + &PathConfigPane::OnRecursiveISOCheckBoxChanged, this); + m_add_iso_path_button->Bind(wxEVT_BUTTON, &PathConfigPane::OnAddISOPath, this); + m_remove_iso_path_button->Bind(wxEVT_BUTTON, &PathConfigPane::OnRemoveISOPath, this); + m_default_iso_filepicker->Bind(wxEVT_FILEPICKER_CHANGED, &PathConfigPane::OnDefaultISOChanged, + this); + m_dvd_root_dirpicker->Bind(wxEVT_DIRPICKER_CHANGED, &PathConfigPane::OnDVDRootChanged, this); + m_apploader_path_filepicker->Bind(wxEVT_FILEPICKER_CHANGED, + &PathConfigPane::OnApploaderPathChanged, this); + m_nand_root_dirpicker->Bind(wxEVT_DIRPICKER_CHANGED, &PathConfigPane::OnNANDRootChanged, this); + m_dump_path_dirpicker->Bind(wxEVT_DIRPICKER_CHANGED, &PathConfigPane::OnDumpPathChanged, this); + m_wii_sdcard_filepicker->Bind(wxEVT_FILEPICKER_CHANGED, &PathConfigPane::OnSdCardPathChanged, + this); + + Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); } void PathConfigPane::OnISOPathSelectionChanged(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/Config/PathConfigPane.h b/Source/Core/DolphinWX/Config/PathConfigPane.h index 2330c30201..76a22a1586 100644 --- a/Source/Core/DolphinWX/Config/PathConfigPane.h +++ b/Source/Core/DolphinWX/Config/PathConfigPane.h @@ -20,7 +20,7 @@ public: private: void InitializeGUI(); void LoadGUIValues(); - void RefreshGUI(); + void BindEvents(); void OnISOPathSelectionChanged(wxCommandEvent&); void OnRecursiveISOCheckBoxChanged(wxCommandEvent&); diff --git a/Source/Core/DolphinWX/Config/WiiConfigPane.cpp b/Source/Core/DolphinWX/Config/WiiConfigPane.cpp index 81af8b48a1..40f72fe471 100644 --- a/Source/Core/DolphinWX/Config/WiiConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/WiiConfigPane.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "DolphinWX/Config/WiiConfigPane.h" + #include #include #include @@ -12,15 +14,15 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "DolphinWX/Config/WiiConfigPane.h" #include "DolphinWX/DolphinSlider.h" +#include "DolphinWX/WxEventUtils.h" #include "DolphinWX/WxUtils.h" WiiConfigPane::WiiConfigPane(wxWindow* parent, wxWindowID id) : wxPanel(parent, id) { InitializeGUI(); LoadGUIValues(); - RefreshGUI(); + BindEvents(); } void WiiConfigPane::InitializeGUI() @@ -56,18 +58,6 @@ void WiiConfigPane::InitializeGUI() m_bt_speaker_volume = new DolphinSlider(this, wxID_ANY, 0, 0, 127); m_bt_wiimote_motor = new wxCheckBox(this, wxID_ANY, _("Wii Remote Motor")); - m_screensaver_checkbox->Bind(wxEVT_CHECKBOX, &WiiConfigPane::OnScreenSaverCheckBoxChanged, this); - m_pal60_mode_checkbox->Bind(wxEVT_CHECKBOX, &WiiConfigPane::OnPAL60CheckBoxChanged, this); - m_aspect_ratio_choice->Bind(wxEVT_CHOICE, &WiiConfigPane::OnAspectRatioChoiceChanged, this); - m_system_language_choice->Bind(wxEVT_CHOICE, &WiiConfigPane::OnSystemLanguageChoiceChanged, this); - m_sd_card_checkbox->Bind(wxEVT_CHECKBOX, &WiiConfigPane::OnSDCardCheckBoxChanged, this); - m_connect_keyboard_checkbox->Bind(wxEVT_CHECKBOX, - &WiiConfigPane::OnConnectKeyboardCheckBoxChanged, this); - m_bt_sensor_bar_pos->Bind(wxEVT_CHOICE, &WiiConfigPane::OnSensorBarPosChanged, this); - m_bt_sensor_bar_sens->Bind(wxEVT_SLIDER, &WiiConfigPane::OnSensorBarSensChanged, this); - m_bt_speaker_volume->Bind(wxEVT_SLIDER, &WiiConfigPane::OnSpeakerVolumeChanged, this); - m_bt_wiimote_motor->Bind(wxEVT_CHECKBOX, &WiiConfigPane::OnWiimoteMotorChanged, this); - m_screensaver_checkbox->SetToolTip(_("Dims the screen after five minutes of inactivity.")); m_pal60_mode_checkbox->SetToolTip(_("Sets the Wii display mode to 60Hz (480i) instead of 50Hz " "(576i) for PAL games.\nMay not work for all games.")); @@ -167,20 +157,35 @@ void WiiConfigPane::LoadGUIValues() m_bt_wiimote_motor->SetValue(SConfig::GetInstance().m_wiimote_motor); } -void WiiConfigPane::RefreshGUI() +void WiiConfigPane::BindEvents() { - if (Core::IsRunning()) - { - m_screensaver_checkbox->Disable(); - m_pal60_mode_checkbox->Disable(); - m_aspect_ratio_choice->Disable(); - m_system_language_choice->Disable(); + m_screensaver_checkbox->Bind(wxEVT_CHECKBOX, &WiiConfigPane::OnScreenSaverCheckBoxChanged, this); + m_screensaver_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); - m_bt_sensor_bar_pos->Disable(); - m_bt_sensor_bar_sens->Disable(); - m_bt_speaker_volume->Disable(); - m_bt_wiimote_motor->Disable(); - } + m_pal60_mode_checkbox->Bind(wxEVT_CHECKBOX, &WiiConfigPane::OnPAL60CheckBoxChanged, this); + m_pal60_mode_checkbox->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_aspect_ratio_choice->Bind(wxEVT_CHOICE, &WiiConfigPane::OnAspectRatioChoiceChanged, this); + m_aspect_ratio_choice->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_system_language_choice->Bind(wxEVT_CHOICE, &WiiConfigPane::OnSystemLanguageChoiceChanged, this); + m_system_language_choice->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_sd_card_checkbox->Bind(wxEVT_CHECKBOX, &WiiConfigPane::OnSDCardCheckBoxChanged, this); + m_connect_keyboard_checkbox->Bind(wxEVT_CHECKBOX, + &WiiConfigPane::OnConnectKeyboardCheckBoxChanged, this); + + m_bt_sensor_bar_pos->Bind(wxEVT_CHOICE, &WiiConfigPane::OnSensorBarPosChanged, this); + m_bt_sensor_bar_pos->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_bt_sensor_bar_sens->Bind(wxEVT_SLIDER, &WiiConfigPane::OnSensorBarSensChanged, this); + m_bt_sensor_bar_sens->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_bt_speaker_volume->Bind(wxEVT_SLIDER, &WiiConfigPane::OnSpeakerVolumeChanged, this); + m_bt_speaker_volume->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_bt_wiimote_motor->Bind(wxEVT_CHECKBOX, &WiiConfigPane::OnWiimoteMotorChanged, this); + m_bt_wiimote_motor->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); } void WiiConfigPane::OnScreenSaverCheckBoxChanged(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/Config/WiiConfigPane.h b/Source/Core/DolphinWX/Config/WiiConfigPane.h index beffa23f99..bb68f89e4e 100644 --- a/Source/Core/DolphinWX/Config/WiiConfigPane.h +++ b/Source/Core/DolphinWX/Config/WiiConfigPane.h @@ -21,7 +21,7 @@ public: private: void InitializeGUI(); void LoadGUIValues(); - void RefreshGUI(); + void BindEvents(); void OnScreenSaverCheckBoxChanged(wxCommandEvent&); void OnPAL60CheckBoxChanged(wxCommandEvent&); diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj b/Source/Core/DolphinWX/DolphinWX.vcxproj index b3bf40f906..e45f1e49f7 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcxproj +++ b/Source/Core/DolphinWX/DolphinWX.vcxproj @@ -120,6 +120,7 @@ + @@ -184,6 +185,7 @@ + diff --git a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters index 32cf32242e..d4c1d6675c 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcxproj.filters +++ b/Source/Core/DolphinWX/DolphinWX.vcxproj.filters @@ -35,6 +35,7 @@ + @@ -223,6 +224,7 @@ + diff --git a/Source/Core/DolphinWX/WxEventUtils.cpp b/Source/Core/DolphinWX/WxEventUtils.cpp new file mode 100644 index 0000000000..04520a1fd9 --- /dev/null +++ b/Source/Core/DolphinWX/WxEventUtils.cpp @@ -0,0 +1,22 @@ +// Copyright 2016 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinWX/WxEventUtils.h" + +#include +#include "Core/Core.h" +#include "Core/NetPlayProto.h" + +namespace WxEventUtils +{ +void OnEnableIfCoreNotRunning(wxUpdateUIEvent& event) +{ + event.Enable(!Core::IsRunning()); +} + +void OnEnableIfNetplayNotRunning(wxUpdateUIEvent& event) +{ + event.Enable(!NetPlay::IsNetPlayRunning()); +} +} // namespace WxEventUtils diff --git a/Source/Core/DolphinWX/WxEventUtils.h b/Source/Core/DolphinWX/WxEventUtils.h new file mode 100644 index 0000000000..b75bf0cf84 --- /dev/null +++ b/Source/Core/DolphinWX/WxEventUtils.h @@ -0,0 +1,17 @@ +// Copyright 2016 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +// Intended for containing event functions that are bound to +// different window controls through wxEvtHandler's Bind() +// function. + +class wxUpdateUIEvent; + +namespace WxEventUtils +{ +void OnEnableIfCoreNotRunning(wxUpdateUIEvent&); +void OnEnableIfNetplayNotRunning(wxUpdateUIEvent&); +} // namespace WxEventUtils