Add clear list option to ISO Selector

This commit is contained in:
Brian 2017-09-28 01:40:59 -04:00 committed by Jonathan Li
parent 3356c63cdc
commit 7a7844162d
6 changed files with 43 additions and 3 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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);

View File

@ -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();

View File

@ -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 )

View File

@ -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 );