mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-12 01:36:58 +00:00
Add End emulation and better Recent files menu
This commit is contained in:
parent
d54fb0ba78
commit
fe428cad87
5 changed files with 37 additions and 16 deletions
|
|
@ -677,13 +677,7 @@ void MainWindow::OnFileMenu(wxCommandEvent& event)
|
||||||
}
|
}
|
||||||
else if (menuId == MAINFRAME_MENU_ID_FILE_END_EMULATION)
|
else if (menuId == MAINFRAME_MENU_ID_FILE_END_EMULATION)
|
||||||
{
|
{
|
||||||
CafeSystem::ShutdownTitle();
|
EndEmulation();
|
||||||
DestroyCanvas();
|
|
||||||
m_game_launched = false;
|
|
||||||
RecreateMenu();
|
|
||||||
CreateGameListAndStatusBar();
|
|
||||||
DoLayout();
|
|
||||||
UpdateChildWindowTitleRunningState();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1743,6 +1737,17 @@ void MainWindow::SetFullScreen(bool state)
|
||||||
SetMenuVisible(true);
|
SetMenuVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::EndEmulation()
|
||||||
|
{
|
||||||
|
CafeSystem::ShutdownTitle();
|
||||||
|
DestroyCanvas();
|
||||||
|
m_game_launched = false;
|
||||||
|
RecreateMenu();
|
||||||
|
CreateGameListAndStatusBar();
|
||||||
|
DoLayout();
|
||||||
|
UpdateChildWindowTitleRunningState();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::SetMenuVisible(bool state)
|
void MainWindow::SetMenuVisible(bool state)
|
||||||
{
|
{
|
||||||
if (m_menu_visible == 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_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..."));
|
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_fileMenuSeparator0 = nullptr;
|
||||||
m_fileMenuSeparator1 = nullptr;
|
m_fileMenuSeparator1 = nullptr;
|
||||||
for (size_t i = 0; i < guiConfig.recent_launch_files.size(); i++)
|
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];
|
const std::string& pathStr = guiConfig.recent_launch_files[i];
|
||||||
if (pathStr.empty())
|
if (pathStr.empty())
|
||||||
continue;
|
continue;
|
||||||
if (recentFileIndex == 0)
|
recentMenu->Append(MAINFRAME_MENU_ID_FILE_RECENT_0 + i, to_wxString(fmt::format("{}. {}", recentFileIndex, pathStr)));
|
||||||
m_fileMenuSeparator0 = m_fileMenu->AppendSeparator();
|
|
||||||
m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_RECENT_0 + i, to_wxString(fmt::format("{}. {}", recentFileIndex, pathStr)));
|
|
||||||
recentFileIndex++;
|
recentFileIndex++;
|
||||||
|
|
||||||
if (recentFileIndex >= 8)
|
if (recentFileIndex >= 10)
|
||||||
break;
|
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
|
else
|
||||||
{
|
{
|
||||||
// add 'Stop emulation' menu entry to file menu
|
// add 'Stop emulation' menu entry to file menu
|
||||||
#ifdef CEMU_DEBUG_ASSERT
|
m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_END_EMULATION, _("&Stop emulation"));
|
||||||
m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_END_EMULATION, _("Stop emulation"));
|
m_fileMenuSeparator1 = m_fileMenu->AppendSeparator();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, _("&Open Cemu folder"));
|
m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, _("&Open Cemu folder"));
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ public:
|
||||||
[[nodiscard]] bool IsGameLaunched() const { return m_game_launched; }
|
[[nodiscard]] bool IsGameLaunched() const { return m_game_launched; }
|
||||||
|
|
||||||
void SetFullScreen(bool state);
|
void SetFullScreen(bool state);
|
||||||
|
void EndEmulation();
|
||||||
void SetMenuVisible(bool state);
|
void SetMenuVisible(bool state);
|
||||||
void UpdateNFCMenu();
|
void UpdateNFCMenu();
|
||||||
bool IsMenuHidden() const;
|
bool IsMenuHidden() const;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "HotkeySettings.h"
|
#include "HotkeySettings.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
|
#include <wx/app.h>
|
||||||
#include <wx/clipbrd.h>
|
#include <wx/clipbrd.h>
|
||||||
|
|
||||||
#if BOOST_OS_WINDOWS
|
#if BOOST_OS_WINDOWS
|
||||||
|
|
@ -157,6 +158,7 @@ HotkeySettings::HotkeySettings(wxWindow* parent)
|
||||||
CreateHotkeyRow(_tr("Toggle fullscreen"), s_cfgHotkeys.toggleFullscreen);
|
CreateHotkeyRow(_tr("Toggle fullscreen"), s_cfgHotkeys.toggleFullscreen);
|
||||||
CreateHotkeyRow(_tr("Take screenshot"), s_cfgHotkeys.takeScreenshot);
|
CreateHotkeyRow(_tr("Take screenshot"), s_cfgHotkeys.takeScreenshot);
|
||||||
CreateHotkeyRow(_tr("Toggle fast-forward"), s_cfgHotkeys.toggleFastForward);
|
CreateHotkeyRow(_tr("Toggle fast-forward"), s_cfgHotkeys.toggleFastForward);
|
||||||
|
CreateHotkeyRow(_tr("End emulation"), s_cfgHotkeys.endEmulation);
|
||||||
|
|
||||||
m_controllerTimer = new wxTimer(this);
|
m_controllerTimer = new wxTimer(this);
|
||||||
Bind(wxEVT_TIMER, &HotkeySettings::OnControllerTimer, this);
|
Bind(wxEVT_TIMER, &HotkeySettings::OnControllerTimer, this);
|
||||||
|
|
@ -192,6 +194,11 @@ void HotkeySettings::Init(MainWindow* mainWindowFrame)
|
||||||
{&s_cfgHotkeys.toggleFastForward, [](void) {
|
{&s_cfgHotkeys.toggleFastForward, [](void) {
|
||||||
ActiveSettings::SetTimerShiftFactor((ActiveSettings::GetTimerShiftFactor() < 3) ? 3 : 1);
|
ActiveSettings::SetTimerShiftFactor((ActiveSettings::GetTimerShiftFactor() < 3) ? 3 : 1);
|
||||||
}},
|
}},
|
||||||
|
{&s_cfgHotkeys.endEmulation, [](void) {
|
||||||
|
wxTheApp->CallAfter([]() {
|
||||||
|
s_mainWindow->EndEmulation();
|
||||||
|
});
|
||||||
|
}},
|
||||||
});
|
});
|
||||||
|
|
||||||
s_keyboardHotkeyToFuncMap.reserve(s_cfgHotkeyToFuncMap.size());
|
s_keyboardHotkeyToFuncMap.reserve(s_cfgHotkeyToFuncMap.size());
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ void wxCemuConfig::Load(XMLConfigParser& parser)
|
||||||
hotkeys.toggleFullscreenAlt = xml_hotkeys.get("ToggleFullscreenAlt", sHotkeyCfg{uKeyboardHotkey{WXK_CONTROL_M, true}}); // ALT+ENTER
|
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.takeScreenshot = xml_hotkeys.get("TakeScreenshot", sHotkeyCfg{uKeyboardHotkey{WXK_F12}});
|
||||||
hotkeys.toggleFastForward = xml_hotkeys.get("ToggleFastForward", sHotkeyCfg{});
|
hotkeys.toggleFastForward = xml_hotkeys.get("ToggleFastForward", sHotkeyCfg{});
|
||||||
|
hotkeys.endEmulation = xml_hotkeys.get("EndEmulation", sHotkeyCfg{uKeyboardHotkey{WXK_F5}});
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCemuConfig::Save(XMLConfigParser& config)
|
void wxCemuConfig::Save(XMLConfigParser& config)
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ struct wxCemuConfig
|
||||||
sHotkeyCfg exitFullscreen;
|
sHotkeyCfg exitFullscreen;
|
||||||
sHotkeyCfg takeScreenshot;
|
sHotkeyCfg takeScreenshot;
|
||||||
sHotkeyCfg toggleFastForward;
|
sHotkeyCfg toggleFastForward;
|
||||||
|
sHotkeyCfg endEmulation;
|
||||||
} hotkeys{};
|
} hotkeys{};
|
||||||
|
|
||||||
void AddRecentlyLaunchedFile(std::string_view file);
|
void AddRecentlyLaunchedFile(std::string_view file);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue