MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / checkSteam

Function checkSteam

src/spawn.cpp:610–692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

608}
609
610bool checkSteam(QWidget* parent, const SpawnParameters& sp, const QDir& gameDirectory,
611 const QString& steamAppID, const Settings& settings)
612{
613 static const std::vector<QString> steamFiles = {"steam_api.dll", "steam_api64.dll"};
614
615 log::debug("checking steam");
616
617 if (!steamAppID.isEmpty()) {
618 env::set("SteamAPPId", steamAppID);
619 } else {
620 env::set("SteamAPPId", settings.steam().appID());
621 }
622
623 bool steamRequired = false;
624 QString details;
625
626 for (const auto& file : steamFiles) {
627 const QFileInfo fi(gameDirectory.absoluteFilePath(file));
628 if (fi.exists()) {
629 details = QString("managed game is located at '%1' and file '%2' exists")
630 .arg(gameDirectory.absolutePath())
631 .arg(fi.absoluteFilePath());
632
633 log::debug("{}", details);
634 steamRequired = true;
635
636 break;
637 }
638 }
639
640 if (!steamRequired) {
641 log::debug("program doesn't seem to require steam");
642 return true;
643 }
644
645 auto ss = getSteamStatus();
646
647 if (!ss.running) {
648 log::debug("steam isn't running, asking to start steam");
649
650 const auto c = dialogs::confirmStartSteam(parent, sp, details);
651
652 if (c == QDialogButtonBox::Yes) {
653 log::debug("user wants to start steam");
654
655 if (!startSteam(parent)) {
656 // cancel
657 return false;
658 }
659
660 // double-check that Steam is started
661 ss = getSteamStatus();
662 if (!ss.running) {
663 log::error("steam is still not running, hoping for the best");
664 return true;
665 }
666 } else if (c == QDialogButtonBox::No) {
667 log::debug("user declined to start steam");

Callers 1

runBinaryMethod · 0.85

Calls 11

QStringClass · 0.85
getSteamStatusFunction · 0.85
confirmStartSteamFunction · 0.85
startSteamFunction · 0.85
restartAsAdminFunction · 0.85
appIDMethod · 0.80
setFunction · 0.70
isEmptyMethod · 0.45
existsMethod · 0.45
absolutePathMethod · 0.45

Tested by

no test coverage detected