2010-06-07 02:23:58 +00:00
|
|
|
#include "stdafx.h"
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
CPlugins::CPlugins (const stdstr & PluginDir):
|
|
|
|
m_PluginDir(PluginDir),
|
2012-11-02 23:28:09 +00:00
|
|
|
m_Gfx(NULL), m_Audio(NULL), m_RSP(NULL), m_Control(NULL),
|
|
|
|
m_RenderWindow(NULL), m_DummyWindow(NULL)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
CreatePlugins();
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->RegisterChangeCB(Plugin_RSP_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Plugin_GFX_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Plugin_AUDIO_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Plugin_CONT_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Plugin_UseHleGfx,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Plugin_UseHleAudio,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Game_EditPlugin_Gfx,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Game_EditPlugin_Audio,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Game_EditPlugin_Contr,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Game_EditPlugin_RSP,this,(CSettings::SettingChangedFunc)PluginChanged);
|
2010-06-07 02:23:58 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CPlugins::~CPlugins (void) {
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->UnregisterChangeCB(Plugin_RSP_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Plugin_GFX_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Plugin_AUDIO_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Plugin_CONT_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Plugin_UseHleGfx,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Plugin_UseHleAudio,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Game_EditPlugin_Gfx,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Game_EditPlugin_Audio,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Game_EditPlugin_Contr,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Game_EditPlugin_RSP,this,(CSettings::SettingChangedFunc)PluginChanged);
|
2008-09-18 03:15:49 +00:00
|
|
|
ShutDownPlugins();
|
|
|
|
}
|
|
|
|
|
2010-06-07 02:23:58 +00:00
|
|
|
void CPlugins::PluginChanged ( CPlugins * _this )
|
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
bool bGfxChange = _stricmp(_this->m_GfxFile.c_str(),g_Settings->LoadString(Game_Plugin_Gfx).c_str()) != 0;
|
|
|
|
bool bAudioChange = _stricmp(_this->m_AudioFile.c_str(),g_Settings->LoadString(Game_Plugin_Audio).c_str()) != 0;
|
|
|
|
bool bRspChange = _stricmp(_this->m_RSPFile.c_str(),g_Settings->LoadString(Game_Plugin_RSP).c_str()) != 0;
|
|
|
|
bool bContChange = _stricmp(_this->m_ControlFile.c_str(),g_Settings->LoadString(Game_Plugin_Controller).c_str()) != 0;
|
2010-06-07 02:23:58 +00:00
|
|
|
|
|
|
|
if ( bGfxChange || bAudioChange || bRspChange || bContChange )
|
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
if (g_Settings->LoadBool(GameRunning_CPU_Running) != 0)
|
2010-06-07 02:23:58 +00:00
|
|
|
{
|
2010-06-12 02:02:06 +00:00
|
|
|
if (_BaseSystem) { _BaseSystem->ExternalEvent(SysEvent_ChangePlugins); }
|
2010-06-07 02:23:58 +00:00
|
|
|
} else {
|
|
|
|
_this->Reset();
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->RefreshMenu();
|
2010-06-07 02:23:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
void CPlugins::CreatePlugins( void ) {
|
|
|
|
Reset(PLUGIN_TYPE_GFX);
|
|
|
|
Reset(PLUGIN_TYPE_AUDIO);
|
|
|
|
Reset(PLUGIN_TYPE_RSP);
|
|
|
|
Reset(PLUGIN_TYPE_CONTROLLER);
|
|
|
|
|
2012-09-28 20:07:45 +00:00
|
|
|
if (bHaveDebugger())
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->RefreshMenu();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlugins::GameReset ( void )
|
|
|
|
{
|
|
|
|
if (m_Gfx) {
|
|
|
|
m_Gfx->GameReset();
|
|
|
|
}
|
|
|
|
if (m_Audio) {
|
|
|
|
m_Audio->GameReset();
|
|
|
|
}
|
|
|
|
if (m_RSP) {
|
|
|
|
m_RSP->GameReset();
|
|
|
|
}
|
|
|
|
if (m_Control) {
|
|
|
|
m_Control->GameReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
void CPlugins::ShutDownPlugins( void ) {
|
|
|
|
if (m_Gfx) {
|
|
|
|
WriteTrace(TraceGfxPlugin,"Close: Starting");
|
|
|
|
m_Gfx->Close();
|
|
|
|
WriteTrace(TraceGfxPlugin,"Close: Done");
|
|
|
|
WriteTrace(TraceGfxPlugin,"deconstructor: Starting");
|
|
|
|
delete m_Gfx;
|
|
|
|
WriteTrace(TraceGfxPlugin,"deconstructor: Done");
|
|
|
|
m_Gfx = NULL;
|
2012-11-17 01:02:04 +00:00
|
|
|
// g_Settings->UnknownSetting_GFX = NULL;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
if (m_Audio) {
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 5");
|
|
|
|
m_Audio->Close();
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 6");
|
|
|
|
delete m_Audio;
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 7");
|
|
|
|
m_Audio = NULL;
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 8");
|
2012-11-17 01:02:04 +00:00
|
|
|
// g_Settings->UnknownSetting_AUDIO = NULL;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
if (m_RSP) {
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 9");
|
|
|
|
m_RSP->Close();
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 10");
|
|
|
|
delete m_RSP;
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 11");
|
|
|
|
m_RSP = NULL;
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 12");
|
2012-11-17 01:02:04 +00:00
|
|
|
// g_Settings->UnknownSetting_RSP = NULL;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
if (m_Control) {
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 12");
|
|
|
|
m_Control->Close();
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 13");
|
|
|
|
delete m_Control;
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 14");
|
|
|
|
m_Control = NULL;
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::ShutDownPlugins 15");
|
2012-11-17 01:02:04 +00:00
|
|
|
// g_Settings->UnknownSetting_CTRL = NULL;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-02 23:28:09 +00:00
|
|
|
void CPlugins::SetRenderWindows( CMainGui * RenderWindow, CMainGui * DummyWindow )
|
|
|
|
{
|
|
|
|
m_RenderWindow = RenderWindow;
|
|
|
|
m_DummyWindow = DummyWindow;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
bool CPlugins::Initiate ( void )
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2012-11-02 23:28:09 +00:00
|
|
|
bool bResult = m_RenderWindow->InitiatePlugins();
|
2008-09-18 03:15:49 +00:00
|
|
|
if (bResult)
|
|
|
|
{
|
|
|
|
m_Gfx->RomOpened();
|
|
|
|
m_Audio->RomOpened();
|
|
|
|
m_Control->RomOpened();
|
|
|
|
}
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
bool CPlugins::InitiateMainThread( void )
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::Initiate 1");
|
|
|
|
//Check to make sure we have the plugin avaliable to be used
|
|
|
|
if (m_Gfx == NULL) { return false; }
|
|
|
|
if (m_Audio == NULL) { return false; }
|
|
|
|
if (m_RSP == NULL) { return false; }
|
|
|
|
if (m_Control == NULL) { return false; }
|
|
|
|
|
|
|
|
WriteTrace(TraceGfxPlugin,"Close: Starting");
|
|
|
|
m_Gfx->Close();
|
|
|
|
WriteTrace(TraceGfxPlugin,"Close: Done");
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::Initiate 3");
|
|
|
|
m_Audio->Close();
|
|
|
|
WriteTrace(TraceRSP,"Close: Starting");
|
|
|
|
m_RSP->Close();
|
|
|
|
WriteTrace(TraceRSP,"Close: Done");
|
|
|
|
m_Control->Close();
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::Initiate 6");
|
|
|
|
|
|
|
|
WriteTrace(TraceGfxPlugin,"Initiate: Starting");
|
2012-11-17 01:07:04 +00:00
|
|
|
if (!m_Gfx->Initiate(g_System,m_RenderWindow)) { return false; }
|
2008-09-18 03:15:49 +00:00
|
|
|
WriteTrace(TraceGfxPlugin,"Initiate: Done");
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::Initiate 7");
|
2012-11-17 01:07:04 +00:00
|
|
|
if (!m_Audio->Initiate(g_System,m_RenderWindow)) { return false; }
|
2008-09-18 03:15:49 +00:00
|
|
|
WriteTrace(TraceDebug,"CPlugins::Initiate 8");
|
2012-11-17 01:07:04 +00:00
|
|
|
if (!m_Control->Initiate(g_System,m_RenderWindow)) { return false; }
|
2008-09-18 03:15:49 +00:00
|
|
|
WriteTrace(TraceRSP ,"Initiate: Starting");
|
2012-11-17 01:07:04 +00:00
|
|
|
if (!m_RSP->Initiate(this,g_System)) { return false; }
|
2008-09-18 03:15:49 +00:00
|
|
|
WriteTrace(TraceRSP,"Initiate: Done");
|
|
|
|
WriteTrace(TraceDebug,"CPlugins::Initiate 10");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlugins::Reset ( void ) {
|
|
|
|
ShutDownPlugins();
|
|
|
|
CreatePlugins();
|
|
|
|
}
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
void CPlugins::Reset ( PLUGIN_TYPE Type )
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
switch (Type)
|
|
|
|
{
|
|
|
|
case PLUGIN_TYPE_RSP:
|
|
|
|
if (m_RSP)
|
|
|
|
{
|
|
|
|
WriteTrace(TraceRSP,"Close: Starting");
|
|
|
|
m_RSP->Close();
|
|
|
|
WriteTrace(TraceRSP,"Close: Done");
|
|
|
|
WriteTrace(TraceRSP,"deconstructor: Starting");
|
|
|
|
delete m_RSP;
|
|
|
|
WriteTrace(TraceRSP,"deconstructor: Done");
|
|
|
|
m_RSP = NULL;
|
|
|
|
}
|
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
m_RSPFile = g_Settings->LoadString(Plugin_RSP_Current);
|
2010-06-29 02:11:22 +00:00
|
|
|
CPath RspPluginFile(m_PluginDir.c_str(),m_RSPFile.c_str());
|
|
|
|
WriteTraceF(TraceRSP,"Loading (%s): Starting",(LPCTSTR)RspPluginFile);
|
|
|
|
m_RSP = new CRSP_Plugin(RspPluginFile);
|
2008-09-18 03:15:49 +00:00
|
|
|
WriteTrace(TraceRSP,"Loading Done");
|
|
|
|
|
|
|
|
}
|
|
|
|
WriteTraceF(TraceRSP,"Current Ver: %s",m_RSP->PluginName().c_str());
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveString(Plugin_RSP_CurVer,m_RSP->PluginName().c_str());
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
//Enable debugger
|
|
|
|
if (m_RSP->EnableDebugging)
|
|
|
|
{
|
|
|
|
WriteTrace(TraceRSP,"EnableDebugging: starting");
|
2012-09-28 20:07:45 +00:00
|
|
|
m_RSP->EnableDebugging(bHaveDebugger());
|
2008-09-18 03:15:49 +00:00
|
|
|
WriteTrace(TraceRSP,"EnableDebugging: done");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_GFX:
|
|
|
|
if (m_Gfx)
|
|
|
|
{
|
|
|
|
WriteTrace(TraceGfxPlugin,"Close: Starting");
|
|
|
|
m_Gfx->Close();
|
|
|
|
WriteTrace(TraceGfxPlugin,"Close: Done");
|
|
|
|
WriteTrace(TraceGfxPlugin,"deconstructor: Starting");
|
|
|
|
delete m_Gfx;
|
|
|
|
WriteTrace(TraceGfxPlugin,"deconstructor: Done");
|
|
|
|
m_Gfx = NULL;
|
|
|
|
}
|
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
m_GfxFile = g_Settings->LoadString(Game_Plugin_Gfx);
|
2010-06-29 02:11:22 +00:00
|
|
|
CPath GfxPluginFile(m_PluginDir.c_str(),m_GfxFile.c_str());
|
|
|
|
WriteTraceF(TraceGfxPlugin,"Loading (%s): Starting",(LPCTSTR)GfxPluginFile);
|
|
|
|
m_Gfx = new CGfxPlugin(GfxPluginFile);
|
2008-09-18 03:15:49 +00:00
|
|
|
WriteTrace(TraceGfxPlugin,"Loading Done");
|
|
|
|
}
|
|
|
|
WriteTraceF(TraceGfxPlugin,"Current Ver: %s",m_Gfx->PluginName().c_str());
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveString(Plugin_GFX_CurVer,m_Gfx->PluginName().c_str());
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_AUDIO:
|
|
|
|
if (m_Audio) {
|
2008-11-17 10:02:22 +00:00
|
|
|
WriteTrace(TraceDebug,"Audio Plugin: Close Starting");
|
2008-09-18 03:15:49 +00:00
|
|
|
m_Audio->Close();
|
2008-11-17 10:02:22 +00:00
|
|
|
WriteTrace(TraceDebug,"Audio Plugin: Close done");
|
|
|
|
WriteTrace(TraceDebug,"Audio Plugin: Deconstructor Starting");
|
2008-09-18 03:15:49 +00:00
|
|
|
delete m_Audio;
|
2008-11-17 10:02:22 +00:00
|
|
|
WriteTrace(TraceDebug,"Audio Plugin: Deconstructor Done");
|
2008-09-18 03:15:49 +00:00
|
|
|
m_Audio = NULL;
|
|
|
|
}
|
2008-11-17 10:02:22 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
m_AudioFile = g_Settings->LoadString(Game_Plugin_Audio);
|
2010-06-29 02:11:22 +00:00
|
|
|
CPath PluginFile(m_PluginDir.c_str(),m_AudioFile.c_str());
|
|
|
|
WriteTraceF(TraceDebug,"Loading (%s): Starting",(LPCTSTR)PluginFile);
|
|
|
|
m_Audio = new CAudioPlugin(PluginFile);
|
2008-11-17 10:02:22 +00:00
|
|
|
WriteTrace(TraceDebug,"Loading Done");
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveString(Plugin_AUDIO_CurVer,m_Audio->PluginName().c_str());
|
2008-11-17 10:02:22 +00:00
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_CONTROLLER:
|
|
|
|
if (m_Control) {
|
2008-11-17 10:02:22 +00:00
|
|
|
WriteTrace(TraceDebug,"Controller Plugin: Close Starting");
|
2008-09-18 03:15:49 +00:00
|
|
|
m_Control->Close();
|
2008-11-17 10:02:22 +00:00
|
|
|
WriteTrace(TraceDebug,"Controller Plugin: Close done");
|
|
|
|
WriteTrace(TraceDebug,"Controller Plugin: Deconstructor Starting");
|
2008-09-18 03:15:49 +00:00
|
|
|
delete m_Control;
|
2008-11-17 10:02:22 +00:00
|
|
|
WriteTrace(TraceDebug,"Controller Plugin: Deconstructor Done");
|
2008-09-18 03:15:49 +00:00
|
|
|
m_Control = NULL;
|
|
|
|
}
|
2008-11-17 10:02:22 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
m_ControlFile = g_Settings->LoadString(Game_Plugin_Controller);
|
2010-06-29 02:11:22 +00:00
|
|
|
CPath PluginFile(m_PluginDir.c_str(),m_ControlFile.c_str());
|
|
|
|
WriteTraceF(TraceDebug,"Loading (%s): Starting",(LPCTSTR)PluginFile);
|
|
|
|
m_Control = new CControl_Plugin(PluginFile);
|
2008-11-17 10:02:22 +00:00
|
|
|
WriteTrace(TraceDebug,"Loading Done");
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveString(Plugin_CONT_CurVer,m_Control->PluginName().c_str());
|
2008-11-17 10:02:22 +00:00
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) {
|
|
|
|
switch (Type) {
|
|
|
|
case PLUGIN_TYPE_RSP:
|
|
|
|
if (m_RSP == NULL || m_RSP->Config == NULL) { break; }
|
|
|
|
if (!m_RSP->Initilized()) {
|
|
|
|
if (!m_RSP->Initiate(NULL,NULL)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_RSP->Config(hParent);
|
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_GFX:
|
|
|
|
if (m_Gfx == NULL || m_Gfx->Config == NULL) { break; }
|
|
|
|
if (!m_Gfx->Initilized()) {
|
2012-11-02 23:28:09 +00:00
|
|
|
if (!m_Gfx->Initiate(NULL,m_DummyWindow)) {
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_Gfx->Config(hParent);
|
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_AUDIO:
|
|
|
|
if (m_Audio == NULL || m_Audio->Config == NULL) { break; }
|
|
|
|
if (!m_Audio->Initilized()) {
|
2012-11-02 23:28:09 +00:00
|
|
|
if (!m_Audio->Initiate(NULL,m_DummyWindow)) {
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_Audio->Config(hParent);
|
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_CONTROLLER:
|
|
|
|
if (m_Control == NULL || m_Control->Config == NULL) { break; }
|
|
|
|
if (!m_Control->Initilized()) {
|
2012-11-02 23:28:09 +00:00
|
|
|
if (!m_Control->Initiate(NULL,m_DummyWindow)) {
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_Control->Config(hParent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DummyCheckInterrupts ( void ) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void DummyFunction (void) {
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
void CPlugins::CreatePluginDir ( const stdstr & DstDir ) const {
|
|
|
|
char path_buffer[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR],
|
|
|
|
fname[_MAX_FNAME], ext[_MAX_EXT];
|
|
|
|
_splitpath(DstDir.c_str(), drive, dir, fname, ext );
|
|
|
|
_makepath(path_buffer, drive, dir, "", "" );
|
|
|
|
if (CreateDirectory(path_buffer,NULL) == 0 && GetLastError() == ERROR_PATH_NOT_FOUND)
|
|
|
|
{
|
|
|
|
path_buffer[strlen(path_buffer) - 1] = 0;
|
|
|
|
CreatePluginDir(stdstr(path_buffer));
|
|
|
|
CreateDirectory(path_buffer,NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-04 01:47:02 +00:00
|
|
|
bool CPlugins::CopyPlugins ( const stdstr & DstDir ) const
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
//Copy GFX Plugin
|
2012-11-17 01:02:04 +00:00
|
|
|
CPath srcGfxPlugin(m_PluginDir.c_str(),g_Settings->LoadString(Plugin_GFX_Current).c_str());
|
|
|
|
CPath dstGfxPlugin(DstDir.c_str(),g_Settings->LoadString(Plugin_GFX_Current).c_str());
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2012-10-04 01:47:02 +00:00
|
|
|
if (CopyFile(srcGfxPlugin,dstGfxPlugin,false) == 0)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2012-10-05 09:23:41 +00:00
|
|
|
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstGfxPlugin.CreateDirectory(); }
|
2012-10-04 01:47:02 +00:00
|
|
|
if (!CopyFile(srcGfxPlugin,dstGfxPlugin,false))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Copy m_Audio Plugin
|
2012-11-17 01:02:04 +00:00
|
|
|
CPath srcAudioPlugin(m_PluginDir.c_str(),g_Settings->LoadString(Plugin_AUDIO_Current).c_str());
|
|
|
|
CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadString(Plugin_AUDIO_Current).c_str());
|
2012-10-04 01:47:02 +00:00
|
|
|
if (CopyFile(srcAudioPlugin,dstAudioPlugin,false) == 0) {
|
2012-10-05 09:23:41 +00:00
|
|
|
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstAudioPlugin.CreateDirectory(); }
|
2012-10-04 01:47:02 +00:00
|
|
|
if (!CopyFile(srcAudioPlugin,dstAudioPlugin,false))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Copy m_RSP Plugin
|
2012-11-17 01:02:04 +00:00
|
|
|
CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadString(Plugin_RSP_Current).c_str());
|
|
|
|
CPath dstRSPPlugin(DstDir.c_str(),g_Settings->LoadString(Plugin_RSP_Current).c_str());
|
2012-10-04 01:47:02 +00:00
|
|
|
if (CopyFile(srcRSPPlugin,dstRSPPlugin,false) == 0) {
|
2012-10-05 09:23:41 +00:00
|
|
|
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstRSPPlugin.CreateDirectory(); }
|
2012-10-04 01:47:02 +00:00
|
|
|
if (!CopyFile(srcRSPPlugin,dstRSPPlugin,false))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2012-10-04 01:47:02 +00:00
|
|
|
//Copy Controller Plugin
|
2012-11-17 01:02:04 +00:00
|
|
|
CPath srcContPlugin(m_PluginDir.c_str(), g_Settings->LoadString(Plugin_CONT_Current).c_str());
|
|
|
|
CPath dstContPlugin(DstDir.c_str(),g_Settings->LoadString(Plugin_CONT_Current).c_str());
|
2012-10-05 09:23:41 +00:00
|
|
|
if (!srcContPlugin.CopyTo(dstContPlugin))
|
|
|
|
{
|
|
|
|
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstContPlugin.CreateDirectory(); }
|
2012-10-04 01:47:02 +00:00
|
|
|
if (!CopyFile(srcContPlugin,dstContPlugin,false))
|
|
|
|
{
|
2012-10-05 09:23:41 +00:00
|
|
|
DWORD dwError = GetLastError();
|
|
|
|
dwError = dwError;
|
2012-10-04 01:47:02 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-05-31 00:21:08 +00:00
|
|
|
}
|
2012-10-04 01:47:02 +00:00
|
|
|
return true;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|