From 8e4c032b3c3ed62db595ec7b4fd4bb06171d6f8f Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 23 Mar 2024 12:51:48 -0400 Subject: [PATCH] Hide DirectX 9 option if not available --- launcher/include/profile.h | 3 +++ launcher/src/gamerunner.cpp | 2 +- launcher/src/profile.cpp | 6 ++++++ launcher/ui/Settings/ProfileSettings.qml | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/launcher/include/profile.h b/launcher/include/profile.h index 4b9a6bf..f9a43fe 100644 --- a/launcher/include/profile.h +++ b/launcher/include/profile.h @@ -26,6 +26,7 @@ class Profile : public QObject Q_PROPERTY(bool gamescopeEnabled READ gamescopeEnabled WRITE setGamescopeEnabled NOTIFY useGamescopeChanged) Q_PROPERTY(bool gamemodeEnabled READ gamemodeEnabled WRITE setGamemodeEnabled NOTIFY useGamemodeChanged) Q_PROPERTY(bool directx9Enabled READ directx9Enabled WRITE setDirectX9Enabled NOTIFY useDX9Changed) + Q_PROPERTY(bool hasDirectx9 READ hasDirectx9 NOTIFY gamePathChanged) Q_PROPERTY(bool gamescopeFullscreen READ gamescopeFullscreen WRITE setGamescopeFullscreen NOTIFY gamescopeFullscreenChanged) Q_PROPERTY(bool gamescopeBorderless READ gamescopeBorderless WRITE setGamescopeBorderless NOTIFY gamescopeBorderlessChanged) Q_PROPERTY(int gamescopeWidth READ gamescopeWidth WRITE setGamescopeWidth NOTIFY gamescopeWidthChanged) @@ -80,6 +81,8 @@ public: [[nodiscard]] bool directx9Enabled() const; void setDirectX9Enabled(bool value); + [[nodiscard]] bool hasDirectx9() const; + [[nodiscard]] bool gamescopeFullscreen() const; void setGamescopeFullscreen(bool value); diff --git a/launcher/src/gamerunner.cpp b/launcher/src/gamerunner.cpp index ac8e9c0..09a7b7c 100644 --- a/launcher/src/gamerunner.cpp +++ b/launcher/src/gamerunner.cpp @@ -23,7 +23,7 @@ GameRunner::GameRunner(LauncherCore &launcher, QObject *parent) void GameRunner::beginGameExecutable(Profile &profile, const LoginAuth &auth) { QString gameExectuable; - if (profile.directx9Enabled()) { + if (profile.directx9Enabled() && profile.hasDirectx9()) { gameExectuable = profile.gamePath() + QStringLiteral("/game/ffxiv.exe"); } else { gameExectuable = profile.gamePath() + QStringLiteral("/game/ffxiv_dx11.exe"); diff --git a/launcher/src/profile.cpp b/launcher/src/profile.cpp index a971a79..142b546 100644 --- a/launcher/src/profile.cpp +++ b/launcher/src/profile.cpp @@ -239,6 +239,12 @@ void Profile::setDirectX9Enabled(const bool value) } } +bool Profile::hasDirectx9() const +{ + const QDir gameDir(gamePath()); + return QFileInfo::exists(gameDir.absoluteFilePath(QStringLiteral("game/ffxiv.exe"))); +} + bool Profile::gamescopeFullscreen() const { return m_config->gamescopeFullscreen(); diff --git a/launcher/ui/Settings/ProfileSettings.qml b/launcher/ui/Settings/ProfileSettings.qml index cc5f602..d56b268 100644 --- a/launcher/ui/Settings/ProfileSettings.qml +++ b/launcher/ui/Settings/ProfileSettings.qml @@ -61,10 +61,12 @@ FormCard.FormCardPage { model: ["DirectX 11", "DirectX 9"] currentIndex: page.profile.directx9Enabled ? 1 : 0 onCurrentIndexChanged: page.profile.directx9Enabled = (currentIndex === 1) + visible: page.profile.hasDirectx9 } FormCard.FormDelegateSeparator { above: directXDelegate + visible: page.profile.hasDirectx9 } FormCard.FormTextDelegate {