From 7a7844162d8976fee2f31ccd772744046aa90f7e Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 28 Sep 2017 01:40:59 -0400 Subject: [PATCH] Add clear list option to ISO Selector --- pcsx2/gui/App.h | 1 + pcsx2/gui/MainFrame.cpp | 1 + pcsx2/gui/MainFrame.h | 1 + pcsx2/gui/MainMenuClicks.cpp | 17 +++++++++++++++++ pcsx2/gui/RecentIsoList.cpp | 24 +++++++++++++++++++++--- pcsx2/gui/RecentIsoList.h | 2 ++ 6 files changed, 43 insertions(+), 3 deletions(-) diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index a080dd369e..1865f15607 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -86,6 +86,7 @@ enum MenuIdentifiers MenuId_Boot_Iso, // Opens submenu with Iso browser, and recent isos. MenuId_RecentIsos_reservedStart, MenuId_IsoBrowse = MenuId_RecentIsos_reservedStart + 100, // Open dialog, runs selected iso. + MenuId_IsoClear, MenuId_Ask_On_Booting, MenuId_Boot_CDVD, MenuId_Boot_CDVD2, diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index ecd498e822..d819f20939 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -206,6 +206,7 @@ void MainEmuFrame::ConnectMenus() // CDVD Bind(wxEVT_MENU, &MainEmuFrame::Menu_IsoBrowse_Click, this, MenuId_IsoBrowse); + Bind(wxEVT_MENU, &MainEmuFrame::Menu_IsoClear_Click, this, MenuId_IsoClear); Bind(wxEVT_MENU, &MainEmuFrame::Menu_CdvdSource_Click, this, MenuId_Src_Iso); Bind(wxEVT_MENU, &MainEmuFrame::Menu_CdvdSource_Click, this, MenuId_Src_Plugin); Bind(wxEVT_MENU, &MainEmuFrame::Menu_CdvdSource_Click, this, MenuId_Src_NoDisc); diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h index ef730faa2b..8aaaab1cf6 100644 --- a/pcsx2/gui/MainFrame.h +++ b/pcsx2/gui/MainFrame.h @@ -168,6 +168,7 @@ protected: void Menu_ResetAllSettings_Click(wxCommandEvent &event); void Menu_IsoBrowse_Click(wxCommandEvent &event); + void Menu_IsoClear_Click(wxCommandEvent &event); void Menu_EnableBackupStates_Click(wxCommandEvent &event); void Menu_EnablePatches_Click(wxCommandEvent &event); void Menu_EnableCheats_Click(wxCommandEvent &event); diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index c2798db9b8..cb2cfa57ea 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -412,6 +412,23 @@ void MainEmuFrame::Menu_IsoBrowse_Click( wxCommandEvent &event ) AppSaveSettings(); // save the new iso selection; update menus! } +void MainEmuFrame::Menu_IsoClear_Click(wxCommandEvent &event) +{ + wxDialogWithHelpers dialog(this, _("Confirm clearing ISO list")); + dialog += dialog.Heading(_("This will clear the ISO list. If an ISO is running it will remain in the list. Continue?")); + + bool confirmed = pxIssueConfirmation(dialog, MsgButtons().YesNo()) == wxID_YES; + + if (confirmed) + { + // If the CDVD mode is not ISO, or the system isn't running, wipe the CurrentIso field in INI file + if (g_Conf->CdvdSource != CDVD_SourceType::Iso || !SysHasValidState()) + SysUpdateIsoSrcFile(""); + wxGetApp().GetRecentIsoManager().Clear(); + AppSaveSettings(); + } +} + void MainEmuFrame::Menu_Ask_On_Boot_Click(wxCommandEvent &event) { g_Conf->AskOnBoot = event.IsChecked(); diff --git a/pcsx2/gui/RecentIsoList.cpp b/pcsx2/gui/RecentIsoList.cpp index 42fee63606..c19bd9c2ba 100644 --- a/pcsx2/gui/RecentIsoList.cpp +++ b/pcsx2/gui/RecentIsoList.cpp @@ -14,6 +14,7 @@ */ #include "PrecompiledHeader.h" +#include "App.h" #include "AppCoreThread.h" #include "RecentIsoList.h" #include "IsoDropTarget.h" @@ -34,7 +35,9 @@ RecentIsoManager::RecentIsoManager( wxMenu* menu, int firstIdForMenuItems_or_wxI , m_firstIdForMenuItems_or_wxID_ANY ( firstIdForMenuItems_or_wxID_ANY ) { m_cursel = 0; - m_Separator = NULL; + m_Separator = nullptr; + m_ClearSeparator = nullptr; + m_Clear = nullptr; IniLoader loader; LoadListFrom(loader); @@ -94,10 +97,22 @@ void RecentIsoManager::RemoveAllFromMenu() curitem.ItemPtr = NULL; } - if( m_Separator != NULL ) + if( m_Separator != nullptr ) { m_Menu->Destroy( m_Separator ); - m_Separator = NULL; + m_Separator = nullptr; + } + + if ( m_ClearSeparator != nullptr ) + { + m_Menu->Destroy( m_ClearSeparator ); + m_ClearSeparator = nullptr; + } + + if ( m_Clear != nullptr ) + { + m_Menu->Destroy( m_Clear ); + m_Clear = nullptr; } } @@ -119,6 +134,9 @@ void RecentIsoManager::Repopulate() // but the menu is composed in reverse order such that the most recent item appears at the top. for( int i=cnt-1; i>=0; --i ) InsertIntoMenu( i ); + + m_ClearSeparator = m_Menu->AppendSeparator(); + m_Clear = m_Menu->Append(MenuIdentifiers::MenuId_IsoClear, _("Clear ISO list")); } void RecentIsoManager::Add( const wxString& src ) diff --git a/pcsx2/gui/RecentIsoList.h b/pcsx2/gui/RecentIsoList.h index da65d312fb..480645f276 100644 --- a/pcsx2/gui/RecentIsoList.h +++ b/pcsx2/gui/RecentIsoList.h @@ -47,6 +47,8 @@ protected: int m_firstIdForMenuItems_or_wxID_ANY; wxMenuItem* m_Separator; + wxMenuItem* m_ClearSeparator; + wxMenuItem* m_Clear; public: RecentIsoManager( wxMenu* menu , int firstIdForMenuItems_or_wxID_ANY );