[Safe WIP] Presets: PCSX2 configuration for dummies:

- When Presets are disabled: Nothing changes compared to earlier pcsx2 versions.
- When enabled: All important config options are grayed out, and a slider is used to select 1 of 6 overall config presets, 
  in the range of safest (and slowest) emulation, through trying to balance compatibility and speed, to way-too-many-hacks.
- TODO: 1. Resolve UI inconcistencies ("Cancel" button). 2. Fine-tune the presets. 3. Slight refactoring.


git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4182 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
avihal@gmail.com 2011-01-06 23:52:04 +00:00
parent 865cf083f8
commit 9bc27cc7e4
10 changed files with 257 additions and 7 deletions

View File

@ -378,6 +378,9 @@ AppConfig::AppConfig()
EnableSpeedHacks = false;
EnableGameFixes = false;
EnablePresets = false;
PresetIndex = 0;
CdvdSource = CDVDsrc_Iso;
// To be moved to FileMemoryCard pluign (someday)
@ -481,6 +484,9 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini )
IniEntry( EnableSpeedHacks );
IniEntry( EnableGameFixes );
IniEntry( EnablePresets );
IniEntry( PresetIndex );
#ifdef __WXMSW__
IniEntry( McdCompressNTFS );
#endif
@ -507,7 +513,12 @@ void AppConfig::LoadSave( IniInterface& ini )
EmuOptions.LoadSave( ini );
if( ini.IsLoading() )
{
EmuOptions.GS.LimitScalar = Framerate.NominalScalar;
if (EnablePresets){
IsOkApplyPreset(PresetIndex);
}
}
ini.Flush();
}
@ -713,6 +724,94 @@ void AppConfig::FramerateOptions::LoadSave( IniInterface& ini )
IniEntry( SkipOnTurbo );
}
int AppConfig::GeMaxPresetIndex()
{
return 5;
}
bool AppConfig::IsOkApplyPreset(int n)
{
if (n < 0 || n > GeMaxPresetIndex() )
{
Console.WriteLn("Warning: ApplyPreset(%d): index too big, Aborting.", n);
return false;
}
Console.WriteLn("Applying Preset %d ...", n);
AppConfig default_AppConfig;
Pcsx2Config default_Pcsx2Config;
Pcsx2Config original_Pcsx2Config = EmuOptions;
EmuOptions = default_Pcsx2Config; //reset EmuOptions.
//restore the original Pcsx2Config settings which we don't want to override with the application default dettings.
//The ugly part of this is that while most panels are entirely disabled from manual tweaking when a preset is used,
// the options that are not overriden by presets need to be manually excluded from disabling.
// So the Gui panels need to have intimate knowledge of this exclusion list. Bahh..
EmuOptions.EnableCheats = original_Pcsx2Config.EnableCheats;
EmuOptions.GS.FrameLimitEnable = original_Pcsx2Config.GS.FrameLimitEnable;
EmuOptions.BackupSavestate = original_Pcsx2Config.BackupSavestate;
//Make sure these options are forced as a base even if in the future they default to other values.
//Also, as with the exclusions list, the gui needs to know what sections are affected by presets
// such that it can disable them from manual tweaking when a preset is used. This includes most panels BTW.
EnableSpeedHacks =false;
EnableGameFixes =false;
EmuOptions.EnablePatches =true;
//Note that AppConfig was not reset, so if we need some default options for it, we need to set them.
this->Framerate = default_AppConfig.Framerate;
//Actual application of current preset.
//The presets themselves probably need some voodoo tuning to be reasonably useful.
bool vuUsed=false, eeUsed=false, hacksUsed=false;//used to prevent application of specific lower preset values on fallthrough.
switch (n){ //currently implemented such that any preset also applies all lower presets, with few exceptions.
case 5 : //Set VU cycle steal to 2 clicks (maximum-1)
vuUsed?0:(vuUsed=true, EmuOptions.Speedhacks.VUCycleSteal = 2);
case 4 : //set EE cyclerate to 2 clicks (maximum)
eeUsed?0:(eeUsed=true, EmuOptions.Speedhacks.EECycleRate = 2);
case 3 : //Set VU cycle steal to 1 click, enable (m)vuBlockHack, set clamp mode to 'none' for both EE/VU
vuUsed?0:(vuUsed=true, EmuOptions.Speedhacks.VUCycleSteal = 1);
EmuOptions.Speedhacks.vuBlockHack=true;
EmuOptions.Cpu.Recompiler.fpuOverflow=
EmuOptions.Cpu.Recompiler.fpuExtraOverflow=
EmuOptions.Cpu.Recompiler.fpuFullMode=
EmuOptions.Cpu.Recompiler.vuOverflow=
EmuOptions.Cpu.Recompiler.vuExtraOverflow=
EmuOptions.Cpu.Recompiler.vuSignOverflow=false; //Clamp mode to 'none' for both EE and VU
//best balanced hacks combo?
case 2 : //enable EE timing hack, set EE cyclerate to 1 click, enable mvu flag hack
eeUsed?0:(eeUsed=true, EmuOptions.Speedhacks.EECycleRate = 1);
EnableGameFixes=true;
EmuOptions.Gamefixes.EETimingHack=true;
hacksUsed?0:(hacksUsed=true, EmuOptions.Speedhacks.vuFlagHack=true);
case 1 : //Apply recommended speed hacks (which are individually "ckecked" by default) without mvu flag hack.
EnableSpeedHacks = true;
hacksUsed?0:(hacksUsed=true, EmuOptions.Speedhacks.vuFlagHack=false);
case 0 : //default application config. + untick all individual speed hacks to make it visually clear none is used.
hacksUsed?0:(hacksUsed=true, EmuOptions.Speedhacks.bitset=0);
break;
default: Console.WriteLn("Developer Warning: Preset #%d is not implemented. (--> Using application default).", n);
}
EnablePresets=true;
PresetIndex=n;
return true;
}
wxFileConfig* OpenFileConfig( const wxString& filename )
{
return new wxFileConfig( wxEmptyString, wxEmptyString, filename, wxEmptyString, wxCONFIG_USE_RELATIVE_PATH );

View File

@ -231,6 +231,16 @@ public:
bool EnableSpeedHacks;
bool EnableGameFixes;
// Presets try to prevent users from overwhelming when they want to change settings (usually to make a game run faster).
// The presets allow to modify the balance between emulation accuracy and emulation speed using a pseudo-linear control.
// It's pseudo since there's no way to arrange groups of all of pcsx2's settings such that each next group makes it slighty faster and slightly less compatiible for all games.
//However, By carefully selecting these preset config groups, it's hopefully possible to achieve this goal for a reasonable percentage (hopefully above 50%) of the games.
//when presets are enabled, the user has practically no control over the emulation settings, and can only choose the preset to use.
// The next 2 vars enable/disable presets alltogether, and select/reflect current preset, respectively.
bool EnablePresets;
int PresetIndex;
wxString CurrentIso;
wxString CurrentELF;
CDVD_SourceType CdvdSource;
@ -265,6 +275,10 @@ public:
void LoadSave( IniInterface& ini );
void LoadSaveRootItems( IniInterface& ini );
void LoadSaveMemcards( IniInterface& ini );
static int GeMaxPresetIndex();
bool IsOkApplyPreset(int n);
};
extern void AppLoadSettings();

View File

@ -138,7 +138,7 @@ void Dialogs::BaseConfigurationDialog::AddOkCancel( wxSizer* sizer )
wxBitmapButton& screenshotButton( *new wxBitmapButton( this, wxID_SAVE, EmbeddedImage<res_ButtonIcon_Camera>().Get() ) );
screenshotButton.SetToolTip( _("Saves a snapshot of this settings panel to a PNG file.") );
*m_extraButtonSizer += screenshotButton;
*m_extraButtonSizer += screenshotButton|pxMiddle;
}
Dialogs::BaseConfigurationDialog::~BaseConfigurationDialog() throw()

View File

@ -87,6 +87,14 @@ namespace Dialogs
protected:
virtual wxString& GetConfSettingsTabName() const { return g_Conf->SysSettingsTabName; }
pxCheckBox* m_check_presets;
wxSlider* m_slider_presets;
pxStaticText* m_msg_preset;
void AddPresetsControl();
void Preset_Scroll(wxScrollEvent &event);
void Presets_Toggled(wxCommandEvent &event);
};
// --------------------------------------------------------------------------------------

View File

@ -65,6 +65,102 @@ static void CheckPluginsOverrides()
pxIssueConfirmation( dialog, MsgButtons().OK(), L"Dialog.ComponentsConfig.Overrides" );
}
bool isOkGetPresetTextAndColor(int n, wxString& label, wxColor& c){
switch(n){
case 0: label=pxE("!Panel:", L"1 - Safest"); c=wxColor(L"Forest GREEN"); break;
case 1: label=pxE("!Panel:", L"2 - Safe (faster)"); c=wxColor(L"Dark Green"); break;
case 2: label=pxE("!Panel:", L"3 - Balanced"); c=wxColor(L"Blue");break;
case 3: label=pxE("!Panel:", L"4 - Aggressive"); c=wxColor(L"Purple"); break;
case 4: label=pxE("!Panel:", L"5 - Aggressive plus"); c=wxColor(L"Orange"); break;
case 5: label=pxE("!Panel:", L"6 - Mostly Harmful"); c=wxColor(L"Red");break;
default: return false;
}
return true;
}
void Dialogs::SysConfigDialog::AddPresetsControl()
{
m_slider_presets = new wxSlider( this, wxID_ANY, g_Conf->PresetIndex, 0, AppConfig::GeMaxPresetIndex(),
wxDefaultPosition, wxDefaultSize, wxHORIZONTAL /*| wxSL_AUTOTICKS | wxSL_LABELS */);
m_slider_presets->SetToolTip(
pxE( "!Notice:Tooltip",
L"The Presets apply speed hacks, some recompiler options and some game fixes known to boost speed.\n"
L"Known important game fixes ('Patches') will be applied automatically.\n\n"
L"Presets info:\n"
L"1 - The most accurate emulation but also the slowest.\n"
L"3 --> Tries to balance speed with compatibility.\n"
L"4 - Some more aggressive hacks.\n"
L"6 - Too many hacks which will probably slow down most games.\n"
)
);
m_slider_presets->Enable(g_Conf->EnablePresets);
m_check_presets = new pxCheckBox( this, pxE("!Panel:", L"Preset:"), 0);
m_check_presets->SetToolTip(
pxE( "!Notice:Tooltip",
L"The Presets apply speed hacks, some recompiler options and some game fixes known to boost speed.\n"
L"Known important game fixes ('Patches') will be applied automatically.\n\n"
L"--> Uncheck to modify settings manually (with current preset as base)"
)
);
m_check_presets->SetValue(g_Conf->EnablePresets);
wxString l; wxColor c(wxColour( L"Red" ));
isOkGetPresetTextAndColor(g_Conf->PresetIndex, l, c);
m_msg_preset = new pxStaticText(this, l, wxALIGN_LEFT);
m_msg_preset->Enable(g_Conf->EnablePresets);
m_msg_preset->SetForegroundColour( c );
m_msg_preset->Bold();
//I'm unable to do without the next 2 rows.. what am I missing?
m_msg_preset->SetMinWidth(150);
m_msg_preset->Unwrapped();
*m_extraButtonSizer += 20;
*m_extraButtonSizer += *m_check_presets | pxMiddle;
*m_extraButtonSizer += *m_slider_presets | pxMiddle;
*m_extraButtonSizer += 5;
*m_extraButtonSizer += *m_msg_preset | pxMiddle;
Connect( m_slider_presets->GetId(), wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( Dialogs::SysConfigDialog::Preset_Scroll ) );
Connect( m_slider_presets->GetId(), wxEVT_SCROLL_CHANGED, wxScrollEventHandler( Dialogs::SysConfigDialog::Preset_Scroll ) );
Connect( m_check_presets->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( Dialogs::SysConfigDialog::Presets_Toggled ) );
}
void Dialogs::SysConfigDialog::Presets_Toggled(wxCommandEvent &event)
{
g_Conf->EnablePresets = m_check_presets->IsChecked();
m_slider_presets->Enable(g_Conf->EnablePresets);
m_msg_preset->Enable(g_Conf->EnablePresets);
if (g_Conf->EnablePresets)
g_Conf->IsOkApplyPreset(g_Conf->PresetIndex);
sApp.DispatchEvent( AppStatus_SettingsApplied );
event.Skip();
}
void Dialogs::SysConfigDialog::Preset_Scroll(wxScrollEvent &event)
{
if (m_slider_presets->GetValue() == g_Conf->PresetIndex)
return;
wxString pl;
wxColor c;
isOkGetPresetTextAndColor(m_slider_presets->GetValue(), pl, c);
m_msg_preset->SetLabel(pl);
m_msg_preset->SetForegroundColour( c );
g_Conf->IsOkApplyPreset(m_slider_presets->GetValue());
sApp.DispatchEvent( AppStatus_SettingsApplied );
event.Skip();
}
Dialogs::SysConfigDialog::SysConfigDialog(wxWindow* parent)
: BaseConfigurationDialog( parent, AddAppName(_("Emulation Settings - %s")), 580 )
{
@ -82,6 +178,7 @@ Dialogs::SysConfigDialog::SysConfigDialog(wxWindow* parent)
AddListbook();
AddOkCancel();
AddPresetsControl();
if( wxGetApp().Overrides.HasCustomHacks() )
wxGetApp().PostMethod( CheckHacksOverrides );

View File

@ -245,6 +245,11 @@ void Panels::CpuPanelEE::AppStatusEvent_OnSettingsApplied()
const Pcsx2Config::RecompilerOptions& recOps( g_Conf->EmuOptions.Cpu.Recompiler );
m_panel_RecEE->SetSelection( (int)recOps.EnableEE );
m_panel_RecIOP->SetSelection( (int)recOps.EnableIOP );
m_panel_RecEE->Enable(!g_Conf->EnablePresets);
m_panel_RecIOP->Enable(!g_Conf->EnablePresets);
this->Enable(!g_Conf->EnablePresets);
}
void Panels::CpuPanelEE::OnRestoreDefaults(wxCommandEvent &evt)
@ -290,6 +295,10 @@ void Panels::CpuPanelVU::AppStatusEvent_OnSettingsApplied()
m_panel_VU1->SetSelection( recOps.EnableVU1 ? 1 : 0 );
else
m_panel_VU1->SetSelection( recOps.EnableVU1 ? 2 : 0 );
this->Enable(!g_Conf->EnablePresets);
m_panel_VU0->Enable(!g_Conf->EnablePresets);
m_panel_VU1->Enable(!g_Conf->EnablePresets);
}
void Panels::CpuPanelVU::OnRestoreDefaults(wxCommandEvent &evt)
@ -341,6 +350,8 @@ void Panels::AdvancedOptionsFPU::AppStatusEvent_OnSettingsApplied()
else if( recOps.fpuExtraOverflow ) m_ClampModePanel->SetSelection( 2 );
else if( recOps.fpuOverflow ) m_ClampModePanel->SetSelection( 1 );
else m_ClampModePanel->SetSelection( 0 );
this->Enable(!g_Conf->EnablePresets);
}
void Panels::AdvancedOptionsVU::Apply()
@ -374,5 +385,7 @@ void Panels::AdvancedOptionsVU::AppStatusEvent_OnSettingsApplied()
else if( recOps.vuExtraOverflow ) m_ClampModePanel->SetSelection( 2 );
else if( recOps.vuOverflow ) m_ClampModePanel->SetSelection( 1 );
else m_ClampModePanel->SetSelection( 0 );
this->Enable(!g_Conf->EnablePresets);
}

View File

@ -123,6 +123,8 @@ void Panels::GSWindowSettingsPanel::AppStatusEvent_OnSettingsApplied()
m_text_WindowWidth ->SetValue( wxsFormat( L"%d", conf.WindowSize.GetWidth() ) );
m_text_WindowHeight ->SetValue( wxsFormat( L"%d", conf.WindowSize.GetHeight() ) );
m_check_VsyncEnable->Enable(!g_Conf->EnablePresets);
}
void Panels::GSWindowSettingsPanel::Apply()

View File

@ -127,7 +127,7 @@ void Panels::GameFixesPanel::Apply()
void Panels::GameFixesPanel::EnableStuff()
{
for (GamefixId i=GamefixId_FIRST; i < pxEnumEnd; ++i)
m_checkbox[i]->Enable(m_check_Enable->GetValue());
m_checkbox[i]->Enable(m_check_Enable->GetValue() && !g_Conf->EnablePresets);
}
void Panels::GameFixesPanel::OnEnable_Toggled( wxCommandEvent& evt )
@ -140,5 +140,10 @@ void Panels::GameFixesPanel::AppStatusEvent_OnSettingsApplied()
{
const Pcsx2Config::GamefixOptions& opts( g_Conf->EmuOptions.Gamefixes );
for (GamefixId i=GamefixId_FIRST; i < pxEnumEnd; ++i)
m_checkbox[i]->SetValue( opts.Get((GamefixId)i) );
m_checkbox[i]->SetValue( opts.Get((GamefixId)i) );//apply the use/don't-use fix values
m_check_Enable->SetValue( g_Conf->EnableGameFixes );//main gamefixes checkbox
EnableStuff();// enable/disable the all the fixes controls according to the main one
this->Enable(!g_Conf->EnablePresets);
}

View File

@ -268,8 +268,8 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent )
Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) );
Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) );
Connect( m_slider_eecycle->GetId(), wxEVT_SCROLL_CHANGED, wxScrollEventHandler( SpeedHacksPanel::EECycleRate_Scroll ) );
Connect( m_slider_vustealer->GetId(), wxEVT_SCROLL_CHANGED, wxScrollEventHandler( SpeedHacksPanel::VUCycleRate_Scroll ) );
Connect( m_slider_eecycle->GetId(), wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( SpeedHacksPanel::EECycleRate_Scroll ) );
Connect( m_slider_vustealer->GetId(), wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( SpeedHacksPanel::VUCycleRate_Scroll ) );
Connect( m_check_Enable->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SpeedHacksPanel::OnEnable_Toggled ) );
Connect( wxID_DEFAULT, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( SpeedHacksPanel::Defaults_Click ) );
}
@ -283,7 +283,7 @@ void Panels::SpeedHacksPanel::EnableStuff()
while( it != end )
{
(*it)->GetWindow()->Enable( m_check_Enable->GetValue() );
(*it)->GetWindow()->Enable( m_check_Enable->GetValue() && !g_Conf->EnablePresets);
++it;
}
}
@ -316,6 +316,7 @@ void Panels::SpeedHacksPanel::AppStatusEvent_OnSettingsApplied( const Pcsx2Confi
// Layout necessary to ensure changed slider text gets re-aligned properly
Layout();
this->Enable(!g_Conf->EnablePresets);
}
void Panels::SpeedHacksPanel::Apply()

View File

@ -125,6 +125,12 @@ void Panels::FramelimiterPanel::AppStatusEvent_OnSettingsApplied()
m_text_BaseNtsc ->SetValue( gsconf.FramerateNTSC.ToString() );
m_text_BasePal ->SetValue( gsconf.FrameratePAL.ToString() );
m_spin_NominalPct->Enable(!g_Conf->EnablePresets);
m_spin_TurboPct->Enable(!g_Conf->EnablePresets);
m_spin_SlomoPct->Enable(!g_Conf->EnablePresets);
m_text_BaseNtsc->Enable(!g_Conf->EnablePresets);
m_text_BasePal->Enable(!g_Conf->EnablePresets);
}
void Panels::FramelimiterPanel::Apply()
@ -247,6 +253,8 @@ void Panels::FrameSkipPanel::AppStatusEvent_OnSettingsApplied()
m_spin_FramesToDraw ->SetValue( gsconf.FramesToDraw );
m_spin_FramesToSkip ->SetValue( gsconf.FramesToSkip );
this->Enable(!g_Conf->EnablePresets);
}
void Panels::FrameSkipPanel::Apply()
@ -352,4 +360,7 @@ void Panels::VideoPanel::AppStatusEvent_OnSettingsApplied()
{
m_check_SynchronousGS->SetValue( g_Conf->EmuOptions.GS.SynchronousMTGS );
m_check_DisableOutput->SetValue( g_Conf->EmuOptions.GS.DisableOutput );
m_check_SynchronousGS->Enable(!g_Conf->EnablePresets);
m_check_DisableOutput->Enable(!g_Conf->EnablePresets);
}