CDVD: drive selection submenu and OS-specific fixes

This commit is contained in:
Filjo Abraham 2020-07-07 21:38:52 -05:00 committed by refractionpcsx2
parent 2c5a23b696
commit 656efa5e20
20 changed files with 310 additions and 86 deletions

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2014 David Quintana [gigaherz] * Copyright (C) 2002-2020 PCSX2 Dev Team
* *
* PCSX2 is free software: you can redistribute it and/or modify it under the terms * PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found- * of the GNU Lesser General Public License as published by the Free Software Found-
@ -171,9 +171,9 @@ void StopKeepAliveThread()
s32 CALLBACK DISCopen(const char* pTitle) s32 CALLBACK DISCopen(const char* pTitle)
{ {
#if defined(_WIN32) #if defined(_WIN32)
std::wstring drive = g_Conf->Folders.RunDisc.ToString().ToStdWstring(); std::wstring drive = g_Conf->Folders.RunDisc.GetPath().ToStdWstring();
#else #else
std::string drive = g_Conf->Folders.RunDisc.ToString().ToStdString(); std::string drive = g_Conf->Folders.RunDisc.GetPath().ToStdString();
#endif #endif
GetValidDrive(drive); GetValidDrive(drive);

View File

@ -108,5 +108,4 @@ s32 cdvdDirectReadSector(u32 sector, s32 mode, u8* buffer);
s32 cdvdGetMediaType(); s32 cdvdGetMediaType();
s32 cdvdRefreshData(); s32 cdvdRefreshData();
void cdvdParseTOC(); void cdvdParseTOC();
#endif /* __CDVD_DISC_READER_H__ */ #endif /* __CDVD_DISC_READER_H__ */

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2014 David Quintana [gigaherz] * Copyright (C) 2002-2020 PCSX2 Dev Team
* *
* PCSX2 is free software: you can redistribute it and/or modify it under the terms * PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found- * of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2020 PCSX2 Dev Team * Copyright (C) 2002-2020 PCSX2 Dev Team
* *
* PCSX2 is free software: you can redistribute it and/or modify it under the terms * PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found- * of the GNU Lesser General Public License as published by the Free Software Found-
@ -16,14 +16,18 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "../CDVDdiscReader.h" #include "../CDVDdiscReader.h"
#ifdef __linux__
#include <libudev.h> #include <libudev.h>
#include <fcntl.h>
#include <linux/cdrom.h> #include <linux/cdrom.h>
#endif
#include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <unistd.h> #include <unistd.h>
std::vector<std::string> GetOpticalDriveList() std::vector<std::string> GetOpticalDriveList()
{ {
#ifdef __linux__
udev* udev_context = udev_new(); udev* udev_context = udev_new();
if (!udev_context) if (!udev_context)
return {}; return {};
@ -51,11 +55,15 @@ std::vector<std::string> GetOpticalDriveList()
udev_unref(udev_context); udev_unref(udev_context);
return drives; return drives;
#else
return {};
#endif
} }
void GetValidDrive(std::string& drive) void GetValidDrive(std::string& drive)
{ {
if (!drive.empty()) { if (!drive.empty()) {
#ifdef __linux__
int fd = open(drive.c_str(), O_RDONLY | O_NONBLOCK); int fd = open(drive.c_str(), O_RDONLY | O_NONBLOCK);
if (fd != -1) { if (fd != -1) {
if (ioctl(fd, CDROM_GET_CAPABILITY, 0) == -1) if (ioctl(fd, CDROM_GET_CAPABILITY, 0) == -1)
@ -65,6 +73,9 @@ void GetValidDrive(std::string& drive)
else { else {
drive.clear(); drive.clear();
} }
#else
drive.clear();
#endif
} }
if (drive.empty()) { if (drive.empty()) {
auto drives = GetOpticalDriveList(); auto drives = GetOpticalDriveList();

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2016 PCSX2 Dev Team * Copyright (C) 2002-2020 PCSX2 Dev Team
* *
* PCSX2 is free software: you can redistribute it and/or modify it under the terms * PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found- * of the GNU Lesser General Public License as published by the Free Software Found-
@ -16,7 +16,10 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "../CDVDdiscReader.h" #include "../CDVDdiscReader.h"
#ifdef __linux__
#include <linux/cdrom.h> #include <linux/cdrom.h>
#endif
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <unistd.h> #include <unistd.h>
@ -103,6 +106,7 @@ bool IOCtlSrc::ReadSectors2048(u32 sector, u32 count, u8* buffer) const
bool IOCtlSrc::ReadSectors2352(u32 sector, u32 count, u8* buffer) const bool IOCtlSrc::ReadSectors2352(u32 sector, u32 count, u8* buffer) const
{ {
#ifdef __linux__
union union
{ {
cdrom_msf msf; cdrom_msf msf;
@ -122,10 +126,14 @@ bool IOCtlSrc::ReadSectors2352(u32 sector, u32 count, u8* buffer) const
} }
return true; return true;
#else
return false;
#endif
} }
bool IOCtlSrc::ReadDVDInfo() bool IOCtlSrc::ReadDVDInfo()
{ {
#ifdef __linux__
dvd_struct dvdrs; dvd_struct dvdrs;
dvdrs.type = DVD_STRUCT_PHYSICAL; dvdrs.type = DVD_STRUCT_PHYSICAL;
dvdrs.physical.layer_num = 0; dvdrs.physical.layer_num = 0;
@ -165,10 +173,14 @@ bool IOCtlSrc::ReadDVDInfo()
} }
return true; return true;
#else
return false;
#endif
} }
bool IOCtlSrc::ReadCDInfo() bool IOCtlSrc::ReadCDInfo()
{ {
#ifdef __linux__
cdrom_tochdr header; cdrom_tochdr header;
if (ioctl(m_device, CDROMREADTOCHDR, &header) == -1) if (ioctl(m_device, CDROMREADTOCHDR, &header) == -1)
@ -194,10 +206,14 @@ bool IOCtlSrc::ReadCDInfo()
m_media_type = -1; m_media_type = -1;
return true; return true;
#else
return false;
#endif
} }
bool IOCtlSrc::DiscReady() bool IOCtlSrc::DiscReady()
{ {
#ifdef __linux__
if (m_device == -1) if (m_device == -1)
return false; return false;
@ -213,4 +229,7 @@ bool IOCtlSrc::DiscReady()
} }
return !!m_sectors; return !!m_sectors;
#else
return false;
#endif
} }

View File

@ -1,20 +1,17 @@
//Copyright (C) 2020 PCSX2 Dev Team /* PCSX2 - PS2 Emulator for PCs
//Copyright (c) David Quintana <DavidQuintana@canal21.com> * Copyright (C) 2002-2020 PCSX2 Dev Team
// *
//This library is free software; you can redistribute it and/or * PCSX2 is free software: you can redistribute it and/or modify it under the terms
//modify it under the terms of the GNU Lesser General Public * of the GNU Lesser General Public License as published by the Free Software Found-
//License as published by the Free Software Foundation; either * ation, either version 3 of the License, or (at your option) any later version.
//version 3.0 of the License, or (at your option) any later version. *
// * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
//This library is distributed in the hope that it will be useful, * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
//but WITHOUT ANY WARRANTY; without even the implied warranty of * PURPOSE. See the GNU General Public License for more details.
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
//Lesser General Public License for more details. * You should have received a copy of the GNU General Public License along with PCSX2.
// * If not, see <http://www.gnu.org/licenses/>.
//You should have received a copy of the GNU Lesser General Public */
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "../CDVDdiscReader.h" #include "../CDVDdiscReader.h"

View File

@ -1,6 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2016 PCSX2 Dev Team * Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2014 David Quintana [gigaherz]
* *
* PCSX2 is free software: you can redistribute it and/or modify it under the terms * PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found- * of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -286,6 +286,7 @@ set(pcsx2GuiSources
gui/Debugger/DebuggerLists.cpp gui/Debugger/DebuggerLists.cpp
gui/Debugger/DisassemblyDialog.cpp gui/Debugger/DisassemblyDialog.cpp
gui/Debugger/DebugEvents.cpp gui/Debugger/DebugEvents.cpp
gui/DriveList.cpp
gui/ExecutorThread.cpp gui/ExecutorThread.cpp
gui/FrameForGS.cpp gui/FrameForGS.cpp
gui/GlobalCommands.cpp gui/GlobalCommands.cpp
@ -343,6 +344,7 @@ set(pcsx2GuiHeaders
gui/Dialogs/ConfigurationDialog.h gui/Dialogs/ConfigurationDialog.h
gui/Dialogs/LogOptionsDialog.h gui/Dialogs/LogOptionsDialog.h
gui/Dialogs/ModalPopups.h gui/Dialogs/ModalPopups.h
gui/DriveList.h
gui/GSFrame.h gui/GSFrame.h
gui/i18n.h gui/i18n.h
gui/IsoDropTarget.h gui/IsoDropTarget.h
@ -403,8 +405,8 @@ set(pcsx2IPUHeaders
# Linux sources # Linux sources
set(pcsx2LinuxSources set(pcsx2LinuxSources
CDVD/Unix/DriveUtility.cpp CDVD/Linux/DriveUtility.cpp
CDVD/Unix/IOCtlSrc.cpp CDVD/Linux/IOCtlSrc.cpp
gui/CpuUsageProviderLnx.cpp gui/CpuUsageProviderLnx.cpp
Linux/LnxConsolePipe.cpp Linux/LnxConsolePipe.cpp
Linux/LnxKeyCodes.cpp Linux/LnxKeyCodes.cpp
@ -412,8 +414,8 @@ set(pcsx2LinuxSources
) )
set(pcsx2OSXSources set(pcsx2OSXSources
CDVD/Unix/DriveUtility.cpp CDVD/Linux/DriveUtility.cpp
CDVD/Unix/IOCtlSrc.cpp CDVD/Linux/IOCtlSrc.cpp
gui/CpuUsageProviderLnx.cpp gui/CpuUsageProviderLnx.cpp
Linux/LnxConsolePipe.cpp Linux/LnxConsolePipe.cpp
# Linux/LnxKeyCodes.cpp # Linux/LnxKeyCodes.cpp
@ -421,6 +423,8 @@ set(pcsx2OSXSources
) )
set(pcsx2FreeBSDSources set(pcsx2FreeBSDSources
CDVD/Linux/DriveUtility.cpp
CDVD/Linux/IOCtlSrc.cpp
gui/CpuUsageProviderLnx.cpp gui/CpuUsageProviderLnx.cpp
Linux/LnxConsolePipe.cpp Linux/LnxConsolePipe.cpp
Linux/LnxKeyCodes.cpp Linux/LnxKeyCodes.cpp
@ -658,10 +662,6 @@ if(APPLE)
set(Platform set(Platform
${pcsx2OSXSources} ${pcsx2OSXSources}
${pcsx2LinuxHeaders}) ${pcsx2LinuxHeaders})
set(Platform_Libs
${LIBUDEV_LIBRARIES}
)
endif() endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")

View File

@ -285,13 +285,7 @@ void SysCoreThread::OnSuspendInThread()
void SysCoreThread::OnResumeInThread( bool isSuspended ) void SysCoreThread::OnResumeInThread( bool isSuspended )
{ {
GetCorePlugins().Open(); GetCorePlugins().Open();
DoCDVDopen();
// When applying settings thread isn't suspended
// so any components that are still loaded don't need to be opened again
if (isSuspended)
{
DoCDVDopen();
}
} }

View File

@ -26,6 +26,7 @@
#include "AppCommon.h" #include "AppCommon.h"
#include "AppCoreThread.h" #include "AppCoreThread.h"
#include "RecentIsoList.h" #include "RecentIsoList.h"
#include "DriveList.h"
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
# include "Recording/VirtualPad.h" # include "Recording/VirtualPad.h"
@ -98,7 +99,6 @@ enum MenuIdentifiers
// Run SubSection // Run SubSection
MenuId_Cdvd_Source, MenuId_Cdvd_Source,
MenuId_DriveSelector,
MenuId_Src_Iso, MenuId_Src_Iso,
MenuId_Src_Disc, MenuId_Src_Disc,
MenuId_Src_NoDisc, MenuId_Src_NoDisc,
@ -106,6 +106,8 @@ enum MenuIdentifiers
MenuId_RecentIsos_reservedStart, MenuId_RecentIsos_reservedStart,
MenuId_IsoBrowse = MenuId_RecentIsos_reservedStart + 100, // Open dialog, runs selected iso. MenuId_IsoBrowse = MenuId_RecentIsos_reservedStart + 100, // Open dialog, runs selected iso.
MenuId_IsoClear, MenuId_IsoClear,
MenuId_DriveSelector,
MenuId_DriveListRefresh,
MenuId_Ask_On_Booting, MenuId_Ask_On_Booting,
MenuId_Boot_CDVD, MenuId_Boot_CDVD,
MenuId_Boot_CDVD2, MenuId_Boot_CDVD2,
@ -527,6 +529,7 @@ protected:
std::unique_ptr<PipeRedirectionBase> m_StderrRedirHandle; std::unique_ptr<PipeRedirectionBase> m_StderrRedirHandle;
std::unique_ptr<RecentIsoList> m_RecentIsoList; std::unique_ptr<RecentIsoList> m_RecentIsoList;
std::unique_ptr<DriveList> m_DriveList;
std::unique_ptr<pxAppResources> m_Resources; std::unique_ptr<pxAppResources> m_Resources;
public: public:
@ -618,6 +621,7 @@ public:
wxMenu& GetRecentIsoMenu(); wxMenu& GetRecentIsoMenu();
RecentIsoManager& GetRecentIsoManager(); RecentIsoManager& GetRecentIsoManager();
wxMenu& GetDriveListMenu();
pxAppResources& GetResourceCache(); pxAppResources& GetResourceCache();
const wxIconBundle& GetIconBundle(); const wxIconBundle& GetIconBundle();

View File

@ -641,7 +641,6 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini )
ini.Entry( L"CurrentIso", res, res, ini.IsLoading() || IsPortable() ); ini.Entry( L"CurrentIso", res, res, ini.IsLoading() || IsPortable() );
CurrentIso = res.GetFullPath(); CurrentIso = res.GetFullPath();
IniEntry( CurrentDisc );
IniEntry( CurrentBlockdump ); IniEntry( CurrentBlockdump );
IniEntry( CurrentELF ); IniEntry( CurrentELF );
IniEntry( CurrentIRX ); IniEntry( CurrentIRX );
@ -728,7 +727,7 @@ AppConfig::FolderOptions::FolderOptions()
, RunIso ( PathDefs::GetDocuments() ) // raw default is always the Documents folder. , RunIso ( PathDefs::GetDocuments() ) // raw default is always the Documents folder.
, RunELF ( PathDefs::GetDocuments() ) // raw default is always the Documents folder. , RunELF ( PathDefs::GetDocuments() ) // raw default is always the Documents folder.
, RunDisc ( PathDefs::GetDocuments() ) , RunDisc ( PathDefs::GetDocuments().GetFilename() )
{ {
bitset = 0xffffffff; bitset = 0xffffffff;
} }
@ -1261,10 +1260,17 @@ static void LoadUiSettings()
g_Conf->CurrentIso.clear(); g_Conf->CurrentIso.clear();
} }
if( !wxDirExists( g_Conf->CurrentDisc ) ) #if defined(_WIN32)
if( !g_Conf->Folders.RunDisc.DirExists() )
{ {
g_Conf->CurrentDisc.clear(); g_Conf->Folders.RunDisc.Clear();
} }
#else
if (!g_Conf->Folders.RunDisc.Exists())
{
g_Conf->Folders.RunDisc.Clear();
}
#endif
sApp.DispatchUiSettingsEvent( loader ); sApp.DispatchUiSettingsEvent( loader );
} }
@ -1301,10 +1307,17 @@ static void SaveUiSettings()
g_Conf->CurrentIso.clear(); g_Conf->CurrentIso.clear();
} }
if( !wxDirExists( g_Conf->CurrentDisc ) ) #if defined(_WIN32)
if (!g_Conf->Folders.RunDisc.DirExists())
{ {
g_Conf->CurrentDisc.clear(); g_Conf->Folders.RunDisc.Clear();
} }
#else
if (!g_Conf->Folders.RunDisc.Exists())
{
g_Conf->Folders.RunDisc.Clear();
}
#endif
sApp.GetRecentIsoManager().Add( g_Conf->CurrentIso ); sApp.GetRecentIsoManager().Add( g_Conf->CurrentIso );

View File

@ -166,7 +166,7 @@ public:
wxDirName RunIso; // last used location for Iso loading. wxDirName RunIso; // last used location for Iso loading.
wxDirName RunELF; // last used location for ELF loading. wxDirName RunELF; // last used location for ELF loading.
wxDirName RunDisc; // last used location for Disc loading. wxFileName RunDisc; // last used location for Disc loading.
FolderOptions(); FolderOptions();
void LoadSave( IniInterface& conf ); void LoadSave( IniInterface& conf );
@ -325,7 +325,6 @@ public:
bool AskOnBoot; bool AskOnBoot;
wxString CurrentIso; wxString CurrentIso;
wxString CurrentDisc;
wxString CurrentBlockdump; wxString CurrentBlockdump;
wxString CurrentELF; wxString CurrentELF;
wxString CurrentIRX; wxString CurrentIRX;

View File

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

View File

@ -68,6 +68,16 @@ RecentIsoManager& Pcsx2App::GetRecentIsoManager()
return *m_RecentIsoList->Manager; return *m_RecentIsoList->Manager;
} }
wxMenu& Pcsx2App::GetDriveListMenu()
{
if( !m_DriveList )
{
m_DriveList = std::unique_ptr<DriveList>(new DriveList());
}
return *m_DriveList->Menu;
}
pxAppResources& Pcsx2App::GetResourceCache() pxAppResources& Pcsx2App::GetResourceCache()
{ {
ScopedLock lock( m_mtx_Resources ); ScopedLock lock( m_mtx_Resources );

110
pcsx2/gui/DriveList.cpp Normal file
View File

@ -0,0 +1,110 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "DriveList.h"
#include "MainFrame.h"
#include "../CDVD/CDVDdiscReader.h"
DriveList::DriveList()
{
Menu = new wxMenu();
Manager = std::unique_ptr<DriveListManager>(new DriveListManager(Menu));
}
DriveListManager::DriveListManager(wxMenu* menu)
: m_Menu( menu )
{
m_Menu->Append(MenuId_DriveListRefresh, _("&Refresh"));
m_Menu->AppendSeparator();
RefreshList();
// Bind on app level so that the event can be accessed outside DriveListManager
wxGetApp().Bind(wxEVT_MENU, &DriveListManager::OnRefreshClicked, this, MenuId_DriveListRefresh);
}
void DriveListManager::ClearList()
{
for (uint i = 0; i < m_Items.size(); i++)
{
m_Menu->Unbind(wxEVT_MENU, &DriveListManager::OnChangedSelection, this, m_Items.at(i)->itemPtr->GetId());
m_Menu->Destroy(m_Items.at(i)->itemPtr);
}
m_Items.clear();
}
void DriveListManager::RefreshList()
{
ClearList();
auto drives = GetOpticalDriveList();
bool itemChecked = false;
for (auto i : drives)
{
std::unique_ptr<DriveListItem> dli = std::unique_ptr<DriveListItem>(new DriveListItem());
dli->driveLetter = wxString(i);
dli->itemPtr = m_Menu->AppendRadioItem(wxID_ANY, i);
// Check the last used drive item
if (g_Conf->Folders.RunDisc == dli->driveLetter)
{
dli->itemPtr->Check(true);
itemChecked = true;
}
m_Menu->Bind(wxEVT_MENU, &DriveListManager::OnChangedSelection, this, dli->itemPtr->GetId());
m_Items.push_back(std::move(dli));
}
// Last used drive not found so use first found drive
if (itemChecked == false && m_Items.size() > 0)
{
m_Items.at(0)->itemPtr->Check(true);
SysUpdateDiscSrcDrive(m_Items.at(0)->driveLetter);
}
}
void DriveListManager::OnChangedSelection( wxCommandEvent& evt )
{
uint index = m_Items.size();
for (uint i = 0; i < m_Items.size(); i++)
{
if( (m_Items.at(i)->itemPtr != NULL) && (m_Items.at(i)->itemPtr->GetId() == evt.GetId()) )
{
index = i;
break;
}
}
if (index >= m_Items.size())
{
evt.Skip();
return;
}
m_Items.at(index)->itemPtr->Check(true);
ScopedCoreThreadPopup paused_core;
SwapOrReset_Disc(m_Menu->GetWindow(), paused_core, m_Items.at(index)->driveLetter);
}
void DriveListManager::OnRefreshClicked( wxCommandEvent& evt )
{
RefreshList();
}

60
pcsx2/gui/DriveList.h Normal file
View File

@ -0,0 +1,60 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "AppCoreThread.h"
class DriveListManager : public wxEvtHandler
{
protected:
struct DriveListItem
{
wxString driveLetter;
wxMenuItem* itemPtr;
DriveListItem() { itemPtr = NULL; }
DriveListItem( const wxString& src )
: driveLetter( src )
{
itemPtr = NULL;
}
};
std::vector<std::unique_ptr<DriveListItem>> m_Items;
wxMenu* m_Menu;
public:
DriveListManager(wxMenu* menu);
virtual ~DriveListManager() = default;
void RefreshList();
protected:
void ClearList();
void OnChangedSelection( wxCommandEvent& evt );
void OnRefreshClicked( wxCommandEvent& evt );
};
struct DriveList
{
wxMenu* Menu;
std::unique_ptr<DriveListManager> Manager;
DriveList();
};
extern wxWindowID SwapOrReset_Disc(wxWindow* owner, IScopedCoreThread& core, const wxString driveLetter);

View File

@ -124,6 +124,7 @@ protected:
wxMenu& m_GameSettingsSubmenu; wxMenu& m_GameSettingsSubmenu;
wxMenuItem* m_menuItem_RecentIsoMenu; wxMenuItem* m_menuItem_RecentIsoMenu;
wxMenuItem* m_menuItem_DriveListMenu;
wxMenuItem& m_MenuItem_Console; wxMenuItem& m_MenuItem_Console;
#if defined(__unix__) #if defined(__unix__)
wxMenuItem& m_MenuItem_Console_Stdio; wxMenuItem& m_MenuItem_Console_Stdio;

View File

@ -185,7 +185,7 @@ wxWindowID SwapOrReset_Disc( wxWindow* owner, IScopedCoreThread& core, const wxS
{ {
wxWindowID result = wxID_CANCEL; wxWindowID result = wxID_CANCEL;
if ((g_Conf->CdvdSource == CDVD_SourceType::Disc) && (driveLetter == g_Conf->CurrentDisc)) if ((g_Conf->CdvdSource == CDVD_SourceType::Disc) && (driveLetter == g_Conf->Folders.RunDisc.GetPath()))
{ {
core.AllowResume(); core.AllowResume();
return result; return result;
@ -356,12 +356,12 @@ bool MainEmuFrame::_DoSelectELFBrowser()
bool MainEmuFrame::_DoSelectDiscBrowser(wxString& driveLetter) bool MainEmuFrame::_DoSelectDiscBrowser(wxString& driveLetter)
{ {
DriveSelectorDialog driveDialog(this, g_Conf->Folders.RunDisc.ToString()); DriveSelectorDialog driveDialog(this, g_Conf->Folders.RunDisc.GetPath());
if (driveDialog.ShowModal() != wxID_CANCEL) if (driveDialog.ShowModal() != wxID_CANCEL)
{ {
driveLetter = driveDialog.GetSelectedDrive(); driveLetter = driveDialog.GetSelectedDrive();
g_Conf->Folders.RunDisc = wxDirName(driveLetter); SysUpdateDiscSrcDrive(driveLetter);
return true; return true;
} }
@ -406,33 +406,37 @@ void MainEmuFrame::_DoBootCdvd()
} }
else if( g_Conf->CdvdSource == CDVD_SourceType::Disc ) else if( g_Conf->CdvdSource == CDVD_SourceType::Disc )
{ {
bool selector = g_Conf->CurrentDisc.IsEmpty(); #if defined(_WIN32)
const bool driveExists = g_Conf->Folders.RunDisc.DirExists();
#else
const bool driveExists = g_Conf->Folders.RunDisc.Exists();
#endif
if( !selector && !wxDirExists(g_Conf->CurrentDisc) ) if( !driveExists )
{ {
// The previous mounted disc isn't mounted anymore // The previous mounted disc isn't mounted anymore
wxDialogWithHelpers dialog( this, _("Drive not mounted!") ); wxDialogWithHelpers dialog( this, _("Drive not mounted!") );
dialog += dialog.Heading( dialog += dialog.Heading(
_("An error occured while trying to read drive: ") + g_Conf->CurrentDisc + L"\n\n" + _("An error occured while trying to read drive: ") + g_Conf->Folders.RunDisc.GetPath() + L"\n\n" +
_("Error: The configured drive does not exist. Click OK to select a new drive for CDVD.") _("Error: The configured drive does not exist. Click OK to select a new drive for CDVD.")
); );
// Send event to refresh drive list submenu
wxCommandEvent event(wxEVT_MENU, MenuId_DriveListRefresh);
wxGetApp().ProcessEvent(event);
pxIssueConfirmation( dialog, MsgButtons().OK() ); pxIssueConfirmation( dialog, MsgButtons().OK() );
selector = true;
}
if( selector || g_Conf->AskOnBoot )
{
wxString driveLetter; wxString driveLetter;
if( !_DoSelectDiscBrowser( driveLetter ) ) if (!_DoSelectDiscBrowser(driveLetter))
{ {
paused_core.AllowResume(); paused_core.AllowResume();
return; return;
} }
SysUpdateDiscSrcDrive( driveLetter ); // Refresh again after selection
wxGetApp().ProcessEvent(event);
} }
} }
@ -493,7 +497,6 @@ void MainEmuFrame::Menu_DiscBrowse_Click(wxCommandEvent& event)
} }
SwapOrReset_Disc(this, core, driveLetter); SwapOrReset_Disc(this, core, driveLetter);
AppSaveSettings();
} }
wxString GetMsg_IsoImageChanged() wxString GetMsg_IsoImageChanged()

View File

@ -148,25 +148,17 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\CDVD\BlockdumpFileReader.cpp" /> <ClCompile Include="..\..\CDVD\BlockdumpFileReader.cpp" />
<ClCompile Include="..\..\CDVD\CDVDdiscReader.cpp" /> <ClCompile Include="..\..\CDVD\CDVDdiscReader.cpp" />
<ClCompile Include="..\..\CDVD\CDVDdiscThread.cpp"> <ClCompile Include="..\..\CDVD\CDVDdiscThread.cpp" />
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Devel|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\CDVD\ChunksCache.cpp" /> <ClCompile Include="..\..\CDVD\ChunksCache.cpp" />
<ClCompile Include="..\..\CDVD\CompressedFileReader.cpp" /> <ClCompile Include="..\..\CDVD\CompressedFileReader.cpp" />
<ClCompile Include="..\..\CDVD\CsoFileReader.cpp" /> <ClCompile Include="..\..\CDVD\CsoFileReader.cpp" />
<ClCompile Include="..\..\CDVD\GzippedFileReader.cpp" /> <ClCompile Include="..\..\CDVD\GzippedFileReader.cpp" />
<ClCompile Include="..\..\CDVD\OutputIsoFile.cpp" /> <ClCompile Include="..\..\CDVD\OutputIsoFile.cpp" />
<ClCompile Include="..\..\CDVD\Unix\DriveUtility.cpp"> <ClCompile Include="..\..\CDVD\Linux\DriveUtility.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Devel|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\CDVD\Unix\IOCtlSrc.cpp"> <ClCompile Include="..\..\CDVD\Linux\IOCtlSrc.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Devel|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\CDVD\Windows\DriveUtility.cpp" /> <ClCompile Include="..\..\CDVD\Windows\DriveUtility.cpp" />
<ClCompile Include="..\..\CDVD\Windows\IOCtlSrc.cpp" /> <ClCompile Include="..\..\CDVD\Windows\IOCtlSrc.cpp" />
@ -194,6 +186,7 @@
<ClCompile Include="..\..\gui\Debugger\DisassemblyDialog.cpp" /> <ClCompile Include="..\..\gui\Debugger\DisassemblyDialog.cpp" />
<ClCompile Include="..\..\gui\Dialogs\DriveSelectorDialog.cpp" /> <ClCompile Include="..\..\gui\Dialogs\DriveSelectorDialog.cpp" />
<ClCompile Include="..\..\gui\Dialogs\McdConfigDialog.cpp" /> <ClCompile Include="..\..\gui\Dialogs\McdConfigDialog.cpp" />
<ClCompile Include="..\..\gui\DriveList.cpp" />
<ClCompile Include="..\..\gui\Panels\MemoryCardListView.cpp" /> <ClCompile Include="..\..\gui\Panels\MemoryCardListView.cpp" />
<ClCompile Include="..\..\IopGte.cpp" /> <ClCompile Include="..\..\IopGte.cpp" />
<ClCompile Include="..\..\IPU\IPUdma.cpp" /> <ClCompile Include="..\..\IPU\IPUdma.cpp" />
@ -434,6 +427,7 @@
<ClInclude Include="..\..\GameDatabase.h" /> <ClInclude Include="..\..\GameDatabase.h" />
<ClInclude Include="..\..\Gif_Unit.h" /> <ClInclude Include="..\..\Gif_Unit.h" />
<ClInclude Include="..\..\gui\AppGameDatabase.h" /> <ClInclude Include="..\..\gui\AppGameDatabase.h" />
<ClInclude Include="..\..\gui\DriveList.h" />
<ClInclude Include="..\..\gui\Saveslots.h" /> <ClInclude Include="..\..\gui\Saveslots.h" />
<ClInclude Include="..\..\gui\Debugger\BreakpointWindow.h" /> <ClInclude Include="..\..\gui\Debugger\BreakpointWindow.h" />
<ClInclude Include="..\..\gui\Debugger\CtrlDisassemblyView.h" /> <ClInclude Include="..\..\gui\Debugger\CtrlDisassemblyView.h" />

View File

@ -151,7 +151,7 @@
<Filter Include="System\Ps2\Iop\CDVD\Windows"> <Filter Include="System\Ps2\Iop\CDVD\Windows">
<UniqueIdentifier>{be861049-a142-4650-85a5-a2fdd4eef011}</UniqueIdentifier> <UniqueIdentifier>{be861049-a142-4650-85a5-a2fdd4eef011}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="System\Ps2\Iop\CDVD\Unix"> <Filter Include="System\Ps2\Iop\CDVD\Linux">
<UniqueIdentifier>{a5904fb6-e846-4cbf-940c-ca1c604140a0}</UniqueIdentifier> <UniqueIdentifier>{a5904fb6-e846-4cbf-940c-ca1c604140a0}</UniqueIdentifier>
</Filter> </Filter>
</ItemGroup> </ItemGroup>
@ -882,11 +882,14 @@
<ClCompile Include="..\..\CDVD\Windows\IOCtlSrc.cpp"> <ClCompile Include="..\..\CDVD\Windows\IOCtlSrc.cpp">
<Filter>System\Ps2\Iop\CDVD\Windows</Filter> <Filter>System\Ps2\Iop\CDVD\Windows</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\CDVD\Unix\IOCtlSrc.cpp"> <ClCompile Include="..\..\CDVD\Linux\IOCtlSrc.cpp">
<Filter>System\Ps2\Iop\CDVD\Unix</Filter> <Filter>System\Ps2\Iop\CDVD\Linux</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\CDVD\Unix\DriveUtility.cpp"> <ClCompile Include="..\..\CDVD\Linux\DriveUtility.cpp">
<Filter>System\Ps2\Iop\CDVD\Unix</Filter> <Filter>System\Ps2\Iop\CDVD\Linux</Filter>
</ClCompile>
<ClCompile Include="..\..\gui\DriveList.cpp">
<Filter>AppHost</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -1339,6 +1342,9 @@
<ClInclude Include="..\..\CDVD\CDVDdiscReader.h"> <ClInclude Include="..\..\CDVD\CDVDdiscReader.h">
<Filter>System\Ps2\Iop\CDVD</Filter> <Filter>System\Ps2\Iop\CDVD</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\gui\DriveList.h">
<Filter>AppHost\Include</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\wxResources.rc"> <ResourceCompile Include="..\wxResources.rc">