summaryrefslogtreecommitdiffhomepage
path: root/proto-wine
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2020-06-17 15:05:36 +0000
committerGitHub <noreply@github.com>2020-06-17 15:05:36 +0000
commit2493b7256c099e39bdf0d047cb288f3f39f7fa10 (patch)
tree5c8d466fe4efb53558ae8538c14b8d558e20a14a /proto-wine
parent9135324f0031a18c5419babada6615a4eadc4882 (diff)
parent5e3cd6fbe898c6452e61b4edb8d78d4d158fc254 (diff)
Merge pull request #1103 from russell/proton
Proton directory discovery
Diffstat (limited to 'proto-wine')
-rw-r--r--proto-wine/ftnoir_protocol_wine.cpp16
-rw-r--r--proto-wine/ftnoir_protocol_wine.h9
-rw-r--r--proto-wine/ftnoir_protocol_wine_dialog.cpp24
-rw-r--r--proto-wine/proton.cpp94
4 files changed, 94 insertions, 49 deletions
diff --git a/proto-wine/ftnoir_protocol_wine.cpp b/proto-wine/ftnoir_protocol_wine.cpp
index aabaa30c..6652eb48 100644
--- a/proto-wine/ftnoir_protocol_wine.cpp
+++ b/proto-wine/ftnoir_protocol_wine.cpp
@@ -70,13 +70,17 @@ module_status wine::initialize()
if (s.proton_appid == 0)
return error(tr("Must specify application id for Proton (Steam Play)"));
- QProcessEnvironment make_steam_environ(const QString& proton_version, int appid);
- QString proton_path(const QString& proton_version);
+ std::tuple<QProcessEnvironment, QString, bool> make_steam_environ(const QString& proton_path, int appid);
+ QString proton_path(const QString& proton_path);
- wine_path = proton_path(s.proton_version);
- env = make_steam_environ(s.proton_version, s.proton_appid);
+ wine_path = proton_path(s.proton_path().toString());
+ auto [proton_env, error_string, success] = make_steam_environ(s.proton_path().toString(), s.proton_appid);
+ env = proton_env;
+
+ if (!success)
+ return error(error_string);
}
- else
+
{
QString wineprefix = "~/.wine";
if (!s.wineprefix->isEmpty())
@@ -85,7 +89,7 @@ module_status wine::initialize()
wineprefix = qgetenv("HOME") + wineprefix.mid(1);
if (wineprefix[0] != '/')
- error(tr("Wine prefix must be an absolute path (given '%1')").arg(wineprefix));
+ return error(tr("Wine prefix must be an absolute path (given '%1')").arg(wineprefix));
env.insert("WINEPREFIX", wineprefix);
}
diff --git a/proto-wine/ftnoir_protocol_wine.h b/proto-wine/ftnoir_protocol_wine.h
index 0e48e5b5..f7346be9 100644
--- a/proto-wine/ftnoir_protocol_wine.h
+++ b/proto-wine/ftnoir_protocol_wine.h
@@ -9,9 +9,10 @@
#include "options/options.hpp"
using namespace options;
-#include <QString>
-#include <QProcess>
#include <QMutex>
+#include <QProcess>
+#include <QString>
+#include <QVariant>
#include <QDebug>
@@ -24,8 +25,8 @@ struct settings : opts
esync{b, "esync", true};
value<int> proton_appid{b, "proton-appid", 0};
- value<QString> proton_version{b, "proton-version", {} },
- wineprefix{b, "wineprefix", "~/.wine"};
+ value<QVariant> proton_path{b, "proton-version", {} };
+ value<QString> wineprefix{b, "wineprefix", "~/.wine"};
value<int> protocol{b, "protocol", 2};
};
diff --git a/proto-wine/ftnoir_protocol_wine_dialog.cpp b/proto-wine/ftnoir_protocol_wine_dialog.cpp
index b590ee94..a954a752 100644
--- a/proto-wine/ftnoir_protocol_wine_dialog.cpp
+++ b/proto-wine/ftnoir_protocol_wine_dialog.cpp
@@ -1,19 +1,30 @@
#include "ftnoir_protocol_wine.h"
#include <QDebug>
+#include <QDir>
+
#include "api/plugin-api.hpp"
-static const char* proton_versions[] = {
- "5.0", "4.11", "4.2", "3.16", "3.7",
+static const char* proton_paths[] = {
+ "/.steam/steam/steamapps/common",
+ "/.steam/root/compatibilitytools.d",
+ "/.local/share/Steam/steamapps/common",
};
FTControls::FTControls()
{
ui.setupUi(this);
- for (const char* version : proton_versions)
- ui.proton_version->addItem(version, QVariant{version});
-
- tie_setting(s.proton_version, ui.proton_version);
+ for (const char* path : proton_paths) {
+ 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()});
+ }
+ }
+ tie_setting(s.proton_path, ui.proton_version);
tie_setting(s.variant_wine, ui.variant_wine);
tie_setting(s.variant_proton, ui.variant_proton);
tie_setting(s.esync, ui.esync);
@@ -37,4 +48,3 @@ void FTControls::doCancel()
s.b->reload();
close();
}
-
diff --git a/proto-wine/proton.cpp b/proto-wine/proton.cpp
index 15306d26..5ecd1f93 100644
--- a/proto-wine/proton.cpp
+++ b/proto-wine/proton.cpp
@@ -7,56 +7,86 @@
#ifndef OTR_WINE_NO_WRAPPER
-#include <QtGlobal>
-#include <QString>
+#include <QDebug>
+#include <QDir>
+#include <QFileInfo>
#include <QProcessEnvironment>
+#include <QtGlobal>
+
+
+static const char* steam_paths[] = {
+ "/.steam/steam/steamapps/compatdata",
+ "/.local/share/Steam/steamapps/compatdata",
+};
+
+static const char* runtime_paths[] = {
+ "/.local/share/Steam/ubuntu12_32/steam-runtime",
+ "/.steam/ubuntu12_32/steam-runtime",
+};
-QProcessEnvironment make_steam_environ(const QString& proton_version, int appid)
+
+std::tuple<QProcessEnvironment, QString, bool> make_steam_environ(const QString& proton_path, int appid)
{
- auto ret = QProcessEnvironment::systemEnvironment();
+ using ret = std::tuple<QProcessEnvironment, QString, bool>;
+ auto env = QProcessEnvironment::systemEnvironment();
+ QString error = "";
QString home = qgetenv("HOME");
+ QString runtime_path, app_wineprefix;
auto expand = [&](QString x) {
- x.replace("HOME", home);
- x.replace("PROTON", proton_version);
- return x;
- };
+ x.replace("HOME", home);
+ x.replace("PROTON_PATH", proton_path);
+ x.replace("RUNTIME_PATH", runtime_path);
+ return x;
+ };
+
+ for (const char* path : runtime_paths) {
+ QDir dir(QDir::homePath() + path);
+ if (dir.exists())
+ runtime_path = dir.absolutePath();
+ }
+
+ if (runtime_path.isEmpty())
+ error = QString("Couldn't find a Steam runtime.");
+
+ for (const char* path : steam_paths) {
+ QDir dir(QDir::homePath() + path + expand("/%1/pfx").arg(appid));
+ if (dir.exists())
+ app_wineprefix = dir.absolutePath();
+ }
+ if (app_wineprefix.isEmpty())
+ error = QString("Couldn't find a Wineprefix for AppId %1").arg(appid);
QString path = expand(
- ":HOME/.local/share/Steam/steamapps/common/Proton PROTON/dist/bin"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/bin"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/bin"
+ ":PROTON_PATH/dist/bin"
);
path += ':'; path += qgetenv("PATH");
- ret.insert("PATH", path);
+ env.insert("PATH", path);
QString library_path = expand(
- ":HOME/.local/share/Steam/steamapps/common/Proton PROTON/dist/lib"
- ":HOME/.local/share/Steam/steamapps/common/Proton PROTON/dist/lib64"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/pinned_libs_32"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/pinned_libs_64"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/i386/lib/i386-linux-gnu"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/i386/lib"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/lib/x86_64-linux-gnu"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/lib"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu"
- ":HOME/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib"
+ ":PROTON_PATH/dist/lib"
+ ":PROTON_PATH/dist/lib64"
+ ":RUNTIME_PATH/pinned_libs_32"
+ ":RUNTIME_PATH/pinned_libs_64"
+ ":RUNTIME_PATH/i386/lib/i386-linux-gnu"
+ ":RUNTIME_PATH/i386/lib"
+ ":RUNTIME_PATH/i386/usr/lib/i386-linux-gnu"
+ ":RUNTIME_PATH/i386/usr/lib"
+ ":RUNTIME_PATH/amd64/lib/x86_64-linux-gnu"
+ ":RUNTIME_PATH/amd64/lib"
+ ":RUNTIME_PATH/amd64/usr/lib/x86_64-linux-gnu"
+ ":RUNTIME_PATH/amd64/usr/lib"
);
library_path += ':'; library_path += qgetenv("LD_LIBRARY_PATH");
- ret.insert("LD_LIBRARY_PATH", library_path);
- ret.insert("WINEPREFIX", expand("HOME/.local/share/Steam/steamapps/compatdata/%1/pfx").arg(appid));
+ env.insert("LD_LIBRARY_PATH", library_path);
+ env.insert("WINEPREFIX", app_wineprefix);
- return ret;
+ return ret(env, error, error.isEmpty());
}
-QString proton_path(const QString& proton_version)
+QString proton_path(const QString& proton_path)
{
- QString wine_path = "HOME/.local/share/Steam/steamapps/common/Proton PROTON/dist/bin/wine";
- wine_path.replace("HOME", qgetenv("HOME"));
- wine_path.replace("PROTON", proton_version);
- return wine_path;
+ return proton_path + "/dist/bin/wine";
}
#endif