Bugfixes to the new pcsx2-vm / pcsx2-ui split ini system (WIP). Also fixed minor formatting errors in the intro wizard page.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4207 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2011-01-13 20:33:13 +00:00
parent 3b88defb36
commit a6a0197cb2
16 changed files with 127 additions and 87 deletions

View File

@ -394,9 +394,8 @@ void Pcsx2Config::Load( const wxString& srcfile )
{
//m_IsLoaded = true;
// Note: Extra parenthesis resolves "I think this is a function" issues with C++.
wxFileConfig cfg( srcfile );
IniLoader loader( (IniLoader( cfg )) );
IniLoader loader( cfg );
LoadSave( loader );
}
@ -405,6 +404,6 @@ void Pcsx2Config::Save( const wxString& dstfile )
//if( !m_IsLoaded ) return;
wxFileConfig cfg( dstfile );
IniSaver saver( (IniSaver( cfg )) );
IniSaver saver( cfg );
LoadSave( saver );
}

View File

@ -458,7 +458,8 @@ public:
void DispatchEvent( PluginEventType evt );
void DispatchEvent( AppEventType evt );
void DispatchEvent( CoreThreadStatus evt );
void DispatchEvent( IniInterface& ini );
void DispatchUiSettingsEvent( IniInterface& ini );
void DispatchVmSettingsEvent( IniInterface& ini );
// ----------------------------------------------------------------------------
protected:

View File

@ -285,18 +285,12 @@ namespace FilenameDefs
{
wxFileName GetUiConfig()
{
// FIXME? ini extension on Win32 is normal. Linux ini filename default might differ
// from this? like pcsx2_conf or something ... ? --air
return pxGetAppName() + L".ini";
return pxGetAppName() + L"_ui.ini";
}
wxFileName GetVmConfig()
{
// FIXME? ini extension on Win32 is normal. Linux ini filename default might differ
// from this? like pcsx2_conf or something ... ? --air
return pxGetAppName() + L".ini";
return pxGetAppName() + L"_vm.ini";
}
wxFileName GetUsermodeConfig()
@ -437,6 +431,18 @@ void App_LoadSaveInstallSettings( IniInterface& ini )
ini.Flush();
}
void App_LoadInstallSettings( wxConfigBase* ini )
{
IniLoader loader( ini );
App_LoadSaveInstallSettings( loader );
}
void App_SaveInstallSettings( wxConfigBase* ini )
{
IniSaver saver( ini );
App_LoadSaveInstallSettings( saver );
}
// ------------------------------------------------------------------------
void AppConfig::LoadSaveMemcards( IniInterface& ini )
{
@ -962,11 +968,8 @@ AppIniLoader::AppIniLoader()
{
}
void AppLoadSettings()
static void LoadUiSettings()
{
if( wxGetApp().Rpc_TryInvoke(AppLoadSettings) ) return;
AppIniLoader loader;
ConLog_LoadSaveSettings( loader );
SysTraceLog_LoadSaveSettings( loader );
@ -977,21 +980,56 @@ void AppLoadSettings()
if( !wxFile::Exists( g_Conf->CurrentIso ) )
g_Conf->CurrentIso.clear();
sApp.DispatchUiSettingsEvent( loader );
}
static void LoadVmSettings()
{
// Load virtual machine options and apply some defaults overtop saved items, which
// are regulated by the PCSX2 UI.
{
ScopedPtr<wxFileConfig> vmini( OpenFileConfig( GetVmSettingsFilename() ) );
IniLoader vmloader( vmini );
g_Conf->EmuOptions.LoadSave( vmloader );
g_Conf->EmuOptions.GS.LimitScalar = g_Conf->Framerate.NominalScalar;
ScopedPtr<wxFileConfig> vmini( OpenFileConfig( GetVmSettingsFilename() ) );
IniLoader vmloader( vmini );
g_Conf->EmuOptions.LoadSave( vmloader );
g_Conf->EmuOptions.GS.LimitScalar = g_Conf->Framerate.NominalScalar;
if (g_Conf->EnablePresets){
g_Conf->IsOkApplyPreset(g_Conf->PresetIndex);
}
if (g_Conf->EnablePresets){
g_Conf->IsOkApplyPreset(g_Conf->PresetIndex);
}
sApp.DispatchEvent( loader );
sApp.DispatchVmSettingsEvent( vmloader );
}
void AppLoadSettings()
{
if( wxGetApp().Rpc_TryInvoke(AppLoadSettings) ) return;
LoadUiSettings();
LoadVmSettings();
}
static void SaveUiSettings()
{
if( !wxFile::Exists( g_Conf->CurrentIso ) )
g_Conf->CurrentIso.clear();
sApp.GetRecentIsoManager().Add( g_Conf->CurrentIso );
AppIniSaver saver;
g_Conf->LoadSave( saver );
ConLog_LoadSaveSettings( saver );
SysTraceLog_LoadSaveSettings( saver );
sApp.DispatchUiSettingsEvent( saver );
}
static void SaveVmSettings()
{
ScopedPtr<wxFileConfig> vmini( OpenFileConfig( GetVmSettingsFilename() ) );
IniSaver vmsaver( vmini );
g_Conf->EmuOptions.LoadSave( vmsaver );
sApp.DispatchVmSettingsEvent( vmsaver );
}
void AppSaveSettings()
@ -1009,29 +1047,13 @@ void AppSaveSettings()
return;
}
if( !wxFile::Exists( g_Conf->CurrentIso ) )
g_Conf->CurrentIso.clear();
sApp.GetRecentIsoManager().Add( g_Conf->CurrentIso );
SaveUiSettings();
SaveVmSettings();
AtomicExchange( isPosted, false );
AppIniSaver saver;
g_Conf->LoadSave( saver );
ConLog_LoadSaveSettings( saver );
SysTraceLog_LoadSaveSettings( saver );
// Save virtual machine items.
{
ScopedPtr<wxFileConfig> vmini( OpenFileConfig( GetVmSettingsFilename() ) );
IniSaver vmsaver( vmini );
g_Conf->EmuOptions.LoadSave( vmsaver );
}
sApp.DispatchEvent( saver );
}
// Returns the current application configuration file. This is preferred over using
// wxConfigBase::GetAppConfig(), since it defaults to *not* creating a config file
// automatically (which is typically highly undesired behavior in our system)

View File

@ -298,6 +298,8 @@ extern void AppSaveSettings();
extern void AppApplySettings( const AppConfig* oldconf=NULL );
extern void App_LoadSaveInstallSettings( IniInterface& ini );
extern void App_SaveInstallSettings( wxConfigBase* ini );
extern void App_LoadInstallSettings( wxConfigBase* ini );
extern void ConLog_LoadSaveSettings( IniInterface& ini );
extern void SysTraceLog_LoadSaveSettings( IniInterface& ini );

View File

@ -30,8 +30,11 @@ enum CoreThreadStatus
enum AppEventType
{
AppStatus_SettingsLoaded,
AppStatus_SettingsSaved,
AppStatus_UiSettingsLoaded,
AppStatus_UiSettingsSaved,
AppStatus_VmSettingsLoaded,
AppStatus_VmSettingsSaved,
AppStatus_SettingsApplied,
AppStatus_Exiting
};
@ -41,9 +44,9 @@ enum PluginEventType
CorePlugins_Loaded,
CorePlugins_Init,
CorePlugins_Opening, // dispatched prior to plugins being opened
CorePlugins_Opened, // dispatched after plugins are opened
CorePlugins_Opened, // dispatched after plugins are opened
CorePlugins_Closing, // dispatched prior to plugins being closed
CorePlugins_Closed, // dispatched after plugins are closed
CorePlugins_Closed, // dispatched after plugins are closed
CorePlugins_Shutdown,
CorePlugins_Unloaded,
};
@ -62,7 +65,7 @@ struct AppSettingsEventInfo : AppEventInfo
{
IniInterface& m_ini;
AppSettingsEventInfo( IniInterface& ini );
AppSettingsEventInfo( IniInterface& ini, AppEventType evt_type );
IniInterface& GetIni() const
{
@ -143,7 +146,9 @@ public:
virtual void DispatchEvent( const AppEventInfo& evtinfo );
protected:
virtual void AppStatusEvent_OnSettingsLoadSave( const AppSettingsEventInfo& evtinfo ) {}
virtual void AppStatusEvent_OnUiSettingsLoadSave( const AppSettingsEventInfo& evtinfo ) {}
virtual void AppStatusEvent_OnVmSettingsLoadSave( const AppSettingsEventInfo& evtinfo ) {}
virtual void AppStatusEvent_OnSettingsApplied() {}
virtual void AppStatusEvent_OnExit() {}
};
@ -189,7 +194,7 @@ public:
virtual ~EventListenerHelper_CoreThread() throw() {}
protected:
void OnCoreThread_Indeterminate() { Owner.OnCoreThread_Indeterminate(); }
void CoreThread_OnIndeterminate() { Owner.OnCoreThread_Indeterminate(); }
void CoreThread_OnStarted() { Owner.OnCoreThread_Started(); }
void CoreThread_OnResumed() { Owner.OnCoreThread_Resumed(); }
void CoreThread_OnSuspended() { Owner.OnCoreThread_Suspended(); }
@ -245,7 +250,8 @@ public:
virtual ~EventListenerHelper_AppStatus() throw() {}
protected:
virtual void AppStatusEvent_OnSettingsLoadSave( const AppSettingsEventInfo& evtinfo ) { Owner.AppStatusEvent_OnSettingsLoadSave( evtinfo ); }
virtual void AppStatusEvent_OnUiSettingsLoadSave( const AppSettingsEventInfo& evtinfo ) { Owner.AppStatusEvent_OnUiSettingsLoadSave( evtinfo ); }
virtual void AppStatusEvent_OnVmSettingsLoadSave( const AppSettingsEventInfo& evtinfo ) { Owner.AppStatusEvent_OnVmSettingsLoadSave( evtinfo ); }
virtual void AppStatusEvent_OnSettingsApplied() { Owner.AppStatusEvent_OnSettingsApplied(); }
virtual void AppStatusEvent_OnExit() { Owner.AppStatusEvent_OnExit(); }
};

View File

@ -22,8 +22,8 @@ template class EventSource< IEventListener_CoreThread >;
template class EventSource< IEventListener_Plugins >;
template class EventSource< IEventListener_AppStatus >;
AppSettingsEventInfo::AppSettingsEventInfo( IniInterface& ini )
: AppEventInfo( ini.IsSaving() ? AppStatus_SettingsSaved : AppStatus_SettingsLoaded )
AppSettingsEventInfo::AppSettingsEventInfo( IniInterface& ini, AppEventType evt_type )
: AppEventInfo( evt_type )
, m_ini( ini )
{
}
@ -95,13 +95,24 @@ void IEventListener_AppStatus::DispatchEvent( const AppEventInfo& evtinfo )
{
switch( evtinfo.evt_type )
{
case AppStatus_SettingsLoaded:
case AppStatus_SettingsSaved:
AppStatusEvent_OnSettingsLoadSave( (const AppSettingsEventInfo&)evtinfo );
case AppStatus_UiSettingsLoaded:
case AppStatus_UiSettingsSaved:
AppStatusEvent_OnUiSettingsLoadSave( (const AppSettingsEventInfo&)evtinfo );
break;
case AppStatus_SettingsApplied: AppStatusEvent_OnSettingsApplied(); break;
case AppStatus_Exiting: AppStatusEvent_OnExit(); break;
case AppStatus_VmSettingsLoaded:
case AppStatus_VmSettingsSaved:
AppStatusEvent_OnVmSettingsLoadSave( (const AppSettingsEventInfo&)evtinfo );
break;
case AppStatus_SettingsApplied:
AppStatusEvent_OnSettingsApplied();
break;
case AppStatus_Exiting:
AppStatusEvent_OnExit();
break;
}
}
@ -146,10 +157,16 @@ void Pcsx2App::DispatchEvent( CoreThreadStatus evt )
CoreThread.RethrowException();
}
void Pcsx2App::DispatchEvent( IniInterface& ini )
void Pcsx2App::DispatchUiSettingsEvent( IniInterface& ini )
{
if( !AffinityAssert_AllowFrom_MainUI() ) return;
m_evtsrc_AppStatus.Dispatch( AppSettingsEventInfo( ini ) );
m_evtsrc_AppStatus.Dispatch( AppSettingsEventInfo( ini, ini.IsSaving() ? AppStatus_UiSettingsSaved : AppStatus_UiSettingsLoaded ) );
}
void Pcsx2App::DispatchVmSettingsEvent( IniInterface& ini )
{
if( !AffinityAssert_AllowFrom_MainUI() ) return;
m_evtsrc_AppStatus.Dispatch( AppSettingsEventInfo( ini, ini.IsSaving() ? AppStatus_VmSettingsSaved : AppStatus_VmSettingsLoaded ) );
}

View File

@ -613,7 +613,7 @@ void Pcsx2App::CleanupOnExit()
void Pcsx2App::CleanupResources()
{
ScopedBusyCursor cursor( Cursor_ReallyBusy );
delete wxConfigBase::Set( NULL );
//delete wxConfigBase::Set( NULL );
while( wxGetLocale() != NULL )
delete wxGetLocale();

View File

@ -317,16 +317,14 @@ void Pcsx2App::EstablishAppUserMode()
bool runWiz;
conf_install->Read( L"RunWizard", &runWiz, true );
IniLoader loader( conf_install );
App_LoadSaveInstallSettings( loader );
App_LoadInstallSettings( conf_install );
if( !Startup.ForceWizard && !runWiz ) return;
DoFirstTimeWizard();
// Save user's new settings
IniSaver saver( *conf_install );
App_LoadSaveInstallSettings( saver );
App_SaveInstallSettings( conf_install );
AppConfig_OnChangedSettingsFolder( true );
AppSaveSettings();

View File

@ -139,7 +139,7 @@ protected:
// be called after a failed Apply (canceled due to error).
virtual void AppStatusEvent_OnSettingsApplied() {}
virtual void AppStatusEvent_OnSettingsLoadSave( const AppSettingsEventInfo& ) {}
virtual void AppStatusEvent_OnUiSettingsLoadSave( const AppSettingsEventInfo& ) {}
virtual void AppStatusEvent_OnExit() {}
};
@ -187,14 +187,15 @@ public:
void Init();
// Mandatory override: As a rule for proper interface design, all deriving classes need
// to implement this function. There's no implementation of an options/settings panel
// that does not heed the changes of application status/settings changes. ;)
// to implement this OnSettingsApplied function. There's no implementation of an options/
// settings panel that does not heed the changes of application status/settings changes. ;)
//
// Note: This method *will* be called automatically after a successful Apply, but will not
// be called after a failed Apply (canceled due to error).
virtual void AppStatusEvent_OnSettingsApplied()=0;
virtual void AppStatusEvent_OnSettingsLoadSave( const AppSettingsEventInfo& ) {}
virtual void AppStatusEvent_OnUiSettingsLoadSave( const AppSettingsEventInfo& ) {}
virtual void AppStatusEvent_OnVmSettingsLoadSave( const AppSettingsEventInfo& ) {}
virtual void AppStatusEvent_OnExit() {}
protected:

View File

@ -74,7 +74,8 @@ void BaseApplicableDialog::Init()
void BaseApplicableDialog::OnSettingsApplied( wxCommandEvent& evt )
{
evt.Skip();
if( evt.GetId() == GetId() ) AppStatusEvent_OnSettingsApplied();
if( evt.GetId() == GetId() )
AppStatusEvent_OnSettingsApplied();
}

View File

@ -71,7 +71,7 @@ namespace Panels
Panels::FirstTimeIntroPanel::FirstTimeIntroPanel( wxWindow* parent )
: wxPanelWithHelpers( parent, wxVERTICAL )
{
SetMinWidth( 640 );
SetMinWidth( 600 );
FastFormatUnicode faqFile;
faqFile.Write( L"file:///%s/Docs/PCSX2 FAQ %u.%u.%u.pdf",
@ -81,9 +81,10 @@ Panels::FirstTimeIntroPanel::FirstTimeIntroPanel( wxWindow* parent )
wxStaticBoxSizer& langSel = *new wxStaticBoxSizer( wxVERTICAL, this, _("Language selector") );
langSel += new Panels::LanguageSelectionPanel( this ) | StdCenter();
langSel += Label(_("Change this only if you need to.\nThe system default should be fine for most operating systems."));
langSel += Heading(_("Change the language only if you need to.\nThe system default should be fine for most operating systems."));
langSel += 8;
*this += langSel | StdCenter();
*this += langSel | StdExpand();
*this += GetCharHeight() * 2;
*this += Heading(AddAppName(L"Welcome to %s!")).Bold();
@ -101,11 +102,11 @@ Panels::FirstTimeIntroPanel::FirstTimeIntroPanel( wxWindow* parent )
*this += new wxHyperlinkCtrl( this, wxID_ANY,
_("Configuration Guides (online)"), L"http://www.pcsx2.net/guide.php"
) | pxProportion(1).Center().Border( wxALL, 5 );
) | pxCenter.Border( wxALL, 5 );
*this += new wxHyperlinkCtrl( this, wxID_ANY,
_("Readme / FAQ (Offline/PDF)"), faqFile.c_str()
) | pxProportion(1).Center().Border( wxALL, 5 );
) | pxCenter.Border( wxALL, 5 );
}

View File

@ -274,11 +274,6 @@ void MainEmuFrame::DispatchEvent( const CoreThreadStatus& status )
ApplyCoreStatus();
}
void MainEmuFrame::AppStatusEvent_OnSettingsLoadSave()
{
// nothing to do here right now.
}
void MainEmuFrame::AppStatusEvent_OnSettingsApplied()
{
ApplySettings();

View File

@ -132,7 +132,6 @@ protected:
virtual void DispatchEvent( const PluginEventType& plugin_evt );
virtual void DispatchEvent( const CoreThreadStatus& status );
virtual void AppStatusEvent_OnSettingsLoadSave();
virtual void AppStatusEvent_OnSettingsApplied();
public:

View File

@ -439,8 +439,6 @@ Panels::PluginSelectorPanel::PluginSelectorPanel( wxWindow* parent )
Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( PluginSelectorPanel::OnPluginSelected ) );
Connect( ButtonId_Configure, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PluginSelectorPanel::OnConfigure_Clicked ) );
AppStatusEvent_OnSettingsApplied();
}
Panels::PluginSelectorPanel::~PluginSelectorPanel() throw()
@ -455,7 +453,7 @@ void Panels::PluginSelectorPanel::AppStatusEvent_OnSettingsApplied()
static wxString GetApplyFailedMsg()
{
return wxsFormat( pxE( "!Notice:PluginSelector:ApplyFailed",
return pxsFmt( pxE( "!Notice:PluginSelector:ApplyFailed",
L"All plugins must have valid selections for %s to run. If you are unable to make "
L"a valid selection due to missing plugins or an incomplete install of %s, then "
L"press cancel to close the Configuration panel."

View File

@ -186,7 +186,7 @@ void RecentIsoManager::AppStatusEvent_OnSettingsApplied()
// TODO : Implement application of Recent Iso List "maximum" history option
}
void RecentIsoManager::AppStatusEvent_OnSettingsLoadSave( const AppSettingsEventInfo& evt )
void RecentIsoManager::AppStatusEvent_OnUiSettingsLoadSave( const AppSettingsEventInfo& evt )
{
IniInterface& ini( evt.GetIni() );

View File

@ -60,7 +60,7 @@ protected:
void OnChangedSelection( wxCommandEvent& evt );
void LoadListFrom( IniInterface& ini );
void AppStatusEvent_OnSettingsLoadSave( const AppSettingsEventInfo& ini );
void AppStatusEvent_OnUiSettingsLoadSave( const AppSettingsEventInfo& ini );
void AppStatusEvent_OnSettingsApplied();
};