diff --git a/src/gui/wxgui/MainWindow.cpp b/src/gui/wxgui/MainWindow.cpp index c4ace87f..885a684d 100644 --- a/src/gui/wxgui/MainWindow.cpp +++ b/src/gui/wxgui/MainWindow.cpp @@ -677,13 +677,7 @@ void MainWindow::OnFileMenu(wxCommandEvent& event) } else if (menuId == MAINFRAME_MENU_ID_FILE_END_EMULATION) { - CafeSystem::ShutdownTitle(); - DestroyCanvas(); - m_game_launched = false; - RecreateMenu(); - CreateGameListAndStatusBar(); - DoLayout(); - UpdateChildWindowTitleRunningState(); + EndEmulation(); } } @@ -1743,6 +1737,17 @@ void MainWindow::SetFullScreen(bool state) SetMenuVisible(true); } +void MainWindow::EndEmulation() +{ + CafeSystem::ShutdownTitle(); + DestroyCanvas(); + m_game_launched = false; + RecreateMenu(); + CreateGameListAndStatusBar(); + DoLayout(); + UpdateChildWindowTitleRunningState(); +} + void MainWindow::SetMenuVisible(bool state) { if (m_menu_visible == state) @@ -2109,7 +2114,8 @@ void MainWindow::RecreateMenu() m_loadMenuItem = m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_LOAD, _("&Load...")); m_installUpdateMenuItem = m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_INSTALL_UPDATE, _("&Install game title, update or DLC...")); - sint32 recentFileIndex = 0; + wxMenu* recentMenu = new wxMenu(); + sint32 recentFileIndex = 1; m_fileMenuSeparator0 = nullptr; m_fileMenuSeparator1 = nullptr; for (size_t i = 0; i < guiConfig.recent_launch_files.size(); i++) @@ -2117,22 +2123,27 @@ void MainWindow::RecreateMenu() const std::string& pathStr = guiConfig.recent_launch_files[i]; if (pathStr.empty()) continue; - if (recentFileIndex == 0) - m_fileMenuSeparator0 = m_fileMenu->AppendSeparator(); - m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_RECENT_0 + i, to_wxString(fmt::format("{}. {}", recentFileIndex, pathStr))); + recentMenu->Append(MAINFRAME_MENU_ID_FILE_RECENT_0 + i, to_wxString(fmt::format("{}. {}", recentFileIndex, pathStr))); recentFileIndex++; - if (recentFileIndex >= 8) + if (recentFileIndex >= 10) break; } - m_fileMenuSeparator1 = m_fileMenu->AppendSeparator(); + if (recentFileIndex == 0) + { + wxMenuItem* placeholder = recentMenu->Append(wxID_NONE, _("(No recent files)")); + placeholder->Enable(false); + } + + m_fileMenu->AppendSeparator(); + m_fileMenu->AppendSubMenu(recentMenu, _("Recent files")); + m_fileMenu->AppendSeparator(); } else { // add 'Stop emulation' menu entry to file menu -#ifdef CEMU_DEBUG_ASSERT - m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_END_EMULATION, _("Stop emulation")); -#endif + m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_END_EMULATION, _("&Stop emulation")); + m_fileMenuSeparator1 = m_fileMenu->AppendSeparator(); } m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, _("&Open Cemu folder")); diff --git a/src/gui/wxgui/MainWindow.h b/src/gui/wxgui/MainWindow.h index 07464188..c1372a75 100644 --- a/src/gui/wxgui/MainWindow.h +++ b/src/gui/wxgui/MainWindow.h @@ -71,6 +71,7 @@ public: [[nodiscard]] bool IsGameLaunched() const { return m_game_launched; } void SetFullScreen(bool state); + void EndEmulation(); void SetMenuVisible(bool state); void UpdateNFCMenu(); bool IsMenuHidden() const; diff --git a/src/gui/wxgui/input/HotkeySettings.cpp b/src/gui/wxgui/input/HotkeySettings.cpp index 195061d7..9eb2ab8e 100644 --- a/src/gui/wxgui/input/HotkeySettings.cpp +++ b/src/gui/wxgui/input/HotkeySettings.cpp @@ -6,6 +6,7 @@ #include "HotkeySettings.h" #include "MainWindow.h" +#include #include #if BOOST_OS_WINDOWS @@ -157,6 +158,7 @@ HotkeySettings::HotkeySettings(wxWindow* parent) CreateHotkeyRow(_tr("Toggle fullscreen"), s_cfgHotkeys.toggleFullscreen); CreateHotkeyRow(_tr("Take screenshot"), s_cfgHotkeys.takeScreenshot); CreateHotkeyRow(_tr("Toggle fast-forward"), s_cfgHotkeys.toggleFastForward); + CreateHotkeyRow(_tr("End emulation"), s_cfgHotkeys.endEmulation); m_controllerTimer = new wxTimer(this); Bind(wxEVT_TIMER, &HotkeySettings::OnControllerTimer, this); @@ -192,6 +194,11 @@ void HotkeySettings::Init(MainWindow* mainWindowFrame) {&s_cfgHotkeys.toggleFastForward, [](void) { ActiveSettings::SetTimerShiftFactor((ActiveSettings::GetTimerShiftFactor() < 3) ? 3 : 1); }}, + {&s_cfgHotkeys.endEmulation, [](void) { + wxTheApp->CallAfter([]() { + s_mainWindow->EndEmulation(); + }); + }}, }); s_keyboardHotkeyToFuncMap.reserve(s_cfgHotkeyToFuncMap.size()); diff --git a/src/gui/wxgui/wxCemuConfig.cpp b/src/gui/wxgui/wxCemuConfig.cpp index bbd24ab4..fee494b6 100644 --- a/src/gui/wxgui/wxCemuConfig.cpp +++ b/src/gui/wxgui/wxCemuConfig.cpp @@ -115,6 +115,7 @@ void wxCemuConfig::Load(XMLConfigParser& parser) hotkeys.toggleFullscreenAlt = xml_hotkeys.get("ToggleFullscreenAlt", sHotkeyCfg{uKeyboardHotkey{WXK_CONTROL_M, true}}); // ALT+ENTER hotkeys.takeScreenshot = xml_hotkeys.get("TakeScreenshot", sHotkeyCfg{uKeyboardHotkey{WXK_F12}}); hotkeys.toggleFastForward = xml_hotkeys.get("ToggleFastForward", sHotkeyCfg{}); + hotkeys.endEmulation = xml_hotkeys.get("EndEmulation", sHotkeyCfg{uKeyboardHotkey{WXK_F5}}); } void wxCemuConfig::Save(XMLConfigParser& config) diff --git a/src/gui/wxgui/wxCemuConfig.h b/src/gui/wxgui/wxCemuConfig.h index 9463d4df..2a0dde11 100644 --- a/src/gui/wxgui/wxCemuConfig.h +++ b/src/gui/wxgui/wxCemuConfig.h @@ -127,6 +127,7 @@ struct wxCemuConfig sHotkeyCfg exitFullscreen; sHotkeyCfg takeScreenshot; sHotkeyCfg toggleFastForward; + sHotkeyCfg endEmulation; } hotkeys{}; void AddRecentlyLaunchedFile(std::string_view file);