diff options
author | Priton-CE <thies.eric@gmail.com> | 2023-02-26 17:34:07 +0100 |
---|---|---|
committer | Priton-CE <thies.eric@gmail.com> | 2023-02-26 17:34:07 +0100 |
commit | 9a7e5f1b6e18ee4f0c3455c683f7023c2fd66fcb (patch) | |
tree | 563f2b0541b1296ee929938b1b378486652714ac | |
parent | 77c824e2113a7d68123d7a153f4bcd2aacce944f (diff) |
moved changes from master to upstream-merge
-rw-r--r-- | proto-wine/ftnoir_protocol_wine.cpp | 31 | ||||
-rw-r--r-- | proto-wine/ftnoir_protocol_wine.h | 9 | ||||
-rw-r--r-- | proto-wine/ftnoir_protocol_wine_dialog.cpp | 73 | ||||
-rw-r--r-- | proto-wine/ftnoir_winecontrols.ui | 121 | ||||
-rw-r--r-- | proto-wine/lang/nl_NL.ts | 43 | ||||
-rw-r--r-- | proto-wine/lang/ru_RU.ts | 43 | ||||
-rw-r--r-- | proto-wine/lang/stub.ts | 43 | ||||
-rw-r--r-- | proto-wine/lang/zh_CN.ts | 43 |
8 files changed, 361 insertions, 45 deletions
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<int> proton_appid{b, "proton-appid", 0}; value<QVariant> proton_path{b, "proton-version", {} }; - value<QString> wineprefix{b, "wineprefix", "~/.wine"}; + value<QVariant> wine_select_path{b, "wine-select-version", {"WINE"}}; + value<QString> wine_custom_path{b, "wine-custom-version", ""}; + value<QString> wineprefix{b, "wineprefix", "~/Games/star-citizen/"}; value<int> 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 <QDebug> +#include <QFileDialog> #include <QDir> #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 @@ <rect> <x>0</x> <y>0</y> - <width>528</width> + <width>951</width> <height>424</height> </rect> </property> @@ -33,8 +33,8 @@ <string>Wine variant</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QRadioButton" name="variant_wine"> + <item row="10" column="0"> + <widget class="QRadioButton" name="variant_proton"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -42,55 +42,120 @@ </sizepolicy> </property> <property name="text"> - <string>Wine (system)</string> + <string>Proton (Steam Play)</string> </property> </widget> </item> - <item row="2" column="1" alignment="Qt::AlignRight"> - <widget class="QComboBox" name="proton_version"> + <item row="0" column="0"> + <widget class="QRadioButton" name="variant_wine"> <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize"> - <size> - <width>120</width> - <height>0</height> - </size> + <property name="text"> + <string>Wine (select path and prefix)</string> </property> </widget> </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="wineprefix"> + <item row="10" column="1"> + <widget class="QComboBox" name="proton_version"> <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimumSize"> <size> - <width>286</width> + <width>120</width> <height>0</height> </size> </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QRadioButton" name="variant_proton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Proton (Steam Play)</string> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> </property> </widget> </item> + <item row="9" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QLineEdit" name="wineprefix"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>450</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>prefix</p></body></html></string> + </property> + <property name="placeholderText"> + <string>/path_to_the_prefix/</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="browse_wine_prefix_button"> + <property name="text"> + <string>Browse Prefix</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="8" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLineEdit" name="wine_path"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>450</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string><html><head/><body><p>wine/runner exectuable path</p></body></html></string> + </property> + <property name="inputMask"> + <string/> + </property> + <property name="placeholderText"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="browse_wine_path_button"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Browse Wine Path</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="wine_path_combo"/> + </item> </layout> </widget> </item> 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 @@ <!DOCTYPE TS> <TS version="2.1" language="nl_NL"> <context> - <name>UICFTControls</name> + <name>FTControls</name> <message> - <source>Wine settings</source> + <source>Select path to Wine Binary</source> <translation type="unfinished"></translation> </message> <message> - <source>Wine variant</source> + <source>Select Wine Prefix</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>UICFTControls</name> + <message> + <source>Wine settings</source> <translation type="unfinished"></translation> </message> <message> - <source>Wine (system)</source> + <source>Wine variant</source> <translation type="unfinished"></translation> </message> <message> @@ -55,6 +62,30 @@ <source>Both</source> <translation type="unfinished"></translation> </message> + <message> + <source>Wine (select path and prefix)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p>prefix</p></body></html></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>/path_to_the_prefix/</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Browse Prefix</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p>wine/runner exectuable path</p></body></html></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Browse Wine Path</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>wine</name> @@ -70,6 +101,10 @@ <source>Wine prefix must be an absolute path (given '%1')</source> <translation type="unfinished"></translation> </message> + <message> + <source>Failed to start Wine! Make sure the binary is set correctly.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>wine_metadata</name> 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 @@ <!DOCTYPE TS> <TS version="2.1" language="ru_RU"> <context> - <name>UICFTControls</name> + <name>FTControls</name> <message> - <source>Wine settings</source> + <source>Select path to Wine Binary</source> <translation type="unfinished"></translation> </message> <message> - <source>Wine variant</source> + <source>Select Wine Prefix</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>UICFTControls</name> + <message> + <source>Wine settings</source> <translation type="unfinished"></translation> </message> <message> - <source>Wine (system)</source> + <source>Wine variant</source> <translation type="unfinished"></translation> </message> <message> @@ -55,6 +62,30 @@ <source>Both</source> <translation type="unfinished"></translation> </message> + <message> + <source>Wine (select path and prefix)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p>prefix</p></body></html></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>/path_to_the_prefix/</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Browse Prefix</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p>wine/runner exectuable path</p></body></html></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Browse Wine Path</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>wine</name> @@ -70,6 +101,10 @@ <source>Wine prefix must be an absolute path (given '%1')</source> <translation type="unfinished"></translation> </message> + <message> + <source>Failed to start Wine! Make sure the binary is set correctly.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>wine_metadata</name> 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 @@ <!DOCTYPE TS> <TS version="2.1"> <context> - <name>UICFTControls</name> + <name>FTControls</name> <message> - <source>Wine settings</source> + <source>Select path to Wine Binary</source> <translation type="unfinished"></translation> </message> <message> - <source>Wine variant</source> + <source>Select Wine Prefix</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>UICFTControls</name> + <message> + <source>Wine settings</source> <translation type="unfinished"></translation> </message> <message> - <source>Wine (system)</source> + <source>Wine variant</source> <translation type="unfinished"></translation> </message> <message> @@ -55,6 +62,30 @@ <source>Both</source> <translation type="unfinished"></translation> </message> + <message> + <source>Wine (select path and prefix)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p>prefix</p></body></html></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>/path_to_the_prefix/</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Browse Prefix</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p>wine/runner exectuable path</p></body></html></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Browse Wine Path</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>wine</name> @@ -70,6 +101,10 @@ <source>Wine prefix must be an absolute path (given '%1')</source> <translation type="unfinished"></translation> </message> + <message> + <source>Failed to start Wine! Make sure the binary is set correctly.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>wine_metadata</name> 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 @@ <!DOCTYPE TS> <TS version="2.1" language="zh_CN"> <context> - <name>UICFTControls</name> + <name>FTControls</name> <message> - <source>Wine settings</source> + <source>Select path to Wine Binary</source> <translation type="unfinished"></translation> </message> <message> - <source>Wine variant</source> + <source>Select Wine Prefix</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>UICFTControls</name> + <message> + <source>Wine settings</source> <translation type="unfinished"></translation> </message> <message> - <source>Wine (system)</source> + <source>Wine variant</source> <translation type="unfinished"></translation> </message> <message> @@ -55,6 +62,30 @@ <source>Both</source> <translation type="unfinished"></translation> </message> + <message> + <source>Wine (select path and prefix)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p>prefix</p></body></html></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>/path_to_the_prefix/</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Browse Prefix</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><html><head/><body><p>wine/runner exectuable path</p></body></html></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Browse Wine Path</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>wine</name> @@ -70,6 +101,10 @@ <source>Wine prefix must be an absolute path (given '%1')</source> <translation type="unfinished"></translation> </message> + <message> + <source>Failed to start Wine! Make sure the binary is set correctly.</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>wine_metadata</name> |