feat: detect GameMode and MangoHud's presence

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2022-08-08 21:03:02 +02:00
parent f873cd5b1a
commit 68f3f98bc3
No known key found for this signature in database
GPG Key ID: C10411294912A422
4 changed files with 46 additions and 2 deletions

View File

@ -113,6 +113,11 @@
#include <sys.h> #include <sys.h>
#ifdef Q_OS_LINUX
#include <dlfcn.h>
#include "gamemode_client.h"
#endif
#if defined Q_OS_WIN32 #if defined Q_OS_WIN32
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
@ -1573,6 +1578,23 @@ void Application::updateCapabilities()
m_capabilities |= SupportsMSA; m_capabilities |= SupportsMSA;
if (!getFlameAPIKey().isEmpty()) if (!getFlameAPIKey().isEmpty())
m_capabilities |= SupportsFlame; 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) QString Application::getJarPath(QString jarFile)

View File

@ -95,6 +95,8 @@ public:
SupportsMSA = 1 << 0, SupportsMSA = 1 << 0,
SupportsFlame = 1 << 1, SupportsFlame = 1 << 1,
SupportsGameMode = 1 << 2,
SupportsMangoHud = 1 << 3,
}; };
Q_DECLARE_FLAGS(Capabilities, Capability) Q_DECLARE_FLAGS(Capabilities, Capability)

View File

@ -122,6 +122,16 @@ void MinecraftPage::loadSettings()
ui->perfomanceGroupBox->setVisible(false); ui->perfomanceGroupBox->setVisible(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."));
}
ui->showGameTime->setChecked(s->get("ShowGameTime").toBool()); ui->showGameTime->setChecked(s->get("ShowGameTime").toBool());
ui->showGlobalGameTime->setChecked(s->get("ShowGlobalGameTime").toBool()); ui->showGlobalGameTime->setChecked(s->get("ShowGlobalGameTime").toBool());
ui->recordGameTime->setChecked(s->get("RecordGameTime").toBool()); ui->recordGameTime->setChecked(s->get("RecordGameTime").toBool());

View File

@ -348,9 +348,19 @@ void InstanceSettingsPage::loadSettings()
ui->enableMangoHud->setChecked(m_settings->get("EnableMangoHud").toBool()); ui->enableMangoHud->setChecked(m_settings->get("EnableMangoHud").toBool());
ui->useDiscreteGpuCheck->setChecked(m_settings->get("UseDiscreteGpu").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); 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 // Miscellanous
ui->gameTimeGroupBox->setChecked(m_settings->get("OverrideGameTime").toBool()); ui->gameTimeGroupBox->setChecked(m_settings->get("OverrideGameTime").toBool());