diff options
-rw-r--r-- | proto-wine/ftnoir_protocol_wine.cpp | 14 | ||||
-rw-r--r-- | proto-wine/proton.cpp | 20 | ||||
-rw-r--r-- | proto-wine/proton.h | 23 |
3 files changed, 17 insertions, 40 deletions
diff --git a/proto-wine/ftnoir_protocol_wine.cpp b/proto-wine/ftnoir_protocol_wine.cpp index 7052ea41..a9de7557 100644 --- a/proto-wine/ftnoir_protocol_wine.cpp +++ b/proto-wine/ftnoir_protocol_wine.cpp @@ -1,5 +1,4 @@ #include "ftnoir_protocol_wine.h" -#include "proton.h" #ifndef OTR_WINE_NO_WRAPPER # include "csv/csv.h" #endif @@ -71,15 +70,16 @@ 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_path, int appid); + 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_path().toString()); - try { - env = make_steam_environ(s.proton_path().toString(), s.proton_appid); - } catch(const ProtonException &e) { - return error(e.getMessage()); - } + qDebug() << 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); } { diff --git a/proto-wine/proton.cpp b/proto-wine/proton.cpp index b1eb8b9e..5ecd1f93 100644 --- a/proto-wine/proton.cpp +++ b/proto-wine/proton.cpp @@ -7,8 +7,6 @@ #ifndef OTR_WINE_NO_WRAPPER -#include "proton.h" - #include <QDebug> #include <QDir> #include <QFileInfo> @@ -27,9 +25,11 @@ static const char* runtime_paths[] = { }; -QProcessEnvironment make_steam_environ(const QString& proton_path, 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; @@ -47,7 +47,7 @@ QProcessEnvironment make_steam_environ(const QString& proton_path, int appid) } if (runtime_path.isEmpty()) - ProtonException(QString("Couldn't find a Steam runtime.")).raise(); + error = QString("Couldn't find a Steam runtime."); for (const char* path : steam_paths) { QDir dir(QDir::homePath() + path + expand("/%1/pfx").arg(appid)); @@ -55,13 +55,13 @@ QProcessEnvironment make_steam_environ(const QString& proton_path, int appid) app_wineprefix = dir.absolutePath(); } if (app_wineprefix.isEmpty()) - ProtonException(QString("Couldn't find a Wineprefix for AppId %1").arg(appid)).raise(); + error = QString("Couldn't find a Wineprefix for AppId %1").arg(appid); QString path = expand( ":PROTON_PATH/dist/bin" ); path += ':'; path += qgetenv("PATH"); - ret.insert("PATH", path); + env.insert("PATH", path); QString library_path = expand( ":PROTON_PATH/dist/lib" @@ -78,10 +78,10 @@ QProcessEnvironment make_steam_environ(const QString& proton_path, int appid) ":RUNTIME_PATH/amd64/usr/lib" ); library_path += ':'; library_path += qgetenv("LD_LIBRARY_PATH"); - ret.insert("LD_LIBRARY_PATH", library_path); - ret.insert("WINEPREFIX", app_wineprefix); + 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_path) diff --git a/proto-wine/proton.h b/proto-wine/proton.h deleted file mode 100644 index 08179c3d..00000000 --- a/proto-wine/proton.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include <QString> -#include <QException> - -class ProtonException : public QException -{ -public: - ProtonException(const QString& message) - : message(message) {} - - virtual ~ProtonException() - {} - - void raise() const { throw *this; } - ProtonException *clone() const { return new ProtonException(*this); } - - QString getMessage() const { - return message; - } -private: - QString message; -}; |