Skip to content

Commit 2ebac99

Browse files
committed
fix wine lutris steam
shell env variables not working yet also not bash and umu and its not threaded..
1 parent efd526c commit 2ebac99

File tree

8 files changed

+136
-20
lines changed

8 files changed

+136
-20
lines changed

src/Data.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ struct FolderNames {
8080
};
8181
};
8282

83+
struct SteamAppIds {
84+
QMap<int, int> data = {
85+
{0, 0},
86+
{1, 224960},
87+
{2, 225300},
88+
{3, 225320},
89+
{4, 224980},
90+
{5, 225000},
91+
{6, 225020},
92+
};
93+
};
94+
8395
/**
8496
* @struct ExecutableNames
8597
* @brief Executable game file names used on Windows used to start the games.

src/Model.cpp

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,54 @@ int Model::getItemState(int id) {
131131
return status;
132132
}
133133

134+
bool Model::runBash(const int id) {
135+
bool status = true;
136+
// m_bashRunner
137+
return status;
138+
}
139+
140+
bool Model::runUmu(const int id) {
141+
bool status = true;
142+
// m_umuRunner
143+
return status;
144+
}
145+
146+
bool Model::runSteam(const int id) {
147+
bool status = true;
148+
QStringList arg;
149+
const qint64 appid = SteamAppIds().data[data.getType(id)];
150+
arg << QString("steam://run/%1").arg(appid);
151+
m_steamRunner.clearArguments();
152+
m_steamRunner.insertArguments(arg);
153+
m_steamRunner.run();
154+
return status;
155+
}
156+
157+
bool Model::runLutris(const QStringList& arg) {
158+
bool status = true;
159+
m_lutrisRunner.clearArguments();
160+
m_lutrisRunner.insertArguments(arg);
161+
m_lutrisRunner.run();
162+
return status;
163+
}
164+
134165
bool Model::runWine(const int id) {
135166
bool status = true;
167+
168+
QString s;
136169
if (id < 0) { // we use original game id as negative number
137170
int orgId = (-1)*id;
138-
const QString s = QString("/Original.TR%1").arg(orgId);
139-
m_wineRunner.setWorkingDirectory(fileManager.getExtraPathToExe(s));
171+
s = QString("Original.TR%1").arg(orgId);
140172
} else {
141-
const QString s = QString("/%1.TRLE").arg(id);
142-
m_wineRunner.setWorkingDirectory(fileManager.getExtraPathToExe(s));
173+
s = QString("%1.TRLE").arg(id);
143174
}
175+
const QString e = fileManager.getExtraPathToExe(s);
176+
const QString a = fileManager.getFullPath(e, false);
177+
const QString b = ExecutableNames().data[data.getType(id)];
178+
179+
m_wineRunner.setWorkingDirectory(a);
180+
m_wineRunner.insertArguments(QStringList() << QString("%1/%2").arg(a, b));
181+
// m_wineRunner.insertProcessEnvironment()
144182
m_wineRunner.run();
145183
return status;
146184
}

src/Model.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class Model : public QObject {
6868
void getCoverList(QVector<ListItemData*>* tiems);
6969
int getItemState(int id);
7070
bool runWine(const int id);
71+
bool runLutris(const QStringList& arg);
72+
bool runSteam(const int id);
73+
bool runUmu(const int id);
74+
bool runBash(const int id);
7175
bool setLink(int id);
7276
QString getGameDirectory(int id);
7377
QString getExecutableName(int id);
@@ -93,7 +97,12 @@ class Model : public QObject {
9397
const int id, const QString& md5sum, const QString& name);
9498
bool unpackLevel(const int id, const QString& name, const QString& exe);
9599

96-
Runner m_wineRunner = Runner("/usr/bin/wine");
100+
Runner m_wineRunner = Runner("wine");
101+
Runner m_lutrisRunner = Runner("lutris");
102+
Runner m_steamRunner = Runner("steam");
103+
Runner m_umuRunner = Runner("umu-launcher");
104+
Runner m_bashRunner = Runner("bash");
105+
97106
PyRunner m_pyRunner;
98107
Data& data = Data::getInstance();
99108
FileManager& fileManager = FileManager::getInstance();

src/Runner.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,45 @@
1212
*/
1313

1414
#include "../src/Runner.hpp"
15+
#include <QDebug>
16+
#include <QTextStream>
17+
#include <QObject>
1518

1619
Runner::Runner() : m_env(QProcessEnvironment::systemEnvironment()) {
1720
m_status = 0;
18-
// You can modify the environment of the process if needed
19-
// m_env.insert("WINEPREFIX", "/path/to/wineprefix");
20-
// m_process.setProcessEnvironment(m_env);
2121
}
2222

2323
Runner::Runner(const QString& cmd)
2424
: m_env(QProcessEnvironment::systemEnvironment()) {
25-
m_env.insert("WINEDLLOVERRIDES", "winmm=n,b;ddraw=n,b");
26-
m_env.insert("WINEFSYNC", "1");
27-
m_process.setProcessEnvironment(m_env);
2825
m_status = 0;
2926
m_command = cmd;
3027
}
3128

29+
void Runner::insertArguments(const QStringList& value) {
30+
m_arguments << value;
31+
}
32+
33+
void Runner::clearArguments() {
34+
m_arguments.clear();
35+
}
36+
37+
void Runner::insertProcessEnvironment(
38+
const QString& name, const QString& value) {
39+
m_env.insert(name, value);
40+
}
41+
42+
void Runner::clearProcessEnvironment() {
43+
m_env.clear();
44+
}
45+
3246
void Runner::setWorkingDirectory(const QString& cwd) {
3347
m_process.setWorkingDirectory(cwd);
3448
}
3549

3650
void Runner::run() {
3751
// Start Wine with the application as an argument
38-
m_process.start(m_command, QStringList() << "tomb4.exe");
52+
m_process.setProcessEnvironment(m_env);
53+
m_process.start(m_command, m_arguments);
3954
QObject::connect(&m_process, &QProcess::readyReadStandardOutput, [&]() {
4055
// Read and print the output to standard output
4156
QTextStream(stdout) << m_process.readAllStandardOutput();

src/Runner.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include <QProcess>
1818
#include <QProcessEnvironment>
19-
#include <QDebug>
2019

2120

2221
class Runner : public QObject {
@@ -30,15 +29,20 @@ class Runner : public QObject {
3029
int getCommand();
3130
bool setCommand(const QString& cmd);
3231
void setWorkingDirectory(const QString& cwd);
32+
void insertProcessEnvironment(const QString& name, const QString& value);
33+
void clearProcessEnvironment();
34+
void insertArguments(const QStringList& value);
35+
void clearArguments();
3336

3437
signals:
3538
void started();
3639
void stopped();
3740

3841
private:
39-
QProcessEnvironment m_env;
4042
QProcess m_process;
43+
QProcessEnvironment m_env;
4144
QString m_command;
45+
QStringList m_arguments;
4246
qint64 m_status;
4347
};
4448

src/TombRaiderLinuxLauncher.cpp

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,20 +370,54 @@ void TombRaiderLinuxLauncher::setOptionsClicked() {
370370
}
371371

372372
void TombRaiderLinuxLauncher::linkClicked() {
373+
qDebug() << "linkClicked()";
373374
QModelIndex current = ui->listViewLevels->currentIndex();
374375
if (current.isValid()) {
375376
qint64 id = levelListModel->getLid(current);
376377
if (id != 0) {
377-
if (settings.value(QString("level%1/RunnerType").arg(id)) == 2) {
378+
qint64 type = settings.value(
379+
QString("level%1/RunnerType").arg(id)).toInt();
380+
qDebug() << "Type was: " << type;
381+
if (type == 0) {
378382
Model::getInstance().runWine(id);
379-
} else {
383+
} else if (type == 1) {
384+
const QString arg = ui->lineEditEnvironmentVariables->text();
385+
QStringList argList = arg.split(
386+
QRegularExpression("\\s+"), Qt::SkipEmptyParts);
387+
Model::getInstance().runLutris(argList);
388+
} else if (type == 2) {
389+
if (!controller.link(id)) {
390+
qDebug() << "link error";
391+
}
392+
const QString arg = ui->lineEditEnvironmentVariables->text();
393+
QStringList argList = arg.split(
394+
QRegularExpression("\\s+"), Qt::SkipEmptyParts);
395+
Model::getInstance().runLutris(argList);
396+
} else if (type == 3) {
397+
Model::getInstance().runSteam(id);
398+
} else if (type == 4) {
380399
if (levelListModel->getListType()) {
381400
id = (-1)*id;
382401
}
383402
if (!controller.link(id)) {
384403
qDebug() << "link error";
385404
}
386405
QApplication::quit();
406+
} else if (type == 5) {
407+
if (levelListModel->getListType()) {
408+
id = (-1)*id;
409+
}
410+
if (!controller.link(id)) {
411+
qDebug() << "link error";
412+
}
413+
} else if (type == 6) {
414+
const QString arg = ui->lineEditEnvironmentVariables->text();
415+
QStringList argList = arg.split(
416+
QRegularExpression("\\s+"), Qt::SkipEmptyParts);
417+
qDebug() << "args was: " << argList[0];
418+
Model::getInstance().runUmu(id);
419+
} else if (type == 7) {
420+
Model::getInstance().runBash(id);
387421
}
388422
}
389423
}

src/TombRaiderLinuxLauncher.ui

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>1095</width>
10-
<height>749</height>
9+
<width>1289</width>
10+
<height>854</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -1279,6 +1279,11 @@
12791279
<string>Lutris</string>
12801280
</property>
12811281
</item>
1282+
<item>
1283+
<property name="text">
1284+
<string>Link and launch Lutris</string>
1285+
</property>
1286+
</item>
12821287
<item>
12831288
<property name="text">
12841289
<string>Link and launch Steam</string>

test/test.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ class PyRunnerTest : public QObject {
3434
QVERIFY(1 + 1 == 2);
3535
}
3636
private:
37-
PyRunner pyrunner =
38-
PyRunner("tester_root/usr/share/TombRaiderLinuxLauncher");
37+
PyRunner pyrunner = PyRunner();
3938
};
4039

4140
#endif // TEST_TEST_HPP_

0 commit comments

Comments
 (0)