Qt: always use last boot path for game boot actions

The actual path caused the GUI to try to run elfs directly after booting a game from a loader.
This commit is contained in:
Megamouse 2023-06-06 00:24:00 +02:00
parent 11487cd591
commit 404d08ef6d
3 changed files with 19 additions and 8 deletions

View File

@ -731,18 +731,23 @@ game_boot_result Emulator::GetElfPathFromDir(std::string& elf_path, const std::s
game_boot_result Emulator::BootGame(const std::string& path, const std::string& title_id, bool direct, cfg_mode config_mode, const std::string& config_path)
{
auto save_args = std::make_tuple(m_path, argv, envp, data, disc, klic, hdd1, m_config_mode, m_config_path);
auto save_args = std::make_tuple(m_path, m_path_original, argv, envp, data, disc, klic, hdd1, m_config_mode, m_config_path);
auto restore_on_no_boot = [&](game_boot_result result)
{
if (IsStopped() || result != game_boot_result::no_errors)
{
std::tie(m_path, argv, envp, data, disc, klic, hdd1, m_config_mode, m_config_path) = std::move(save_args);
std::tie(m_path, m_path_original, argv, envp, data, disc, klic, hdd1, m_config_mode, m_config_path) = std::move(save_args);
}
return result;
};
if (m_path_original.empty() || config_mode != cfg_mode::continuous)
{
m_path_original = m_path;
}
m_path_old = m_path;
m_config_mode = config_mode;

View File

@ -122,6 +122,7 @@ class Emulator final
std::string m_config_path;
std::string m_path;
std::string m_path_old;
std::string m_path_original;
std::string m_title_id;
std::string m_title;
std::string m_app_version;
@ -235,6 +236,11 @@ public:
return m_path;
}
const std::string& GetLastBoot() const
{
return m_path_original;
}
const std::string& GetTitleID() const
{
return m_title_id;

View File

@ -259,7 +259,7 @@ QString main_window::GetCurrentTitle()
QString title = qstr(Emu.GetTitleAndTitleID());
if (title.isEmpty())
{
title = qstr(Emu.GetBoot());
title = qstr(Emu.GetLastBoot());
}
return title;
}
@ -383,7 +383,7 @@ void main_window::OnPlayOrPause()
gui_log.notice("Booting from OnPlayOrPause...");
Boot(m_selected_game->info.path, m_selected_game->info.serial);
}
else if (const auto path = Emu.GetBoot(); !path.empty())
else if (const std::string path = Emu.GetLastBoot(); !path.empty())
{
if (const auto error = Emu.Load(); error != game_boot_result::no_errors)
{
@ -1971,7 +1971,7 @@ void main_window::BootRecentAction(const QAction* act)
if (contains_path)
{
// clear menu of actions
for (auto action : m_recent_game_acts)
for (QAction* action : m_recent_game_acts)
{
ui->bootRecentMenu->removeAction(action);
}
@ -2062,7 +2062,7 @@ void main_window::AddRecentAction(const q_string_pair& entry)
}
// clear menu of actions
for (auto action : m_recent_game_acts)
for (QAction* action : m_recent_game_acts)
{
ui->bootRecentMenu->removeAction(action);
}
@ -2915,7 +2915,7 @@ void main_window::CreateDockWindows()
ui->toolbar_start->setIcon(m_icon_play);
}
else if (const auto& path = Emu.GetBoot(); !path.empty()) // Restartable games
else if (const std::string& path = Emu.GetLastBoot(); !path.empty()) // Restartable games
{
tooltip = tr("Restart %0").arg(GetCurrentTitle());
@ -2979,7 +2979,7 @@ void main_window::ConfigureGuiFromSettings()
m_rg_entries = m_gui_settings->Var2List(m_gui_settings->GetValue(gui::rg_entries));
// clear recent games menu of actions
for (auto act : m_recent_game_acts)
for (QAction* act : m_recent_game_acts)
{
ui->bootRecentMenu->removeAction(act);
}