mirror of https://github.com/PCSX2/pcsx2.git
CDVD: Convert CDVD_SourceType into enum class
* Add a template function for underlying type conversions of enumerations
This commit is contained in:
parent
f367fa5a98
commit
b86518ef24
|
@ -74,10 +74,11 @@ public:
|
||||||
void EnumEntry(const wxString &var, T &value, const wxChar *const *enumArray = NULL, const T defvalue = (T)0)
|
void EnumEntry(const wxString &var, T &value, const wxChar *const *enumArray = NULL, const T defvalue = (T)0)
|
||||||
{
|
{
|
||||||
int tstore = (int)value;
|
int tstore = (int)value;
|
||||||
|
auto defaultvalue = enum_cast(defvalue);
|
||||||
if (enumArray == NULL)
|
if (enumArray == NULL)
|
||||||
Entry(var, tstore, defvalue);
|
Entry(var, tstore, defaultvalue);
|
||||||
else
|
else
|
||||||
_EnumEntry(var, tstore, enumArray, defvalue);
|
_EnumEntry(var, tstore, enumArray, defaultvalue);
|
||||||
value = (T)tstore;
|
value = (T)tstore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -285,11 +285,11 @@ static void DetectDiskType()
|
||||||
}
|
}
|
||||||
|
|
||||||
static wxString m_SourceFilename[3];
|
static wxString m_SourceFilename[3];
|
||||||
static CDVD_SourceType m_CurrentSourceType = CDVDsrc_NoDisc;
|
static CDVD_SourceType m_CurrentSourceType = CDVD_SourceType::NoDisc;
|
||||||
|
|
||||||
void CDVDsys_SetFile( CDVD_SourceType srctype, const wxString& newfile )
|
void CDVDsys_SetFile( CDVD_SourceType srctype, const wxString& newfile )
|
||||||
{
|
{
|
||||||
m_SourceFilename[srctype] = newfile;
|
m_SourceFilename[enum_cast(srctype)] = newfile;
|
||||||
|
|
||||||
// look for symbol file
|
// look for symbol file
|
||||||
if (symbolMap.IsEmpty())
|
if (symbolMap.IsEmpty())
|
||||||
|
@ -309,7 +309,7 @@ void CDVDsys_SetFile( CDVD_SourceType srctype, const wxString& newfile )
|
||||||
|
|
||||||
const wxString& CDVDsys_GetFile( CDVD_SourceType srctype )
|
const wxString& CDVDsys_GetFile( CDVD_SourceType srctype )
|
||||||
{
|
{
|
||||||
return m_SourceFilename[srctype];
|
return m_SourceFilename[enum_cast(srctype)];
|
||||||
}
|
}
|
||||||
|
|
||||||
CDVD_SourceType CDVDsys_GetSourceType()
|
CDVD_SourceType CDVDsys_GetSourceType()
|
||||||
|
@ -323,15 +323,15 @@ void CDVDsys_ChangeSource( CDVD_SourceType type )
|
||||||
|
|
||||||
switch( m_CurrentSourceType = type )
|
switch( m_CurrentSourceType = type )
|
||||||
{
|
{
|
||||||
case CDVDsrc_Iso:
|
case CDVD_SourceType::Iso:
|
||||||
CDVD = &CDVDapi_Iso;
|
CDVD = &CDVDapi_Iso;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CDVDsrc_NoDisc:
|
case CDVD_SourceType::NoDisc:
|
||||||
CDVD = &CDVDapi_NoDisc;
|
CDVD = &CDVDapi_NoDisc;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CDVDsrc_Plugin:
|
case CDVD_SourceType::Plugin:
|
||||||
CDVD = &CDVDapi_Plugin;
|
CDVD = &CDVDapi_Plugin;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -354,8 +354,9 @@ bool DoCDVDopen()
|
||||||
// question marks if the filename is another language.
|
// question marks if the filename is another language.
|
||||||
// Likely Fix: Force new versions of CDVD plugins to expect UTF8 instead.
|
// Likely Fix: Force new versions of CDVD plugins to expect UTF8 instead.
|
||||||
|
|
||||||
int ret = CDVD->open( !m_SourceFilename[m_CurrentSourceType].IsEmpty() ?
|
auto CurrentSourceType = enum_cast(m_CurrentSourceType);
|
||||||
static_cast<const char*>(m_SourceFilename[m_CurrentSourceType].ToUTF8()) : (char*)NULL
|
int ret = CDVD->open( !m_SourceFilename[CurrentSourceType].IsEmpty() ?
|
||||||
|
static_cast<const char*>(m_SourceFilename[CurrentSourceType].ToUTF8()) : (char*)NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
if( ret == -1 ) return false; // error! (handled by caller)
|
if( ret == -1 ) return false; // error! (handled by caller)
|
||||||
|
@ -374,7 +375,7 @@ bool DoCDVDopen()
|
||||||
// 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 somepick( Path::GetFilenameWithoutExt( m_SourceFilename[m_CurrentSourceType] ) );
|
wxString somepick( Path::GetFilenameWithoutExt( m_SourceFilename[CurrentSourceType] ) );
|
||||||
if( somepick.IsEmpty() )
|
if( somepick.IsEmpty() )
|
||||||
somepick = L"Untitled";
|
somepick = L"Untitled";
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
#include "Plugins.h"
|
#include "Plugins.h"
|
||||||
|
|
||||||
enum CDVD_SourceType
|
enum class CDVD_SourceType : uint8_t
|
||||||
{
|
{
|
||||||
CDVDsrc_Iso = 0, // use built in ISO api
|
Iso, // use built in ISO api
|
||||||
CDVDsrc_Plugin, // use external plugin
|
Plugin, // use external plugin
|
||||||
CDVDsrc_NoDisc, // use built in CDVDnull
|
NoDisc, // use built in CDVDnull
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CDVD_API
|
struct CDVD_API
|
||||||
|
|
|
@ -63,6 +63,13 @@ enum GamefixId
|
||||||
GamefixId_COUNT
|
GamefixId_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Template function for casting enumerations to their underlying type
|
||||||
|
template <typename Enumeration>
|
||||||
|
typename std::underlying_type<Enumeration>::type enum_cast(Enumeration E)
|
||||||
|
{
|
||||||
|
return static_cast<typename std::underlying_type<Enumeration>::type>(E);
|
||||||
|
}
|
||||||
|
|
||||||
ImplementEnumOperators( GamefixId );
|
ImplementEnumOperators( GamefixId );
|
||||||
|
|
||||||
//------------ DEFAULT sseMXCSR VALUES ---------------
|
//------------ DEFAULT sseMXCSR VALUES ---------------
|
||||||
|
|
|
@ -305,7 +305,7 @@ public:
|
||||||
SysAutoRun = false;
|
SysAutoRun = false;
|
||||||
SysAutoRunElf = false;
|
SysAutoRunElf = false;
|
||||||
SysAutoRunIrx = false;
|
SysAutoRunIrx = false;
|
||||||
CdvdSource = CDVDsrc_NoDisc;
|
CdvdSource = CDVD_SourceType::NoDisc;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -549,7 +549,7 @@ AppConfig::AppConfig()
|
||||||
EnablePresets = true;
|
EnablePresets = true;
|
||||||
PresetIndex = 1;
|
PresetIndex = 1;
|
||||||
|
|
||||||
CdvdSource = CDVDsrc_Iso;
|
CdvdSource = CDVD_SourceType::Iso;
|
||||||
|
|
||||||
// To be moved to FileMemoryCard pluign (someday)
|
// To be moved to FileMemoryCard pluign (someday)
|
||||||
for( uint slot=0; slot<8; ++slot )
|
for( uint slot=0; slot<8; ++slot )
|
||||||
|
|
|
@ -191,12 +191,12 @@ void Pcsx2App::SysApplySettings()
|
||||||
CoreThread.ApplySettings( g_Conf->EmuOptions );
|
CoreThread.ApplySettings( g_Conf->EmuOptions );
|
||||||
|
|
||||||
CDVD_SourceType cdvdsrc( g_Conf->CdvdSource );
|
CDVD_SourceType cdvdsrc( g_Conf->CdvdSource );
|
||||||
if( cdvdsrc != CDVDsys_GetSourceType() || (cdvdsrc==CDVDsrc_Iso && (CDVDsys_GetFile(cdvdsrc) != g_Conf->CurrentIso)) )
|
if( cdvdsrc != CDVDsys_GetSourceType() || (cdvdsrc == CDVD_SourceType::Iso && (CDVDsys_GetFile(cdvdsrc) != g_Conf->CurrentIso)) )
|
||||||
{
|
{
|
||||||
CoreThread.ResetCdvd();
|
CoreThread.ResetCdvd();
|
||||||
}
|
}
|
||||||
|
|
||||||
CDVDsys_SetFile( CDVDsrc_Iso, g_Conf->CurrentIso );
|
CDVDsys_SetFile(CDVD_SourceType::Iso, g_Conf->CurrentIso );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppCoreThread::OnResumeReady()
|
void AppCoreThread::OnResumeReady()
|
||||||
|
|
|
@ -366,7 +366,7 @@ bool Pcsx2App::OnCmdLineParsed( wxCmdLineParser& parser )
|
||||||
|
|
||||||
if( parser.Found(L"usecd") )
|
if( parser.Found(L"usecd") )
|
||||||
{
|
{
|
||||||
Startup.CdvdSource = CDVDsrc_Plugin;
|
Startup.CdvdSource = CDVD_SourceType::Plugin;
|
||||||
Startup.SysAutoRun = true;
|
Startup.SysAutoRun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1064,7 +1064,7 @@ public:
|
||||||
SysExecEvent_Execute()
|
SysExecEvent_Execute()
|
||||||
: m_UseCDVDsrc(false)
|
: m_UseCDVDsrc(false)
|
||||||
, m_UseELFOverride(false)
|
, m_UseELFOverride(false)
|
||||||
, m_cdvdsrc_type(CDVDsrc_Iso)
|
, m_cdvdsrc_type(CDVD_SourceType::Iso)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1090,11 +1090,11 @@ protected:
|
||||||
CoreThread.ResetQuick();
|
CoreThread.ResetQuick();
|
||||||
symbolMap.Clear();
|
symbolMap.Clear();
|
||||||
|
|
||||||
CDVDsys_SetFile( CDVDsrc_Iso, g_Conf->CurrentIso );
|
CDVDsys_SetFile(CDVD_SourceType::Iso, g_Conf->CurrentIso );
|
||||||
if( m_UseCDVDsrc )
|
if( m_UseCDVDsrc )
|
||||||
CDVDsys_ChangeSource( m_cdvdsrc_type );
|
CDVDsys_ChangeSource( m_cdvdsrc_type );
|
||||||
else if( CDVD == NULL )
|
else if( CDVD == NULL )
|
||||||
CDVDsys_ChangeSource( CDVDsrc_NoDisc );
|
CDVDsys_ChangeSource(CDVD_SourceType::NoDisc);
|
||||||
|
|
||||||
if( m_UseELFOverride && !CoreThread.HasActiveMachine() )
|
if( m_UseELFOverride && !CoreThread.HasActiveMachine() )
|
||||||
CoreThread.SetElfOverride( m_elf_override );
|
CoreThread.SetElfOverride( m_elf_override );
|
||||||
|
|
|
@ -57,14 +57,14 @@ void MainEmuFrame::UpdateIsoSrcSelection()
|
||||||
|
|
||||||
switch( g_Conf->CdvdSource )
|
switch( g_Conf->CdvdSource )
|
||||||
{
|
{
|
||||||
case CDVDsrc_Iso: cdsrc = MenuId_Src_Iso; break;
|
case CDVD_SourceType::Iso: cdsrc = MenuId_Src_Iso; break;
|
||||||
case CDVDsrc_Plugin: cdsrc = MenuId_Src_Plugin; break;
|
case CDVD_SourceType::Plugin: cdsrc = MenuId_Src_Plugin; break;
|
||||||
case CDVDsrc_NoDisc: cdsrc = MenuId_Src_NoDisc; break;
|
case CDVD_SourceType::NoDisc: cdsrc = MenuId_Src_NoDisc; break;
|
||||||
|
|
||||||
jNO_DEFAULT
|
jNO_DEFAULT
|
||||||
}
|
}
|
||||||
sMenuBar.Check( cdsrc, true );
|
sMenuBar.Check( cdsrc, true );
|
||||||
m_statusbar.SetStatusText( CDVD_SourceLabels[g_Conf->CdvdSource], 1 );
|
m_statusbar.SetStatusText( CDVD_SourceLabels[enum_cast(g_Conf->CdvdSource)], 1 );
|
||||||
|
|
||||||
EnableCdvdPluginSubmenu( cdsrc == MenuId_Src_Plugin );
|
EnableCdvdPluginSubmenu( cdsrc == MenuId_Src_Plugin );
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ wxWindowID SwapOrReset_Iso( wxWindow* owner, IScopedCoreThread& core_control, co
|
||||||
{
|
{
|
||||||
wxWindowID result = wxID_CANCEL;
|
wxWindowID result = wxID_CANCEL;
|
||||||
|
|
||||||
if( (g_Conf->CdvdSource == CDVDsrc_Iso) && (isoFilename == g_Conf->CurrentIso) )
|
if( (g_Conf->CdvdSource == CDVD_SourceType::Iso) && (isoFilename == g_Conf->CurrentIso) )
|
||||||
{
|
{
|
||||||
core_control.AllowResume();
|
core_control.AllowResume();
|
||||||
return result;
|
return result;
|
||||||
|
@ -158,12 +158,12 @@ wxWindowID SwapOrReset_Iso( wxWindow* owner, IScopedCoreThread& core_control, co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_Conf->CdvdSource = CDVDsrc_Iso;
|
g_Conf->CdvdSource = CDVD_SourceType::Iso;
|
||||||
SysUpdateIsoSrcFile( isoFilename );
|
SysUpdateIsoSrcFile( isoFilename );
|
||||||
if( result == wxID_RESET )
|
if( result == wxID_RESET )
|
||||||
{
|
{
|
||||||
core_control.DisallowResume();
|
core_control.DisallowResume();
|
||||||
sApp.SysExecute( CDVDsrc_Iso );
|
sApp.SysExecute(CDVD_SourceType::Iso);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -173,7 +173,7 @@ wxWindowID SwapOrReset_Iso( wxWindow* owner, IScopedCoreThread& core_control, co
|
||||||
core_control.AllowResume();
|
core_control.AllowResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
GetMainFrame().EnableCdvdPluginSubmenu( g_Conf->CdvdSource == CDVDsrc_Plugin );
|
GetMainFrame().EnableCdvdPluginSubmenu( g_Conf->CdvdSource == CDVD_SourceType::Plugin);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ wxWindowID SwapOrReset_CdvdSrc( wxWindow* owner, CDVD_SourceType newsrc )
|
||||||
|
|
||||||
wxString changeMsg;
|
wxString changeMsg;
|
||||||
changeMsg.Printf(_("You've selected to switch the CDVD source from %s to %s."),
|
changeMsg.Printf(_("You've selected to switch the CDVD source from %s to %s."),
|
||||||
CDVD_SourceLabels[g_Conf->CdvdSource], CDVD_SourceLabels[newsrc] );
|
CDVD_SourceLabels[enum_cast(g_Conf->CdvdSource)], CDVD_SourceLabels[enum_cast(newsrc)] );
|
||||||
|
|
||||||
dialog += dialog.Heading(changeMsg + L"\n\n" +
|
dialog += dialog.Heading(changeMsg + L"\n\n" +
|
||||||
_("Do you want to swap discs or boot the new image (system reset)?")
|
_("Do you want to swap discs or boot the new image (system reset)?")
|
||||||
|
@ -212,7 +212,8 @@ wxWindowID SwapOrReset_CdvdSrc( wxWindow* owner, CDVD_SourceType newsrc )
|
||||||
if( result != wxID_RESET )
|
if( result != wxID_RESET )
|
||||||
{
|
{
|
||||||
Console.Indent().WriteLn(L"(CdvdSource) HotSwapping CDVD source types from %s to %s.",
|
Console.Indent().WriteLn(L"(CdvdSource) HotSwapping CDVD source types from %s to %s.",
|
||||||
WX_STR(wxString(CDVD_SourceLabels[oldsrc])), WX_STR(wxString(CDVD_SourceLabels[newsrc])));
|
WX_STR(wxString(CDVD_SourceLabels[enum_cast(oldsrc)])),
|
||||||
|
WX_STR(wxString(CDVD_SourceLabels[enum_cast(newsrc)])));
|
||||||
//CoreThread.ChangeCdvdSource();
|
//CoreThread.ChangeCdvdSource();
|
||||||
sMainFrame.UpdateIsoSrcSelection();
|
sMainFrame.UpdateIsoSrcSelection();
|
||||||
core.AllowResume();
|
core.AllowResume();
|
||||||
|
@ -223,7 +224,7 @@ wxWindowID SwapOrReset_CdvdSrc( wxWindow* owner, CDVD_SourceType newsrc )
|
||||||
sApp.SysExecute( g_Conf->CdvdSource );
|
sApp.SysExecute( g_Conf->CdvdSource );
|
||||||
}
|
}
|
||||||
|
|
||||||
GetMainFrame().EnableCdvdPluginSubmenu( g_Conf->CdvdSource == CDVDsrc_Plugin );
|
GetMainFrame().EnableCdvdPluginSubmenu( g_Conf->CdvdSource == CDVD_SourceType::Plugin );
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -313,7 +314,7 @@ void MainEmuFrame::_DoBootCdvd()
|
||||||
{
|
{
|
||||||
ScopedCoreThreadPause paused_core;
|
ScopedCoreThreadPause paused_core;
|
||||||
|
|
||||||
if( g_Conf->CdvdSource == CDVDsrc_Iso )
|
if( g_Conf->CdvdSource == CDVD_SourceType::Iso )
|
||||||
{
|
{
|
||||||
bool selector = g_Conf->CurrentIso.IsEmpty();
|
bool selector = g_Conf->CurrentIso.IsEmpty();
|
||||||
|
|
||||||
|
@ -369,13 +370,13 @@ void MainEmuFrame::EnableCdvdPluginSubmenu(bool isEnable)
|
||||||
|
|
||||||
void MainEmuFrame::Menu_CdvdSource_Click( wxCommandEvent &event )
|
void MainEmuFrame::Menu_CdvdSource_Click( wxCommandEvent &event )
|
||||||
{
|
{
|
||||||
CDVD_SourceType newsrc = CDVDsrc_NoDisc;
|
CDVD_SourceType newsrc = CDVD_SourceType::NoDisc;
|
||||||
|
|
||||||
switch( event.GetId() )
|
switch( event.GetId() )
|
||||||
{
|
{
|
||||||
case MenuId_Src_Iso: newsrc = CDVDsrc_Iso; break;
|
case MenuId_Src_Iso: newsrc = CDVD_SourceType::Iso; break;
|
||||||
case MenuId_Src_Plugin: newsrc = CDVDsrc_Plugin; break;
|
case MenuId_Src_Plugin: newsrc = CDVD_SourceType::Plugin; break;
|
||||||
case MenuId_Src_NoDisc: newsrc = CDVDsrc_NoDisc; break;
|
case MenuId_Src_NoDisc: newsrc = CDVD_SourceType::NoDisc; break;
|
||||||
jNO_DEFAULT
|
jNO_DEFAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ void RecentIsoManager::OnChangedSelection( wxCommandEvent& evt )
|
||||||
// Actually there is no change on the selection so the event can be skip
|
// Actually there is no change on the selection so the event can be skip
|
||||||
// Note: It also avoids a deadlock which appears when the core thread is already paused
|
// Note: It also avoids a deadlock which appears when the core thread is already paused
|
||||||
// and ScopedCoreThreadPopup try to stop the thread (GSOpen1 code path)
|
// and ScopedCoreThreadPopup try to stop the thread (GSOpen1 code path)
|
||||||
if( (g_Conf->CdvdSource == CDVDsrc_Iso) && (m_Items[i].Filename == g_Conf->CurrentIso) )
|
if( (g_Conf->CdvdSource == CDVD_SourceType::Iso) && (m_Items[i].Filename == g_Conf->CurrentIso) )
|
||||||
{
|
{
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue