From d38d046f7a10114752031d2c40c946d4c8c28d2b Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Thu, 6 Aug 2015 00:23:12 +0300 Subject: [PATCH] gui: EE and VU panels: restore defaults programatically The code was restoring the defaults with hardcoded values. This patch restores the values however they're defined as defaults for AppConfig. The code still uses hardcode values to set the highlights (bold) of the default radio button text - using SetDefaultItem. Note that other than these two panels, the speedhacks panel is the only other which has a restore-defaults button, and it already does so programatically. It's probably not worth trying to unify these three restore-defaults button into a single system. --- common/src/Utilities/pxRadioPanel.cpp | 2 ++ pcsx2/gui/Panels/CpuPanel.cpp | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/common/src/Utilities/pxRadioPanel.cpp b/common/src/Utilities/pxRadioPanel.cpp index 6f1f387a2f..a221391c86 100644 --- a/common/src/Utilities/pxRadioPanel.cpp +++ b/common/src/Utilities/pxRadioPanel.cpp @@ -149,6 +149,8 @@ void pxRadioPanel::_RealizeDefaultOption() } } +// Highlights (bold) the text of the default radio. +// Not intended for restoring default value at later time. pxRadioPanel& pxRadioPanel::SetDefaultItem( int idx ) { if( idx == m_DefaultIdx ) return *this; diff --git a/pcsx2/gui/Panels/CpuPanel.cpp b/pcsx2/gui/Panels/CpuPanel.cpp index 13ed7d9c28..3a82301a0a 100644 --- a/pcsx2/gui/Panels/CpuPanel.cpp +++ b/pcsx2/gui/Panels/CpuPanel.cpp @@ -74,8 +74,9 @@ void Panels::BaseAdvancedCpuOptions::OnRestoreDefaults(wxCommandEvent& evt) void Panels::BaseAdvancedCpuOptions::RestoreDefaults() { - m_RoundModePanel->SetSelection( 3 ); // Roundmode chop - m_ClampModePanel->SetSelection( 1 ); // clamp mode normal + AppConfig def; // created with default values + def.EnablePresets = false; // disable presets otherwise it'll disable some widgets + ApplyConfigToGui(def); } Panels::AdvancedOptionsFPU::AdvancedOptionsFPU( wxWindow* parent ) @@ -260,9 +261,9 @@ void Panels::CpuPanelEE::ApplyConfigToGui( AppConfig& configToApply, int flags ) void Panels::CpuPanelEE::OnRestoreDefaults(wxCommandEvent &evt) { - m_panel_RecEE->SetSelection( m_panel_RecEE->GetButton(1)->IsEnabled() ? 1 : 0 ); - m_panel_RecIOP->SetSelection( m_panel_RecIOP->GetButton(1)->IsEnabled() ? 1 : 0 ); - m_check_EECacheEnable->SetValue(0); + AppConfig def; // created with default values + def.EnablePresets = false; // disable presets otherwise it'll disable some widgets + ApplyConfigToGui(def); if( BaseAdvancedCpuOptions* opts = (BaseAdvancedCpuOptions*)FindWindowByName(L"AdvancedOptionsFPU") ) opts->RestoreDefaults(); @@ -335,8 +336,9 @@ void Panels::CpuPanelVU::ApplyConfigToGui( AppConfig& configToApply, int flags ) void Panels::CpuPanelVU::OnRestoreDefaults(wxCommandEvent &evt) { - m_panel_VU0->SetSelection( m_panel_VU0->GetButton(1)->IsEnabled() ? 1 : 0 ); - m_panel_VU1->SetSelection( m_panel_VU1->GetButton(1)->IsEnabled() ? 1 : 0 ); + AppConfig def; // created with default values + def.EnablePresets = false; // disable presets otherwise it'll disable some widgets + ApplyConfigToGui(def); if( BaseAdvancedCpuOptions* opts = (BaseAdvancedCpuOptions*)FindWindowByName(L"AdvancedOptionsVU") ) opts->RestoreDefaults();