From 9a7e5f1b6e18ee4f0c3455c683f7023c2fd66fcb Mon Sep 17 00:00:00 2001 From: Priton-CE Date: Sun, 26 Feb 2023 17:34:07 +0100 Subject: moved changes from master to upstream-merge --- proto-wine/ftnoir_protocol_wine.cpp | 31 ++++++++ proto-wine/ftnoir_protocol_wine.h | 9 ++- proto-wine/ftnoir_protocol_wine_dialog.cpp | 73 +++++++++++++++++ proto-wine/ftnoir_winecontrols.ui | 121 ++++++++++++++++++++++------- proto-wine/lang/nl_NL.ts | 43 +++++++++- proto-wine/lang/ru_RU.ts | 43 +++++++++- proto-wine/lang/stub.ts | 43 +++++++++- proto-wine/lang/zh_CN.ts | 43 +++++++++- 8 files changed, 361 insertions(+), 45 deletions(-) (limited to 'proto-wine') diff --git a/proto-wine/ftnoir_protocol_wine.cpp b/proto-wine/ftnoir_protocol_wine.cpp index af53ff1f..7b82b76f 100644 --- a/proto-wine/ftnoir_protocol_wine.cpp +++ b/proto-wine/ftnoir_protocol_wine.cpp @@ -44,6 +44,7 @@ void wine::pose(const double *headpose, const double*) #ifndef OTR_WINE_NO_WRAPPER if (shm->gameid != gameid) { + qDebug() << "proto/wine: looking up gameData"; QString gamename; QMutexLocker foo(&game_name_mutex); /* only EZCA for FSX requires dummy process, and FSX doesn't work on Linux */ @@ -63,6 +64,22 @@ module_status wine::initialize() static const QString library_path(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH); QString wine_path = "wine"; + if (s.wine_select_path().toString() != "WINE") { + // if we are not supposed to use system wine then: + if (s.wine_select_path().toString() != "CUSTOM") { + // if we don't have a custom path then change the wine_path to the path corresponding to the selected version + wine_path = s.wine_select_path().toString(); + } + else if (!s.wine_custom_path->isEmpty()) { + // if we do have a custom path and it is not empty then + wine_path = s.wine_custom_path; + } + } + if (wine_path[0] == '~') + wine_path = qgetenv("HOME") + wine_path.mid(1); + + qDebug() << "proto/wine: wine_path:" << wine_path; + auto env = QProcessEnvironment::systemEnvironment(); if (s.variant_proton) @@ -91,6 +108,8 @@ module_status wine::initialize() if (wineprefix[0] != '/') return error(tr("Wine prefix must be an absolute path (given '%1')").arg(wineprefix)); + qDebug() << "proto/wine: wineprefix:" << wineprefix; + env.insert("WINEPREFIX", wineprefix); } @@ -104,12 +123,24 @@ module_status wine::initialize() wrapper.setProcessEnvironment(env); wrapper.setWorkingDirectory(OPENTRACK_BASE_PATH); wrapper.start(wine_path, { library_path + "opentrack-wrapper-wine.exe.so" }); + wrapper.waitForStarted(); + if (wrapper.state() == QProcess::ProcessState::NotRunning) { + return error(tr("Failed to start Wine! Make sure the binary is set correctly.")); + } #endif if (lck_shm.success()) { shm = (WineSHM*) lck_shm.ptr(); memset(shm, 0, sizeof(*shm)); + + qDebug() << "proto/wine: shm success"; + + // display "waiting for game message" (overwritten once a game is detected) + connected_game = "waiting for game..."; + } + else { + qDebug() << "proto/wine: shm no success"; } if (lck_shm.success()) diff --git a/proto-wine/ftnoir_protocol_wine.h b/proto-wine/ftnoir_protocol_wine.h index f7346be9..23845d51 100644 --- a/proto-wine/ftnoir_protocol_wine.h +++ b/proto-wine/ftnoir_protocol_wine.h @@ -26,7 +26,9 @@ struct settings : opts value proton_appid{b, "proton-appid", 0}; value proton_path{b, "proton-version", {} }; - value wineprefix{b, "wineprefix", "~/.wine"}; + value wine_select_path{b, "wine-select-version", {"WINE"}}; + value wine_custom_path{b, "wine-custom-version", ""}; + value wineprefix{b, "wineprefix", "~/Games/star-citizen/"}; value protocol{b, "protocol", 2}; }; @@ -77,6 +79,11 @@ private: settings s; private slots: + void onWinePathComboUpdated(QString selection); + + void doBrowseWine(); + void doBrowsePrefix(); + void doOK(); void doCancel(); }; diff --git a/proto-wine/ftnoir_protocol_wine_dialog.cpp b/proto-wine/ftnoir_protocol_wine_dialog.cpp index a954a752..07dc1469 100644 --- a/proto-wine/ftnoir_protocol_wine_dialog.cpp +++ b/proto-wine/ftnoir_protocol_wine_dialog.cpp @@ -1,9 +1,20 @@ #include "ftnoir_protocol_wine.h" #include +#include #include #include "api/plugin-api.hpp" +/* + * 0: path to the directory with wine versions + * 1: path from a wine version to the exectuable + * 2: name of the application using the wine versions + */ +static const char* wine_paths[][3] = { + {"/.local/share/lutris/runners/wine/", "/bin/wine", "Lutris"}, + {"/.var/app/net.lutris.Lutris/data/lutris/runners/wine/", "/bin/wine", "Flatpak Lutris"} +}; + static const char* proton_paths[] = { "/.steam/steam/steamapps/common", "/.steam/root/compatibilitytools.d", @@ -14,6 +25,23 @@ FTControls::FTControls() { ui.setupUi(this); + //populate wine select + ui.wine_path_combo->addItem("System Wine", QVariant{"WINE"}); + for (const char** path : wine_paths) { + QDir dir(QDir::homePath() + path[0]); + dir.setFilter(QDir::Dirs); + QFileInfoList list = dir.entryInfoList(); + for (int i = 0; i < list.size(); ++i) { + QFileInfo fileInfo = list.at(i); + if (fileInfo.fileName() == "." || fileInfo.fileName() == "..") continue; + + QString name = fileInfo.fileName() + " (" + path[2] + ")"; + ui.wine_path_combo->addItem(name, QVariant{fileInfo.filePath() + path[1]}); + } + } + ui.wine_path_combo->addItem("Custom path to Wine executable", QVariant{"CUSTOM"}); + + //populate proton select for (const char* path : proton_paths) { QDir dir(QDir::homePath() + path); dir.setFilter(QDir::Dirs); @@ -24,17 +52,62 @@ FTControls::FTControls() 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); tie_setting(s.fsync, ui.fsync); tie_setting(s.proton_appid, ui.proton_appid); + tie_setting(s.wine_select_path, ui.wine_path_combo); + tie_setting(s.wine_custom_path, ui.wine_path); tie_setting(s.wineprefix, ui.wineprefix); tie_setting(s.protocol, ui.protocol_selection); + connect(ui.wine_path_combo, &QComboBox::currentTextChanged, this, &FTControls::onWinePathComboUpdated); + connect(ui.browse_wine_path_button, &QPushButton::clicked, this, &FTControls::doBrowseWine); + connect(ui.browse_wine_prefix_button, &QPushButton::clicked, this, &FTControls::doBrowsePrefix); connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &FTControls::doOK); connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &FTControls::doCancel); + + // update state of the combo box and associated ui elements + onWinePathComboUpdated(ui.wine_path_combo->currentText()); +} + +void FTControls::onWinePathComboUpdated(QString selection) { + // enable the custom text field if required + if (selection == "Custom path to Wine executable") { + ui.wine_path->setEnabled(true); + ui.browse_wine_path_button->setEnabled(true); + } + else { + ui.wine_path->setEnabled(false); + ui.browse_wine_path_button->setEnabled(false); + } +} + +void FTControls::doBrowseWine() { + QFileDialog d(this); + d.setFileMode(QFileDialog::FileMode::ExistingFile); + d.setWindowTitle(tr("Select path to Wine Binary")); + if (s.wine_custom_path->startsWith("~/.local/share/lutris/runners")) { + d.selectFile(s.wine_custom_path); + } + if (d.exec()) { + s.wine_custom_path = d.selectedFiles()[0]; + } +} +void FTControls::doBrowsePrefix() { + QFileDialog d(this); + d.setFileMode(QFileDialog::FileMode::Directory); + d.setOption(QFileDialog::Option::ShowDirsOnly, true); + d.setWindowTitle(tr("Select Wine Prefix")); + if (s.wineprefix->startsWith("/") || s.wineprefix->startsWith("~")) { + d.selectFile(s.wineprefix); + } + if (d.exec()) { + s.wineprefix = d.selectedFiles()[0]; + } } void FTControls::doOK() diff --git a/proto-wine/ftnoir_winecontrols.ui b/proto-wine/ftnoir_winecontrols.ui index e9541447..365922ca 100644 --- a/proto-wine/ftnoir_winecontrols.ui +++ b/proto-wine/ftnoir_winecontrols.ui @@ -9,7 +9,7 @@ 0 0 - 528 + 951 424 @@ -33,8 +33,8 @@ Wine variant - - + + 0 @@ -42,55 +42,120 @@ - Wine (system) + Proton (Steam Play) - - + + - + 0 0 - - - 120 - 0 - + + Wine (select path and prefix) - - + + - + 0 0 - 286 + 120 0 - - - - - - - 0 - 0 - - - - Proton (Steam Play) + + Qt::LeftToRight + + + + + + + 0 + 0 + + + + + 450 + 0 + + + + <html><head/><body><p>prefix</p></body></html> + + + /path_to_the_prefix/ + + + + + + + Browse Prefix + + + + + + + + + + + false + + + + 0 + 0 + + + + + 450 + 0 + + + + <html><head/><body><p>wine/runner exectuable path</p></body></html> + + + + + + + + + + + + + false + + + Browse Wine Path + + + + + + + + diff --git a/proto-wine/lang/nl_NL.ts b/proto-wine/lang/nl_NL.ts index e2183cc8..0298092b 100644 --- a/proto-wine/lang/nl_NL.ts +++ b/proto-wine/lang/nl_NL.ts @@ -2,17 +2,24 @@ - UICFTControls + FTControls - Wine settings + Select path to Wine Binary - Wine variant + Select Wine Prefix + + + + + UICFTControls + + Wine settings - Wine (system) + Wine variant @@ -55,6 +62,30 @@ Both + + Wine (select path and prefix) + + + + <html><head/><body><p>prefix</p></body></html> + + + + /path_to_the_prefix/ + + + + Browse Prefix + + + + <html><head/><body><p>wine/runner exectuable path</p></body></html> + + + + Browse Wine Path + + wine @@ -70,6 +101,10 @@ Wine prefix must be an absolute path (given '%1') + + Failed to start Wine! Make sure the binary is set correctly. + + wine_metadata diff --git a/proto-wine/lang/ru_RU.ts b/proto-wine/lang/ru_RU.ts index f3b44bd2..c7e9c52e 100644 --- a/proto-wine/lang/ru_RU.ts +++ b/proto-wine/lang/ru_RU.ts @@ -2,17 +2,24 @@ - UICFTControls + FTControls - Wine settings + Select path to Wine Binary - Wine variant + Select Wine Prefix + + + + + UICFTControls + + Wine settings - Wine (system) + Wine variant @@ -55,6 +62,30 @@ Both + + Wine (select path and prefix) + + + + <html><head/><body><p>prefix</p></body></html> + + + + /path_to_the_prefix/ + + + + Browse Prefix + + + + <html><head/><body><p>wine/runner exectuable path</p></body></html> + + + + Browse Wine Path + + wine @@ -70,6 +101,10 @@ Wine prefix must be an absolute path (given '%1') + + Failed to start Wine! Make sure the binary is set correctly. + + wine_metadata diff --git a/proto-wine/lang/stub.ts b/proto-wine/lang/stub.ts index dd4f946f..3366b44b 100644 --- a/proto-wine/lang/stub.ts +++ b/proto-wine/lang/stub.ts @@ -2,17 +2,24 @@ - UICFTControls + FTControls - Wine settings + Select path to Wine Binary - Wine variant + Select Wine Prefix + + + + + UICFTControls + + Wine settings - Wine (system) + Wine variant @@ -55,6 +62,30 @@ Both + + Wine (select path and prefix) + + + + <html><head/><body><p>prefix</p></body></html> + + + + /path_to_the_prefix/ + + + + Browse Prefix + + + + <html><head/><body><p>wine/runner exectuable path</p></body></html> + + + + Browse Wine Path + + wine @@ -70,6 +101,10 @@ Wine prefix must be an absolute path (given '%1') + + Failed to start Wine! Make sure the binary is set correctly. + + wine_metadata diff --git a/proto-wine/lang/zh_CN.ts b/proto-wine/lang/zh_CN.ts index b7c9ea7d..0d285c7c 100644 --- a/proto-wine/lang/zh_CN.ts +++ b/proto-wine/lang/zh_CN.ts @@ -2,17 +2,24 @@ - UICFTControls + FTControls - Wine settings + Select path to Wine Binary - Wine variant + Select Wine Prefix + + + + + UICFTControls + + Wine settings - Wine (system) + Wine variant @@ -55,6 +62,30 @@ Both + + Wine (select path and prefix) + + + + <html><head/><body><p>prefix</p></body></html> + + + + /path_to_the_prefix/ + + + + Browse Prefix + + + + <html><head/><body><p>wine/runner exectuable path</p></body></html> + + + + Browse Wine Path + + wine @@ -70,6 +101,10 @@ Wine prefix must be an absolute path (given '%1') + + Failed to start Wine! Make sure the binary is set correctly. + + wine_metadata -- cgit v1.2.3