mirror of https://github.com/PCSX2/pcsx2.git
CDVD: drive selection submenu and OS-specific fixes
This commit is contained in:
parent
2c5a23b696
commit
656efa5e20
|
@ -1,5 +1,5 @@
|
|||
/* 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
|
||||
* 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)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
std::wstring drive = g_Conf->Folders.RunDisc.ToString().ToStdWstring();
|
||||
std::wstring drive = g_Conf->Folders.RunDisc.GetPath().ToStdWstring();
|
||||
#else
|
||||
std::string drive = g_Conf->Folders.RunDisc.ToString().ToStdString();
|
||||
std::string drive = g_Conf->Folders.RunDisc.GetPath().ToStdString();
|
||||
#endif
|
||||
GetValidDrive(drive);
|
||||
|
||||
|
|
|
@ -108,5 +108,4 @@ s32 cdvdDirectReadSector(u32 sector, s32 mode, u8* buffer);
|
|||
s32 cdvdGetMediaType();
|
||||
s32 cdvdRefreshData();
|
||||
void cdvdParseTOC();
|
||||
|
||||
#endif /* __CDVD_DISC_READER_H__ */
|
|
@ -1,5 +1,5 @@
|
|||
/* 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
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* 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
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
|
@ -16,14 +16,18 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
#include "../CDVDdiscReader.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <libudev.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/cdrom.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
std::vector<std::string> GetOpticalDriveList()
|
||||
{
|
||||
#ifdef __linux__
|
||||
udev* udev_context = udev_new();
|
||||
if (!udev_context)
|
||||
return {};
|
||||
|
@ -51,11 +55,15 @@ std::vector<std::string> GetOpticalDriveList()
|
|||
udev_unref(udev_context);
|
||||
|
||||
return drives;
|
||||
#else
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
void GetValidDrive(std::string& drive)
|
||||
{
|
||||
if (!drive.empty()) {
|
||||
#ifdef __linux__
|
||||
int fd = open(drive.c_str(), O_RDONLY | O_NONBLOCK);
|
||||
if (fd != -1) {
|
||||
if (ioctl(fd, CDROM_GET_CAPABILITY, 0) == -1)
|
||||
|
@ -65,6 +73,9 @@ void GetValidDrive(std::string& drive)
|
|||
else {
|
||||
drive.clear();
|
||||
}
|
||||
#else
|
||||
drive.clear();
|
||||
#endif
|
||||
}
|
||||
if (drive.empty()) {
|
||||
auto drives = GetOpticalDriveList();
|
||||
|
@ -73,4 +84,4 @@ void GetValidDrive(std::string& drive)
|
|||
}
|
||||
if (!drive.empty())
|
||||
printf(" * CDVD: Opening drive '%s'...\n", drive.c_str());
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/* 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
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
|
@ -16,7 +16,10 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
#include "../CDVDdiscReader.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/cdrom.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.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
|
||||
{
|
||||
#ifdef __linux__
|
||||
union
|
||||
{
|
||||
cdrom_msf msf;
|
||||
|
@ -122,10 +126,14 @@ bool IOCtlSrc::ReadSectors2352(u32 sector, u32 count, u8* buffer) const
|
|||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IOCtlSrc::ReadDVDInfo()
|
||||
{
|
||||
#ifdef __linux__
|
||||
dvd_struct dvdrs;
|
||||
dvdrs.type = DVD_STRUCT_PHYSICAL;
|
||||
dvdrs.physical.layer_num = 0;
|
||||
|
@ -165,10 +173,14 @@ bool IOCtlSrc::ReadDVDInfo()
|
|||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IOCtlSrc::ReadCDInfo()
|
||||
{
|
||||
#ifdef __linux__
|
||||
cdrom_tochdr header;
|
||||
|
||||
if (ioctl(m_device, CDROMREADTOCHDR, &header) == -1)
|
||||
|
@ -194,10 +206,14 @@ bool IOCtlSrc::ReadCDInfo()
|
|||
m_media_type = -1;
|
||||
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IOCtlSrc::DiscReady()
|
||||
{
|
||||
#ifdef __linux__
|
||||
if (m_device == -1)
|
||||
return false;
|
||||
|
||||
|
@ -213,4 +229,7 @@ bool IOCtlSrc::DiscReady()
|
|||
}
|
||||
|
||||
return !!m_sectors;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
|
@ -1,20 +1,17 @@
|
|||
//Copyright (C) 2020 PCSX2 Dev Team
|
||||
//Copyright (c) David Quintana <DavidQuintana@canal21.com>
|
||||
//
|
||||
//This library 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 Foundation; either
|
||||
//version 3.0 of the License, or (at your option) any later version.
|
||||
//
|
||||
//This library 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
|
||||
//Lesser General Public License for more details.
|
||||
//
|
||||
//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
|
||||
//
|
||||
/* 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 "../CDVDdiscReader.h"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2016 PCSX2 Dev Team
|
||||
* 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
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
|
|
|
@ -286,6 +286,7 @@ set(pcsx2GuiSources
|
|||
gui/Debugger/DebuggerLists.cpp
|
||||
gui/Debugger/DisassemblyDialog.cpp
|
||||
gui/Debugger/DebugEvents.cpp
|
||||
gui/DriveList.cpp
|
||||
gui/ExecutorThread.cpp
|
||||
gui/FrameForGS.cpp
|
||||
gui/GlobalCommands.cpp
|
||||
|
@ -343,6 +344,7 @@ set(pcsx2GuiHeaders
|
|||
gui/Dialogs/ConfigurationDialog.h
|
||||
gui/Dialogs/LogOptionsDialog.h
|
||||
gui/Dialogs/ModalPopups.h
|
||||
gui/DriveList.h
|
||||
gui/GSFrame.h
|
||||
gui/i18n.h
|
||||
gui/IsoDropTarget.h
|
||||
|
@ -403,8 +405,8 @@ set(pcsx2IPUHeaders
|
|||
|
||||
# Linux sources
|
||||
set(pcsx2LinuxSources
|
||||
CDVD/Unix/DriveUtility.cpp
|
||||
CDVD/Unix/IOCtlSrc.cpp
|
||||
CDVD/Linux/DriveUtility.cpp
|
||||
CDVD/Linux/IOCtlSrc.cpp
|
||||
gui/CpuUsageProviderLnx.cpp
|
||||
Linux/LnxConsolePipe.cpp
|
||||
Linux/LnxKeyCodes.cpp
|
||||
|
@ -412,8 +414,8 @@ set(pcsx2LinuxSources
|
|||
)
|
||||
|
||||
set(pcsx2OSXSources
|
||||
CDVD/Unix/DriveUtility.cpp
|
||||
CDVD/Unix/IOCtlSrc.cpp
|
||||
CDVD/Linux/DriveUtility.cpp
|
||||
CDVD/Linux/IOCtlSrc.cpp
|
||||
gui/CpuUsageProviderLnx.cpp
|
||||
Linux/LnxConsolePipe.cpp
|
||||
# Linux/LnxKeyCodes.cpp
|
||||
|
@ -421,6 +423,8 @@ set(pcsx2OSXSources
|
|||
)
|
||||
|
||||
set(pcsx2FreeBSDSources
|
||||
CDVD/Linux/DriveUtility.cpp
|
||||
CDVD/Linux/IOCtlSrc.cpp
|
||||
gui/CpuUsageProviderLnx.cpp
|
||||
Linux/LnxConsolePipe.cpp
|
||||
Linux/LnxKeyCodes.cpp
|
||||
|
@ -658,10 +662,6 @@ if(APPLE)
|
|||
set(Platform
|
||||
${pcsx2OSXSources}
|
||||
${pcsx2LinuxHeaders})
|
||||
|
||||
set(Platform_Libs
|
||||
${LIBUDEV_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
|
||||
|
|
|
@ -285,13 +285,7 @@ void SysCoreThread::OnSuspendInThread()
|
|||
void SysCoreThread::OnResumeInThread( bool isSuspended )
|
||||
{
|
||||
GetCorePlugins().Open();
|
||||
|
||||
// When applying settings thread isn't suspended
|
||||
// so any components that are still loaded don't need to be opened again
|
||||
if (isSuspended)
|
||||
{
|
||||
DoCDVDopen();
|
||||
}
|
||||
DoCDVDopen();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "AppCommon.h"
|
||||
#include "AppCoreThread.h"
|
||||
#include "RecentIsoList.h"
|
||||
#include "DriveList.h"
|
||||
|
||||
#ifndef DISABLE_RECORDING
|
||||
# include "Recording/VirtualPad.h"
|
||||
|
@ -98,7 +99,6 @@ enum MenuIdentifiers
|
|||
|
||||
// Run SubSection
|
||||
MenuId_Cdvd_Source,
|
||||
MenuId_DriveSelector,
|
||||
MenuId_Src_Iso,
|
||||
MenuId_Src_Disc,
|
||||
MenuId_Src_NoDisc,
|
||||
|
@ -106,6 +106,8 @@ enum MenuIdentifiers
|
|||
MenuId_RecentIsos_reservedStart,
|
||||
MenuId_IsoBrowse = MenuId_RecentIsos_reservedStart + 100, // Open dialog, runs selected iso.
|
||||
MenuId_IsoClear,
|
||||
MenuId_DriveSelector,
|
||||
MenuId_DriveListRefresh,
|
||||
MenuId_Ask_On_Booting,
|
||||
MenuId_Boot_CDVD,
|
||||
MenuId_Boot_CDVD2,
|
||||
|
@ -527,6 +529,7 @@ protected:
|
|||
std::unique_ptr<PipeRedirectionBase> m_StderrRedirHandle;
|
||||
|
||||
std::unique_ptr<RecentIsoList> m_RecentIsoList;
|
||||
std::unique_ptr<DriveList> m_DriveList;
|
||||
std::unique_ptr<pxAppResources> m_Resources;
|
||||
|
||||
public:
|
||||
|
@ -618,6 +621,7 @@ public:
|
|||
|
||||
wxMenu& GetRecentIsoMenu();
|
||||
RecentIsoManager& GetRecentIsoManager();
|
||||
wxMenu& GetDriveListMenu();
|
||||
|
||||
pxAppResources& GetResourceCache();
|
||||
const wxIconBundle& GetIconBundle();
|
||||
|
|
|
@ -641,7 +641,6 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini )
|
|||
ini.Entry( L"CurrentIso", res, res, ini.IsLoading() || IsPortable() );
|
||||
CurrentIso = res.GetFullPath();
|
||||
|
||||
IniEntry( CurrentDisc );
|
||||
IniEntry( CurrentBlockdump );
|
||||
IniEntry( CurrentELF );
|
||||
IniEntry( CurrentIRX );
|
||||
|
@ -728,7 +727,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() )
|
||||
, RunDisc ( PathDefs::GetDocuments().GetFilename() )
|
||||
{
|
||||
bitset = 0xffffffff;
|
||||
}
|
||||
|
@ -1261,10 +1260,17 @@ static void LoadUiSettings()
|
|||
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 );
|
||||
}
|
||||
|
@ -1301,10 +1307,17 @@ static void SaveUiSettings()
|
|||
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 );
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ public:
|
|||
|
||||
wxDirName RunIso; // last used location for Iso 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();
|
||||
void LoadSave( IniInterface& conf );
|
||||
|
@ -325,7 +325,6 @@ public:
|
|||
bool AskOnBoot;
|
||||
|
||||
wxString CurrentIso;
|
||||
wxString CurrentDisc;
|
||||
wxString CurrentBlockdump;
|
||||
wxString CurrentELF;
|
||||
wxString CurrentIRX;
|
||||
|
|
|
@ -1185,7 +1185,12 @@ void SysUpdateIsoSrcFile( const wxString& newIsoFile )
|
|||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,16 @@ RecentIsoManager& Pcsx2App::GetRecentIsoManager()
|
|||
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()
|
||||
{
|
||||
ScopedLock lock( m_mtx_Resources );
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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);
|
|
@ -124,6 +124,7 @@ protected:
|
|||
wxMenu& m_GameSettingsSubmenu;
|
||||
|
||||
wxMenuItem* m_menuItem_RecentIsoMenu;
|
||||
wxMenuItem* m_menuItem_DriveListMenu;
|
||||
wxMenuItem& m_MenuItem_Console;
|
||||
#if defined(__unix__)
|
||||
wxMenuItem& m_MenuItem_Console_Stdio;
|
||||
|
|
|
@ -185,7 +185,7 @@ wxWindowID SwapOrReset_Disc( wxWindow* owner, IScopedCoreThread& core, const wxS
|
|||
{
|
||||
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();
|
||||
return result;
|
||||
|
@ -356,12 +356,12 @@ bool MainEmuFrame::_DoSelectELFBrowser()
|
|||
|
||||
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)
|
||||
{
|
||||
driveLetter = driveDialog.GetSelectedDrive();
|
||||
g_Conf->Folders.RunDisc = wxDirName(driveLetter);
|
||||
SysUpdateDiscSrcDrive(driveLetter);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -406,33 +406,37 @@ void MainEmuFrame::_DoBootCdvd()
|
|||
}
|
||||
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
|
||||
|
||||
wxDialogWithHelpers dialog( this, _("Drive not mounted!") );
|
||||
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.")
|
||||
);
|
||||
|
||||
// Send event to refresh drive list submenu
|
||||
wxCommandEvent event(wxEVT_MENU, MenuId_DriveListRefresh);
|
||||
wxGetApp().ProcessEvent(event);
|
||||
|
||||
pxIssueConfirmation( dialog, MsgButtons().OK() );
|
||||
|
||||
selector = true;
|
||||
}
|
||||
|
||||
if( selector || g_Conf->AskOnBoot )
|
||||
{
|
||||
wxString driveLetter;
|
||||
if( !_DoSelectDiscBrowser( driveLetter ) )
|
||||
if (!_DoSelectDiscBrowser(driveLetter))
|
||||
{
|
||||
paused_core.AllowResume();
|
||||
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);
|
||||
AppSaveSettings();
|
||||
}
|
||||
|
||||
wxString GetMsg_IsoImageChanged()
|
||||
|
|
|
@ -148,25 +148,17 @@
|
|||
<ItemGroup>
|
||||
<ClCompile Include="..\..\CDVD\BlockdumpFileReader.cpp" />
|
||||
<ClCompile Include="..\..\CDVD\CDVDdiscReader.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\CDVDdiscThread.cpp" />
|
||||
<ClCompile Include="..\..\CDVD\ChunksCache.cpp" />
|
||||
<ClCompile Include="..\..\CDVD\CompressedFileReader.cpp" />
|
||||
<ClCompile Include="..\..\CDVD\CsoFileReader.cpp" />
|
||||
<ClCompile Include="..\..\CDVD\GzippedFileReader.cpp" />
|
||||
<ClCompile Include="..\..\CDVD\OutputIsoFile.cpp" />
|
||||
<ClCompile Include="..\..\CDVD\Unix\DriveUtility.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Devel|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ClCompile Include="..\..\CDVD\Linux\DriveUtility.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\CDVD\Unix\IOCtlSrc.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Devel|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ClCompile Include="..\..\CDVD\Linux\IOCtlSrc.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\CDVD\Windows\DriveUtility.cpp" />
|
||||
<ClCompile Include="..\..\CDVD\Windows\IOCtlSrc.cpp" />
|
||||
|
@ -194,6 +186,7 @@
|
|||
<ClCompile Include="..\..\gui\Debugger\DisassemblyDialog.cpp" />
|
||||
<ClCompile Include="..\..\gui\Dialogs\DriveSelectorDialog.cpp" />
|
||||
<ClCompile Include="..\..\gui\Dialogs\McdConfigDialog.cpp" />
|
||||
<ClCompile Include="..\..\gui\DriveList.cpp" />
|
||||
<ClCompile Include="..\..\gui\Panels\MemoryCardListView.cpp" />
|
||||
<ClCompile Include="..\..\IopGte.cpp" />
|
||||
<ClCompile Include="..\..\IPU\IPUdma.cpp" />
|
||||
|
@ -434,6 +427,7 @@
|
|||
<ClInclude Include="..\..\GameDatabase.h" />
|
||||
<ClInclude Include="..\..\Gif_Unit.h" />
|
||||
<ClInclude Include="..\..\gui\AppGameDatabase.h" />
|
||||
<ClInclude Include="..\..\gui\DriveList.h" />
|
||||
<ClInclude Include="..\..\gui\Saveslots.h" />
|
||||
<ClInclude Include="..\..\gui\Debugger\BreakpointWindow.h" />
|
||||
<ClInclude Include="..\..\gui\Debugger\CtrlDisassemblyView.h" />
|
||||
|
@ -631,4 +625,4 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -151,7 +151,7 @@
|
|||
<Filter Include="System\Ps2\Iop\CDVD\Windows">
|
||||
<UniqueIdentifier>{be861049-a142-4650-85a5-a2fdd4eef011}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="System\Ps2\Iop\CDVD\Unix">
|
||||
<Filter Include="System\Ps2\Iop\CDVD\Linux">
|
||||
<UniqueIdentifier>{a5904fb6-e846-4cbf-940c-ca1c604140a0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
|
@ -882,11 +882,14 @@
|
|||
<ClCompile Include="..\..\CDVD\Windows\IOCtlSrc.cpp">
|
||||
<Filter>System\Ps2\Iop\CDVD\Windows</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\CDVD\Unix\IOCtlSrc.cpp">
|
||||
<Filter>System\Ps2\Iop\CDVD\Unix</Filter>
|
||||
<ClCompile Include="..\..\CDVD\Linux\IOCtlSrc.cpp">
|
||||
<Filter>System\Ps2\Iop\CDVD\Linux</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\CDVD\Unix\DriveUtility.cpp">
|
||||
<Filter>System\Ps2\Iop\CDVD\Unix</Filter>
|
||||
<ClCompile Include="..\..\CDVD\Linux\DriveUtility.cpp">
|
||||
<Filter>System\Ps2\Iop\CDVD\Linux</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\gui\DriveList.cpp">
|
||||
<Filter>AppHost</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -1339,6 +1342,9 @@
|
|||
<ClInclude Include="..\..\CDVD\CDVDdiscReader.h">
|
||||
<Filter>System\Ps2\Iop\CDVD</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\gui\DriveList.h">
|
||||
<Filter>AppHost\Include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\wxResources.rc">
|
||||
|
|
Loading…
Reference in New Issue