diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-08-08 21:03:02 +0200 |
---|---|---|
committer | Sefa Eyeoglu <contact@scrumplex.net> | 2022-08-08 21:16:37 +0200 |
commit | 68f3f98bc3974667812ed778d572a0aeb0c89bec (patch) | |
tree | 3b097a452c15cbd267a771c338081e3f05395e93 | |
parent | f873cd5b1aa17fe8119f27cc5d9b9eba10bd42bf (diff) | |
download | PrismLauncher-68f3f98bc3974667812ed778d572a0aeb0c89bec.tar.gz PrismLauncher-68f3f98bc3974667812ed778d572a0aeb0c89bec.tar.bz2 PrismLauncher-68f3f98bc3974667812ed778d572a0aeb0c89bec.zip |
feat: detect GameMode and MangoHud's presence
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
-rw-r--r-- | launcher/Application.cpp | 22 | ||||
-rw-r--r-- | launcher/Application.h | 2 | ||||
-rw-r--r-- | launcher/ui/pages/global/MinecraftPage.cpp | 10 | ||||
-rw-r--r-- | launcher/ui/pages/instance/InstanceSettingsPage.cpp | 14 |
4 files changed, 46 insertions, 2 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 710fa38d..31e9d1a3 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -113,6 +113,11 @@ #include <sys.h> +#ifdef Q_OS_LINUX +#include <dlfcn.h> +#include "gamemode_client.h" +#endif + #if defined Q_OS_WIN32 #ifndef WIN32_LEAN_AND_MEAN @@ -1573,6 +1578,23 @@ void Application::updateCapabilities() m_capabilities |= SupportsMSA; if (!getFlameAPIKey().isEmpty()) m_capabilities |= SupportsFlame; + +#ifdef Q_OS_LINUX + if (gamemode_query_status() >= 0) + m_capabilities |= SupportsGameMode; + + { + void *dummy = dlopen("libMangoHud_dlsym.so", RTLD_LAZY); + // try normal variant as well + if (dummy == NULL) + dummy = dlopen("libMangoHud.so", RTLD_LAZY); + + if (dummy != NULL) { + dlclose(dummy); + m_capabilities |= SupportsMangoHud; + } + } +#endif } QString Application::getJarPath(QString jarFile) diff --git a/launcher/Application.h b/launcher/Application.h index 05525bcf..41fd4c47 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -95,6 +95,8 @@ public: SupportsMSA = 1 << 0, SupportsFlame = 1 << 1, + SupportsGameMode = 1 << 2, + SupportsMangoHud = 1 << 3, }; Q_DECLARE_FLAGS(Capabilities, Capability) diff --git a/launcher/ui/pages/global/MinecraftPage.cpp b/launcher/ui/pages/global/MinecraftPage.cpp index e3ac7e7c..cc597fe0 100644 --- a/launcher/ui/pages/global/MinecraftPage.cpp +++ b/launcher/ui/pages/global/MinecraftPage.cpp @@ -122,6 +122,16 @@ void MinecraftPage::loadSettings() ui->perfomanceGroupBox->setVisible(false); #endif + if (!(APPLICATION->capabilities() & Application::SupportsGameMode)) { + ui->enableFeralGamemodeCheck->setDisabled(true); + ui->enableFeralGamemodeCheck->setToolTip(tr("Feral Interactive's GameMode could not be found on your system.")); + } + + if (!(APPLICATION->capabilities() & Application::SupportsMangoHud)) { + ui->enableMangoHud->setDisabled(true); + ui->enableMangoHud->setToolTip(tr("MangoHud could not be found on your system.")); + } + ui->showGameTime->setChecked(s->get("ShowGameTime").toBool()); ui->showGlobalGameTime->setChecked(s->get("ShowGlobalGameTime").toBool()); ui->recordGameTime->setChecked(s->get("RecordGameTime").toBool()); diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp index f11cf992..03910745 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -348,9 +348,19 @@ void InstanceSettingsPage::loadSettings() ui->enableMangoHud->setChecked(m_settings->get("EnableMangoHud").toBool()); ui->useDiscreteGpuCheck->setChecked(m_settings->get("UseDiscreteGpu").toBool()); - #if !defined(Q_OS_LINUX) +#if !defined(Q_OS_LINUX) ui->settingsTabs->setTabVisible(ui->settingsTabs->indexOf(ui->performancePage), false); - #endif +#endif + + if (!(APPLICATION->capabilities() & Application::SupportsGameMode)) { + ui->enableFeralGamemodeCheck->setDisabled(true); + ui->enableFeralGamemodeCheck->setToolTip(tr("Feral Interactive's GameMode could not be found on your system.")); + } + + if (!(APPLICATION->capabilities() & Application::SupportsMangoHud)) { + ui->enableMangoHud->setDisabled(true); + ui->enableMangoHud->setToolTip(tr("MangoHud could not be found on your system.")); + } // Miscellanous ui->gameTimeGroupBox->setChecked(m_settings->get("OverrideGameTime").toBool()); |