diff options
author | Kiril Zvezdarov <kzvezdarov@gmail.com> | 2024-06-08 16:54:50 -0400 |
---|---|---|
committer | Kiril Zvezdarov <kzvezdarov@gmail.com> | 2024-06-08 17:56:36 -0400 |
commit | 180953b399b8ae48ead049d17b73cab7a2717f17 (patch) | |
tree | b515d4aadd800661ca4adc8dbbfe43929e727c5d | |
parent | 788d478be6c363d151a9693b3b1d4e4eaa11c021 (diff) |
Refactored proton_path to be the dist dir location
From Proton 9.0 and up, the directory containing
library files and wine executables - previously
called `dist`, appears to have been renamed to
`files`. This breaks OpenTrack with newer Proton
versions, because the path to the `wine` executable
and proton library files is constructed as
`:PROTON_PATH/dist/bin/wine`, i.e. the dist dir
name is hardcoded.
To fix this while preserving backward compatibility,
this commit changes `proton_path` to point to the
`dist` dir directly, be it `files` for 9.0+ or
`dist` for older versions. Templated variables
are adjusted accordingly to omit the dist dir.
Obtaining the dist. dir path for a specific Proton
version is done by recursively iterating the version's
directory, looking for the `wine` executable. The
first match is used to discover the grandparent dir path,
which is the desired `:PROTON_PATH/:DIST_DIR` path.
-rw-r--r-- | proto-wine/ftnoir_protocol_wine.cpp | 10 | ||||
-rw-r--r-- | proto-wine/ftnoir_protocol_wine_dialog.cpp | 25 | ||||
-rw-r--r-- | proto-wine/proton.cpp | 17 |
3 files changed, 36 insertions, 16 deletions
diff --git a/proto-wine/ftnoir_protocol_wine.cpp b/proto-wine/ftnoir_protocol_wine.cpp index c44cfc43..b70b3f16 100644 --- a/proto-wine/ftnoir_protocol_wine.cpp +++ b/proto-wine/ftnoir_protocol_wine.cpp @@ -87,11 +87,13 @@ module_status wine::initialize() if (s.proton_appid == 0) return error(tr("Must specify application id for Proton (Steam Play)")); - std::tuple<QProcessEnvironment, QString, bool> make_steam_environ(const QString& proton_path, int appid); - QString proton_path(const QString& proton_path); + std::tuple<QProcessEnvironment, QString, bool> make_steam_environ(const QString& proton_dist_path, int appid); + QString proton_path(const QString& proton_dist_path); - wine_path = proton_path(s.proton_path().toString()); - auto [proton_env, error_string, success] = make_steam_environ(s.proton_path().toString(), s.proton_appid); + QString proton_dist_path = s.proton_path().toString(); + + wine_path = proton_path(proton_dist_path); + auto [proton_env, error_string, success] = make_steam_environ(proton_dist_path, s.proton_appid); env = proton_env; if (!success) diff --git a/proto-wine/ftnoir_protocol_wine_dialog.cpp b/proto-wine/ftnoir_protocol_wine_dialog.cpp index 07dc1469..23f82fda 100644 --- a/proto-wine/ftnoir_protocol_wine_dialog.cpp +++ b/proto-wine/ftnoir_protocol_wine_dialog.cpp @@ -2,6 +2,9 @@ #include <QDebug> #include <QFileDialog> #include <QDir> +#include <QDirIterator> +#include <qdebug.h> +#include <qdir.h> #include "api/plugin-api.hpp" @@ -46,13 +49,27 @@ FTControls::FTControls() QDir dir(QDir::homePath() + path); dir.setFilter(QDir::Dirs); dir.setNameFilters({ "Proton*" }); - QFileInfoList list = dir.entryInfoList(); - for (int i = 0; i < list.size(); ++i) { - QFileInfo fileInfo = list.at(i); - ui.proton_version->addItem(fileInfo.fileName(), QVariant{fileInfo.filePath()}); + + QFileInfoList proton_dir_list = dir.entryInfoList(); + for (int i = 0; i < proton_dir_list.size(); ++i) { + const QFileInfo &proton_dir = proton_dir_list.at(i); + qDebug() << proton_dir.canonicalFilePath(); + + QDirIterator proton_executable_it(proton_dir.canonicalFilePath(), QStringList() << "wine", QDir::Files, QDirIterator::Subdirectories); + + if (proton_executable_it.hasNext()) { + QString proton_executable_path = proton_executable_it.next(); + QDir proton_dist_dir(proton_executable_path); + proton_dist_dir.cd("../../"); + + qDebug() << proton_dist_dir.canonicalPath(); + + ui.proton_version->addItem(proton_dir.fileName(), QVariant{proton_dist_dir.canonicalPath()}); + } } } + tie_setting(s.proton_path, ui.proton_version); tie_setting(s.variant_wine, ui.variant_wine); tie_setting(s.variant_proton, ui.variant_proton); diff --git a/proto-wine/proton.cpp b/proto-wine/proton.cpp index 5ecd1f93..973206a5 100644 --- a/proto-wine/proton.cpp +++ b/proto-wine/proton.cpp @@ -25,7 +25,7 @@ static const char* runtime_paths[] = { }; -std::tuple<QProcessEnvironment, QString, bool> make_steam_environ(const QString& proton_path, int appid) +std::tuple<QProcessEnvironment, QString, bool> make_steam_environ(const QString& proton_dist_path, int appid) { using ret = std::tuple<QProcessEnvironment, QString, bool>; auto env = QProcessEnvironment::systemEnvironment(); @@ -35,7 +35,7 @@ std::tuple<QProcessEnvironment, QString, bool> make_steam_environ(const QString& auto expand = [&](QString x) { x.replace("HOME", home); - x.replace("PROTON_PATH", proton_path); + x.replace("PROTON_DIST_PATH", proton_dist_path); x.replace("RUNTIME_PATH", runtime_path); return x; }; @@ -58,14 +58,15 @@ std::tuple<QProcessEnvironment, QString, bool> make_steam_environ(const QString& error = QString("Couldn't find a Wineprefix for AppId %1").arg(appid); QString path = expand( - ":PROTON_PATH/dist/bin" + ":PROTON_DIST_PATH/bin" + ":PROTON_DIST_PATH/bin" ); path += ':'; path += qgetenv("PATH"); env.insert("PATH", path); QString library_path = expand( - ":PROTON_PATH/dist/lib" - ":PROTON_PATH/dist/lib64" + ":PROTON_DIST_PATH/lib" + ":PROTON_DIST_PATH/lib64" ":RUNTIME_PATH/pinned_libs_32" ":RUNTIME_PATH/pinned_libs_64" ":RUNTIME_PATH/i386/lib/i386-linux-gnu" @@ -84,9 +85,9 @@ std::tuple<QProcessEnvironment, QString, bool> make_steam_environ(const QString& return ret(env, error, error.isEmpty()); } -QString proton_path(const QString& proton_path) + +QString proton_path(const QString& proton_dist_path) { - return proton_path + "/dist/bin/wine"; + return proton_dist_path + "/bin/wine"; } - #endif |