From 45f08e76306f0f8ffa05e57f3c9f253dac31712b Mon Sep 17 00:00:00 2001 From: "avihal@gmail.com" Date: Sat, 22 Jan 2011 13:50:26 +0000 Subject: [PATCH] Presets: better semantics on arguments. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4246 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/gui/AppConfig.cpp | 11 ++++++---- pcsx2/gui/AppConfig.h | 5 +++++ pcsx2/gui/ApplyState.h | 3 ++- pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp | 4 ++-- pcsx2/gui/Dialogs/SysConfigDialog.cpp | 6 +++++- pcsx2/gui/Panels/ConfigurationPanels.h | 20 +++++++++---------- pcsx2/gui/Panels/CpuPanel.cpp | 12 +++++------ pcsx2/gui/Panels/GSWindowPanel.cpp | 4 ++-- pcsx2/gui/Panels/GameFixesPanel.cpp | 2 +- pcsx2/gui/Panels/SpeedhacksPanel.cpp | 2 +- pcsx2/gui/Panels/VideoPanel.cpp | 10 +++++----- 11 files changed, 46 insertions(+), 33 deletions(-) diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index a65daba5b5..6237c7e8c6 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -775,10 +775,10 @@ bool AppConfig::IsOkApplyPreset(int n) Pcsx2Config default_Pcsx2Config; - // NOTE: Because the system currently only supports passing of an entire AppConfig to the GUI panels to apply, - // the GUI panels should be aware of the settings which the presets control, such that when presets are used: - // 1. The panels should prevent manual modifications (by graying out) of settings which the presets control. - // 2. The panels should not apply values which the presets don't control. + // NOTE: Because the system currently only supports passing of an entire AppConfig to the GUI panels/menus to apply/reflect, + // the GUI entities should be aware of the settings which the presets control, such that when presets are used: + // 1. The panels/entities should prevent manual modifications (by graying out) of settings which the presets control. + // 2. The panels should not apply values which the presets don't control if the value is initiated by a preset. // Currently controlled by the presets: // - AppConfig: Framerate, EnableSpeedHacks, EnableGameFixes. // - EmuOptions: Cpu, Gamefixes, SpeedHacks, EnablePatches, GS (except FrameLimitEnable). @@ -786,6 +786,9 @@ bool AppConfig::IsOkApplyPreset(int n) // This essentially currently covers all the options on all the panels except for framelimiter which isn't // controlled by the presets, and almost the entire GSWindow panel which also isn't controlled by presets // (however, vsync IS controlled by the presets). + // + // So, if changing the scope of the presets (making them affect more or less values), the relevant GUI entities + // shoulld me modified to support it. //Force some settings as a (current) base for all presets. diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index bd22f0a8af..4c0d4890b7 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -305,7 +305,12 @@ public: static int GetMaxPresetIndex(); static bool isOkGetPresetTextAndColor(int n, wxString& label, wxColor& c); + bool IsOkApplyPreset(int n); + //flags to allow manual application of settings to GUI entities. Used by the presets system. + static const int APPLY_FLAG_MANUALLY_PROPAGATE = 0x01; + static const int APPLY_FLAG_FROM_PRESET = 0x02; + }; diff --git a/pcsx2/gui/ApplyState.h b/pcsx2/gui/ApplyState.h index 6b0631fb3b..60cf326d8d 100644 --- a/pcsx2/gui/ApplyState.h +++ b/pcsx2/gui/ApplyState.h @@ -218,7 +218,8 @@ public: BaseApplicableConfigPanel_SpecificConfig( wxWindow* parent, wxOrientation orient=wxVERTICAL ); BaseApplicableConfigPanel_SpecificConfig( wxWindow* parent, wxOrientation orient, const wxString& staticLabel ); - virtual void ApplyConfigToGui(AppConfig& configToApply, bool manuallyPropagate=false)=0; + //possible flags are: AppConfig: APPLY_FLAG_MANUALLY_PROPAGATE and APPLY_FLAG_IS_FROM_PRESET + virtual void ApplyConfigToGui(AppConfig& configToApply, int flags=0)=0; }; class ApplicableWizardPage : public wxWizardPageSimple, public IApplyState diff --git a/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp b/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp index 9fb55d6af6..a0b9cb95b3 100644 --- a/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp +++ b/pcsx2/gui/Dialogs/BaseConfigurationDialog.cpp @@ -257,8 +257,8 @@ void Dialogs::BaseConfigurationDialog::OnApply_Click( wxCommandEvent& evt ) { ScopedOkButtonDisabler disabler(this); - //if current instance also holds settings that need application. Apply it. - //Currently only used by SysConfigDialog, which applies the preset. + //if current instance also holds settings that need application, Apply them. + //Currently only used by SysConfigDialog, which applies the preset and derivatives (menu system). //Needs to come before actual panels Apply since they enable/disable themselves upon Preset state, // so the preset needs to be applied first. Apply(); diff --git a/pcsx2/gui/Dialogs/SysConfigDialog.cpp b/pcsx2/gui/Dialogs/SysConfigDialog.cpp index 8812f4f07f..6dd8980edf 100644 --- a/pcsx2/gui/Dialogs/SysConfigDialog.cpp +++ b/pcsx2/gui/Dialogs/SysConfigDialog.cpp @@ -83,6 +83,7 @@ void Dialogs::SysConfigDialog::UpdateGuiForPreset ( int presetIndex, bool preset preset.IsOkApplyPreset( presetIndex ); //apply a preset to a copy of g_Conf. preset.EnablePresets = presetsEnabled; //override IsOkApplyPreset (which always applies/enabled) to actual required state + //update the config panels of SysConfigDialog to reflect the preset. size_t pages = m_labels.GetCount(); for( size_t i=0; iGetPage(i)))->IsSpecificConfig() ) { ((BaseApplicableConfigPanel_SpecificConfig*)(m_listbook->GetPage(i))) - ->ApplyConfigToGui( preset, true ); + ->ApplyConfigToGui( preset, AppConfig::APPLY_FLAG_FROM_PRESET | AppConfig::APPLY_FLAG_MANUALLY_PROPAGATE ); } } @@ -182,6 +183,9 @@ void Dialogs::SysConfigDialog::Preset_Scroll(wxScrollEvent &event) event.Skip(); } +//Write the values SysConfigDialog holds (preset index and enabled) to g_Conf. +//Make the main menu system write the presets values it holds to g_Conf (preset may have affected the gui without changing g_Conf) +//The panels will write themselves to g_Conf on apply (AFTER this function) and will also trigger a global OnSettingsApplied. void Dialogs::SysConfigDialog::Apply() { //Console.WriteLn("Applying preset to to g_Conf: Preset index: %d, EnablePresets: %s", (int)m_slider_presets->GetValue(), m_check_presets->IsChecked()?"true":"false"); diff --git a/pcsx2/gui/Panels/ConfigurationPanels.h b/pcsx2/gui/Panels/ConfigurationPanels.h index 62a89dfbac..dd51dd386e 100644 --- a/pcsx2/gui/Panels/ConfigurationPanels.h +++ b/pcsx2/gui/Panels/ConfigurationPanels.h @@ -152,7 +152,7 @@ namespace Panels virtual ~AdvancedOptionsFPU() throw() { } void Apply(); void AppStatusEvent_OnSettingsApplied(); - void ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate=false ); + void ApplyConfigToGui( AppConfig& configToApply, int flags=0 ); }; class AdvancedOptionsVU : public BaseAdvancedCpuOptions @@ -162,7 +162,7 @@ namespace Panels virtual ~AdvancedOptionsVU() throw() { } void Apply(); void AppStatusEvent_OnSettingsApplied(); - void ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate=false ); + void ApplyConfigToGui( AppConfig& configToApply, int flags=0 ); }; @@ -182,7 +182,7 @@ namespace Panels void Apply(); void AppStatusEvent_OnSettingsApplied(); - void ApplyConfigToGui(AppConfig& configToApply, bool manuallyPropagate=false); + void ApplyConfigToGui(AppConfig& configToApply, int flags=0); protected: void OnRestoreDefaults( wxCommandEvent& evt ); @@ -201,7 +201,7 @@ namespace Panels void Apply(); void AppStatusEvent_OnSettingsApplied(); - void ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate=false ); + void ApplyConfigToGui( AppConfig& configToApply, int flags=0 ); protected: void OnRestoreDefaults( wxCommandEvent& evt ); @@ -226,7 +226,7 @@ namespace Panels void Apply(); void AppStatusEvent_OnSettingsApplied(); - void ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate=false ); + void ApplyConfigToGui( AppConfig& configToApply, int flags=0 ); }; // -------------------------------------------------------------------------------------- @@ -253,7 +253,7 @@ namespace Panels void Apply(); void AppStatusEvent_OnSettingsApplied(); - void ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate=false ); + void ApplyConfigToGui( AppConfig& configToApply, int flags=0 ); }; // -------------------------------------------------------------------------------------- @@ -280,7 +280,7 @@ namespace Panels virtual ~GSWindowSettingsPanel() throw() {} void Apply(); void AppStatusEvent_OnSettingsApplied(); - void ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate=false ); + void ApplyConfigToGui( AppConfig& configToApply, int flags=0 ); }; class VideoPanel : public BaseApplicableConfigPanel_SpecificConfig @@ -296,7 +296,7 @@ namespace Panels virtual ~VideoPanel() throw() {} void Apply(); void AppStatusEvent_OnSettingsApplied(); - void ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate=false ); + void ApplyConfigToGui( AppConfig& configToApply, int flags=0 ); protected: void OnOpenWindowSettings( wxCommandEvent& evt ); @@ -331,7 +331,7 @@ namespace Panels void Apply(); void EnableStuff( AppConfig* configToUse=NULL ); void AppStatusEvent_OnSettingsApplied(); - void ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate=false ); + void ApplyConfigToGui( AppConfig& configToApply, int flags=0 ); protected: const wxChar* GetEEcycleSliderMsg( int val ); @@ -362,7 +362,7 @@ namespace Panels void OnEnable_Toggled( wxCommandEvent& evt ); void Apply(); void AppStatusEvent_OnSettingsApplied(); - void ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate=false ); + void ApplyConfigToGui( AppConfig& configToApply, int flags=0 ); }; // -------------------------------------------------------------------------------------- diff --git a/pcsx2/gui/Panels/CpuPanel.cpp b/pcsx2/gui/Panels/CpuPanel.cpp index 9d561040fb..4c274caaf2 100644 --- a/pcsx2/gui/Panels/CpuPanel.cpp +++ b/pcsx2/gui/Panels/CpuPanel.cpp @@ -240,7 +240,7 @@ void Panels::CpuPanelEE::AppStatusEvent_OnSettingsApplied() ApplyConfigToGui( *g_Conf ); } -void Panels::CpuPanelEE::ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate ){ +void Panels::CpuPanelEE::ApplyConfigToGui( AppConfig& configToApply, int flags ){ m_panel_RecEE->Enable( x86caps.hasStreamingSIMD2Extensions ); // IOP rec should work fine on any CPU. :D @@ -255,7 +255,7 @@ void Panels::CpuPanelEE::ApplyConfigToGui( AppConfig& configToApply, bool manual this->Enable(!configToApply.EnablePresets); - if( manuallyPropagate ) + if( flags & AppConfig::APPLY_FLAG_MANUALLY_PROPAGATE ) { m_advancedOptsFpu->ApplyConfigToGui( configToApply, true ); } @@ -288,7 +288,7 @@ void Panels::CpuPanelVU::AppStatusEvent_OnSettingsApplied() ApplyConfigToGui( *g_Conf ); } -void Panels::CpuPanelVU::ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate ) +void Panels::CpuPanelVU::ApplyConfigToGui( AppConfig& configToApply, int flags ) { m_panel_VU0->Enable( x86caps.hasStreamingSIMD2Extensions ); m_panel_VU1->Enable( x86caps.hasStreamingSIMD2Extensions ); @@ -314,7 +314,7 @@ void Panels::CpuPanelVU::ApplyConfigToGui( AppConfig& configToApply, bool manual m_panel_VU0->Enable(!configToApply.EnablePresets); m_panel_VU1->Enable(!configToApply.EnablePresets); - if ( manuallyPropagate ) + if ( flags & AppConfig::APPLY_FLAG_MANUALLY_PROPAGATE ) { m_advancedOptsVu->ApplyConfigToGui( configToApply, true ); } @@ -361,7 +361,7 @@ void Panels::AdvancedOptionsFPU::AppStatusEvent_OnSettingsApplied() ApplyConfigToGui( *g_Conf ); } -void Panels::AdvancedOptionsFPU::ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate ) +void Panels::AdvancedOptionsFPU::ApplyConfigToGui( AppConfig& configToApply, int flags ) { const Pcsx2Config::CpuOptions& cpuOps( configToApply.EmuOptions.Cpu ); const Pcsx2Config::RecompilerOptions& recOps( cpuOps.Recompiler ); @@ -401,7 +401,7 @@ void Panels::AdvancedOptionsVU::AppStatusEvent_OnSettingsApplied() ApplyConfigToGui( *g_Conf ); } -void Panels::AdvancedOptionsVU::ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate ) +void Panels::AdvancedOptionsVU::ApplyConfigToGui( AppConfig& configToApply, int flags ) { const Pcsx2Config::CpuOptions& cpuOps( configToApply.EmuOptions.Cpu ); const Pcsx2Config::RecompilerOptions& recOps( cpuOps.Recompiler ); diff --git a/pcsx2/gui/Panels/GSWindowPanel.cpp b/pcsx2/gui/Panels/GSWindowPanel.cpp index ef05cd09aa..a2e1b920ec 100644 --- a/pcsx2/gui/Panels/GSWindowPanel.cpp +++ b/pcsx2/gui/Panels/GSWindowPanel.cpp @@ -116,11 +116,11 @@ void Panels::GSWindowSettingsPanel::AppStatusEvent_OnSettingsApplied() ApplyConfigToGui( *g_Conf ); } -void Panels::GSWindowSettingsPanel::ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate ) +void Panels::GSWindowSettingsPanel::ApplyConfigToGui( AppConfig& configToApply, int flags ) { const AppConfig::GSWindowOptions& conf( configToApply.GSWindow ); - if( !manuallyPropagate ) //Presets don't control these: only change if config doesn't come from preset. + if( !(flags & AppConfig::APPLY_FLAG_FROM_PRESET) ) //Presets don't control these: only change if config doesn't come from preset. { m_check_CloseGS ->SetValue( conf.CloseOnEsc ); m_check_Fullscreen ->SetValue( conf.DefaultToFullscreen ); diff --git a/pcsx2/gui/Panels/GameFixesPanel.cpp b/pcsx2/gui/Panels/GameFixesPanel.cpp index cd253a18fd..4553835585 100644 --- a/pcsx2/gui/Panels/GameFixesPanel.cpp +++ b/pcsx2/gui/Panels/GameFixesPanel.cpp @@ -145,7 +145,7 @@ void Panels::GameFixesPanel::AppStatusEvent_OnSettingsApplied() ApplyConfigToGui( *g_Conf ); } -void Panels::GameFixesPanel::ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate ) +void Panels::GameFixesPanel::ApplyConfigToGui( AppConfig& configToApply, int flags ) { const Pcsx2Config::GamefixOptions& opts( configToApply.EmuOptions.Gamefixes ); for (GamefixId i=GamefixId_FIRST; i < pxEnumEnd; ++i) diff --git a/pcsx2/gui/Panels/SpeedhacksPanel.cpp b/pcsx2/gui/Panels/SpeedhacksPanel.cpp index 0bde65c545..62d0b15281 100644 --- a/pcsx2/gui/Panels/SpeedhacksPanel.cpp +++ b/pcsx2/gui/Panels/SpeedhacksPanel.cpp @@ -297,7 +297,7 @@ void Panels::SpeedHacksPanel::AppStatusEvent_OnSettingsApplied() ApplyConfigToGui( *g_Conf ); } -void Panels::SpeedHacksPanel::ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate ) +void Panels::SpeedHacksPanel::ApplyConfigToGui( AppConfig& configToApply, int flags ) { const bool enabled = configToApply.EnableSpeedHacks; Pcsx2Config::SpeedhackOptions& opts=configToApply.EmuOptions.Speedhacks; diff --git a/pcsx2/gui/Panels/VideoPanel.cpp b/pcsx2/gui/Panels/VideoPanel.cpp index a3e285af46..d86fbc5bb8 100644 --- a/pcsx2/gui/Panels/VideoPanel.cpp +++ b/pcsx2/gui/Panels/VideoPanel.cpp @@ -116,13 +116,13 @@ void Panels::FramelimiterPanel::AppStatusEvent_OnSettingsApplied() ApplyConfigToGui( *g_Conf ); } -void Panels::FramelimiterPanel::ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate ) +void Panels::FramelimiterPanel::ApplyConfigToGui( AppConfig& configToApply, int flags ) { const AppConfig::GSWindowOptions& appwin( configToApply.GSWindow ); const AppConfig::FramerateOptions& appfps( configToApply.Framerate ); const Pcsx2Config::GSOptions& gsconf( configToApply.EmuOptions.GS ); - if( !manuallyPropagate ) //Presets don't control this: only change if config doesn't come from preset. + if( ! (flags & AppConfig::APPLY_FLAG_FROM_PRESET) ) //Presets don't control this: only change if config doesn't come from preset. m_check_LimiterDisable->SetValue( !gsconf.FrameLimitEnable ); m_spin_NominalPct ->SetValue( appfps.NominalScalar.Raw ); @@ -252,7 +252,7 @@ void Panels::FrameSkipPanel::AppStatusEvent_OnSettingsApplied() ApplyConfigToGui( *g_Conf ); } -void Panels::FrameSkipPanel::ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate ) +void Panels::FrameSkipPanel::ApplyConfigToGui( AppConfig& configToApply, int flags ) { const AppConfig::FramerateOptions& appfps( configToApply.Framerate ); const Pcsx2Config::GSOptions& gsconf( configToApply.EmuOptions.GS ); @@ -373,7 +373,7 @@ void Panels::VideoPanel::AppStatusEvent_OnSettingsApplied() ApplyConfigToGui(*g_Conf); } -void Panels::VideoPanel::ApplyConfigToGui( AppConfig& configToApply, bool manuallyPropagate ){ +void Panels::VideoPanel::ApplyConfigToGui( AppConfig& configToApply, int flags ){ m_check_SynchronousGS->SetValue( configToApply.EmuOptions.GS.SynchronousMTGS ); m_check_DisableOutput->SetValue( configToApply.EmuOptions.GS.DisableOutput ); @@ -381,7 +381,7 @@ void Panels::VideoPanel::ApplyConfigToGui( AppConfig& configToApply, bool manual m_check_SynchronousGS->Enable(!configToApply.EnablePresets); m_check_DisableOutput->Enable(!configToApply.EnablePresets); - if( manuallyPropagate ) + if( flags & AppConfig::APPLY_FLAG_MANUALLY_PROPAGATE ) { m_span->ApplyConfigToGui( configToApply, true ); m_fpan->ApplyConfigToGui( configToApply, true );