diff --git a/src/launchercore.cpp b/src/launchercore.cpp index 33fb0f3..6e0d303 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -266,6 +266,9 @@ QString LauncherCore::readVersion(QString path) { void LauncherCore::readInitialInformation() { defaultProfileIndex = settings.value("defaultProfile", 0).toInt(); + gamescopeAvailable = checkIfInPath("gamescope"); + gamemodeAvailable = checkIfInPath("gamemoderun"); + auto profiles = settings.childGroups(); // create the Default profile if it doesnt exist @@ -348,8 +351,13 @@ void LauncherCore::readInitialInformation() { profile.useDX9 = settings.value("useDX9", false).toBool(); profile.useEsync = settings.value("useEsync", false).toBool(); - profile.useGamemode = settings.value("useGamemode", false).toBool(); - profile.useGamescope = settings.value("useGamescope", false).toBool(); + + if(gamescopeAvailable) + profile.useGamescope = settings.value("useGamescope", false).toBool(); + + if(gamemodeAvailable) + profile.useGamemode = settings.value("useGamemode", false).toBool(); + profile.enableDXVKhud = settings.value("enableDXVKhud", false).toBool(); profile.enableWatchdog = settings.value("enableWatchdog", false).toBool(); @@ -560,3 +568,12 @@ void LauncherCore::readExpansionVersions(ProfileSettings& info, int max) { for(int i = 0; i < max; i++) info.expansionVersions.push_back(readVersion(QString("%1/game/sqpack/ex%2/ex%2.ver").arg(info.gamePath, QString::number(i + 1)))); } + +bool LauncherCore::checkIfInPath(const QString program) { + // TODO: also check /usr/local/bin, /bin32 etc (basically read $PATH) + const QString directory = "/usr/bin"; + + QFileInfo fileInfo(directory + "/" + program); + + return fileInfo.exists() && fileInfo.isFile(); +} \ No newline at end of file diff --git a/src/launchercore.h b/src/launchercore.h index 140255f..b6f0bfc 100755 --- a/src/launchercore.h +++ b/src/launchercore.h @@ -88,7 +88,7 @@ public: int addProfile(); int deleteProfile(QString name); - void launchGame(const ProfileSettings& settings, const LoginAuth auth); + void launchGame(const ProfileSettings& settings, LoginAuth auth); void launchExecutable(const ProfileSettings& settings, QStringList args); void launchExecutable(const ProfileSettings& settings, QProcess* process, QStringList args); void buildRequest(QNetworkRequest& request); @@ -109,12 +109,16 @@ public: AssetUpdater* assetUpdater; Watchdog* watchdog; + bool gamescopeAvailable = false; + bool gamemodeAvailable = false; + int defaultProfileIndex = 0; signals: void settingsChanged(); private: void readExpansionVersions(ProfileSettings& info, int max); + bool checkIfInPath(QString program); QVector profileSettings; }; diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 389ff23..bb8dae4 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -273,17 +273,18 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidg }); gamescopeButtonLayout->addWidget(gamescopeLabel); - auto gamescopeCfg = new QPushButton("Configure..."); - connect(gamescopeCfg, &QPushButton::pressed, [&] { + configureGamescopeButton = new QPushButton("Configure..."); + connect(configureGamescopeButton, &QPushButton::pressed, [&] { auto gamescopeSettingsWindow = new GamescopeSettingsWindow(getCurrentProfile(), this->core, this); gamescopeSettingsWindow->show(); }); - gamescopeButtonLayout->addWidget(gamescopeCfg); + gamescopeButtonLayout->addWidget(configureGamescopeButton); connect(useGamescope, &QCheckBox::stateChanged, [this](int state) { getCurrentProfile().useGamescope = state; this->core.saveSettings(); + this->reloadControls(); }); useGamemode = new QCheckBox("Use Gamemode"); @@ -393,6 +394,11 @@ void SettingsWindow::reloadControls() { useEsync->setChecked(profile.useEsync); useGamescope->setChecked(profile.useGamescope); useGamemode->setChecked(profile.useGamemode); + + useGamemode->setEnabled(core.gamemodeAvailable); + useGamescope->setEnabled(core.gamescopeAvailable); + + configureGamescopeButton->setEnabled(profile.useGamescope); #endif #ifdef ENABLE_WATCHDOG diff --git a/src/settingswindow.h b/src/settingswindow.h index d9b97f6..ff61656 100644 --- a/src/settingswindow.h +++ b/src/settingswindow.h @@ -37,6 +37,7 @@ private: QPushButton* selectWineButton; QLineEdit* winePathLabel; QLineEdit* winePrefixDirectory; + QPushButton* configureGamescopeButton; QCheckBox* useGamescope, *useEsync, *useGamemode; QCheckBox* enableWatchdog;