Added a hotkey to open the previously played title

This commit is contained in:
MoistyMarley 2022-12-03 20:11:40 +00:00
parent 1eb61aa9ab
commit 6d2724a861
2 changed files with 22 additions and 3 deletions

View File

@ -813,6 +813,10 @@ void EmulatorWindow::OnKeyDown(ui::KeyEvent& e) {
ShowBuildCommit(); ShowBuildCommit();
} break; } break;
case ui::VirtualKey::kF9: {
RunPreviouslyPlayedTitle();
} break;
default: default:
return; return;
} }
@ -1079,6 +1083,12 @@ void EmulatorWindow::SetInitializingShaderStorage(bool initializing) {
UpdateTitle(); UpdateTitle();
} }
void EmulatorWindow::RunPreviouslyPlayedTitle() {
if (!emulator()->is_title_open() && recently_launched_titles_.size() >= 1) {
RunRecentlyPlayedTitle(recently_launched_titles_[0].path_to_file);
}
}
void EmulatorWindow::RunRecentlyPlayedTitle( void EmulatorWindow::RunRecentlyPlayedTitle(
std::filesystem::path path_to_file) { std::filesystem::path path_to_file) {
if (path_to_file.empty()) { if (path_to_file.empty()) {
@ -1097,11 +1107,19 @@ void EmulatorWindow::RunRecentlyPlayedTitle(
void EmulatorWindow::FillRecentlyLaunchedTitlesMenu( void EmulatorWindow::FillRecentlyLaunchedTitlesMenu(
xe::ui::MenuItem* recent_menu) { xe::ui::MenuItem* recent_menu) {
unsigned int index = 0;
for (const auto& [title_name, path] : recently_launched_titles_) { for (const auto& [title_name, path] : recently_launched_titles_) {
if (index == 0) {
recent_menu->AddChild(MenuItem::Create(
MenuItem::Type::kString, title_name, "F9",
std::bind(&EmulatorWindow::RunRecentlyPlayedTitle, this, path)));
} else {
recent_menu->AddChild(MenuItem::Create( recent_menu->AddChild(MenuItem::Create(
MenuItem::Type::kString, title_name, MenuItem::Type::kString, title_name,
std::bind(&EmulatorWindow::RunRecentlyPlayedTitle, this, path))); std::bind(&EmulatorWindow::RunRecentlyPlayedTitle, this, path)));
} }
index++;
}
} }
void EmulatorWindow::ReadRecentlyLaunchedTitles() { void EmulatorWindow::ReadRecentlyLaunchedTitles() {

View File

@ -152,6 +152,7 @@ class EmulatorWindow {
void ShowFAQ(); void ShowFAQ();
void ShowBuildCommit(); void ShowBuildCommit();
void RunPreviouslyPlayedTitle();
void RunRecentlyPlayedTitle(std::filesystem::path path_to_file); void RunRecentlyPlayedTitle(std::filesystem::path path_to_file);
void FillRecentlyLaunchedTitlesMenu(xe::ui::MenuItem* recent_menu); void FillRecentlyLaunchedTitlesMenu(xe::ui::MenuItem* recent_menu);
void ReadRecentlyLaunchedTitles(); void ReadRecentlyLaunchedTitles();