cdvd: Simplify and fix disc variable handling

This fixes an issue on Windows where the previously selected disc drive
choice is cleared if there is no disc in the drive when PCSX2 is opened.
This commit is contained in:
Jonathan Li 2021-06-06 18:04:14 +01:00
parent 7f8ca17752
commit 982ef41814
5 changed files with 7 additions and 35 deletions

View File

@ -184,9 +184,9 @@ void StopKeepAliveThread()
s32 CALLBACK DISCopen(const char* pTitle)
{
#if defined(_WIN32)
std::wstring drive = g_Conf->Folders.RunDisc.GetPath().ToStdWstring();
std::wstring drive = g_Conf->Folders.RunDisc.ToStdWstring();
#else
std::string drive = g_Conf->Folders.RunDisc.GetPath().ToStdString();
std::string drive = g_Conf->Folders.RunDisc.ToStdString();
#endif
GetValidDrive(drive);
if (drive.empty())

View File

@ -737,7 +737,7 @@ AppConfig::FolderOptions::FolderOptions()
, RunIso ( PathDefs::GetDocuments() ) // raw default is always the Documents folder.
, RunELF ( PathDefs::GetDocuments() ) // raw default is always the Documents folder.
, RunDisc ( PathDefs::GetDocuments().GetFilename() )
, RunDisc()
{
bitset = 0xffffffff;
}
@ -777,7 +777,7 @@ void AppConfig::FolderOptions::LoadSave( IniInterface& ini )
IniEntryDirFile( RunIso, rel );
IniEntryDirFile( RunELF, rel );
IniEntryDirFile( RunDisc, rel );
IniEntry(RunDisc);
if( ini.IsLoading() )
{
@ -1303,18 +1303,6 @@ static void LoadUiSettings()
g_Conf->CurrentIso.clear();
}
#if defined(_WIN32)
if( !g_Conf->Folders.RunDisc.DirExists() )
{
g_Conf->Folders.RunDisc.Clear();
}
#else
if (!g_Conf->Folders.RunDisc.Exists())
{
g_Conf->Folders.RunDisc.Clear();
}
#endif
sApp.DispatchUiSettingsEvent( loader );
}
@ -1350,18 +1338,6 @@ static void SaveUiSettings()
g_Conf->CurrentIso.clear();
}
#if defined(_WIN32)
if (!g_Conf->Folders.RunDisc.DirExists())
{
g_Conf->Folders.RunDisc.Clear();
}
#else
if (!g_Conf->Folders.RunDisc.Exists())
{
g_Conf->Folders.RunDisc.Clear();
}
#endif
sApp.GetRecentIsoManager().Add( g_Conf->CurrentIso );
AppIniSaver saver;

View File

@ -172,7 +172,7 @@ public:
wxDirName RunIso; // last used location for Iso loading.
wxDirName RunELF; // last used location for ELF loading.
wxFileName RunDisc; // last used location for Disc loading.
wxString RunDisc; // last used location for Disc loading.
FolderOptions();
void LoadSave( IniInterface& conf );

View File

@ -1218,11 +1218,7 @@ void SysUpdateIsoSrcFile( const wxString& newIsoFile )
void SysUpdateDiscSrcDrive( const wxString& newDiscDrive )
{
#if defined(_WIN32)
g_Conf->Folders.RunDisc = wxFileName::DirName(newDiscDrive);
#else
g_Conf->Folders.RunDisc = wxFileName(newDiscDrive);
#endif
g_Conf->Folders.RunDisc = newDiscDrive;
AppSaveSettings();
sMainFrame.UpdateCdvdSrcSelection();
}

View File

@ -237,7 +237,7 @@ wxWindowID SwapOrReset_Disc(wxWindow* owner, IScopedCoreThread& core, const wxSt
}
wxWindowID result = wxID_CANCEL;
if ((g_Conf->CdvdSource == CDVD_SourceType::Disc) && (driveLetter == g_Conf->Folders.RunDisc.GetPath()))
if ((g_Conf->CdvdSource == CDVD_SourceType::Disc) && (driveLetter == g_Conf->Folders.RunDisc))
{
core.AllowResume();
return result;