wxgui: Runs games. 'nuff said.

* Fixed some deadlock conditions by adding a message pump to semaphore waits ont he main/gui thread.
 * Many more config and init bugfixes.
 * Implemented most of the new Boot menu.

git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxgui@1745 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-09-05 23:07:23 +00:00
parent 163efebb29
commit 9308d86ffc
27 changed files with 494 additions and 239 deletions

View File

@ -70,6 +70,9 @@ namespace Threading
void Post(); void Post();
void Post( int multiple ); void Post( int multiple );
#if wxUSE_GUI
void WaitGui();
#endif
void Wait(); void Wait();
void Wait( const wxTimeSpan& timeout ); void Wait( const wxTimeSpan& timeout );
void WaitNoCancel(); void WaitNoCancel();

View File

@ -20,6 +20,8 @@
#include "Threading.h" #include "Threading.h"
#include <wx/datetime.h> #include <wx/datetime.h>
#include <wx/thread.h>
#include <wx/app.h>
#ifdef __LINUX__ #ifdef __LINUX__
# include <signal.h> // for pthread_kill, which is in pthread.h on w32-pthreads # include <signal.h> // for pthread_kill, which is in pthread.h on w32-pthreads
@ -245,6 +247,28 @@ namespace Threading
} }
#endif #endif
#if wxUSE_GUI
// This is a wxApp-safe implementation of Wait, which makes sure and executes the App's
// pending messages *if* the Wait is performed on the Main/GUI thread. If the Wait is
// called from another thread, no message pumping is performed.
void Semaphore::WaitGui()
{
if( !wxThread::IsMain() || (wxTheApp == NULL) )
Wait();
else
{
// In order to avoid deadlock we need to make sure we cut some time
// to handle messages. I choose 200ms:
static const timespec fail = { 0, 200 * 1000000 };
do {
wxTheApp->ProcessPendingEvents();
} while( sem_timedwait( &sema, &fail ) == ETIMEDOUT );
}
}
#endif
void Semaphore::Wait() void Semaphore::Wait()
{ {
sem_wait( &sema ); sem_wait( &sema );

View File

@ -82,7 +82,7 @@ FILE *_cdvdOpenMechaVer() {
// get the name of the bios file // get the name of the bios file
// use the bios filename to get the name of the mecha ver file // use the bios filename to get the name of the mecha ver file
// [TODO] : Upgrade this to use std::string! // [TODO] : Upgrade this to use wxstring!
strcpy(file, g_Conf->FullpathToBios().ToAscii().data() ); strcpy(file, g_Conf->FullpathToBios().ToAscii().data() );
@ -133,7 +133,7 @@ FILE *_cdvdOpenNVM() {
// get the name of the bios file // get the name of the bios file
// use the bios filename to get the name of the nvm file // use the bios filename to get the name of the nvm file
// [TODO] : Upgrade this to use std::string! // [TODO] : Upgrade this to use wxString!
strcpy( file, g_Conf->FullpathToBios().ToAscii().data() ); strcpy( file, g_Conf->FullpathToBios().ToAscii().data() );
ptr = file; ptr = file;

View File

@ -134,37 +134,6 @@ struct cdvdStruct {
}; };
struct CDVD_API
{
void (CALLBACK *close)();
// Don't need init or shutdown. iso/nodisc have no init/shutdown and plugin's
// is handled by the PluginManager.
// Don't need plugin specific things like freeze, test, or other stuff here.
// Those are handled by the plugin manager specifically.
_CDVDopen open;
_CDVDreadTrack readTrack;
_CDVDgetBuffer getBuffer;
_CDVDreadSubQ readSubQ;
_CDVDgetTN getTN;
_CDVDgetTD getTD;
_CDVDgetTOC getTOC;
_CDVDgetDiskType getDiskType;
_CDVDgetTrayStatus getTrayStatus;
_CDVDctrlTrayOpen ctrlTrayOpen;
_CDVDctrlTrayClose ctrlTrayClose;
_CDVDnewDiskCB newDiskCB;
// special functions, not in external interface yet
_CDVDreadSector readSector;
_CDVDgetBuffer2 getBuffer2;
_CDVDgetDualInfo getDualInfo;
wxString (*getUniqueFilename)();
};
extern void cdvdReset(); extern void cdvdReset();
extern void cdvdVsync(); extern void cdvdVsync();
extern void cdvdActionInterrupt(); extern void cdvdActionInterrupt();
@ -175,10 +144,3 @@ extern void cdvdDetectDisk();
extern void cdvdNewDiskCB(); extern void cdvdNewDiskCB();
extern u8 cdvdRead(u8 key); extern u8 cdvdRead(u8 key);
extern void cdvdWrite(u8 key, u8 rt); extern void cdvdWrite(u8 key, u8 rt);
extern void CDVDsys_ChangeSource( CDVD_SourceType type );
extern CDVD_API* CDVD; // currently active CDVD access mode api (either Iso, NoDisc, or Plugin)
extern CDVD_API CDVDapi_Plugin;
extern CDVD_API CDVDapi_Iso;
extern CDVD_API CDVDapi_NoDisc;

View File

@ -33,6 +33,14 @@
#include "IsoFSdrv.h" #include "IsoFSdrv.h"
#include "CDVDisoReader.h" #include "CDVDisoReader.h"
const wxChar* CDVD_SourceLabels[] =
{
L"Iso",
L"Plugin",
L"NoDisc",
NULL
};
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// diskTypeCached // diskTypeCached
// Internal disc type cache, to reduce the overhead of disc type checks, which are // Internal disc type cache, to reduce the overhead of disc type checks, which are
@ -61,7 +69,7 @@ static void CheckNullCDVD()
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// Disk Type detection stuff (from cdvdGigaherz) // Disk Type detection stuff (from cdvdGigaherz)
// //
int CheckDiskTypeFS(int baseType) static int CheckDiskTypeFS(int baseType)
{ {
int f; int f;
char buffer[256];//if a file is longer...it should be shorter :D char buffer[256];//if a file is longer...it should be shorter :D
@ -258,14 +266,19 @@ static void DetectDiskType()
diskTypeCached = FindDiskType(mType); diskTypeCached = FindDiskType(mType);
} }
// ---------------------------------------------------------------------------- static wxString m_SourceFilename[3];
// CDVDsys_ChangeSource static CDVD_SourceType m_CurrentSourceType = CDVDsrc_NoDisc;
//
void CDVDsys_SetFile( CDVD_SourceType srctype, const wxString& newfile )
{
m_SourceFilename[srctype] = newfile;
}
void CDVDsys_ChangeSource( CDVD_SourceType type ) void CDVDsys_ChangeSource( CDVD_SourceType type )
{ {
GetPluginManager().Close( PluginId_CDVD ); GetPluginManager().Close( PluginId_CDVD );
switch( type ) switch( m_CurrentSourceType = type )
{ {
case CDVDsrc_Iso: case CDVDsrc_Iso:
CDVD = &CDVDapi_Iso; CDVD = &CDVDapi_Iso;
@ -283,11 +296,13 @@ void CDVDsys_ChangeSource( CDVD_SourceType type )
} }
} }
s32 DoCDVDopen(const char* pTitleFilename) bool DoCDVDopen()
{ {
CheckNullCDVD(); CheckNullCDVD();
int ret = CDVD->open(pTitleFilename); int ret = CDVD->open( m_SourceFilename[m_CurrentSourceType].IsEmpty() ? NULL : m_SourceFilename[m_CurrentSourceType].ToUTF8().data() );
if( ret == -1 ) return false;
int cdtype = DoCDVDdetectDiskType(); int cdtype = DoCDVDdetectDiskType();
if (EmuConfig.CdvdDumpBlocks && (cdtype != CDVD_TYPE_NODISC)) if (EmuConfig.CdvdDumpBlocks && (cdtype != CDVD_TYPE_NODISC))
@ -297,7 +312,11 @@ s32 DoCDVDopen(const char* pTitleFilename)
// TODO: "Untitled" should use pnach/slus name resolution, slus if no patch, // TODO: "Untitled" should use pnach/slus name resolution, slus if no patch,
// and finally an "Untitled-[ElfCRC]" if no slus. // and finally an "Untitled-[ElfCRC]" if no slus.
wxString temp( Path::Combine( wxGetCwd(), CDVD->getUniqueFilename() ) ); wxString somepick( Path::GetFilenameWithoutExt( m_SourceFilename[m_CurrentSourceType] ) );
if( somepick.IsEmpty() )
somepick = L"Untitled";
wxString temp( Path::Combine( wxGetCwd(), somepick ) );
#ifdef ENABLE_TIMESTAMPS #ifdef ENABLE_TIMESTAMPS
wxDateTime curtime( wxDateTime::GetTimeNow() ); wxDateTime curtime( wxDateTime::GetTimeNow() );
@ -338,7 +357,7 @@ s32 DoCDVDopen(const char* pTitleFilename)
blockDumpFile = NULL; blockDumpFile = NULL;
} }
return ret; return true;
} }
void DoCDVDclose() void DoCDVDclose()
@ -495,12 +514,6 @@ s32 CALLBACK NODISCgetDualInfo(s32* dualType, u32* _layer1start)
return -1; return -1;
} }
wxString NODISCgetUniqueFilename()
{
DevAssert( false, "NODISC is an invalid CDVD object for block dumping.. >_<" );
return L"epicfail";
}
CDVD_API CDVDapi_NoDisc = CDVD_API CDVDapi_NoDisc =
{ {
NODISCclose, NODISCclose,
@ -521,6 +534,4 @@ CDVD_API CDVDapi_NoDisc =
NODISCreadSector, NODISCreadSector,
NODISCgetBuffer2, NODISCgetBuffer2,
NODISCgetDualInfo, NODISCgetDualInfo,
NODISCgetUniqueFilename
}; };

View File

@ -18,7 +18,62 @@
#pragma once #pragma once
extern s32 DoCDVDopen(const char* pTitleFilename); #include "Plugins.h"
enum CDVD_SourceType
{
CDVDsrc_Iso = 0, // use built in ISO api
CDVDsrc_Plugin, // use external plugin
CDVDsrc_NoDisc, // use built in CDVDnull
};
struct CDVD_API
{
void (CALLBACK *close)();
// Don't need init or shutdown. iso/nodisc have no init/shutdown and plugin's
// is handled by the PluginManager.
// Don't need plugin specific things like freeze, test, or other stuff here.
// Those are handled by the plugin manager specifically.
_CDVDopen open;
_CDVDreadTrack readTrack;
_CDVDgetBuffer getBuffer;
_CDVDreadSubQ readSubQ;
_CDVDgetTN getTN;
_CDVDgetTD getTD;
_CDVDgetTOC getTOC;
_CDVDgetDiskType getDiskType;
_CDVDgetTrayStatus getTrayStatus;
_CDVDctrlTrayOpen ctrlTrayOpen;
_CDVDctrlTrayClose ctrlTrayClose;
_CDVDnewDiskCB newDiskCB;
// special functions, not in external interface yet
_CDVDreadSector readSector;
_CDVDgetBuffer2 getBuffer2;
_CDVDgetDualInfo getDualInfo;
};
// ----------------------------------------------------------------------------
// Multiple interface system for CDVD, used to provide internal CDVDiso and NoDisc,
// and external plugin interfaces. Do* functions are meant as replacements for
// direct CDVD plugin invocation, and add universal block dumping features.
// ----------------------------------------------------------------------------
extern CDVD_API* CDVD; // currently active CDVD access mode api (either Iso, NoDisc, or Plugin)
extern CDVD_API CDVDapi_Plugin;
extern CDVD_API CDVDapi_Iso;
extern CDVD_API CDVDapi_NoDisc;
extern const wxChar* CDVD_SourceLabels[];
extern void CDVDsys_ChangeSource( CDVD_SourceType type );
extern void CDVDsys_SetFile( CDVD_SourceType srctype, const wxString& newfile );
extern bool DoCDVDopen();
extern void DoCDVDclose(); extern void DoCDVDclose();
extern s32 DoCDVDreadSector(u8* buffer, u32 lsn, int mode); extern s32 DoCDVDreadSector(u8* buffer, u32 lsn, int mode);
extern s32 DoCDVDreadTrack(u32 lsn, int mode); extern s32 DoCDVDreadTrack(u32 lsn, int mode);

View File

@ -29,7 +29,6 @@
#include "CDVDisoReader.h" #include "CDVDisoReader.h"
static char isoFileName[g_MaxPath];
static u8 *pbuffer; static u8 *pbuffer;
static u8 cdbuffer[2352] = {0}; static u8 cdbuffer[2352] = {0};
static isoFile *iso = NULL; static isoFile *iso = NULL;
@ -46,13 +45,16 @@ s32 CALLBACK ISOopen(const char* pTitle)
{ {
ISOclose(); // just in case ISOclose(); // just in case
if ((pTitle != NULL) && (strlen(pTitle) > 0)) if( (pTitle == NULL) || (pTitle[0] == 0) )
strcpy(isoFileName, pTitle); {
Console::Error( "CDVDiso Error: No filename specified." );
return -1;
}
iso = isoOpen(isoFileName); iso = isoOpen(pTitle);
if (iso == NULL) if (iso == NULL)
{ {
Console::Error("Error loading %s\n", params isoFileName); Console::Error( "CDVDiso Error: Failed loading %s", params pTitle );
return -1; return -1;
} }
@ -399,11 +401,6 @@ void CALLBACK ISOnewDiskCB(void(CALLBACK*)())
{ {
} }
wxString ISOgetUniqueFilename()
{
return Path::GetFilenameWithoutExt(wxString::FromAscii(isoFileName));
}
CDVD_API CDVDapi_Iso = CDVD_API CDVDapi_Iso =
{ {
ISOclose, ISOclose,
@ -425,6 +422,4 @@ CDVD_API CDVDapi_Iso =
ISOreadSector, ISOreadSector,
ISOgetBuffer2, ISOgetBuffer2,
ISOgetDualInfo, ISOgetDualInfo,
ISOgetUniqueFilename
}; };

View File

@ -211,7 +211,7 @@ void mtgsThreadObject::Start()
// Wait for the thread to finish initialization (it runs GSopen, which can take // Wait for the thread to finish initialization (it runs GSopen, which can take
// some time since it's creating a new window and all), and then check for errors. // some time since it's creating a new window and all), and then check for errors.
m_sem_InitDone.Wait(); m_sem_InitDone.WaitGui();
if( m_returncode != 0 ) // means the thread failed to init the GS plugin if( m_returncode != 0 ) // means the thread failed to init the GS plugin
throw Exception::PluginOpenError( PluginId_GS ); throw Exception::PluginOpenError( PluginId_GS );

View File

@ -708,7 +708,7 @@ static bool OpenPlugin_GS()
return !GSopen( (void*)&pDsp, "PCSX2", renderswitch ? 2 : 1 ); return !GSopen( (void*)&pDsp, "PCSX2", renderswitch ? 2 : 1 );
// Note: rederswitch is us abusing the isMultiThread parameter for that so // Note: renderswitch is us abusing the isMultiThread parameter for that so
// we don't need a new callback // we don't need a new callback
} }
@ -765,7 +765,7 @@ void PluginManager::Open( PluginsEnum_t pid )
bool result = true; bool result = true;
switch( pid ) switch( pid )
{ {
case PluginId_CDVD: result = OpenPlugin_CDVD(); break; case PluginId_CDVD: result = DoCDVDopen(); break;
case PluginId_GS: result = OpenPlugin_GS(); break; case PluginId_GS: result = OpenPlugin_GS(); break;
case PluginId_PAD: result = OpenPlugin_PAD(); break; case PluginId_PAD: result = OpenPlugin_PAD(); break;
case PluginId_SPU2: result = OpenPlugin_SPU2(); break; case PluginId_SPU2: result = OpenPlugin_SPU2(); break;
@ -784,6 +784,8 @@ void PluginManager::Open()
const PluginInfo* pi = tbl_PluginInfo-1; const PluginInfo* pi = tbl_PluginInfo-1;
while( ++pi, pi->shortname != NULL ) while( ++pi, pi->shortname != NULL )
g_plugins->Open( pi->id ); g_plugins->Open( pi->id );
cdvdDetectDisk();
} }
void PluginManager::Close( PluginsEnum_t pid ) void PluginManager::Close( PluginsEnum_t pid )
@ -803,6 +805,11 @@ void PluginManager::Close( PluginsEnum_t pid )
return; return;
} }
} }
else if( pid == PluginId_CDVD )
{
DoCDVDclose();
return;
}
m_info[pid].IsOpened = false; m_info[pid].IsOpened = false;
m_info[pid].CommonBindings.Close(); m_info[pid].CommonBindings.Close();
@ -902,6 +909,11 @@ void PluginManager::Freeze( SaveState& state )
Freeze( pi->id, state ); Freeze( pi->id, state );
} }
void PluginManager::Configure( PluginsEnum_t pid )
{
m_info[pid].CommonBindings.Configure();
}
// Creates an instance of a plugin manager, using the specified plugin filenames for sources. // Creates an instance of a plugin manager, using the specified plugin filenames for sources.
// Impl Note: Have to use this stupid effing 'friend' declaration because static members of // Impl Note: Have to use this stupid effing 'friend' declaration because static members of
// classes can't access their own protected members. W-T-F? // classes can't access their own protected members. W-T-F?

View File

@ -213,6 +213,8 @@ public:
void Freeze( PluginsEnum_t pid, SaveState& state ); void Freeze( PluginsEnum_t pid, SaveState& state );
void Freeze( SaveState& state ); void Freeze( SaveState& state );
void Configure( PluginsEnum_t pid );
friend PluginManager* PluginManager_Create( const wxString (&folders)[PluginId_Count] ); friend PluginManager* PluginManager_Create( const wxString (&folders)[PluginId_Count] );
friend PluginManager* PluginManager_Create( const wxChar* (&folders)[PluginId_Count] ); friend PluginManager* PluginManager_Create( const wxChar* (&folders)[PluginId_Count] );

View File

@ -22,17 +22,7 @@
#include "Utilities/SafeArray.h" #include "Utilities/SafeArray.h"
#include "Utilities/Threading.h" // to use threading stuff, include the Threading namespace in your file. #include "Utilities/Threading.h" // to use threading stuff, include the Threading namespace in your file.
#include "Misc.h" #include "Misc.h"
#include "CDVD/CDVDaccess.h"
// ----------------------------------------------------------------------------
// Multiple interface system for CDVD
// used to provide internal CDVDiso and NoDisc, and external plugin interfaces.
// ---------------------------------------------------------------------------
enum CDVD_SourceType
{
CDVDsrc_Iso = 0, // use built in ISO api
CDVDsrc_Plugin, // use external plugin
CDVDsrc_NoDisc, // use built in CDVDnull
};
class CoreEmuThread; class CoreEmuThread;

View File

@ -54,13 +54,13 @@ enum MenuIdentifiers
// Run SubSection // Run SubSection
MenuId_Cdvd_Source, MenuId_Cdvd_Source,
MenuId_Src_Iso, MenuId_Src_Iso,
MenuId_Src_Cdvd, MenuId_Src_Plugin,
MenuId_Src_NoDisc, MenuId_Src_NoDisc,
MenuId_Boot_Iso, // Opens submenu with Iso browser, and recent isos. MenuId_Boot_Iso, // Opens submenu with Iso browser, and recent isos.
MenuId_IsoBrowse, // Open dialog, runs selected iso. MenuId_IsoBrowse, // Open dialog, runs selected iso.
MenuId_Boot_CDVD, // opens a submenu filled by CDVD plugin (usually list of drives) MenuId_Boot_CDVD, // opens a submenu filled by CDVD plugin (usually list of drives)
MenuId_RunWithoutDisc, // used to enter the bios (subs in cdvdnull)
MenuId_Boot_ELF, MenuId_Boot_ELF,
MenuId_Boot_Recent, // Menu populated with recent source bootings
MenuId_SkipBiosToggle, // enables the Bios Skip speedhack MenuId_SkipBiosToggle, // enables the Bios Skip speedhack
@ -83,24 +83,30 @@ enum MenuIdentifiers
// Config Subsection // Config Subsection
MenuId_Config_Settings, MenuId_Config_Settings,
MenuId_Config_BIOS, MenuId_Config_BIOS,
// Plugin ID order is important. Must match the order in tbl_PluginInfo.
MenuId_Config_GS,
MenuId_Config_PAD,
MenuId_Config_SPU2,
MenuId_Config_CDVD, MenuId_Config_CDVD,
MenuId_Config_DEV9,
MenuId_Config_USB, MenuId_Config_USB,
MenuId_Config_FW,
MenuId_Config_DEV9,
MenuId_Config_FireWire, MenuId_Config_FireWire,
MenuId_Config_Patches, MenuId_Config_Patches,
// Video Subsection // Video Subsection
// Top items are Pcsx2-controlled. GS plugin items are inserted beneath. // Top items are PCSX2-controlled. GS plugin items are inserted beneath.
MenuId_Video_Basics, // includes frame timings and skippings settings MenuId_Video_Basics, // includes frame timings and skippings settings
MenuId_Video_Advanced, // inserted at the bottom of the menu MenuId_Video_Advanced, // inserted at the bottom of the menu
// Audio subsection // Audio subsection
// Top items are Pcsx2-controlled. SPU2 plugin items are inserted beneath. // Top items are PCSX2-controlled. SPU2 plugin items are inserted beneath.
// [no items at this time] // [no items at this time]
MenuId_Audio_Advanced, // inserted at the bottom of the menu MenuId_Audio_Advanced, // inserted at the bottom of the menu
// Controller subsection // Controller subsection
// Top items are Pcsx2-controlled. Pad plugin items are inserted beneath. // Top items are PCSX2-controlled. Pad plugin items are inserted beneath.
// [no items at this time] // [no items at this time]
MenuId_Pad_Advanced, MenuId_Pad_Advanced,
@ -116,6 +122,28 @@ enum MenuIdentifiers
MenuId_Debug_Usermode, MenuId_Debug_Usermode,
}; };
//////////////////////////////////////////////////////////////////////////////////////////
//
class ScopedWindowDisable
{
DeclareNoncopyableObject( ScopedWindowDisable )
protected:
wxWindow& m_window;
public:
ScopedWindowDisable( wxWindow* whee ) :
m_window( *whee )
{
wxASSERT( whee != NULL );
m_window.Disable();
}
~ScopedWindowDisable()
{
m_window.Enable();
}
};
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// //
@ -200,7 +228,6 @@ public:
int OnExit(); int OnExit();
void OnInitCmdLine( wxCmdLineParser& parser ); void OnInitCmdLine( wxCmdLineParser& parser );
bool OnCmdLineParsed( wxCmdLineParser& parser ); bool OnCmdLineParsed( wxCmdLineParser& parser );
bool PrepForExit(); bool PrepForExit();
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
@ -222,6 +249,10 @@ public:
void PostMenuAction( MenuIdentifiers menu_id ) const; void PostMenuAction( MenuIdentifiers menu_id ) const;
void Ping() const; void Ping() const;
void ApplySettings();
void LoadSettings();
void SaveSettings();
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Console / Program Logging Helpers // Console / Program Logging Helpers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -303,5 +334,3 @@ extern void OpenPlugins();
extern wxRect wxGetDisplayArea(); extern wxRect wxGetDisplayArea();
extern bool pxIsValidWindowPosition( const wxWindow& window, const wxPoint& windowPos ); extern bool pxIsValidWindowPosition( const wxWindow& window, const wxPoint& windowPos );
extern wxFileHistory* g_RecentIsoList;

View File

@ -369,12 +369,14 @@ AppConfig::AppConfig() :
, McdEnableNTFS( true ) , McdEnableNTFS( true )
, CurrentIso()
, CdvdSource( CDVDsrc_Iso )
, ProgLogBox() , ProgLogBox()
, Ps2ConBox() , Ps2ConBox()
, Folders() , Folders()
, BaseFilenames() , BaseFilenames()
, EmuOptions() , EmuOptions()
, m_IsLoaded( false )
{ {
Mcd[0].Enabled = true; Mcd[0].Enabled = true;
Mcd[1].Enabled = true; Mcd[1].Enabled = true;
@ -427,6 +429,10 @@ void AppConfig::LoadSave( IniInterface& ini )
IniEntry( Toolbar_ImageSize ); IniEntry( Toolbar_ImageSize );
IniEntry( Toolbar_ShowLabels ); IniEntry( Toolbar_ShowLabels );
IniEntry( CurrentIso );
ini.EnumEntry( L"CdvdSource", CdvdSource, CDVD_SourceLabels, defaults.CdvdSource );
// Process various sub-components: // Process various sub-components:
ProgLogBox.LoadSave( ini, L"ProgramLog" ); ProgLogBox.LoadSave( ini, L"ProgramLog" );
Ps2ConBox.LoadSave( ini, L"Ps2Console" ); Ps2ConBox.LoadSave( ini, L"Ps2Console" );
@ -434,9 +440,6 @@ void AppConfig::LoadSave( IniInterface& ini )
Folders.LoadSave( ini ); Folders.LoadSave( ini );
BaseFilenames.LoadSave( ini ); BaseFilenames.LoadSave( ini );
if( ini.IsSaving() && (g_RecentIsoList != NULL) )
g_RecentIsoList->Save( ini.GetConfig() );
EmuOptions.LoadSave( ini ); EmuOptions.LoadSave( ini );
ini.Flush(); ini.Flush();
@ -450,8 +453,6 @@ void AppConfig::Apply()
{ {
Folders.ApplyDefaults(); Folders.ApplyDefaults();
if( NULL == wxConfigBase::Get( false ) ) return;
// Ensure existence of necessary documents folders. Plugins and other parts // Ensure existence of necessary documents folders. Plugins and other parts
// of PCSX2 rely on them. // of PCSX2 rely on them.
@ -474,41 +475,6 @@ void AppConfig::Apply()
} }
} }
} }
// Always perform delete and reload of the Recent Iso List. This handles cases where
// the recent file count has been changed, and it's a helluva lot easier than trying
// to make a clone copy of this complex object. ;)
wxConfigBase* cfg = wxConfigBase::Get( false );
wxASSERT( cfg != NULL );
if( g_RecentIsoList != NULL )
g_RecentIsoList->Save( *cfg );
safe_delete( g_RecentIsoList );
g_RecentIsoList = new wxFileHistory( RecentFileCount );
g_RecentIsoList->Load( *cfg );
cfg->Flush();
}
// ------------------------------------------------------------------------
void AppConfig::Load()
{
if( NULL == wxConfigBase::Get( false ) ) return;
m_IsLoaded = true;
// Note: Extra parenthesis resolves "I think this is a function" issues with C++.
IniLoader loader( (IniLoader()) );
LoadSave( loader );
}
void AppConfig::Save()
{
if( NULL == wxConfigBase::Get( false ) ) return;
IniSaver saver( (IniSaver()) );
LoadSave( saver );
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -629,9 +595,9 @@ void AppConfig_ReloadGlobalSettings( bool overwrite )
wxConfigBase::Get()->SetRecordDefaults(); wxConfigBase::Get()->SetRecordDefaults();
if( !overwrite ) if( !overwrite )
g_Conf->Load(); wxGetApp().LoadSettings();
g_Conf->Apply(); wxGetApp().ApplySettings();
g_Conf->Folders.Logs.Mkdir(); g_Conf->Folders.Logs.Mkdir();
wxString newlogname( Path::Combine( g_Conf->Folders.Logs.ToString(), L"emuLog.txt" ) ); wxString newlogname( Path::Combine( g_Conf->Folders.Logs.ToString(), L"emuLog.txt" ) );

View File

@ -18,6 +18,8 @@
#pragma once #pragma once
#include "CDVD/CDVDaccess.h"
class IniInterface; class IniInterface;
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
@ -131,6 +133,9 @@ public:
// enables automatic ntfs compression of memory cards (Win32 only) // enables automatic ntfs compression of memory cards (Win32 only)
bool McdEnableNTFS; bool McdEnableNTFS;
wxString CurrentIso;
CDVD_SourceType CdvdSource;
McdOptions Mcd[2]; McdOptions Mcd[2];
ConsoleLogOptions ProgLogBox; ConsoleLogOptions ProgLogBox;
ConsoleLogOptions Ps2ConBox; ConsoleLogOptions Ps2ConBox;
@ -143,11 +148,6 @@ public:
// used by emulation. The gui allows temporary per-game and commandline level overrides. // used by emulation. The gui allows temporary per-game and commandline level overrides.
Pcsx2Config EmuOptions; Pcsx2Config EmuOptions;
protected:
// indicates if the main AppConfig settings are valid (excludes the status of UseAdminMode,
// which is a special value that's initialized independently of the rest of the config)
bool m_IsLoaded;
public: public:
AppConfig(); AppConfig();
@ -156,16 +156,16 @@ public:
wxString FullpathTo( PluginsEnum_t pluginId ) const; wxString FullpathTo( PluginsEnum_t pluginId ) const;
wxString FullPathToConfig() const; wxString FullPathToConfig() const;
void Load();
void Save();
void Apply();
void LoadSaveUserMode( IniInterface& ini, const wxString& cwdhash ); void LoadSaveUserMode( IniInterface& ini, const wxString& cwdhash );
wxString GetDefaultDocumentsFolder(); wxString GetDefaultDocumentsFolder();
protected: protected:
void Apply();
void LoadSave( IniInterface& ini ); void LoadSave( IniInterface& ini );
void LoadSaveMemcards( IniInterface& ini ); void LoadSaveMemcards( IniInterface& ini );
friend class Pcsx2App;
}; };
class wxFileConfig; // forward declare. class wxFileConfig; // forward declare.

View File

@ -124,7 +124,7 @@ void Dialogs::ConfigurationDialog::OnOk_Click( wxCommandEvent& evt )
{ {
FindWindow( wxID_APPLY )->Disable(); FindWindow( wxID_APPLY )->Disable();
g_Conf->SettingsTabName = m_labels[m_listbook.GetSelection()]; g_Conf->SettingsTabName = m_labels[m_listbook.GetSelection()];
g_Conf->Save(); wxGetApp().SaveSettings();
Close(); Close();
evt.Skip(); evt.Skip();
@ -143,7 +143,7 @@ void Dialogs::ConfigurationDialog::OnApply_Click( wxCommandEvent& evt )
FindWindow( wxID_APPLY )->Disable(); FindWindow( wxID_APPLY )->Disable();
g_Conf->SettingsTabName = m_labels[m_listbook.GetSelection()]; g_Conf->SettingsTabName = m_labels[m_listbook.GetSelection()];
g_Conf->Save(); wxGetApp().SaveSettings();
} }

View File

@ -20,6 +20,18 @@
#include "System.h" #include "System.h"
#include "IniInterface.h" #include "IniInterface.h"
static int _calcEnumLength( const wxChar* const* enumArray )
{
int cnt = 0;
while( *enumArray != NULL )
{
enumArray++;
cnt++;
}
return cnt;
}
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// //
IniInterface::IniInterface( wxConfigBase& config ) : IniInterface::IniInterface( wxConfigBase& config ) :
@ -149,6 +161,14 @@ void IniLoader::Entry( const wxString& var, wxRect& value, const wxRect& defvalu
void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, const int defvalue ) void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, const int defvalue )
{ {
// Confirm default value sanity...
const int cnt = _calcEnumLength( enumArray );
if( defvalue >= cnt )
throw Exception::IndexBoundsFault( L"IniLoader Enumeration DefaultValue", defvalue, cnt );
// Sanity confirmed, proceed with craziness!
wxString retval; wxString retval;
m_Config.Read( var, &retval, enumArray[defvalue] ); m_Config.Read( var, &retval, enumArray[defvalue] );
@ -238,6 +258,22 @@ void IniSaver::Entry( const wxString& var, wxRect& value, const wxRect& defvalue
void IniSaver::_EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, const int defvalue ) void IniSaver::_EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, const int defvalue )
{ {
const int cnt = _calcEnumLength( enumArray );
if( value >= cnt )
{
Console::Notice( wxsFormat(
L"Settings Warning: An illegal enumerated index was detected when saving '%s'\n"
L"\tIllegal Value: %d\n"
L"\tUsing Default: %d (%s)\n",
var.c_str(), value, defvalue, enumArray[defvalue] )
);
// Cause a debug assertion, since this is a fully recoverable error.
wxASSERT( value < cnt );
value = defvalue;
}
m_Config.Write( var, enumArray[value] ); m_Config.Write( var, enumArray[value] );
} }

View File

@ -37,49 +37,66 @@ wxMenu* MainEmuFrame::MakeStatesSubMenu( int baseid ) const
{ {
wxMenu* mnuSubstates = new wxMenu(); wxMenu* mnuSubstates = new wxMenu();
mnuSubstates->Append( baseid+1, _("Slot 0"), wxEmptyString, wxITEM_NORMAL ); mnuSubstates->Append( baseid+1, _("Slot 0") );
mnuSubstates->Append( baseid+2, _("Slot 1"), wxEmptyString, wxITEM_NORMAL ); mnuSubstates->Append( baseid+2, _("Slot 1") );
mnuSubstates->Append( baseid+3, _("Slot 2"), wxEmptyString, wxITEM_NORMAL ); mnuSubstates->Append( baseid+3, _("Slot 2") );
mnuSubstates->Append( baseid+4, _("Slot 3"), wxEmptyString, wxITEM_NORMAL ); mnuSubstates->Append( baseid+4, _("Slot 3") );
mnuSubstates->Append( baseid+5, _("Slot 4"), wxEmptyString, wxITEM_NORMAL ); mnuSubstates->Append( baseid+5, _("Slot 4") );
mnuSubstates->Append( baseid, _("Other..."), wxEmptyString, wxITEM_NORMAL ); mnuSubstates->Append( baseid, _("Other...") );
return mnuSubstates; return mnuSubstates;
} }
/*struct StringListNode
{
wxString* item;
StringListNode* next;
};*/
// ------------------------------------------------------------------------
wxMenu* MainEmuFrame::MakeIsoMenu()
{
wxMenu* mnuIso = new wxMenu();
mnuIso->Append( MenuId_IsoBrowse, _("Browse..."), _("Select an Iso image from your hard drive.") );
if( g_RecentIsoList != NULL )
{
g_RecentIsoList->UseMenu( mnuIso );
g_RecentIsoList->AddFilesToMenu( mnuIso );
}
return mnuIso;
}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
wxMenu* MainEmuFrame::MakeCdvdMenu() wxMenu* MainEmuFrame::MakeCdvdMenu()
{ {
wxMenu* mnuCdvd = new wxMenu(); wxMenu* mnuCdvd = new wxMenu();
mnuCdvd->Append( MenuId_Src_Iso, _("Iso image"), wxEmptyString, wxITEM_RADIO ); mnuCdvd->Append( MenuId_Src_Iso, _("Iso"), wxEmptyString, wxITEM_RADIO );
mnuCdvd->Append( MenuId_Src_Cdvd, _("Cdvd plugin"), wxEmptyString, wxITEM_RADIO ); mnuCdvd->Append( MenuId_Src_Plugin, _("Plugin"), wxEmptyString, wxITEM_RADIO );
mnuCdvd->Append( MenuId_Src_NoDisc, _("No disc"), wxEmptyString, wxITEM_RADIO ); mnuCdvd->Append( MenuId_Src_NoDisc, _("No disc"), wxEmptyString, wxITEM_RADIO );
mnuCdvd->AppendSeparator();
mnuCdvd->Append( MenuId_IsoBrowse, _("Iso Browser..."), _("Select the Iso source image.") );
mnuCdvd->Append( MenuId_Config_CDVD, _("Plugin settings..."),
_("Opens the CDVD plugin configuration dialog") );
return mnuCdvd; return mnuCdvd;
} }
void MainEmuFrame::UpdateIsoSrcSelection()
{
MenuIdentifiers cdsrc = MenuId_Src_Iso;
switch( g_Conf->CdvdSource )
{
case CDVDsrc_Iso: cdsrc = MenuId_Src_Iso; break;
case CDVDsrc_Plugin: cdsrc = MenuId_Src_Plugin; break;
case CDVDsrc_NoDisc: cdsrc = MenuId_Src_NoDisc; break;
jNO_DEFAULT
}
GetMenuBar()->Check( cdsrc, true );
m_statusbar.SetStatusText( CDVD_SourceLabels[g_Conf->CdvdSource], 1 );
}
void MainEmuFrame::UpdateIsoSrcFile()
{
UpdateIsoSrcSelection();
const bool exists = wxFile::Exists( g_Conf->CurrentIso );
if( !exists )
g_Conf->CurrentIso.Clear();
wxString label;
label.Printf( L"%s -> %s", _("Iso"),
exists ? g_Conf->CurrentIso.c_str() : _("Empty")
);
GetMenuBar()->SetLabel( MenuId_Src_Iso, label );
}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Video / Audio / Pad "Extensible" Menus // Video / Audio / Pad "Extensible" Menus
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void MainEmuFrame::PopulateVideoMenu() void MainEmuFrame::PopulateVideoMenu()
{ {
m_menuVideo.Append( MenuId_Video_Basics, _("Basic Settings..."), wxEmptyString, wxITEM_CHECK ); m_menuVideo.Append( MenuId_Video_Basics, _("Basic Settings..."), wxEmptyString, wxITEM_CHECK );
@ -164,12 +181,19 @@ void MainEmuFrame::ConnectMenus()
ConnectMenu( MenuId_Config_Settings, Menu_ConfigSettings_Click ); ConnectMenu( MenuId_Config_Settings, Menu_ConfigSettings_Click );
ConnectMenu( MenuId_Config_BIOS, Menu_SelectBios_Click ); ConnectMenu( MenuId_Config_BIOS, Menu_SelectBios_Click );
ConnectMenu( MenuId_IsoBrowse, Menu_RunIso_Click );
ConnectMenu( MenuId_RunWithoutDisc, Menu_RunWithoutDisc_Click );
Connect( wxID_FILE1, wxID_FILE1+20, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainEmuFrame::Menu_IsoRecent_Click) ); Connect( wxID_FILE1, wxID_FILE1+20, wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(MainEmuFrame::Menu_IsoRecent_Click) );
Connect( MenuId_Config_GS, MenuId_Config_GS+PluginId_Count, wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(MainEmuFrame::Menu_ConfigPlugin_Click) );
Connect( MenuId_Src_Iso, MenuId_Src_Iso+3, wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(MainEmuFrame::Menu_CdvdSource_Click) );
ConnectMenu( MenuId_Boot_CDVD, Menu_BootCdvd_Click );
ConnectMenu( MenuId_Boot_ELF, Menu_OpenELF_Click ); ConnectMenu( MenuId_Boot_ELF, Menu_OpenELF_Click );
ConnectMenu( MenuId_IsoBrowse, Menu_IsoBrowse_Click );
ConnectMenu( MenuId_Exit, Menu_Exit_Click ); ConnectMenu( MenuId_Exit, Menu_Exit_Click );
ConnectMenu( MenuId_Emu_Pause, Menu_EmuPause_Click ); ConnectMenu( MenuId_Emu_Pause, Menu_EmuPause_Click );
@ -210,6 +234,8 @@ void MainEmuFrame::InitLogBoxPosition( AppConfig::ConsoleLogOptions& conf )
MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title): MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title):
wxFrame(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE & ~(wxMAXIMIZE_BOX | wxRESIZE_BORDER) ), wxFrame(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE & ~(wxMAXIMIZE_BOX | wxRESIZE_BORDER) ),
m_RecentIsoList( new wxFileHistory( g_Conf->RecentFileCount ) ),
m_statusbar( *CreateStatusBar(2, 0) ), m_statusbar( *CreateStatusBar(2, 0) ),
m_background( this, wxID_ANY, wxGetApp().GetLogoBitmap() ), m_background( this, wxID_ANY, wxGetApp().GetLogoBitmap() ),
@ -217,15 +243,15 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title):
m_menubar( *new wxMenuBar() ), m_menubar( *new wxMenuBar() ),
m_menuBoot( *new wxMenu() ), m_menuBoot ( *new wxMenu() ),
m_menuEmu( *new wxMenu() ), m_menuEmu ( *new wxMenu() ),
m_menuConfig( *new wxMenu() ), m_menuConfig( *new wxMenu() ),
m_menuMisc( *new wxMenu() ), m_menuMisc ( *new wxMenu() ),
m_menuVideo( *new wxMenu() ), m_menuVideo ( *new wxMenu() ),
m_menuAudio( *new wxMenu() ), m_menuAudio ( *new wxMenu() ),
m_menuPad( *new wxMenu() ), m_menuPad ( *new wxMenu() ),
m_menuDebug( *new wxMenu() ), m_menuDebug ( *new wxMenu() ),
m_LoadStatesSubmenu( *MakeStatesSubMenu( MenuId_State_Load01 ) ), m_LoadStatesSubmenu( *MakeStatesSubMenu( MenuId_State_Load01 ) ),
m_SaveStatesSubmenu( *MakeStatesSubMenu( MenuId_State_Save01 ) ), m_SaveStatesSubmenu( *MakeStatesSubMenu( MenuId_State_Save01 ) ),
@ -257,8 +283,8 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title):
int m_statusbar_widths[] = { (int)(backsize.GetWidth()*0.73), (int)(backsize.GetWidth()*0.25) }; int m_statusbar_widths[] = { (int)(backsize.GetWidth()*0.73), (int)(backsize.GetWidth()*0.25) };
m_statusbar.SetStatusWidths(2, m_statusbar_widths); m_statusbar.SetStatusWidths(2, m_statusbar_widths);
m_statusbar.SetStatusText( _T("The Status is Good!"), 0); m_statusbar.SetStatusText( L"The Status is Good!", 0);
m_statusbar.SetStatusText( _T("Good Status"), 1); m_statusbar.SetStatusText( wxEmptyString, 1);
wxBoxSizer& joe( *new wxBoxSizer( wxVERTICAL ) ); wxBoxSizer& joe( *new wxBoxSizer( wxVERTICAL ) );
joe.Add( &m_background ); joe.Add( &m_background );
@ -279,16 +305,18 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title):
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
m_menuBoot.Append(MenuId_Boot_Iso, _("Run ISO"), m_menuBoot.Append(MenuId_Boot_CDVD, _("Run CDVD"),
MakeIsoMenu() );
m_menuBoot.AppendSeparator();
m_menuBoot.Append(MenuId_RunWithoutDisc,_("Boot without Disc"),
_("Use this to access the PS2 system configuration menu")); _("Use this to access the PS2 system configuration menu"));
m_menuBoot.Append(MenuId_Boot_ELF, _("Run ELF File..."), m_menuBoot.Append(MenuId_Boot_ELF, _("Run ELF File..."),
_("For running raw binaries")); _("For running raw binaries"));
wxMenu* recentRunMenu = new wxMenu();
m_menuBoot.Append(MenuId_Boot_Recent, _("Run Recent"), recentRunMenu);
m_RecentIsoList->UseMenu( recentRunMenu );
m_RecentIsoList->AddFilesToMenu( recentRunMenu );
m_menuBoot.AppendSeparator(); m_menuBoot.AppendSeparator();
m_menuBoot.Append(MenuId_Cdvd_Source, _("Select CDVD source"), MakeCdvdMenu() ); m_menuBoot.Append(MenuId_Cdvd_Source, _("Select CDVD source"), MakeCdvdMenu() );
m_menuBoot.Append(MenuId_SkipBiosToggle,_("BIOS Skip Hack"), m_menuBoot.Append(MenuId_SkipBiosToggle,_("BIOS Skip Hack"),
@ -362,11 +390,42 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title):
m_menuDebug.Append(MenuId_Debug_Logging, _("Logging..."), wxEmptyString); m_menuDebug.Append(MenuId_Debug_Logging, _("Logging..."), wxEmptyString);
m_menuDebug.AppendSeparator(); m_menuDebug.AppendSeparator();
m_menuDebug.Append(MenuId_Debug_Usermode, _("Change Usermode..."), _(" Advanced feature for managing multiple concurrent PCSX2 environments.")); m_menuDebug.Append(MenuId_Debug_Usermode, _("Change Usermode..."),
_(" Advanced feature for managing multiple concurrent PCSX2 environments."));
m_MenuItem_Console.Check( g_Conf->ProgLogBox.Visible ); m_MenuItem_Console.Check( g_Conf->ProgLogBox.Visible );
ConnectMenus(); ConnectMenus();
Connect( wxEVT_MOVE, wxMoveEventHandler (MainEmuFrame::OnMoveAround) ); Connect( wxEVT_MOVE, wxMoveEventHandler (MainEmuFrame::OnMoveAround) );
Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler(MainEmuFrame::OnCloseWindow) ); Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler(MainEmuFrame::OnCloseWindow) );
UpdateIsoSrcFile();
}
MainEmuFrame::~MainEmuFrame()
{
if( m_RecentIsoList != NULL )
{
m_RecentIsoList->Save( *wxConfigBase::Get( false ) );
safe_delete( m_RecentIsoList );
}
}
void MainEmuFrame::ApplySettings()
{
// Always perform delete and reload of the Recent Iso List. This handles cases where
// the recent file count has been changed, and it's a helluva lot easier than trying
// to make a clone copy of this complex object. ;)
wxConfigBase* cfg = wxConfigBase::Get( false );
wxASSERT( cfg != NULL );
if( m_RecentIsoList != NULL )
m_RecentIsoList->Save( *cfg );
safe_delete( m_RecentIsoList );
m_RecentIsoList = new wxFileHistory( g_Conf->RecentFileCount );
m_RecentIsoList->Load( *cfg );
UpdateIsoSrcFile();
cfg->Flush();
} }

View File

@ -26,13 +26,12 @@
class MainEmuFrame: public wxFrame class MainEmuFrame: public wxFrame
{ {
public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// MainEmuFrame Protected Variables // MainEmuFrame Protected Variables
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
protected: protected:
wxFileHistory* m_RecentIsoList;
wxStatusBar& m_statusbar; wxStatusBar& m_statusbar;
wxStaticBitmap m_background; wxStaticBitmap m_background;
@ -59,9 +58,14 @@ protected:
public: public:
MainEmuFrame(wxWindow* parent, const wxString& title); MainEmuFrame(wxWindow* parent, const wxString& title);
virtual ~MainEmuFrame();
void OnLogBoxHidden(); void OnLogBoxHidden();
bool IsPaused() const { return GetMenuBar()->IsChecked( MenuId_Emu_Pause ); } bool IsPaused() const { return GetMenuBar()->IsChecked( MenuId_Emu_Pause ); }
void UpdateIsoSrcFile();
void UpdateIsoSrcSelection();
void ApplySettings();
protected: protected:
void InitLogBoxPosition( AppConfig::ConsoleLogOptions& conf ); void InitLogBoxPosition( AppConfig::ConsoleLogOptions& conf );
@ -73,11 +77,12 @@ protected:
void Menu_SelectBios_Click(wxCommandEvent &event); void Menu_SelectBios_Click(wxCommandEvent &event);
void Menu_RunIso_Click(wxCommandEvent &event); void Menu_RunIso_Click(wxCommandEvent &event);
void Menu_RunWithoutDisc_Click(wxCommandEvent &event);
void Menu_IsoBrowse_Click(wxCommandEvent &event); void Menu_IsoBrowse_Click(wxCommandEvent &event);
void Menu_IsoRecent_Click(wxCommandEvent &event); void Menu_IsoRecent_Click(wxCommandEvent &event);
void Menu_BootCdvd_Click(wxCommandEvent &event);
void Menu_OpenELF_Click(wxCommandEvent &event); void Menu_OpenELF_Click(wxCommandEvent &event);
void Menu_CdvdSource_Click(wxCommandEvent &event);
void Menu_LoadStateOther_Click(wxCommandEvent &event); void Menu_LoadStateOther_Click(wxCommandEvent &event);
void Menu_SaveStateOther_Click(wxCommandEvent &event); void Menu_SaveStateOther_Click(wxCommandEvent &event);
void Menu_Exit_Click(wxCommandEvent &event); void Menu_Exit_Click(wxCommandEvent &event);
@ -86,6 +91,8 @@ protected:
void Menu_EmuClose_Click(wxCommandEvent &event); void Menu_EmuClose_Click(wxCommandEvent &event);
void Menu_EmuReset_Click(wxCommandEvent &event); void Menu_EmuReset_Click(wxCommandEvent &event);
void Menu_ConfigPlugin_Click(wxCommandEvent &event);
void Menu_Debug_Open_Click(wxCommandEvent &event); void Menu_Debug_Open_Click(wxCommandEvent &event);
void Menu_Debug_MemoryDump_Click(wxCommandEvent &event); void Menu_Debug_MemoryDump_Click(wxCommandEvent &event);
void Menu_Debug_Logging_Click(wxCommandEvent &event); void Menu_Debug_Logging_Click(wxCommandEvent &event);
@ -100,12 +107,13 @@ protected:
wxMenu* MakeStatesSubMenu( int baseid ) const; wxMenu* MakeStatesSubMenu( int baseid ) const;
wxMenu* MakeStatesMenu(); wxMenu* MakeStatesMenu();
wxMenu* MakeLanguagesMenu() const; wxMenu* MakeLanguagesMenu() const;
wxMenu* MakeIsoMenu();
wxMenu* MakeCdvdMenu(); wxMenu* MakeCdvdMenu();
void PopulateVideoMenu(); void PopulateVideoMenu();
void PopulateAudioMenu(); void PopulateAudioMenu();
void PopulatePadMenu(); void PopulatePadMenu();
void ConnectMenus(); void ConnectMenus();
friend class Pcsx2App;
}; };

View File

@ -32,7 +32,7 @@ void MainEmuFrame::Menu_ConfigSettings_Click(wxCommandEvent &event)
{ {
if( Dialogs::ConfigurationDialog( this ).ShowModal() ) if( Dialogs::ConfigurationDialog( this ).ShowModal() )
{ {
g_Conf->Save(); wxGetApp().SaveSettings();
} }
} }
@ -40,18 +40,72 @@ void MainEmuFrame::Menu_SelectBios_Click(wxCommandEvent &event)
{ {
if( Dialogs::BiosSelectorDialog( this ).ShowModal() ) if( Dialogs::BiosSelectorDialog( this ).ShowModal() )
{ {
g_Conf->Save(); wxGetApp().SaveSettings();
} }
} }
static const wxChar* isoFilterTypes = void MainEmuFrame::Menu_CdvdSource_Click( wxCommandEvent &event )
L"Iso Image (*.iso)|*.iso|Bin Image|(*.bin)|MDF Image (*.mdf)|*.mdf|Nero Image (*.nrg)|*.nrg"; {
switch( event.GetId() )
{
case MenuId_Src_Iso: g_Conf->CdvdSource = CDVDsrc_Iso; break;
case MenuId_Src_Plugin: g_Conf->CdvdSource = CDVDsrc_Plugin; break;
case MenuId_Src_NoDisc: g_Conf->CdvdSource = CDVDsrc_NoDisc; break;
void MainEmuFrame::Menu_RunIso_Click(wxCommandEvent &event) jNO_DEFAULT
}
UpdateIsoSrcSelection();
wxGetApp().SaveSettings();
}
void MainEmuFrame::Menu_BootCdvd_Click( wxCommandEvent &event )
{
if( EmulationInProgress() )
{
SysSuspend();
// [TODO] : Add one of 'dems checkboxes that read like "[x] don't show this stupid shit again, kthx."
bool result = Msgbox::OkCancel( pxE( ".Popup:ConfirmEmuReset", L"This will reset the emulator and your current emulation session will be lost. Are you sure?") );
if( !result )
{
SysResume();
return;
}
}
SysEndExecution();
InitPlugins();
CDVDsys_SetFile( CDVDsrc_Iso, g_Conf->CurrentIso );
SysExecute( new AppEmuThread(), g_Conf->CdvdSource );
}
extern const wxChar* isoFilterTypes;
void MainEmuFrame::Menu_IsoBrowse_Click( wxCommandEvent &event )
{
SysSuspend();
wxFileDialog ctrl( this, _("Select CDVD source iso..."), g_Conf->Folders.RunIso.ToString(), wxEmptyString,
isoFilterTypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( ctrl.ShowModal() != wxID_CANCEL )
{
g_Conf->Folders.RunIso = wxFileName( ctrl.GetPath() ).GetPath();
g_Conf->CurrentIso = ctrl.GetPath();
wxGetApp().SaveSettings();
UpdateIsoSrcFile();
}
SysResume();
}
void MainEmuFrame::Menu_RunIso_Click( wxCommandEvent &event )
{ {
SysSuspend(); SysSuspend();
Console::Status( L"Default Folder: " + g_Conf->Folders.RunIso.ToString() );
wxFileDialog ctrl( this, _("Run PS2 Iso..."), g_Conf->Folders.RunIso.ToString(), wxEmptyString, wxFileDialog ctrl( this, _("Run PS2 Iso..."), g_Conf->Folders.RunIso.ToString(), wxEmptyString,
isoFilterTypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); isoFilterTypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
@ -63,14 +117,17 @@ void MainEmuFrame::Menu_RunIso_Click(wxCommandEvent &event)
SysEndExecution(); SysEndExecution();
g_Conf->Folders.RunIso = ctrl.GetPath(); g_Conf->Folders.RunIso = wxFileName( ctrl.GetPath() ).GetPath();
g_Conf->Save(); g_Conf->CurrentIso = ctrl.GetPath();
wxGetApp().SaveSettings();
UpdateIsoSrcFile();
wxString elf_file; wxString elf_file;
if( EmuConfig.SkipBiosSplash ) if( EmuConfig.SkipBiosSplash )
{ {
// Fetch the ELF filename and CD type from the CDVD provider. // Fetch the ELF filename and CD type from the CDVD provider.
wxString ename( ctrl.GetFilename() ); wxString ename( g_Conf->CurrentIso );
int result = GetPS2ElfName( ename ); int result = GetPS2ElfName( ename );
switch( result ) switch( result )
{ {
@ -86,6 +143,8 @@ void MainEmuFrame::Menu_RunIso_Click(wxCommandEvent &event)
// PS2 game. Valid! // PS2 game. Valid!
elf_file = ename; elf_file = ename;
break; break;
jNO_DEFAULT
} }
} }
@ -93,7 +152,7 @@ void MainEmuFrame::Menu_RunIso_Click(wxCommandEvent &event)
SysExecute( new AppEmuThread( elf_file ), CDVDsrc_Iso ); SysExecute( new AppEmuThread( elf_file ), CDVDsrc_Iso );
} }
void MainEmuFrame::Menu_RunWithoutDisc_Click(wxCommandEvent &event) /*void MainEmuFrame::Menu_RunWithoutDisc_Click(wxCommandEvent &event)
{ {
if( EmulationInProgress() ) if( EmulationInProgress() )
{ {
@ -112,7 +171,7 @@ void MainEmuFrame::Menu_RunWithoutDisc_Click(wxCommandEvent &event)
SysEndExecution(); SysEndExecution();
InitPlugins(); InitPlugins();
SysExecute( new AppEmuThread(), CDVDsrc_NoDisc ); SysExecute( new AppEmuThread(), CDVDsrc_NoDisc );
} }*/
void MainEmuFrame::Menu_IsoRecent_Click(wxCommandEvent &event) void MainEmuFrame::Menu_IsoRecent_Click(wxCommandEvent &event)
{ {
@ -163,6 +222,16 @@ void MainEmuFrame::Menu_EmuReset_Click(wxCommandEvent &event)
SysExecute( new AppEmuThread() ); SysExecute( new AppEmuThread() );
} }
void MainEmuFrame::Menu_ConfigPlugin_Click(wxCommandEvent &event)
{
typedef void (CALLBACK* PluginConfigureFnptr)();
const PluginsEnum_t pid = (PluginsEnum_t)( event.GetId() - MenuId_Config_GS );
LoadPlugins();
ScopedWindowDisable disabler( this );
g_plugins->Configure( pid );
}
void MainEmuFrame::Menu_Debug_Open_Click(wxCommandEvent &event) void MainEmuFrame::Menu_Debug_Open_Click(wxCommandEvent &event)
{ {
} }

View File

@ -23,6 +23,7 @@
#include "ps2/BiosTools.h" #include "ps2/BiosTools.h"
#include <wx/dir.h> #include <wx/dir.h>
#include <wx/listbox.h>
using namespace wxHelpers; using namespace wxHelpers;

View File

@ -27,7 +27,6 @@
#include <wx/image.h> #include <wx/image.h>
#include <wx/statline.h> #include <wx/statline.h>
#include <wx/bookctrl.h> #include <wx/bookctrl.h>
#include <wx/listbox.h>
#include <list> #include <list>
@ -36,6 +35,8 @@
#include "Utilities/SafeArray.h" #include "Utilities/SafeArray.h"
#include "Utilities/Threading.h" #include "Utilities/Threading.h"
class wxListBox;
// Annoyances of C++ forward declarations. Having to type in this red tape mess // Annoyances of C++ forward declarations. Having to type in this red tape mess
// is keeping me form eating a good sandwich right now... >_< // is keeping me form eating a good sandwich right now... >_<
namespace Panels namespace Panels

View File

@ -18,8 +18,10 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "ConfigurationPanels.h" #include "ConfigurationPanels.h"
#include "ps2/BiosTools.h"
#include "App.h"
#include "ps2/BiosTools.h"
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
using namespace wxHelpers; using namespace wxHelpers;
@ -81,9 +83,9 @@ bool Panels::StaticApplyState::ApplyPage( int pageid, bool saveOnSuccess )
*g_Conf = confcopy; *g_Conf = confcopy;
UseAdminMode = g_ApplyState.UseAdminMode; UseAdminMode = g_ApplyState.UseAdminMode;
g_Conf->Apply(); wxGetApp().ApplySettings();
if( saveOnSuccess ) if( saveOnSuccess )
g_Conf->Save(); wxGetApp().SaveSettings();
} }
catch( Exception::CannotApplySettings& ex ) catch( Exception::CannotApplySettings& ex )
{ {

View File

@ -368,9 +368,8 @@ 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" ) )
{ {
wxGetTopLevelParent( this )->Disable(); ScopedWindowDisable disabler( wxGetTopLevelParent( this ) );
configfunc(); configfunc();
wxGetTopLevelParent( this )->Enable();
} }
} }

View File

@ -39,7 +39,6 @@ DEFINE_EVENT_TYPE( pxEVT_SemaphorePing )
bool UseAdminMode = false; bool UseAdminMode = false;
AppConfig* g_Conf = NULL; AppConfig* g_Conf = NULL;
wxFileHistory* g_RecentIsoList = NULL;
namespace Exception namespace Exception
{ {
@ -180,7 +179,7 @@ void Pcsx2App::ReadUserModeSettings()
IniSaver saver( *conf_usermode ); IniSaver saver( *conf_usermode );
g_Conf->LoadSaveUserMode( saver, groupname ); g_Conf->LoadSaveUserMode( saver, groupname );
AppConfig_ReloadGlobalSettings( true ); AppConfig_ReloadGlobalSettings( true );
g_Conf->Save(); wxGetApp().SaveSettings();
} }
else else
{ {
@ -205,7 +204,7 @@ void Pcsx2App::ReadUserModeSettings()
IniSaver saver( *conf_usermode ); IniSaver saver( *conf_usermode );
g_Conf->LoadSaveUserMode( saver, groupname ); g_Conf->LoadSaveUserMode( saver, groupname );
AppConfig_ReloadGlobalSettings( true ); AppConfig_ReloadGlobalSettings( true );
g_Conf->Save(); wxGetApp().SaveSettings();
} }
} }
} }
@ -311,6 +310,8 @@ bool Pcsx2App::OnInit()
return false; return false;
} }
ApplySettings();
return true; return true;
} }
@ -354,7 +355,7 @@ void Pcsx2App::OnMessageBox( pxMessageBoxEvent& evt )
void Pcsx2App::CleanupMess() void Pcsx2App::CleanupMess()
{ {
safe_delete( g_RecentIsoList ); SysReset();
safe_delete( m_Bitmap_Logo ); safe_delete( m_Bitmap_Logo );
safe_delete( g_Conf ); safe_delete( g_Conf );
} }
@ -392,17 +393,20 @@ bool Pcsx2App::PrepForExit()
int Pcsx2App::OnExit() int Pcsx2App::OnExit()
{ {
m_ProgramLogBox = NULL; m_ProgramLogBox = NULL;
m_MainFrame = NULL;
MemoryCard::Shutdown(); MemoryCard::Shutdown();
if( g_Conf != NULL ) if( g_Conf != NULL )
g_Conf->Save(); SaveSettings();
CleanupMess(); CleanupMess();
return wxApp::OnExit(); return wxApp::OnExit();
} }
Pcsx2App::Pcsx2App() : Pcsx2App::Pcsx2App() :
m_ProgramLogBox( NULL ) m_MainFrame( NULL )
, m_ProgramLogBox( NULL )
, m_ConfigImages( 32, 32 ) , m_ConfigImages( 32, 32 )
, m_ConfigImagesAreLoaded( false ) , m_ConfigImagesAreLoaded( false )
, m_ToolbarImages( NULL ) , m_ToolbarImages( NULL )
@ -417,3 +421,33 @@ Pcsx2App::~Pcsx2App()
} }
void Pcsx2App::ApplySettings()
{
g_Conf->Apply();
if( m_MainFrame != NULL )
m_MainFrame->ApplySettings();
}
void Pcsx2App::LoadSettings()
{
wxConfigBase* conf = wxConfigBase::Get( false );
if( NULL == conf ) return;
IniLoader loader( *conf );
g_Conf->LoadSave( loader );
if( m_MainFrame != NULL )
m_MainFrame->m_RecentIsoList->Load( *conf );
}
void Pcsx2App::SaveSettings()
{
wxConfigBase* conf = wxConfigBase::Get( false );
if( NULL == conf ) return;
IniSaver saver( *conf );
g_Conf->LoadSave( saver );
if( m_MainFrame != NULL )
m_MainFrame->m_RecentIsoList->Save( *conf );
}

View File

@ -41,6 +41,7 @@ void CoreEmuThread::CpuInitializeMess()
GetPluginManager().Open(); GetPluginManager().Open();
cpuReset(); cpuReset();
SysClearExecutionCache(); SysClearExecutionCache();
GetPluginManager().Open();
if( GSsetGameCRC != NULL ) if( GSsetGameCRC != NULL )
GSsetGameCRC( ElfCRC, 0 ); GSsetGameCRC( ElfCRC, 0 );
@ -100,7 +101,7 @@ sptr CoreEmuThread::ExecuteTask()
while( m_ExecMode != ExecMode_Running ) while( m_ExecMode != ExecMode_Running )
{ {
m_ResumeEvent.Wait(); m_ResumeEvent.WaitGui();
} }
CpuInitializeMess(); CpuInitializeMess();
@ -134,7 +135,7 @@ void CoreEmuThread::StateCheck()
case ExecMode_Suspended: case ExecMode_Suspended:
while( m_ExecMode == ExecMode_Suspended ) while( m_ExecMode == ExecMode_Suspended )
m_ResumeEvent.Wait(); m_ResumeEvent.WaitGui();
break; break;
} }
} }
@ -185,7 +186,7 @@ void CoreEmuThread::Resume()
if( m_resetRecompilers || m_resetProfilers ) if( m_resetRecompilers || m_resetProfilers )
{ {
locker.Unlock(); // no deadlocks please, thanks. :) locker.Unlock(); // no deadlocks please, thanks. :)
m_SuspendEvent.Wait(); m_SuspendEvent.WaitGui();
} }
else else
{ {
@ -235,7 +236,7 @@ void CoreEmuThread::Suspend( bool isBlocking )
DevAssert( m_ExecMode == ExecMode_Suspending, "ExecMode should be nothing other than Suspended..." ); DevAssert( m_ExecMode == ExecMode_Suspending, "ExecMode should be nothing other than Suspended..." );
} }
m_SuspendEvent.Wait(); m_SuspendEvent.WaitGui();
} }
// Applies a full suite of new settings, which will automatically facilitate the necessary // Applies a full suite of new settings, which will automatically facilitate the necessary

View File

@ -1764,10 +1764,6 @@
RelativePath="..\..\CDVD\CDVDisoReader.h" RelativePath="..\..\CDVD\CDVDisoReader.h"
> >
</File> </File>
<File
RelativePath="..\..\CDVD\CDVDlib.h"
>
</File>
<File <File
RelativePath="..\..\CDVD\IsoFileTools.cpp" RelativePath="..\..\CDVD\IsoFileTools.cpp"
> >

View File

@ -739,8 +739,8 @@ void recClear(u32 addr, u32 size)
u32 blockend = pexblock->startpc + pexblock->size * 4; u32 blockend = pexblock->startpc + pexblock->size * 4;
if (pexblock->startpc >= addr && pexblock->startpc < addr + size * 4 if (pexblock->startpc >= addr && pexblock->startpc < addr + size * 4
|| pexblock->startpc < addr && blockend > addr) { || pexblock->startpc < addr && blockend > addr) {
Console::Error("Impossible block clearing failure"); Console::Error( "Impossible block clearing failure" );
jASSUME(0); wxASSERT_MSG( false, L"Impossible block clearing failure" );
} }
} }
#endif #endif