From 58102a39a421c3066685ef295d52ad26cc2eddf5 Mon Sep 17 00:00:00 2001 From: Akash Date: Sun, 18 Jun 2017 15:27:59 +0530 Subject: [PATCH] PCSX2-WX: Add "Always ask when booting" option When enabled, this option opens the file explorer to directly select the ISO at each boot instances instead of relying on the Recent ISO list. --- pcsx2/gui/App.h | 1 + pcsx2/gui/AppConfig.cpp | 1 + pcsx2/gui/AppConfig.h | 2 ++ pcsx2/gui/AppRes.cpp | 5 ++++- pcsx2/gui/MainFrame.cpp | 1 + pcsx2/gui/MainFrame.h | 1 + pcsx2/gui/MainMenuClicks.cpp | 13 ++++++++++++- pcsx2/gui/RecentIsoList.cpp | 15 +++++++++------ pcsx2/gui/RecentIsoList.h | 1 + pcsx2/gui/UpdateUI.cpp | 4 ++++ 10 files changed, 36 insertions(+), 8 deletions(-) diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 6b03938381..a080dd369e 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_Ask_On_Booting, MenuId_Boot_CDVD, MenuId_Boot_CDVD2, MenuId_Boot_ELF, diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index 1a1a4e88ee..d0ff02de7a 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -670,6 +670,7 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini ) IniEntry( EnablePresets ); IniEntry( PresetIndex ); + IniEntry( AskOnBoot ); #ifdef __WXMSW__ IniEntry( McdCompressNTFS ); diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index 89b2dd9a62..cf9682cadf 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -315,6 +315,8 @@ public: bool EnablePresets; int PresetIndex; + bool AskOnBoot; + wxString CurrentIso; wxString CurrentELF; wxString CurrentIRX; diff --git a/pcsx2/gui/AppRes.cpp b/pcsx2/gui/AppRes.cpp index 250c912dfd..42d426511a 100644 --- a/pcsx2/gui/AppRes.cpp +++ b/pcsx2/gui/AppRes.cpp @@ -63,7 +63,10 @@ const wxImage& LoadImageAny( RecentIsoList::RecentIsoList(int firstIdForMenuItems_or_wxID_ANY) { Menu = std::unique_ptr(new wxMenu()); - Menu->Append( MenuId_IsoBrowse, _("Browse..."), _("Browse for an ISO that is not in your recent history.") ); + Menu->AppendCheckItem( MenuId_Ask_On_Booting, _("Always ask when booting"), _("Manually select an ISO upon boot ignoring the selection from recent ISO list.") ); + Menu->AppendSeparator(); + Menu->Append( MenuId_IsoBrowse, _("Browse..."), _("Browse for an ISO that is not in your recent history."))->Enable(!g_Conf->AskOnBoot); + Menu->Check( MenuId_Ask_On_Booting, g_Conf->AskOnBoot ); Manager = std::unique_ptr(new RecentIsoManager( Menu.get(), firstIdForMenuItems_or_wxID_ANY )); } diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index 2c91c0a100..ecd498e822 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -209,6 +209,7 @@ void MainEmuFrame::ConnectMenus() 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); + Bind(wxEVT_MENU, &MainEmuFrame::Menu_Ask_On_Boot_Click, this, MenuId_Ask_On_Booting); Bind(wxEVT_MENU, &MainEmuFrame::Menu_Debug_CreateBlockdump_Click, this, MenuId_Debug_CreateBlockdump); // Config diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h index 16a061c19a..ef730faa2b 100644 --- a/pcsx2/gui/MainFrame.h +++ b/pcsx2/gui/MainFrame.h @@ -195,6 +195,7 @@ protected: void Menu_Debug_MemoryDump_Click(wxCommandEvent &event); void Menu_Debug_Logging_Click(wxCommandEvent &event); void Menu_Debug_CreateBlockdump_Click(wxCommandEvent &event); + void Menu_Ask_On_Boot_Click(wxCommandEvent &event); void Menu_ShowConsole(wxCommandEvent &event); void Menu_ChangeLang(wxCommandEvent &event); diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 6e891054d5..c2798db9b8 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -331,7 +331,7 @@ void MainEmuFrame::_DoBootCdvd() selector = true; } - if( selector ) + if( selector || g_Conf->AskOnBoot) { wxString result; if( !_DoSelectIsoBrowser( result ) ) @@ -412,6 +412,17 @@ void MainEmuFrame::Menu_IsoBrowse_Click( wxCommandEvent &event ) AppSaveSettings(); // save the new iso selection; update menus! } +void MainEmuFrame::Menu_Ask_On_Boot_Click(wxCommandEvent &event) +{ + g_Conf->AskOnBoot = event.IsChecked(); + + if (SysHasValidState()) + return; + + wxGetApp().GetRecentIsoManager().EnableItems(!event.IsChecked()); + FindItemInMenuBar(MenuId_IsoBrowse)->Enable(!event.IsChecked()); +} + void MainEmuFrame::Menu_Debug_CreateBlockdump_Click(wxCommandEvent &event) { g_Conf->EmuOptions.CdvdDumpBlocks = event.IsChecked(); diff --git a/pcsx2/gui/RecentIsoList.cpp b/pcsx2/gui/RecentIsoList.cpp index aede377a90..42fee63606 100644 --- a/pcsx2/gui/RecentIsoList.cpp +++ b/pcsx2/gui/RecentIsoList.cpp @@ -171,13 +171,16 @@ void RecentIsoManager::InsertIntoMenu( int id ) wxid = this->m_firstIdForMenuItems_or_wxID_ANY + id; curitem.ItemPtr = m_Menu->AppendRadioItem( wxid, Path::GetFilename(curitem.Filename), curitem.Filename ); - bool exists = wxFileExists( curitem.Filename ); + curitem.ItemPtr->Enable(wxFileExists(curitem.Filename) && !g_Conf->AskOnBoot); +} - if( m_cursel == id && exists ) - curitem.ItemPtr->Check(); - - if ( !exists ) - curitem.ItemPtr->Enable( false ); +void RecentIsoManager::EnableItems(bool display) +{ + for (const auto& list : m_Items) + { + // Files which don't exist still need to be grayed out. + list.ItemPtr->Enable(display && wxFileExists(list.Filename)); + } } void RecentIsoManager::LoadListFrom( IniInterface& ini ) diff --git a/pcsx2/gui/RecentIsoList.h b/pcsx2/gui/RecentIsoList.h index 8c2f077b84..da65d312fb 100644 --- a/pcsx2/gui/RecentIsoList.h +++ b/pcsx2/gui/RecentIsoList.h @@ -53,6 +53,7 @@ public: virtual ~RecentIsoManager(); void RemoveAllFromMenu(); + void EnableItems(bool display); void Repopulate(); void Clear(); void Add( const wxString& src ); diff --git a/pcsx2/gui/UpdateUI.cpp b/pcsx2/gui/UpdateUI.cpp index 11566d5265..5397e2a96b 100644 --- a/pcsx2/gui/UpdateUI.cpp +++ b/pcsx2/gui/UpdateUI.cpp @@ -55,6 +55,8 @@ void UI_DisableSysShutdown() if( wxGetApp().Rpc_TryInvokeAsync( &UI_DisableSysShutdown ) ) return; sMainFrame.EnableMenuItem( MenuId_Sys_Shutdown, false ); + sMainFrame.EnableMenuItem(MenuId_IsoBrowse, !g_Conf->AskOnBoot); + wxGetApp().GetRecentIsoManager().EnableItems(!g_Conf->AskOnBoot); } void UI_EnableSysShutdown() @@ -79,6 +81,8 @@ void UI_EnableSysActions() if( wxGetApp().Rpc_TryInvokeAsync( &UI_EnableSysActions ) ) return; sMainFrame.EnableMenuItem( MenuId_Sys_Shutdown, true ); + sMainFrame.EnableMenuItem(MenuId_IsoBrowse, true); + wxGetApp().GetRecentIsoManager().EnableItems(true); _SaveLoadStuff( true ); }