From 982ef418146bf484ecedca955bcc4292a86bb66d Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 6 Jun 2021 18:04:14 +0100 Subject: [PATCH] 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. --- pcsx2/CDVD/CDVDdiscReader.cpp | 4 ++-- pcsx2/gui/AppConfig.cpp | 28 ++-------------------------- pcsx2/gui/AppConfig.h | 2 +- pcsx2/gui/AppMain.cpp | 6 +----- pcsx2/gui/MainMenuClicks.cpp | 2 +- 5 files changed, 7 insertions(+), 35 deletions(-) diff --git a/pcsx2/CDVD/CDVDdiscReader.cpp b/pcsx2/CDVD/CDVDdiscReader.cpp index 0d57018855..2b54f19b3a 100644 --- a/pcsx2/CDVD/CDVDdiscReader.cpp +++ b/pcsx2/CDVD/CDVDdiscReader.cpp @@ -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()) diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index 985a79d64a..fb7454b487 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -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; diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index 7fac2c2f63..0a13f71e29 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -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 ); diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 2c0ac94576..cdea8a9717 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -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(); } diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 63f46d4ade..286c788b60 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -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;