Implemented plugin override command line options, and preliminary support for proper EmuConfig ApplySettings.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1793 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-09-09 02:48:54 +00:00
parent fd719d7571
commit a526e57848
7 changed files with 118 additions and 46 deletions

View File

@ -54,7 +54,7 @@ namespace Exception
virtual wxString FormatDisplayMessage() const; virtual wxString FormatDisplayMessage() const;
}; };
// Plugin load errors occur when initially trying to load plugins durign the // Plugin load errors occur when initially trying to load plugins during the
// creation of a PluginManager object. The error may either be due to non-existence, // creation of a PluginManager object. The error may either be due to non-existence,
// corruption, or incompatible versioning. // corruption, or incompatible versioning.
class PluginLoadError : public virtual PluginError, public virtual BadStream class PluginLoadError : public virtual PluginError, public virtual BadStream

View File

@ -225,6 +225,7 @@ public:
int OnExit(); int OnExit();
void OnInitCmdLine( wxCmdLineParser& parser ); void OnInitCmdLine( wxCmdLineParser& parser );
bool OnCmdLineParsed( wxCmdLineParser& parser ); bool OnCmdLineParsed( wxCmdLineParser& parser );
bool OnCmdLineError( wxCmdLineParser& parser );
bool PrepForExit(); bool PrepForExit();
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__

View File

@ -18,6 +18,7 @@
#include "CDVD/CDVDaccess.h" #include "CDVD/CDVDaccess.h"
class IniInterface; class IniInterface;
class wxFileConfig;
extern bool UseAdminMode; // dictates if the program uses /home/user or /cwd for the program data extern bool UseAdminMode; // dictates if the program uses /home/user or /cwd for the program data
@ -168,7 +169,13 @@ protected:
friend class Pcsx2App; friend class Pcsx2App;
}; };
class wxFileConfig; // forward declare. struct ConfigOverrides
{
AppConfig::FilenameOptions Filenames;
wxString SettingsFolder;
};
extern ConfigOverrides OverrideOptions;
extern wxFileConfig* OpenFileConfig( const wxString& filename ); extern wxFileConfig* OpenFileConfig( const wxString& filename );
extern void AppConfig_ReloadGlobalSettings( bool overwrite = false ); extern void AppConfig_ReloadGlobalSettings( bool overwrite = false );

View File

@ -365,7 +365,7 @@ void Panels::PluginSelectorPanel::OnConfigure_Clicked( wxCommandEvent& evt )
wxDynamicLibrary dynlib( (*m_FileList)[(int)m_ComponentBoxes.Get(pid).GetClientData(sel)] ); wxDynamicLibrary dynlib( (*m_FileList)[(int)m_ComponentBoxes.Get(pid).GetClientData(sel)] );
if( PluginConfigureFnptr configfunc = (PluginConfigureFnptr)dynlib.GetSymbol( tbl_PluginInfo[pid].GetShortname() + L"configure" ) ) if( PluginConfigureFnptr configfunc = (PluginConfigureFnptr)dynlib.GetSymbol( tbl_PluginInfo[pid].GetShortname() + L"configure" ) )
{ {
ScopedWindowDisable disabler( wxGetTopLevelParent( this ) ); //ScopedWindowDisable disabler( wxGetTopLevelParent( this ) );
configfunc(); configfunc();
} }
} }

View File

@ -51,7 +51,12 @@ void LoadPlugins()
const PluginInfo* pi = tbl_PluginInfo-1; const PluginInfo* pi = tbl_PluginInfo-1;
while( ++pi, pi->shortname != NULL ) while( ++pi, pi->shortname != NULL )
passins[pi->id] = g_Conf->FullpathTo( pi->id ); {
passins[pi->id] = OverrideOptions.Filenames[pi->id].GetFullPath();
if( passins[pi->id].IsEmpty() || !wxFileExists( passins[pi->id] ) )
passins[pi->id] = g_Conf->FullpathTo( pi->id );
}
g_plugins = PluginManager_Create( passins ); g_plugins = PluginManager_Create( passins );
} }

View File

@ -36,6 +36,7 @@ DEFINE_EVENT_TYPE( pxEVT_SemaphorePing )
bool UseAdminMode = false; bool UseAdminMode = false;
AppConfig* g_Conf = NULL; AppConfig* g_Conf = NULL;
ConfigOverrides OverrideOptions;
namespace Exception namespace Exception
{ {
@ -125,6 +126,23 @@ void AppEmuThread::StateCheck()
} }
} }
static bool HandlePluginError( Exception::PluginError& ex )
{
bool result = Msgbox::OkCancel( ex.FormatDisplayMessage() +
_("\n\nPress Ok to go to the Plugin Configuration Panel.") );
if( result )
{
g_Conf->SettingsTabName = L"Plugins";
wxGetApp().PostMenuAction( MenuId_Config_Settings );
wxGetApp().Ping();
// fixme: Send a message to the panel to select the failed plugin.
// fixme: handle case where user cancels the settings dialog. (should return FALSE).
}
return result;
}
sptr AppEmuThread::ExecuteTask() sptr AppEmuThread::ExecuteTask()
{ {
try try
@ -134,6 +152,7 @@ sptr AppEmuThread::ExecuteTask()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
catch( Exception::FileNotFound& ex ) catch( Exception::FileNotFound& ex )
{ {
GetPluginManager().Close();
if( ex.StreamName == g_Conf->FullpathToBios() ) if( ex.StreamName == g_Conf->FullpathToBios() )
{ {
GetPluginManager().Close(); GetPluginManager().Close();
@ -144,31 +163,19 @@ sptr AppEmuThread::ExecuteTask()
{ {
wxGetApp().PostMenuAction( MenuId_Config_BIOS ); wxGetApp().PostMenuAction( MenuId_Config_BIOS );
wxGetApp().Ping(); wxGetApp().Ping();
// fixme: handle case where user cancels the settings dialog. (should return FALSE).
// fixme: automatically re-try emu startup here...
} }
} }
else }
// ----------------------------------------------------------------------------
catch( Exception::PluginError& ex )
{
GetPluginManager().Close();
if( HandlePluginError( ex ) )
{ {
// Probably a plugin. Find out which one! // fixme: automatically re-try emu startup here...
const PluginInfo* pi = tbl_PluginInfo-1;
while( ++pi, pi->shortname != NULL )
{
const PluginsEnum_t pid = pi->id;
if( g_Conf->FullpathTo( pid ) == ex.StreamName ) break;
}
if( pi->shortname != NULL )
{
bool result = Msgbox::OkCancel( ex.FormatDisplayMessage() +
_("\n\nPress Ok to go to the Plugin Configuration Panel.") );
if( result )
{
g_Conf->SettingsTabName = L"Plugins";
wxGetApp().PostMenuAction( MenuId_Config_Settings );
wxGetApp().Ping();
}
}
} }
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -269,29 +276,43 @@ void Pcsx2App::ReadUserModeSettings()
void Pcsx2App::OnInitCmdLine( wxCmdLineParser& parser ) void Pcsx2App::OnInitCmdLine( wxCmdLineParser& parser )
{ {
parser.SetLogo( L" >> PCSX2 -- A Playstation2 Emulator for the PC\n"); parser.SetLogo( (wxString)L" >> PCSX2 -- A Playstation2 Emulator for the PC <<\n\n" +
_("All options are for the current session only and will not be saved.\n")
);
parser.AddParam( L"CDVD/ELF", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL ); parser.AddParam( _("IsoFile"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL );
parser.AddSwitch( L"h", L"help", L"displays this list of command line options", wxCMD_LINE_OPTION_HELP ); parser.AddSwitch( L"h", L"help", _("displays this list of command line options"), wxCMD_LINE_OPTION_HELP );
parser.AddSwitch( L"nogui", L"nogui", L"disables display of the gui and enables the Escape Hack." );
parser.AddOption( L"bootmode", wxEmptyString, L"0 - quick (default), 1 - bios, 2 - load elf", wxCMD_LINE_VAL_NUMBER ); parser.AddSwitch( wxEmptyString,L"nogui", _("disables display of the gui while running games") );
parser.AddOption( wxEmptyString,L"cfg", L"configuration file override", wxCMD_LINE_VAL_STRING ); parser.AddSwitch( wxEmptyString,L"skipbios",_("skips standard BIOS splash screens and software checks") );
parser.AddOption( wxEmptyString,L"elf", _("executes an ELF image"), wxCMD_LINE_VAL_STRING );
parser.AddSwitch( wxEmptyString,L"nodisc", _("boots an empty dvd tray; use to enter the PS2 system menu") );
parser.AddSwitch( wxEmptyString,L"usecd", _("boots from the configured CDVD plugin (ignores IsoFile parameter)") );
parser.AddSwitch( L"forcewiz", wxEmptyString, L"Forces PCSX2 to start the First-time Wizard" ); parser.AddOption( wxEmptyString,L"cfgpath", _("changes the configuration file path"), wxCMD_LINE_VAL_STRING );
parser.AddOption( wxEmptyString,L"cfg", _("specifies the PCSX2 configuration file to use [not implemented]"), wxCMD_LINE_VAL_STRING );
parser.AddOption( wxEmptyString, L"cdvd", L"specify the CDVD plugin for this session only." ); parser.AddSwitch( wxEmptyString,L"forcewiz",_("Forces PCSX2 to start the First-time Wizard") );
parser.AddOption( wxEmptyString, L"gs", L"specify the GS plugin for this session only." );
parser.AddOption( wxEmptyString, L"spu", L"specify the SPU2 plugin for this session only." ); const PluginInfo* pi = tbl_PluginInfo-1;
parser.AddOption( wxEmptyString, L"pad", L"specify the PAD plugin for this session only." ); while( ++pi, pi->shortname != NULL )
parser.AddOption( wxEmptyString, L"dev9", L"specify the DEV9 plugin for this session only." ); {
parser.AddOption( wxEmptyString, L"usb", L"specify the USB plugin for this session only." ); parser.AddOption( wxEmptyString, pi->GetShortname().Lower(),
wxsFormat( _("specify the file to use as the %s plugin"), pi->GetShortname().c_str() )
);
}
parser.SetSwitchChars( L"-" ); parser.SetSwitchChars( L"-" );
} }
bool Pcsx2App::OnCmdLineParsed(wxCmdLineParser& parser) bool Pcsx2App::OnCmdLineError( wxCmdLineParser& parser )
{
wxApp::OnCmdLineError( parser );
return false;
}
bool Pcsx2App::OnCmdLineParsed( wxCmdLineParser& parser )
{ {
if( parser.GetParamCount() >= 1 ) if( parser.GetParamCount() >= 1 )
{ {
@ -299,12 +320,37 @@ bool Pcsx2App::OnCmdLineParsed(wxCmdLineParser& parser)
parser.GetParam( 0 ); parser.GetParam( 0 );
} }
// Suppress wxWidgets automatic options parsing since none of them pertain to Pcsx2 needs. // Suppress wxWidgets automatic options parsing since none of them pertain to PCSX2 needs.
//wxApp::OnCmdLineParsed( parser ); //wxApp::OnCmdLineParsed( parser );
//bool yay = parser.Found(L"nogui"); //bool yay = parser.Found(L"nogui");
m_ForceWizard = parser.Found( L"forcewiz" ); m_ForceWizard = parser.Found( L"forcewiz" );
const PluginInfo* pi = tbl_PluginInfo-1;
while( ++pi, pi->shortname != NULL )
{
wxString dest;
if( !parser.Found( pi->GetShortname().Lower(), &dest ) ) continue;
OverrideOptions.Filenames.Plugins[pi->id] = dest;
if( wxFileExists( dest ) )
Console::Notice( pi->GetShortname() + L" override: " + dest );
else
{
bool result = Msgbox::OkCancel(
wxsFormat( _("Plugin Override Error! Specified %s plugin does not exist:\n\n"), pi->GetShortname().c_str() ) +
dest +
_("Press OK to use the default configured plugin, or Cancel to close."),
_("Plugin Override Error - PCSX2"), wxICON_ERROR
);
if( !result ) return false;
}
}
parser.Found( L"cfgpath", &OverrideOptions.SettingsFolder );
return true; return true;
} }
@ -314,7 +360,7 @@ typedef void (wxEvtHandler::*pxMessageBoxEventFunction)(pxMessageBoxEvent&);
bool Pcsx2App::OnInit() bool Pcsx2App::OnInit()
{ {
wxInitAllImageHandlers(); wxInitAllImageHandlers();
wxApp::OnInit(); if( !wxApp::OnInit() ) return false;
g_Conf = new AppConfig(); g_Conf = new AppConfig();
@ -365,13 +411,18 @@ bool Pcsx2App::OnInit()
ApplySettings(); ApplySettings();
InitPlugins(); InitPlugins();
} }
catch( Exception::StartupAborted& ) // ----------------------------------------------------------------------------
catch( Exception::StartupAborted& ex )
{ {
// Note: wx does not call OnExit() when returning false. Console::Notice( ex.FormatDiagnosticMessage() );
CleanupMess();
return false; return false;
} }
// ----------------------------------------------------------------------------
catch( Exception::PluginError& ex )
{
if( !HandlePluginError( ex ) )
return false;
}
return true; return true;
} }
@ -488,6 +539,9 @@ void Pcsx2App::ApplySettings()
g_Conf->Apply(); g_Conf->Apply();
if( m_MainFrame != NULL ) if( m_MainFrame != NULL )
m_MainFrame->ApplySettings(); m_MainFrame->ApplySettings();
if( g_EmuThread != NULL )
g_EmuThread->ApplySettings( g_Conf->EmuOptions );
} }
void Pcsx2App::LoadSettings() void Pcsx2App::LoadSettings()

View File

@ -263,8 +263,13 @@ void CoreEmuThread::Suspend( bool isBlocking )
// is determined by comparing the current settings against the new settings. // is determined by comparing the current settings against the new settings.
void CoreEmuThread::ApplySettings( const Pcsx2Config& src ) void CoreEmuThread::ApplySettings( const Pcsx2Config& src )
{ {
const bool isRunning = IsRunning();
Suspend();
m_resetRecompilers = ( src.Cpu != EmuConfig.Cpu ) || ( src.Gamefixes != EmuConfig.Gamefixes ) || ( src.Speedhacks != EmuConfig.Speedhacks ); m_resetRecompilers = ( src.Cpu != EmuConfig.Cpu ) || ( src.Gamefixes != EmuConfig.Gamefixes ) || ( src.Speedhacks != EmuConfig.Speedhacks );
m_resetProfilers = (src.Profiler != EmuConfig.Profiler ); m_resetProfilers = (src.Profiler != EmuConfig.Profiler );
EmuConfig = src; EmuConfig = src;
if( isRunning ) Resume();
} }