Core::IsRunning: Avoid Global System Accessor

This commit is contained in:
mitaclaw
2024-04-08 20:33:55 -07:00
parent b71fdef356
commit 0df401b164
25 changed files with 90 additions and 74 deletions

View File

@ -370,6 +370,7 @@ void GameList::ShowContextMenu(const QPoint&)
{
if (!GetSelectedGame())
return;
auto& system = Core::System::GetInstance();
QMenu* menu = new QMenu(this);
@ -421,8 +422,8 @@ void GameList::ShowContextMenu(const QPoint&)
QAction* change_disc = menu->addAction(tr("Change &Disc"), this, &GameList::ChangeDisc);
connect(&Settings::Instance(), &Settings::EmulationStateChanged, change_disc,
[change_disc] { change_disc->setEnabled(Core::IsRunning()); });
change_disc->setEnabled(Core::IsRunning());
[&system, change_disc] { change_disc->setEnabled(Core::IsRunning(system)); });
change_disc->setEnabled(Core::IsRunning(system));
menu->addSeparator();
}
@ -436,7 +437,7 @@ void GameList::ShowContextMenu(const QPoint&)
// system menu, trigger a refresh.
Settings::Instance().NANDRefresh();
});
perform_disc_update->setEnabled(!Core::IsRunning() || !Core::System::GetInstance().IsWii());
perform_disc_update->setEnabled(!Core::IsRunning(system) || !system.IsWii());
}
if (!is_mod_descriptor && platform == DiscIO::Platform::WiiWAD)
@ -449,10 +450,10 @@ void GameList::ShowContextMenu(const QPoint&)
for (QAction* a : {wad_install_action, wad_uninstall_action})
{
a->setEnabled(!Core::IsRunning());
a->setEnabled(!Core::IsRunning(system));
menu->addAction(a);
}
if (!Core::IsRunning())
if (!Core::IsRunning(system))
wad_uninstall_action->setEnabled(WiiUtils::IsTitleInstalled(game->GetTitleID()));
connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu,
@ -473,8 +474,8 @@ void GameList::ShowContextMenu(const QPoint&)
QAction* export_wii_save =
menu->addAction(tr("Export Wii Save"), this, &GameList::ExportWiiSave);
open_wii_save_folder->setEnabled(!Core::IsRunning());
export_wii_save->setEnabled(!Core::IsRunning());
open_wii_save_folder->setEnabled(!Core::IsRunning(system));
export_wii_save->setEnabled(!Core::IsRunning(system));
menu->addSeparator();
}
@ -531,7 +532,7 @@ void GameList::ShowContextMenu(const QPoint&)
connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu, [=](Core::State state) {
netplay_host->setEnabled(state == Core::State::Uninitialized);
});
netplay_host->setEnabled(!Core::IsRunning());
netplay_host->setEnabled(!Core::IsRunning(system));
menu->addAction(netplay_host);
}